def printScore( name, rogScore ): clist = rogScore.colorCommentList.zap(1) if len(clist) == 0: clist.append('---') printf('%-20s%-10s %s\n', name, rogScore, clist[0]) for c in clist[1:]: printf('%-20s%-10s %s\n', '', '', c)
def printResidueScores( projects ): n = len(projects) print constants.dots20*(n+1) print ' Residues' print constants.dots20*(n+1) p0 = projects[0] for res in p0.molecule.allResidues(): printf('%s %s %s\n', '-'*5, res, '-'*5 ) # printf('%-20s%-10s %s\n', p0.name, res.rogScore, res.rogScore.colorCommentList.zap(1).format()) printScore( p0.name, res.rogScore ) # find the corresponding residues for p in projects[1:]: nameTuple = (p.molecule.name, res.chain.name, res.resNum, None, None, None, constants.INTERNAL) res2 = p.decodeNameTuple( nameTuple ) if res2: #printf('%-20s%-10s %s\n', p.name, res2.rogScore, res2.rogScore.colorCommentList.zap(1).format()) printScore( p.name, res2.rogScore ) else: printf('%-20s%-10s\n', p.name, 'Not found') #end if #end for print
def exportDef(self, stream=sys.stdout, convention=constants.INTERNAL): """export definitions to stream""" io.printf(stream, "\n#=======================================================================\n") io.printf(stream, "#\t%-8s %-8s\n", "internal", "short") io.printf(stream, "RESIDUE\t%-8s %-8s\n", self.translate(convention), self.shortName) io.printf(stream, "#=======================================================================\n") # saving different residue attributes for attr in ["nameDict", "comment"]: io.printf(stream, "\t%s = %s\n", attr, repr(self[attr])) # end for # clean the properties list props = [] for prop in self.properties: # Do not store name and residueDef.name as property. Add those dynamically upon reading if not prop in [self.name, self.shortName] and not prop in props: props.append(prop) # end if # end for io.printf(stream, "\t%s = %s\n", "properties", repr(props)) for dh in self.dihedrals: dh.exportDef(stream=stream, convention=convention) # end for for atm in self.atoms: atm.exportDef(stream=stream, convention=convention) # end for io.printf(stream, "END_RESIDUE\n") io.printf(stream, "#=======================================================================\n")
def exportDef(self, stream=sys.stdout, convention=constants.INTERNAL): """export definitions to stream""" io.printf(stream, "\t#---------------------------------------------------------------\n") io.printf(stream, "\tDIHEDRAL %-8s\n", self.name) io.printf(stream, "\t#---------------------------------------------------------------\n") if convention == constants.INTERNAL: atms = self.atoms else: # convert atoms atms = [] for resId, atmName in self.atoms: if resId != 0: nTwarning("DihedralDef.exportDef: %s topology (%d,%s) skipped translation", self, resId, atmName) atms.append((resId, atmName)) elif not atmName in self.residueDef: nTerror("DihedralDef.exportDef: %s topology (%d,%s) not decoded", self, resId, atmName) atms.append((resId, atmName)) else: atm = self.residueDef[atmName] atms.append((resId, atm.translate(convention))) # end if # end for # print 'atms', atms # end if io.printf(stream, "\t\t%s = %s\n", "atoms", repr(atms)) for attr in ["karplus"]: io.printf(stream, "\t\t%s = %s\n", attr, repr(self[attr])) # end for io.printf(stream, "\tEND_DIHEDRAL\n")
def exportDef(self, stream=sys.stdout, convention=constants.INTERNAL): """export definitions to stream""" io.printf(stream, "\t#---------------------------------------------------------------\n") io.printf(stream, "\tATOM %-8s\n", self.translate(convention)) io.printf(stream, "\t#---------------------------------------------------------------\n") # Topology; optionally convert if convention == constants.INTERNAL: top2 = self.topology else: # convert topology top2 = [] for resId, atmName in self.topology: if resId != 0: nTwarning("AtomDef.exportDef: %s topology (%d,%s) skipped translation", self, resId, atmName) top2.append((resId, atmName)) elif not atmName in self.residueDef: nTerror("AtomDef.exportDef: %s topology (%d,%s) not decoded", self, resId, atmName) top2.append((resId, atmName)) else: atm = self.residueDef[atmName] top2.append((resId, atm.translate(convention))) # end if # end for # print 'top2', top2 # end if io.printf(stream, "\t\t%s = %s\n", "topology", repr(top2)) # clean the properties list props = [] for prop in self.properties: # Do not store name and residueDef.name as property. Add those dynamically upon reading if ( not prop in [self.name, self.residueDef.name, self.residueDef.shortName, self.spinType] and not prop in props ): props.append(prop) # end if # end for io.printf(stream, "\t\t%s = %s\n", "properties", repr(props)) # Others for attr in ["nameDict", "aliases", "pseudo", "real", "type", "spinType", "shift", "hetatm"]: if self.has_key(attr): io.printf(stream, "\t\t%s = %s\n", attr, repr(self[attr])) # end for io.printf(stream, "\tEND_ATOM\n")