def importAco(project, acoFile): """Read Cyana acoFile ( 512 THR PSI 116.0 148.0) convention = CYANA or CYANA2 return a DihedralRestraintList or None on error """ maxErrorCount = 50 errorCount = 0 # check the molecule if not project or not project.molecule: nTerror("importAco: initialize molecule first") return None # end if molecule = project.molecule # Sometimes set from other than CYANA coordinate file. # chainId = molecule.chains[0].name if not os.path.exists(acoFile): nTerror('importAco: file "%s" not found\n', acoFile) return None # end if _dir, name, _ext = nTpath(acoFile) result = project.dihedrals.new(name=name, status="keep") resNumDict = molecule.getResNumDict() nTmessage("Now reading: " + acoFile) for line in AwkLike(acoFile, commentString="#", minNF=5): resNum = line.int(1) res = None if resNum in resNumDict: res = resNumDict[resNum] angle = line.dollar[3] lower = line.float(4) upper = line.float(5) if res and angle in res.db: atoms = translateTopology(res, res.db[angle].atoms) # print '>', atoms, res, res.db[angle] if None in atoms: if errorCount <= maxErrorCount: nTerror("Failed to decode all atoms from line:" + line.dollar[0]) if errorCount == (maxErrorCount + 1): nTerror("And so on") errorCount += 1 continue else: r = DihedralRestraint(atoms=atoms, lower=lower, upper=upper, angle=angle, residue=res) # print r.format() result.append(r) # end if # end if # end for if errorCount: nTerror("Found number of errors importing upl file: %s" % errorCount) # nTmessage("Imported items: " + repr(len(result))) nTmessage('==> importAco: new %s from "%s"', result, acoFile) return result
def importAco( project, acoFile ): """Read Cyana acoFile ( 512 THR PSI 116.0 148.0) convention = CYANA or CYANA2 return a DihedralRestraintList or None on error """ maxErrorCount = 50 errorCount = 0 # check the molecule if (not project or not project.molecule ): nTerror("importAco: initialize molecule first") return None #end if molecule = project.molecule # Sometimes set from other than CYANA coordinate file. # chainId = molecule.chains[0].name if not os.path.exists( acoFile ): nTerror('importAco: file "%s" not found\n', acoFile) return None #end if _dir,name,_ext = nTpath( acoFile ) result = project.dihedrals.new( name=name, status='keep') resNumDict = molecule.getResNumDict() nTmessage("Now reading: " + acoFile) for line in AwkLike( acoFile, commentString = '#' , minNF = 5): resNum = line.int(1) res = None if resNum in resNumDict: res = resNumDict[resNum] angle = line.dollar[3] lower = line.float(4) upper = line.float(5) if res and angle in res.db: atoms = translateTopology( res, res.db[angle].atoms ) # print '>', atoms, res, res.db[angle] if None in atoms: if errorCount <= maxErrorCount: nTerror("Failed to decode all atoms from line:"+ line.dollar[0]) if errorCount == (maxErrorCount+1): nTerror("And so on") errorCount += 1 continue else: r = DihedralRestraint( atoms = atoms, lower=lower, upper=upper, angle = angle, residue = res ) #print r.format() result.append( r ) #end if #end if #end for if errorCount: nTerror("Found number of errors importing upl file: %s" % errorCount) # nTmessage("Imported items: " + repr(len(result))) nTmessage('==> importAco: new %s from "%s"', result, acoFile ) return result
#=========================================================================== # Adjust to generate different output resonances = [(0, 'HN'), (0, 'N'), (0, 'CA'), (0, 'CB'), (-1, 'CA'), (-1, 'CB')] #=========================================================================== # No need to edit below here (I think) #=========================================================================== nTmessage('%-8s ', ' ') for index, name in resonances: nTmessage('%-8s ', name + 'i' + str(index)) #end for nTmessage('') # Generate peaks for all residues for residue in project.molecule.allResidues(): #@UndefinedVariable atoms = translateTopology(residue, resonances) nTmessage('%-8s ', residue.name) for atm in atoms: if not atm: nTmessage('%-8s ', '-X-') elif atm.isAssigned(resonanceListIdx=RESONANCE_LIST_IDX_ANY): nTmessage('%-8.3f ', atm.shift()) else: nTmessage('%-8s ', '-?-') #end if #end for nTmessage('') #end for
def __iter__( self ): for peak in self.peaks: atoms = translateTopology( self.residue, peak ).reorder( self.axisOrder ) yield atoms
#=========================================================================== # Adjust to generate different output resonances =[ (0,'HN'),(0,'N'),( 0,'CA'),(0,'CB'),( -1,'CA'), (-1,'CB')] #=========================================================================== # No need to edit below here (I think) #=========================================================================== nTmessage('%-8s ', ' ') for index,name in resonances: nTmessage('%-8s ', name+'i'+str(index) ) #end for nTmessage('') # Generate peaks for all residues for residue in project.molecule.allResidues(): #@UndefinedVariable atoms = translateTopology( residue, resonances ) nTmessage('%-8s ', residue.name) for atm in atoms: if not atm: nTmessage('%-8s ', '-X-') elif atm.isAssigned(resonanceListIdx=RESONANCE_LIST_IDX_ANY): nTmessage('%-8.3f ', atm.shift() ) else: nTmessage('%-8s ', '-?-' ) #end if #end for nTmessage('') #end for