-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.py
More file actions
135 lines (101 loc) · 4.58 KB
/
Copy pathInterface.py
File metadata and controls
135 lines (101 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python
# -*- coding: ISO-8859-1 -*-
import sys
from math import sqrt
from StructureTools import distancePoints, centerMassOfResidue, computeDist_dico
from ResiduesProperties import hydrophobicResidue
from parsing import parserPDB
def initBfactor(dPDB) :
"""
Initialize a "bfactor" key to "position" dictionary to label those which belong to the interface
Input: dico dPDB
Output: dico dPDB with bfactor for each residue
"""
for chain in dPDB["nchaine"]:
for res in dPDB[chain]["position"]:
dPDB[chain][res]["bfactor"] = 0
def computeInterfaceScore(dPDB1, dPDB2, threshold, mode) :
"""
compute interface hydrophobic/hydrophilic score proportion by comparing hydrophobic properties of each atom
which belong to the interface
Input: dico dPDB1 and dPDB2 corresponding to the receptor and ligand, threshold distance for the interface,
mode for the mode of calculation of the distance (center or atom)
Output: the hydrophobic/hydrophilic proportion at the interface between ligand and receptor
"""
#Initialize bfactor
initBfactor(dPDB1)
initBfactor(dPDB2)
nbContactHH = 0
nbResInterface = 0
proportion = 0
for chain1 in dPDB1 :
if not chain1 == "nchaine":
for res1 in dPDB1[chain1]["position"] :
for chain2 in dPDB2 :
if not chain2 == "nchaine" :
for res2 in dPDB2[chain2]["position"] :
#Calculate the distance between all residues
distance = computeDist_dico(dPDB1[chain1][res1], dPDB2[chain2][res2], mode = mode)
if not distance > threshold : # means, the two residues belong to the interface
nbResInterface += 1
#Compare the interface residues hydrophobicity
if ((hydrophobicResidue(dPDB1[chain1][res1]['residu'])) and not(hydrophobicResidue(dPDB2[chain2][res2]['residu']))) or (not(hydrophobicResidue(dPDB1[chain1][res1]['residu'])) and hydrophobicResidue(dPDB2[chain2][res2]['residu'])):
nbContactHH += 1
#If there is an interface
if not nbResInterface == 0:
proportion = (nbContactHH)/(nbResInterface)
return proportion
def interfaceHydrophobicity(listBestHits, listBestScores, dico_Rec, thresholdParam, interfaceModeParam):
"""
Compute the new score by multiplyinf the former scores by (1-output of the ComputInterfaceScore)
Input: a list of the 100 best files and their score (see function Extract100Bests) as well as the threshold and the mode (arguments)
Output: a list of the new scores taking hydrophobicity into account
"""
listPercentage=[]
for files in listBestHits:
dico=parserPDB(files)
percentage=int(computeInterfaceScore(dico_Rec, dico, thresholdParam, interfaceModeParam))
listPercentage.append(percentage)
listnewScore=[(1-a)*b for a,b in zip(listPercentage,listBestScores)]
return listnewScore
def computeInterface(dPDB, threshold, mode) :
"""
compute interface of a ligand-receptor complex
Input: dico dPDB corresponding to the ligand-receptor complex, threshold distance for the interface, mode
for the mode of calculation of the distance (center or atom)
Output: dico dPDB with modified bfactor at the interface and the number of residues which belong to the
interface
"""
#Initialize bfactor
initBfactor(dPDB)
#The number of residues with belong to the interface
nbResInter = 0
for chain1 in dPDB :
if not chain1 == "nchaine":
for chain2 in dPDB :
if not chain2 == "nchaine" and not chain2 == chain1:
for resi in dPDB[chain1]["position"] :
for resj in dPDB[chain2]["position"] :
#Calculate the distance between all residues
distance = computeDist_dico(dPDB[chain1][resi], dPDB[chain2][resj], mode = mode)
if not distance > threshold :# means, the two residues belong to the interface --> bfactor = 1, nbResInter++
if dPDB[chain1][resi]["bfactor"] == 0 :
dPDB[chain1][resi]["bfactor"] = 1
if dPDB[chain2][resj]["bfactor"] == 0 :
dPDB[chain2][resj]["bfactor"] = 1
nbResInter += 1
return nbResInter
def compareInterface (dPDB1, dPDB2) :
"""
compare the residues with belong to the interface between two ligand-receptor complexes
Input: dico dPDB1 and dPDB2 corresponding to ligand-receptor complexes to compare
Output: the number of complexes interface shared residues
"""
nbInter = 0
for chain in dPDB1 :
if not chain == "nchaine":
for res in dPDB1[chain]["position"] :
#If both residues belong to the interface, the number of interface shared residues increases
if dPDB1[chain][res]["bfactor"] and dPDB2[chain][res]["bfactor"] :
nbInter += 1
return nbInter