Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
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 
Ejemplo n.º 5
0
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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')
Ejemplo n.º 8
0
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    
Ejemplo n.º 9
0
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
Ejemplo n.º 10
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')
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
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
Ejemplo n.º 13
0
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
Ejemplo n.º 14
0
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])
Ejemplo n.º 15
0
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])
Ejemplo n.º 16
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
Ejemplo n.º 17
0
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
Ejemplo n.º 18
0
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
Ejemplo n.º 19
0
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
Ejemplo n.º 20
0
def test_parseMol_BasicRec():
    from MolKit.pdbParser import PdbParser
    parser = PdbParser('Data/1crn.pdb')
    mols = parser.parse()
Ejemplo n.º 21
0
def test_parseSSData():
    from MolKit.pdbParser import PdbParser
    parser = PdbParser('Data/1crn.pdb')
    mols = parser.parse()
    ssDataForMol = parser.parseSSData(mols[0])
Ejemplo n.º 22
0
def test_parseMol_BasicRec():
    from MolKit.pdbParser import PdbParser
    parser = PdbParser('Data/1crn.pdb')
    mols = parser.parse()
Ejemplo n.º 23
0
def test_parseSSData():
    from MolKit.pdbParser import PdbParser
    parser = PdbParser('Data/1crn.pdb')
    mols = parser.parse()
    ssDataForMol = parser.parseSSData(mols[0])