Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions HInt.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
###Informations #All arguments are optional
Signal_peptide : Yes #Yes, No or None.
DeepLoc : Periplasmic, Extracellular
Max_protein_lenght :
Min_protein_lenght :
Max_protein_length :
Min_protein_length :
Homo-oligomer : #Integer between 2-20
Interact_with : P33790 #UniprotID/Protein Name
Organism : gram- #gram-, gram+, euk, arch or None
Expand Down
28 changes: 14 additions & 14 deletions HInt/File_proteins.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def set_proteins_sequence_SP (self, new_protein_sequence) :

def set_proteins_sequence_no_SP (self, new_protein_sequence) :
"""
Sets a dict of all sequences without Signal peptide and set a lenght dict.
Sets a dict of all sequences without Signal peptide and set a length dict.

Parameters:
----------
Expand All @@ -53,7 +53,7 @@ def set_proteins_sequence_no_SP (self, new_protein_sequence) :
----------
"""
self.protein_sequence_no_SP = new_protein_sequence
self.find_prot_lenght(new_protein_sequence)
self.find_prot_length(new_protein_sequence)

def set_proteins (self, new_protein) :
"""
Expand Down Expand Up @@ -81,18 +81,18 @@ def set_file_name (self, filename) :
"""
self.file_name = filename

def set_lenght_prot (self, lenght_prot) :
def set_length_prot (self, length_prot) :
"""
Sets lenght of all proteins.
Sets length of all proteins.

Parameters:
----------
lenght_prot = dictionary
length_prot = dictionary

Returns:
----------
"""
self.lenght_prot = lenght_prot
self.length_prot = length_prot

def set_result_dict (self, result_dict) :
"""
Expand Down Expand Up @@ -264,18 +264,18 @@ def get_file_name (self) :
"""
return self.file_name

def get_lenght_prot (self) :
def get_length_prot (self) :
"""
Return the lenght of proteins.
Return the length of proteins.

Parameters:
----------

Returns:
----------
lenght_prot : dictionary
length_prot : dictionary
"""
return self.lenght_prot
return self.length_prot

def get_result_dict (self) :
"""
Expand Down Expand Up @@ -724,7 +724,7 @@ def Make_save_dict (self) :
with open('log_file/save_dict.pkl', 'wb') as out_file :
pickle.dump(pkl_dict, out_file)

def find_prot_lenght (self, prot_dict = None) :
def find_prot_length (self, prot_dict = None) :
"""
Compute and store the length (number of amino acids) of each protein based on sequences without signal peptides.

Expand All @@ -737,10 +737,10 @@ def find_prot_lenght (self, prot_dict = None) :
else :
proteins = prot_dict
sequences = self.get_proteins_sequence_no_SP()
lenght_prot = dict()
length_prot = dict()
for protein in proteins :
lenght_prot[protein] = len(sequences[protein])
self.set_lenght_prot(lenght_prot)
length_prot[protein] = len(sequences[protein])
self.set_length_prot(length_prot)


def create_fasta_file (self, with_SP, need_msa=[], need_pkl=[]) :
Expand Down
10 changes: 5 additions & 5 deletions HInt/HInt.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def main() :
HInt_object = File_proteins(Informations_dict["Path_Uniprot_ID"], Informations_dict["Interact_with"], Informations_dict["AlphaFold"])

time_dict = HInt_object.get_time_dict()
time_dict["Summarize_info"] = [Informations_dict["Interact_with"], Informations_dict["DeepLoc"], Informations_dict["Signal_peptide"], Informations_dict["Min_protein_lenght"], Informations_dict["Max_protein_lenght"], Informations_dict["Homo-oligomer"],str(len(HInt_object.get_possible_prey())),Informations_dict["Organism"]]
time_dict["Summarize_info"] = [Informations_dict["Interact_with"], Informations_dict["DeepLoc"], Informations_dict["Signal_peptide"], Informations_dict["Min_protein_length"], Informations_dict["Max_protein_length"], Informations_dict["Homo-oligomer"],str(len(HInt_object.get_possible_prey())),Informations_dict["Organism"]]

logger.info("GPUs set to: %s", GPU)
logger.info("Number of CPUs set to: %s", CPU)
Expand Down Expand Up @@ -116,7 +116,7 @@ def main() :

# Filter proteins based on sequence length
# (default: remove proteins shorter than 20 AA)
need_msa, need_pkl, need_DeepLoc = filter_lenght(HInt_object, Informations_dict, need_msa, need_pkl, need_DeepLoc)
need_msa, need_pkl, need_DeepLoc = filter_length(HInt_object, Informations_dict, need_msa, need_pkl, need_DeepLoc)

# --------------------------------------------------------------
# DeepLoc filtering
Expand Down Expand Up @@ -159,11 +159,11 @@ def main() :

for bait in Informations_dict["Interact_with"] : # Adjust bait protein lengths if specific regions are defined
if Informations_dict["Regions"][bait] != "0-0" :
dict_lenght = HInt_object.get_lenght_prot()
dict_length = HInt_object.get_length_prot()
start = int(Informations_dict["Regions"][bait].split("-")[0])
end = int(Informations_dict["Regions"][bait].split("-")[1])
dict_lenght[bait] = end - start + 1
HInt_object.set_lenght_prot(dict_lenght)
dict_length[bait] = end - start + 1
HInt_object.set_length_prot(dict_length)


# Filter proteins based on signal peptide criteria
Expand Down
36 changes: 18 additions & 18 deletions HInt/Scoring_HInt.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ def Create_figures (file, Informations_dict, AF_version, sorted_proteins, CPU) :
regions = Informations_dict["Regions"]
possible_prey = file.get_possible_prey()
result_dict = file.get_result_dict()
complete_lenght_prot = file.get_lenght_prot()
complete_length_prot = file.get_length_prot()
complete_seq_prot = file.get_proteins_sequence_no_SP()

interface_dict = dict()
tasks = []
baits_seq = {}
baits_lenght = {}
baits_length = {}
for baits in Informations_dict["Multimer_bait"] :
bait_file = baits
for bait in baits.split(",") :
Expand All @@ -428,15 +428,15 @@ def Create_figures (file, Informations_dict, AF_version, sorted_proteins, CPU) :
end = int(regions[bait].split("-")[1])
bait_file = bait_file.replace(bait,f"{bait}_{start}-{end}")
baits_seq [bait] = complete_seq_prot[bait]
baits_lenght [bait] = complete_lenght_prot[bait]
baits_length [bait] = complete_length_prot[bait]
bait_file = bait_file.replace(",","_and_")
for prey in possible_prey :
lenght_prot = copy.deepcopy(baits_lenght)
lenght_prot [prey] = complete_lenght_prot[prey]
length_prot = copy.deepcopy(baits_length)
length_prot [prey] = complete_length_prot[prey]
seq_prot = copy.deepcopy(baits_seq)
seq_prot [prey] = complete_seq_prot[prey]
if "Reason_for_filtering" not in result_dict[prey].keys() : #only for validate preys
tasks.append((AF_version, bait_file, prey, lenght_prot, seq_prot, baits, regions))
tasks.append((AF_version, bait_file, prey, length_prot, seq_prot, baits, regions))
if tasks : #if there is interaction to process
with Pool(processes=CPU) as pool :
results_res_int = pool.map(postprocess_interaction, tasks)
Expand Down Expand Up @@ -466,7 +466,7 @@ def postprocess_interaction (args) : #maybe split first and second part of funct
----------
interface_dict : dict
"""
(AF_version, bait_file, prey, lenght_prot, seq_prot, baits, region) = args
(AF_version, bait_file, prey, length_prot, seq_prot, baits, region) = args
if os.path.isdir (f"./result_PPI_int/{bait_file}_and_{prey}") == True :
outdir = f"./result_PPI_int/{bait_file}_and_{prey}"
if os.path.isdir (f"./result_PPI_int/{prey}_and_{bait_file}") == True :
Expand All @@ -475,7 +475,7 @@ def postprocess_interaction (args) : #maybe split first and second part of funct
if AF_version == "2" :
plot_Distogram(outdir)

residues_at_interface, proteins, path_int, color_res = make_table_res_int(lenght_prot, seq_prot, outdir, baits, prey, AF_version, region)
residues_at_interface, proteins, path_int, color_res = make_table_res_int(length_prot, seq_prot, outdir, baits, prey, AF_version, region)

if residues_at_interface is not None :
color_int_residues(path_int, color_res, proteins)
Expand Down Expand Up @@ -549,7 +549,7 @@ def plot_Distogram (job) :
logger.info(f"Distogram created for {job}")


def make_table_res_int (lenght_prot, seq_prot, path_int, baits, prey, AF_version, regions) :
def make_table_res_int (length_prot, seq_prot, path_int, baits, prey, AF_version, regions) :
"""
Generate a detailed table of residue-residue interactions for a protein-protein complex.

Expand All @@ -559,7 +559,7 @@ def make_table_res_int (lenght_prot, seq_prot, path_int, baits, prey, AF_version

Parameters :
----------
lenght_prot : dict
length_prot : dict
seq_prot : dict
path_int : str
baits : str
Expand Down Expand Up @@ -612,16 +612,16 @@ def make_table_res_int (lenght_prot, seq_prot, path_int, baits, prey, AF_version
del logits
del bin_edges
gc.collect()
complete_lenght = 0
complete_length = 0
max_hori_index = 0
for bait in baits.split(",") :
complete_lenght += lenght_prot[bait]
complete_length += length_prot[bait]
for bait in baits.split(",") :
min_hori_index = max_hori_index
max_hori_index += lenght_prot[bait]
max_hori_index += length_prot[bait]
bait_prey = bait +"_and_" + proteins[-1]
dict_int[bait_prey] = [[bait," "+proteins[-1]," Distance_Ä"," PAE_score"]]
for line in range(complete_lenght,complete_lenght+lenght_prot[proteins[-1]]) :
for line in range(complete_length,complete_length+length_prot[proteins[-1]]) :
hori_index = -1
for distance in dist[line] :
hori_index += 1
Expand All @@ -633,10 +633,10 @@ def make_table_res_int (lenght_prot, seq_prot, path_int, baits, prey, AF_version
if regions[bait] != "0-0" : #if region selected, need to ajust index
res_in_tot_seq = hori_index - min_hori_index + int(regions[bait].split("-")[0]) - 1
residue1 = seq_prot[bait][res_in_tot_seq]
residue2 = seq_prot[proteins[-1]][line-complete_lenght]
dict_int[bait_prey].append([residue1+":"+str(res_in_tot_seq+1)," "+residue2+":"+str(line-complete_lenght+1)," "+str(distance), " "+str(pae_mtx[line][real_hori_index])])
residue2 = seq_prot[proteins[-1]][line-complete_length]
dict_int[bait_prey].append([residue1+":"+str(res_in_tot_seq+1)," "+residue2+":"+str(line-complete_length+1)," "+str(distance), " "+str(pae_mtx[line][real_hori_index])])
color_res[bait].add(str(res_in_tot_seq+1))
color_res[proteins[-1]].add(str(line-complete_lenght+1))
color_res[proteins[-1]].add(str(line-complete_length+1))
del dist
del pae_mtx
gc.collect()
Expand All @@ -651,7 +651,7 @@ def make_table_res_int (lenght_prot, seq_prot, path_int, baits, prey, AF_version
PAE_CUTOFF = 10.0 #Observation: PAE value for residue at the interaciotn of AF3 model is generally lower than AF2 model
ATOM_CONTACT = ["C","CA","CB"]

len_chain_last = lenght_prot[proteins[-1]]
len_chain_last = length_prot[proteins[-1]]
total_len = pae_mtx.shape[0]
int_already_know = {}
structure = parser.get_structure('protein',os.path.join(path_int, f"{names_int}_ranked_0.pdb"))
Expand Down
Loading