def guessFiles(refiner,homeDir): if homeDir == None: homeDir = os.getcwd( ) seqFile = os.path.join(homeDir,'sequence.seq') if os.path.exists(seqFile): refiner.readSequence(seqFile) else: pdbFile = os.path.join(homeDir,'*.pdb') pdbFiles = glob.glob(pdbFile) if (len(pdbFiles) > 0): molio.readPDB(pdbFiles[0]) angleFiles = glob.glob(os.path.join(homeDir,'dihedral*.tbl')) for file in angleFiles: refiner.addAngleFile(file,'nv') disFiles = glob.glob(os.path.join(homeDir,'distance*.tbl')) for file in disFiles: refiner.addDistanceFile(file,'nv') angleFiles = glob.glob(os.path.join(homeDir,'dihedral*.txt')) for file in angleFiles: refiner.addAngleFile(file,'cyana') disFiles = glob.glob(os.path.join(homeDir,'*.upl')) for file in disFiles: file = file[:-4] refiner.addDistanceFile(file,'cyana')
def setupFile(fileName,disFile=''): refiner = refine() molecule = molio.readPDB(fileName) if disFile != '': refiner.addDistanceFile(disFile,mode='NV') else: disFile = 'distances' refiner.addDistanceFile(disFile,mode='cyana') seed = 0 refiner.setup(homeDir,seed) refiner.outDir = outDir refiner.energy() return refiner
def predictWithRCFromPDB(pdbFile, refShifts, ringRatio, typeRCDist, atomNames, builtin): """ Reads an RNA molecule from PDB file and predict chemical shifts. # Parameters: pdbFile (str); the name of the PDB file refShifts (dict); the reference shifts for each atom to be predicted. ringRatio (float); A scale parameter to multiply the ring-current contributions by typeRCDist (String): Type of analysis to perform, 'rc' (ring current) or 'dist' (distances) # Returns: shifts (dict) the chemical shifts that were predicted. The reference ppm value of each atom is also updated with shift """ Molecule.removeAll() pdb = PDBFile() mol = molio.readPDB(pdbFile) #pdb.readCoordinates(pdbFile,-1,False, False) activeStructures = mol.getActiveStructures() avgOverStructures = False if not avgOverStructures: if len(activeStructures) > 0: repI = super.findRepresentative(mol) iStruct = repI[0] else: iStruct=0 structList=[iStruct] else: if len(activeStructures) > 0: structList = list(activeStructures) else: structList=[0] if builtin: shifts = rnapred.predictBuiltIn(mol, atomNames, typeRCDist, structList) else: if typeRCDist.lower() == 'rc': shifts = rnapred.predictRCShifts(mol, structList, refShifts, ringRatio, ringTypes) elif typeRCDist.lower() == 'dist': alphas = ringRatio shifts = rnapred.predictDistShifts(mol, rmax, structList, refShifts, alphas) return mol, shifts
def genRCTrainingMatrix(outFileName, pdbFiles, shiftSources, atomNames, ringMode, typeRCDist): """ Generate the training data from a list of pdbFiles and dotBracket values. Each file is predicted using the attribute method based on a specified dot-bracket string and the output is appended to the training matrix # Parameters: outFileName (str); The output file name. File is deleted if present already. pdbFiles (list); list of PDB Files to use shiftSources (list); list of sources for shifts. Either dot-bracket values (vienna string) or bmrb id to use for each pdb file atomNames (list): list of atom names ringMode typeRCDist (String): Type of analysis to perform, 'rc' (ring current) or 'dist' (distances) # Returns: _ (None); Training data is written to specified file """ try: os.remove(outFileName) except: pass with open(outFileName,'a') as f1: for pdbID,shiftSource in zip(pdbFiles,shiftSources): Molecule.removeAll() pdbFile = 'pdbfiles/'+pdbID+'.pdb' if not getPDBFile(pdbID): print 'skip',pdbFile continue print 'train',pdbFile pdb = PDBFile() mol = molio.readPDB(pdbFile) if shiftSource[0]=="." or shiftSource[0]=="(": rnapred.predictFromSequence(mol,shiftSource) else: setRefShiftsFromBMRB(shiftSource, {}) genRCMat(mol,atomNames,f1, ringMode, typeRCDist)
input = FileInputStream(argFile) yaml = Yaml() data = yaml.load(input) refiner=refine() osfiles.setOutFiles(refiner,dataDir, 0) refiner.rootName = "temp" refiner.loadFromYaml(data,0) mol = refiner.molecule vienna = data['rna']['vienna'] mol.setDotBracket(vienna) #rnapred.predictFromSequence(mol,vienna) rnapred.predictFromSequence() rnapred.dumpPredictions(mol) elif argFile.endswith('.pdb') or argFile.endswith('.cif'): if argFile.endswith('.pdb'): mol = molio.readPDB(argFile) elif argFile.endswith('.cif'): mol = molio.readMMCIF(argFile) else: print 'Invalid file type' exit(1) # fixme, need to do this by polymer so you can have protein-rna complex if isRNA(mol): refiner=refine() shifts = refiner.predictRNAShifts() dumpPredictions(mol) else: predictProtein(mol)