From 31e4aab90326463523600819b4a0e6702db8a030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20P=C3=B6verlein?= Date: Tue, 9 Aug 2022 10:48:47 +0200 Subject: [PATCH] make hydrophobicity scale user specific --- src/metrics/metrics.py | 58 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/metrics/metrics.py b/src/metrics/metrics.py index 0489314..fccef53 100755 --- a/src/metrics/metrics.py +++ b/src/metrics/metrics.py @@ -9,29 +9,29 @@ from Bio.PDB.Polypeptide import three_to_one, standard_aa_names GLYXGLY_ASA = { # from Miller, Janin et al (1987) - "A": 113, - "R": 241, - "N": 158, - "D": 151, - "C": 140, - "Q": 189, - "E": 183, - "G": 85, - "H": 194, - "I": 182, - "L": 180, - "K": 211, - "M": 204, - "F": 218, - "P": 143, - "S": 122, - "T": 146, - "W": 259, - "Y": 229, - "V": 160, + 'A': 113, + 'R': 241, + 'N': 158, + 'D': 151, + 'C': 140, + 'Q': 189, + 'E': 183, + 'G': 85, + 'H': 194, + 'I': 182, + 'L': 180, + 'K': 211, + 'M': 204, + 'F': 218, + 'P': 143, + 'S': 122, + 'T': 146, + 'W': 259, + 'Y': 229, + 'V': 160, } -hydrophobicityscale = { # from Guy, H.R., Biophys J. 47:61-70(1985) +hydrophobicityscale = { # from Guy, H.R., Biophys J. 47:61-70(1985), table 4 'A': 0.100, 'R': 1.910, 'N': 0.480, @@ -64,6 +64,7 @@ class ModStructure(Structure): def __init__(self, id): Structure.__init__(self, id) + self.hydrophobicityscale = hydrophobicityscale def measure(self): ''' @@ -227,7 +228,7 @@ def dipolevector(self): def dipolemoment(self): ''' - Calculation of the dipole moment from the dipole vector. + Calculation of the dipole moment in Debye from the dipole vector. :param self: Structure entity :return: Dipole moment @@ -236,6 +237,14 @@ def dipolemoment(self): ''' return 4.803 * np.linalg.norm(self.dipolevector()) + def sethydrophobicityscale(self, scale): + ''' + Customize values of hydrophobicity scale. + :param scale: dictionary: {residue: energy required to transfer residue from surface of protein to its interior} + :rtype: None + ''' + self.hydrophobicityscale = scale + def truehydrophobicity(self): ''' Calculate total hydrophobicity for residues that are more than 25% @@ -251,7 +260,7 @@ def truehydrophobicity(self): # if residue.get_resname() in GLYXGLY_ASA: sasaratio = residue.sasa / GLYXGLY_ASA[residue.resletter] if sasaratio > 0.25: - truehydrophobicity += hydrophobicityscale[residue.resletter] + truehydrophobicity += self.hydrophobicityscale[residue.resletter] return truehydrophobicity def hydrophobicvector(self): @@ -267,7 +276,7 @@ def hydrophobicvector(self): for residue in self.get_residues(): #if residue.get_resname() in GLYXGLY_ASA: hydrophobicvector += ( - hydrophobicityscale[residue.resletter] * residue.sasa * ( + self.hydrophobicityscale[residue.resletter] * residue.sasa * ( residue.center_of_mass() - self.center_of_mass())) return hydrophobicvector @@ -378,6 +387,7 @@ def init_residue(self, resname, field, resseq, icode): parser = PDBParser(QUIET=1, structure_builder=Builder()) s = parser.get_structure("1ris", "data/data1/1ris.pdb") # s.calculate_sasa() + s.sethydrophobicityscale({k: np.random.rand() for k in hydrophobicityscale}) s.measure() com = s.center_of_mass() dpv = s.dipolevector()