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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
|
#
# * This library is free software; you can redistribute it and/or
# * modify it under the terms of the GNU Lesser General Public
# * License as published by the Free Software Foundation; either
# * version 2.1 of the License, or (at your option) any later version.
# *
# * This library is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# * Lesser General Public License for more details.
#
#propka3.0, revision 182 2011-08-09
#-------------------------------------------------------------------------------------------------------
#-- --
#-- PROPKA: A PROTEIN PKA PREDICTOR --
#-- --
#-- VERSION 3.0, 01/01/2011, COPENHAGEN --
#-- BY MATS H.M. OLSSON AND CHRESTEN R. SONDERGARD --
#-- --
#-------------------------------------------------------------------------------------------------------
#
#
#-------------------------------------------------------------------------------------------------------
# References:
#
# Very Fast Empirical Prediction and Rationalization of Protein pKa Values
# Hui Li, Andrew D. Robertson and Jan H. Jensen
# PROTEINS: Structure, Function, and Bioinformatics 61:704-721 (2005)
#
# Very Fast Prediction and Rationalization of pKa Values for Protein-Ligand Complexes
# Delphine C. Bas, David M. Rogers and Jan H. Jensen
# PROTEINS: Structure, Function, and Bioinformatics 73:765-783 (2008)
#
# PROPKA3: Consistent Treatment of Internal and Surface Residues in Empirical pKa predictions
# Mats H.M. Olsson, Chresten R. Sondergard, Michal Rostkowski, and Jan H. Jensen
# Journal of Chemical Theory and Computation, 7, 525-537 (2011)
#-------------------------------------------------------------------------------------------------------
import math, sys
from . import lib
pka_print = lib.pka_print
from . import mutate
from .residue import Residue
class Chain:
"""
Chain class - contains a chain and properties of chain
"""
def __init__(self, atoms, resInfo=None, options=None):
"""
Constructer of chain object
"""
self.chainID = atoms[ atoms["keys"][0] ][0].chainID
self.alignment = None
self.residues = []
self.configurations = []
self.last_residue = None
if options.verbose == True:
pka_print("constructing chain %c (atoms: configurations)" % (self.chainID))
# creating the 'residues'
for key in atoms["keys"]:
myResidue = Residue(atoms[key], resInfo=resInfo)
if myResidue.checked():
self.last_residue = myResidue
self.residues.append(myResidue)
# setting up list of configuration keys in this chain
for residue in self.residues:
for key in residue.configurations:
if key not in self.configurations:
self.configurations.append(key)
# checking and correcting C-terminus and N-terminus
self.addNTerminus(resInfo=resInfo)
self.addCTerminus(resInfo=resInfo)
def addNTerminus(self, resInfo=None):
"""
Creating a N-terminus residue for this chain and adding it to 'residues' list
"""
atom = None
for residue in self.residues:
if residue.type == "amino-acid":
atom = residue.getAtom(name="N")
break
if atom != None:
Nterminus = Residue([atom], resName="N+ ", resInfo=resInfo)
self.residues.append(Nterminus)
def addCTerminus(self, resInfo=None):
"""
Creating a C-terminus residue for this chain and adding it to 'residues' list
"""
last_residue = None
for residue in self.residues:
if residue.type == "amino-acid":
last_residue = residue
if last_residue != None:
atoms = last_residue.checkOXT()
Cterminus = Residue(atoms, resName="C- ", resInfo=resInfo)
self.residues.append(Cterminus)
def fillUnknownConfigurations(self, keys=None, options=None):
"""
Fills in the configurations that have not been read
"""
for residue in self.residues:
residue.fillUnknownConfigurations(keys=keys, options=options)
def checkResidues(self, options=None):
"""
Checks that there are only known residues - I ignore ligands for now
"""
resNumb = 0
for residue in self.residues:
resNumb += 1
while resNumb < residue.resNumb:
pka_print("XXX%4d - missing residue" % (resNumb))
resNumb += 1
residue.checkResidue(options=options)
def calculateDesolvation(self, atoms, version=None, options=None):
"""
Calculates the desolvation for each residue in this chain. Note, 'atoms' contains ALL atoms, not only
atoms belonging to this chain. Thus, you will get the desolvation of this chain in the presence of all.
"""
propka1_list = lib.residueList("propka1")
for residue in self.residues:
if residue.location == "BONDED":
do_it = False
elif residue.type == "ion":
do_it = True
elif residue.resName in propka1_list:
do_it = True
else:
do_it = False
if do_it == True:
residue.calculateDesolvation(atoms, version=version, options=options)
def appendToBackBoneLists(self, NHlist, COlist):
"""
Creates and returns CO-list list for base-backbone interactions
"""
for residue in self.residues:
if residue == self.last_residue:
""" do nothing """
elif residue.type == "amino-acid":
N, H, C, O = residue.extractBackBoneAtoms()
if N == None or H == None:
""" do nothing, probably PRO; pka_print("%s missing N-H" % (residue.label)) """
else:
NHlist.append([N, H])
if C == None or O == None:
""" do nothing, no idear what this is; pka_print("%s missing N-H" % (residue.label)) """
else:
COlist.append([C, O])
else:
""" do nothing """
def appendToResidueDictionary(self, residue_dictionary):
"""
Adds all propka interesting residues for this chain to list.
"""
# list of residue names that should be included in the dictionary
for residue in self.residues:
if residue.type in ["amino-acid", "N-terminus", "C-terminus"]:
key = residue.resName
elif residue.type == "ligand":
key = "LIG"
elif residue.type == "ion":
key = "ION"
else:
pka_print("don't know what I have here %s (%s)" % (residue.type, residue.resName))
continue
if residue.location != "BONDED":
if key in residue_dictionary:
residue_dictionary[key].append(residue)
else:
residue_dictionary[key] = [residue]
def appendPropkaResidues(self, propka_residues):
"""
Adds all propka interesting residues for this chain to list.
"""
residue_interaction_list = lib.residueInteractionList("ALL")
#ligand_interaction_list = version.ions.keys()
ligand_interaction_list = []
for residue in self.residues:
if residue.resName in residue_interaction_list or residue.resName in ligand_interaction_list:
if residue.location == "BONDED":
""" do nothing """
#pka_print("%s %s" % (residue.label, residue.type))
else:
propka_residues.append(residue)
def appendAcidicResidues(self, acidic_residues, pka_residues):
"""
Creates and returns a list for acid-backbone interactions
"""
acidic_residue_list = lib.residueList("acids")
for residue in self.residues:
if residue.resName in acidic_residue_list:
if residue.location == "BONDED":
""" do nothing """
else:
acidic_residues.append(residue)
pka_residues.append(residue)
def appendBasicResidues(self, basic_residues, pka_residues):
"""
Creates and returns a list for base-backbone interactions
"""
basic_residue_list = lib.residueList("bases")
for residue in self.residues:
if residue.resName in basic_residue_list:
basic_residues.append(residue)
pka_residues.append(residue)
def calculateTotalPKA(self):
"""
Calculates the total pKa from pKa_mod and the determinants
"""
residue_list = lib.residueList("propka1")
for residue in self.residues:
if residue.resName in residue_list:
residue.calculateTotalPKA()
def setConfiguration(self, key=None):
"""
set the 'current possition' to a 'configuration'
"""
#pka_print( "switching to configuration %s (chain)" % (key) )
for residue in self.residues:
residue.setConfiguration(key=key)
def cleanupResidues(self):
"""
Initializing/cleaning residues from 'old' determinants etc.
"""
for residue in self.residues:
residue.cleanupPKA()
def setChain(self, chainID):
"""
Sets the chainID to a specific label, 'chainID'
"""
self.chainID = chainID
for residue in self.residues:
residue.setChain(chainID)
def makeSequence(self, mutation=None):
"""
creates a sequence from the chain object to be used in Scwrl-mutations
"""
sequence = ""
for residue in self.residues:
if residue.resName in lib.residueList("standard"):
if mutation == None:
code, resName = lib.convertResidueCode(resName=residue.resName)
sequence += code.lower()
elif residue.label in mutation:
new_label = mutation[residue.label]['label']
code, resName = lib.convertResidueCode(resName=new_label[:3])
sequence += code.upper()
else:
code, resName = lib.convertResidueCode(resName=residue.resName)
sequence += code.lower()
return sequence
def setAlignment(self, alignment=None):
"""
Sets the alignment information (from self)
"""
if alignment == None:
pka_print("setting alignment according to protein")
self.alignment = ""
for residue in self.residues:
if residue.resName != "N+ " and residue.resName != "C- ":
code, resName = lib.convertResidueCode(resName=residue.resName)
if code in "ARNDCQEGHILKMFPSTWYV":
self.alignment += (code)
pka_print(self.alignment)
pka_print( len(self.alignment) )
else:
self.alignment = alignment
def shiftResidueNumber(self, shift):
"""
Shift the residue numbers with 'shift'
"""
for residue in self.residues:
residue.shiftResidueNumber(shift)
def printDeterminants(self):
"""
prints the resulting pKa values and determinants to stdout
"""
# Get same order as propka2.0
residue_list = lib.residueList("propka1")
for residue_type in residue_list:
for residue in self.residues:
if residue.resName == residue_type:
pka_print("%s" % ( residue.getDeterminantString() ))
def writeDeterminants(self, file, verbose=True):
"""
prints the resulting pKa values and determinants to stdout
"""
# Get same order as propka2.0
residue_list = lib.residueList("propka1")
for residue_type in residue_list:
for residue in self.residues:
if residue.resName == residue_type:
str = "%s\n" % ( residue.getDeterminantString() )
file.write(str)
if verbose == True:
pka_print(str)
def writeSummary(self, file, verbose=True):
"""
prints the resulting pKa values in summary form to stdout
"""
residue_list = lib.residueList("propka1")
for residue_type in residue_list:
for residue in self.residues:
if residue.resName == residue_type:
str = "%s\n" % ( residue.getSummaryString() )
file.write(str)
if verbose == True:
pka_print(str)
def printSummary(self):
"""
prints the resulting pKa values in summary form to stdout
"""
residue_list = lib.residueList("propka1")
for residue_type in residue_list:
for residue in self.residues:
if residue.resName == residue_type:
str = residue.getSummaryString()
pka_print(str)
def calculateCharge(self, pH):
"""
Calculates the total charge of this chain at pH 'pH'
"""
propka1_residue_labels = lib.residueList("propka1")
Qpro = 0.00
Qmod = 0.00
for residue in self.residues:
if residue.resName in propka1_residue_labels:
Qpro += residue.getCharge(pH, "folded")
Qmod += residue.getCharge(pH, "unfolded")
return Qpro, Qmod
def calculateFoldingEnergy(self, pH=None, reference=None, options=None):
"""
Calculates the folding energy given the correct pKa values; given
pKa values calculated for the entire protein 'all chains' will give
the total folding energy partitioned to chains, not chain folding
energies.
"""
propka1_residue_labels = lib.residueList("propka1")
dG = 0.00
for residue in self.residues:
if residue.resName in propka1_residue_labels:
ddG = residue.calculateFoldingEnergy(pH=pH, reference=reference, options=options)
dG += ddG
#print "%s %6.2lf" % (residue.label, ddG)
return dG
|