Mercurial > repos > guerler > springsuite
comparison spring_package/Modeller.py @ 41:f316caf098a6 draft default tip
"planemo upload commit 685e1236afde7cf6bb0c9236de06998d2c211dd3"
author | guerler |
---|---|
date | Mon, 01 Mar 2021 15:02:36 +0000 |
parents | 06337927c198 |
children |
comparison
equal
deleted
inserted
replaced
40:06337927c198 | 41:f316caf098a6 |
---|---|
83 raise Exception("TMalign::Failed to retrieve TMalign results.") | 83 raise Exception("TMalign::Failed to retrieve TMalign results.") |
84 templateResidues = sorted(bioMolecule.calpha[templateChain].values(), key=lambda item: item["residueNumber"]) | 84 templateResidues = sorted(bioMolecule.calpha[templateChain].values(), key=lambda item: item["residueNumber"]) |
85 templateIndex = 0 | 85 templateIndex = 0 |
86 for i in range(len(alignment)): | 86 for i in range(len(alignment)): |
87 t = templateAlign[i] | 87 t = templateAlign[i] |
88 if alignment[i] == ":": | 88 if alignment[i] in [":", "."]: |
89 templateResidue = templateResidues[templateIndex] | 89 templateResidue = templateResidues[templateIndex] |
90 templateResidue["alignedResidue"] = modelAlign[i] | 90 templateResidue["alignedResidue"] = modelAlign[i] |
91 aligned.append(templateResidue) | 91 aligned.append(templateResidue) |
92 if t != "-": | 92 if t != "-": |
93 templateIndex = templateIndex + 1 | 93 templateIndex = templateIndex + 1 |
110 print("Found %d templates." % len(templateList)) | 110 print("Found %d templates." % len(templateList)) |
111 for templateHit in templateList: | 111 for templateHit in templateList: |
112 if templateHit["score"] < minScore or maxTries == 0: | 112 if templateHit["score"] < minScore or maxTries == 0: |
113 break | 113 break |
114 maxTries = maxTries - 1 | 114 maxTries = maxTries - 1 |
115 yield templateHit["templatePair"] | 115 yield templateHit["templatePair"], templateHit["score"] |
116 | 116 |
117 | 117 |
118 def createModel(args): | 118 def createModel(args): |
119 print("SPRING - Complex Model Creation") | 119 print("SPRING - Complex Model Creation") |
120 aName = basename(args.a_hhr) | 120 aName = basename(args.a_hhr) |
137 return False | 137 return False |
138 maxScore = -9999 | 138 maxScore = -9999 |
139 maxInfo = None | 139 maxInfo = None |
140 minScore = float(args.minscore) | 140 minScore = float(args.minscore) |
141 maxTries = int(args.maxtries) | 141 maxTries = int(args.maxtries) |
142 for [aTemplate, bTemplate] in getFrameworks(aTemplates, bTemplates, crossReference, minScore=minScore, maxTries=maxTries): | 142 for [aTemplate, bTemplate], zscore in getFrameworks(aTemplates, bTemplates, crossReference, minScore=minScore, maxTries=maxTries): |
143 print("Evaluating Complex Template: %s." % aTemplate) | 143 print("Evaluating Complex Template: %s." % aTemplate) |
144 templateFile = "temp/template.pdb" | 144 templateFile = "temp/template.pdb" |
145 createPDB(aTemplate, pdbDatabase, templateFile) | 145 createPDB(aTemplate, pdbDatabase, templateFile) |
146 templateMolecule = Molecule(templateFile) | 146 templateMolecule = Molecule(templateFile) |
147 aTemplateChain = getChain(aTemplate) | 147 aTemplateChain = getChain(aTemplate) |
166 except Exception as e: | 166 except Exception as e: |
167 print("Warning: Failed TMalign [%s]." % bTemplateChain) | 167 print("Warning: Failed TMalign [%s]." % bTemplateChain) |
168 print(str(e)) | 168 print(str(e)) |
169 continue | 169 continue |
170 biomolFound = True | 170 biomolFound = True |
171 print(" zscore:\t%5.2f" % zscore) | |
171 tmscore = min(coreScore, partnerScore) | 172 tmscore = min(coreScore, partnerScore) |
172 print(" tmscore:\t%5.2f" % tmscore) | 173 print(" tmscore:\t%5.2f" % tmscore) |
173 energy = -interfaceEnergy.get(coreAligned, partnerAligned) | 174 energy = -interfaceEnergy.get(coreAligned, partnerAligned) |
174 print(" energy:\t%5.2f" % energy) | 175 print(" energy:\t%5.2f" % energy) |
175 clashes = interfaceEnergy.getClashes(coreMolecule, partnerMolecule) | 176 clashes = interfaceEnergy.getClashes(coreMolecule, partnerMolecule) |
176 print(" clashes:\t%5.2f" % clashes) | 177 print(" clashes:\t%5.2f" % clashes) |
177 springscore = tmscore + energy * args.wenergy | 178 springscore = tmscore + energy * args.wenergy |
178 print(" springscore:\t%5.2f" % springscore) | 179 print(" springscore:\t%5.2f" % springscore) |
179 if springscore > maxScore and clashes < args.maxclashes: | 180 if springscore > maxScore and clashes < args.maxclashes: |
180 maxScore = springscore | 181 maxScore = springscore |
181 maxInfo = dict(springscore=springscore, tmscore=tmscore, energy=energy, clashes=clashes) | 182 maxInfo = dict(aTemplate=aTemplate, bTemplate=bTemplate, springscore=springscore, tmscore=tmscore, energy=energy, clashes=clashes, zscore=zscore) |
182 coreMolecule.save(outputName, chainName="0") | 183 coreMolecule.save(outputName, chainName="0") |
183 partnerMolecule.save(outputName, chainName="1", append=True) | 184 partnerMolecule.save(outputName, chainName="1", append=True) |
184 if args.showtemplate == "true": | 185 if args.showtemplate == "true": |
185 bioMolecule.save(outputName, append=True) | 186 bioMolecule.save(outputName, append=True) |
186 if biomolFound: | 187 if biomolFound: |
187 break | 188 break |
188 if maxInfo is not None: | 189 if maxInfo is not None: |
189 print("Final Model:") | 190 print("Final Model:") |
190 for key in maxInfo: | 191 for key in maxInfo: |
191 print(" %s:\t%5.2f" % (key, maxInfo[key])) | 192 print(" %s:\t%s" % (key, maxInfo[key])) |
192 print("Completed.") | 193 print("Completed.") |
193 else: | 194 else: |
194 print("Warning: Failed to determine model.") | 195 print("Warning: Failed to determine model.") |
195 return maxInfo | 196 return maxInfo |