Source code for schrodinger.protein.reliability
import os
import sys
from schrodinger import structure
from schrodinger.protein import _reliability
from schrodinger.structutils import analyze
from schrodinger.utils import cmdline
[docs]def run_quick_check(ct, binding_site_atoms=None):
"""
Runs a quick analysis of protein health.
:param ct: protein CT
:type ct: schrodinger.structure
:param binding_site_asl: list of atom indices to define binding site.
Limits checks to area around the binding site.
:type binding_site_asl: atom indices
:rtype str
Returns a Results object of problems spotted in the protein.
"""
params = ProteinCheckParameters()
# Avoid side chain packing analysis to speed up quick check
params.disableSidechainPacking()
if binding_site_atoms:
site_asl = analyze.generate_asl(ct, binding_site_atoms)
params.setBindingSiteASL(site_asl)
return run_check(ct, params)
[docs]def run_check(ct, params):
"""
Returns a Results object of problems spotted in the protein.
"""
mc = _reliability.ModelCheck(ct,
settings=params._reliability_settings,
save_ct=False)
return Results(mc)
[docs]def find_isolated_water_molecules(ct):
"""
Finds water molecules that are isolated (greater than 4.6 A) from other
water clusters.
Returns a list of tuples (water_molecule, distance). The water molecule
is represented as a set() of atom indexes, and the distance is the minimum
distance from another water molecule.
"""
# This method is in private module to avoid circular import problem
return _reliability.find_isolated_water_molecules(ct)
[docs]class ProteinCheckParameters(object):
[docs] def __init__(self):
self._reliability_settings = {
'SITE_ASL': '',
'JOBNAME': '',
'LIGAND': 'none',
'SITE_RADIUS': 6.0,
'PERMISSIVE': False,
}
[docs] def enableSidechainPacking(self):
self._reliability_settings["RUN_SIDECHAIN_PACKING"] = True
[docs] def disableSidechainPacking(self):
self._reliability_settings["RUN_SIDECHAIN_PACKING"] = False
[docs] def setBindingSiteASL(self, site_asl):
self._reliability_settings["SITE_ASL"] = site_asl
[docs]class Results(object):
"""
The Results object stores the results from a protein
health check.
"""
[docs] def __init__(self, model):
self.model = model
[docs] def getTextSummary(self):
"""
Returns a summary of problems found in the protein. If no problems,
returns an empty list.
:rtype list of str
"""
return self.model.get_quick_results()
[docs]def main():
doc = 'Run a quick protein reliability check on the specified structure.'
parser = cmdline.create_argument_parser(description=doc)
parser.add_argument('inputfile',
type=str,
help='Structure file containing protein to check')
parser.add_argument('reportfile',
type=str,
help='Filename to write results. If there are no '
'problems, file will be blank')
parser.add_argument('outputfile',
type=str,
help='Structure file containing protein and '
'properties that describe health issues.')
args = parser.parse_args(sys.argv[1:])
if not os.path.isfile(args.inputfile):
parser.error('File nat found: %s' % args.inputfile)
sys.exit(1)
protein = structure.Structure.read(args.inputfile)
mc = run_quick_check(protein)
mc.model.save_data_to_CT()
with structure.StructureWriter(args.outputfile) as writer:
writer.append(mc.model.ct)
prot_probs = mc.getTextSummary()
with open(args.reportfile, 'w') as f:
f.write('\n'.join(prot_probs))
if __name__ == '__main__':
main()