def test_parseHYDBND_2(): """ """ from MolKit.pdbParser import PdbParser parser = PdbParser("Data/smfx_goodHYDBND.pdb") parser.parse() mol = parser.mol atmsInHBond = mol.allAtoms.get(lambda x: hasattr(x, 'hbonds')) hbonds = atmsInHBond.hbonds assert len(hbonds) == 21
def test_parseFileWrongFormat(): from MolKit.pdbParser import PdbParser parser = PdbParser("Data/fakePDB.pdb") mols = parser.parse() assert mols is None or len(mols) == 0 parser = PdbParser("Data/hpi1s.mol2") mols = parser.parse() assert mols is None or len(mols) == 0 from MolKit.mol2Parser import Mol2Parser parser = Mol2Parser("Data/1crn.pdb") mols = parser.parse() assert mols is None or len(mols) == 0
def test_parseHYDBND_1(): """ """ from MolKit.pdbParser import PdbParser parser = PdbParser("Data/smfx_badHYDBND.pdb") parser.PDBtags.remove("HYDBND") del parser.pdbRecordParser['HYDBND'] parser.parse() failure = False hdbndLines = parser.getRecords(parser.allLines, "HYDBND") try: parser.parse_PDB_HYDBND(hbndLines) except: failure = True assert failure
def test_parseFileWrongFormat(): from MolKit.pdbParser import PdbParser parser = PdbParser("Data/fakePDB.pdb") mols = parser.parse() assert mols is None or len(mols)==0 parser = PdbParser("Data/hpi1s.mol2") mols = parser.parse() assert mols is None or len(mols)==0 from MolKit.mol2Parser import Mol2Parser parser = Mol2Parser("Data/1crn.pdb") mols=parser.parse() assert mols is None or len(mols)==0
def test_parseMol_HelixRec(): from MolKit.pdbParser import PdbParser parser = PdbParser('Data/1crn.pdb') parser.SetReadOptions('HELIX') assert 'HELIX' in parser.pdbRecordParser.keys() mols = parser.parse() assert parser.recordInfo.has_key('HELIX')
def getTheMol(filename): # from MolKit.protein import Protein from MolKit.pdbParser import PdbParser parser = PdbParser(filename=filename) mol = parser.parse() # mol.read( filename, PdbParser() ) return mol
def Read(filename, modelsAs='molecules'): if not os.path.exists(filename): raise AssertionError , "%s does't exist" %filename from MolKit.pdbParser import PdbParser, PdbqParser,PdbqsParser,\ PdbqtParser, PQRParser from MolKit.mol2Parser import Mol2Parser from MolKit.mmcifParser import MMCIFParser ext = string.split(filename, '.') if ext[-1]=='pdb': parser = PdbParser(filename, modelsAs=modelsAs) elif ext[-1]=='pdbq': parser = PdbqParser(filename, modelsAs=modelsAs) elif ext[-1]=='pdbqt': parser = PdbqtParser(filename, modelsAs=modelsAs) elif ext[-1]=='pdbqs': parser = PdbqsParser(filename, modelsAs=modelsAs) elif ext[-1]=='pqr': parser = PQRParser(filename, modelsAs=modelsAs) elif ext[-1]=='mol2': parser = Mol2Parser(filename) #??should modelsAs be available for mol2 format?? elif ext[-1]=='cif': parser = MMCIFParser(filename, modelsAs=modelsAs) else: print "File Format unknown can't parse it" return [] molecules = parser.parse() return molecules
def test_parseHYDBND_3(): """ check that HYDBND records are read correctly when names start with a space (eg residue name " A1") """ from MolKit.pdbParser import PdbParser parser = PdbParser("Data/bdna_HS.pdb") m = parser.parse()[0] assert len(m.allAtoms.get(lambda x: hasattr(x, 'hbonds')))==110
def test_parseHYDBND_3(): """ check that HYDBND records are read correctly when names start with a space (eg residue name " A1") """ from MolKit.pdbParser import PdbParser parser = PdbParser("Data/bdna_HS.pdb") m = parser.parse()[0] assert len(m.allAtoms.get(lambda x: hasattr(x, 'hbonds'))) == 110
def test_parseSSData_2(): """ Calling parseSSData after setting the readOption to parse HELIX, STRAND, TURN, etc...""" from MolKit.pdbParser import PdbParser parser = PdbParser('Data/1crn.pdb') parser.SetReadOptions('HELIX') parser.SetReadOptions('SHEET') parser.SetReadOptions('TURN') mols = parser.parse() assert parser.recordInfo.has_key('HELIX') assert parser.recordInfo.has_key('SHEET') assert parser.recordInfo.has_key('TURN') ssDataForMol = parser.parseSSData(mols[0])
def Read(filename=None, alllines=None, dataformat='pdb', modelsAs='molecules'): if not alllines and not filename: raise AssertionError("%s invalid molecule" % filename) elif alllines and filename: alllines = None elif filename: if not os.path.exists(filename): raise AssertionError("%s does't exist" % filename) if alllines: ext = dataformat args = [None, alllines] else: ext = filename.split('.')[1] args = [filename, None] if ext == 'pdb': parser = PdbParser(*args, modelsAs=modelsAs) elif ext == 'pdbq': parser = PdbqParser(*args, modelsAs=modelsAs) elif ext == 'pdbqt': parser = PdbqtParser(*args, modelsAs=modelsAs) elif ext == 'pdbqs': parser = PdbqsParser(*args, modelsAs=modelsAs) elif ext == 'pqr': parser = PQRParser(*args, modelsAs=modelsAs) # FIXME: pass all lines??? elif ext == 'mol2': parser = Mol2Parser( filename) # ??should modelsAs be available for mol2 format?? elif ext == 'cif': parser = MMCIFParser(filename) elif ext == 'f2d': parser = F2DParser(filename) else: print("File Format unknown can't parse it") return [] molecules = parser.parse() return molecules
def Read(filename, modelsAs='molecules'): if not os.path.exists(filename): raise AssertionError, "%s does't exist" % filename from MolKit.pdbParser import PdbParser, PdbqParser,PdbqsParser,\ PdbqtParser, PQRParser, F2DParser from MolKit.mol2Parser import Mol2Parser from MolKit.mmcifParser import MMCIFParser ext = string.split(filename, '.') if ext[-1] == 'pdb': parser = PdbParser(filename, modelsAs=modelsAs) elif ext[-1] == 'pdbq': parser = PdbqParser(filename, modelsAs=modelsAs) elif ext[-1] == 'pdbqt': parser = PdbqtParser(filename, modelsAs=modelsAs) elif ext[-1] == 'pdbqs': parser = PdbqsParser(filename, modelsAs=modelsAs) elif ext[-1] == 'pqr': parser = PQRParser(filename, modelsAs=modelsAs) elif ext[-1] == 'mol2': parser = Mol2Parser( filename) #??should modelsAs be available for mol2 format?? elif ext[-1] == 'cif': parser = MMCIFParser(filename, modelsAs=modelsAs) elif ext[-1] == 'f2d': parser = F2DParser(filename) else: print "File Format unknown can't parse it" return [] molecules = parser.parse() return molecules
def Read(filename): from MolKit.pdbParser import PdbParser, PdbqParser, PdbqsParser, PQRParser from MolKit.mol2Parser import Mol2Parser ext = string.split(filename, '.') if ext[-1] == 'pdb': parser = PdbParser(filename) elif ext[-1] == 'pdbq': parser = PdbqParser(filename) elif ext[-1] == 'pdbqs': parser = PdbqsParser(filename) elif ext[-1] == 'pqr': parser = PQRParser(filename) elif ext[-1] == 'mol2': parser = Mol2Parser(filename) else: print "File Format unknown can't parse it" return [] molecules = parser.parse() return molecules
def Read(filename): from MolKit.pdbParser import PdbParser, PdbqParser,PdbqsParser, PQRParser from MolKit.mol2Parser import Mol2Parser ext = string.split(filename, '.') if ext[-1]=='pdb': parser = PdbParser(filename) elif ext[-1]=='pdbq': parser = PdbqParser(filename) elif ext[-1]=='pdbqs': parser = PdbqsParser(filename) elif ext[-1]=='pqr': parser = PQRParser(filename) elif ext[-1]=='mol2': parser = Mol2Parser(filename) else: print "File Format unknown can't parse it" return [] molecules = parser.parse() return molecules
def test_parseMol_BasicRec(): from MolKit.pdbParser import PdbParser parser = PdbParser('Data/1crn.pdb') mols = parser.parse()
def test_parseSSData(): from MolKit.pdbParser import PdbParser parser = PdbParser('Data/1crn.pdb') mols = parser.parse() ssDataForMol = parser.parseSSData(mols[0])