コード例 #1
0
ファイル: PdbSearcher.py プロジェクト: pengfeili1/pymsmt
                    reso = float(line[-2])
                except:
                    reso = 'UNKNOWN'
        elif 'EXPERIMENT TYPE' in line:
            line = line.split()
            exptyp = line[-1]
            if line[-1] == 'DIFFRACTION' and line[-2] == 'X-RAY':
                exptyp = 'X-RAY'
    fp1.close()

    #Get the metal ion which is the ion user want to process
    metallist = []
    for i in atids:
        resname = mol.residues[mol.atoms[i].resid].resname
        atname = mol.atoms[i].atname
        if (resname, atname) in list(METAL_PDB.keys()):
            if METAL_PDB[(resname, atname)][0] == ionname:
                metallist.append(i)

    #for each metal ion in the metal list, print the metal center
    for i in metallist:

        mccrds = [] #The crds of metal site
        crdi = mol.atoms[i].crd
        elmti = mol.atoms[i].element
        residi = mol.atoms[i].resid
        atnamei = mol.atoms[i].atname
        resnamei = mol.residues[residi].resname
        radiusi = CoRadiiDict[elmti]
        mcresids = [] #MetalCenter residue IDs
コード例 #2
0
ファイル: readpdb.py プロジェクト: aslyons/pymsmt
def get_atominfo_fpdb(fname):
    Atoms = {}
    Residues = {}

    atids = []
    resids = []
    resnamedict = {}
    conterdict = {}

    fp = open(fname, 'r')

    for line in fp:
        if (line[0:4] == "ATOM") or (line[0:6] == "HETATM"):
            gtype = line[0:6].strip(" ")
            atid = int(line[6:11])
            atids.append(atid)
            atname = line[12:16].strip(" ")
            allocind = line[16:17]
            resname = line[17:20].strip(" ")
            chainid = line[21:22]
            resid = int(line[22:26])
            codeinsert = line[26:27]
            crdx = float(line[30:38])
            crdy = float(line[38:46])
            crdz = float(line[46:54])
            crd = (crdx, crdy, crdz)
            occp = line[54:60]
            tempfac = line[60:66]
            atomtype = line[76:78].strip(" ")
            charge = line[78:80]

            if (resname, atname) in list(METAL_PDB.keys()):
                element = METAL_PDB[(resname, atname)][0]
            elif atname[0:2].upper() in ['CL', 'BR']:
                element = atname[0].upper() + atname[1].lower()
            else:
                element = atname[0]

            if atid not in list(Atoms.keys()):
                Atoms[atid] = Atom(gtype, atid, atname, element, atomtype, crd,
                                   charge, resid, resname)
            else:
                raise pymsmtError('There are more than one atom with atom id '
                                  '%d in the PDB file : %s .' % (atid, fname))

            if resid not in resids:
                resids.append(resid)
            if resid not in list(resnamedict.keys()):
                resnamedict[resid] = resname

    fp.close()

    resids.sort()

    for i in resids:
        preconter = []
        for j in atids:
            if (Atoms[j].resid == i) and (j not in preconter):
                preconter.append(j)
        preconter.sort()
        conterdict[i] = preconter

    for i in resids:
        resname = resnamedict[i]
        resconter = conterdict[i]
        Residues[i] = Residue(i, resname, resconter)

    del resnamedict
    del conterdict

    mol = Molecule(Atoms, Residues)

    return mol, atids, resids
コード例 #3
0
ファイル: readmol2.py プロジェクト: aslyons/pymsmt
def get_atominfo(fname):

    #Detect the line numbers of each part information
    fp = open(fname, 'r')
    lnum = 1
    for line in fp:
        if ("@<TRIPOS>ATOM" in line):
            atbgin = lnum + 1
        elif ("@<TRIPOS>BOND" in line):
            atend = lnum
        lnum = lnum + 1
    fp.close()

    Atoms = {}
    Residues = {}

    atids = []
    resids = []
    resnamedict = {}
    conterdict = {}

    for i in range(atbgin, atend):
        atid, atname, crdx, crdy, crdz, atomtype, resid, resname, charge = \
        linecache.getline(fname, i).split()[:9]

        #for atom part
        gtype = "ATOM"
        atid = int(atid)
        atids.append(atid)
        crd = (float(crdx),float(crdy),float(crdz))
        charge = float(charge)
        resid = int(resid)

        if (resname, atname) in list(METAL_PDB.keys()):
            element = METAL_PDB[(resname, atname)][0]
        elif atname[0:2].upper() in ['CL', 'BR']:
            element = atname[0].upper() + atname[1].lower()
        else:
            element = atname[0]

        if atid not in list(Atoms.keys()):
            Atoms[atid] = Atom(gtype, atid, atname, element, atomtype, crd, charge, resid, resname)
        else:
            raise pymsmtError('There are more than one atom with atom id '
                              '%d in the mol2 file : %s .' %(atid, fname))

        #for the residue part
        if resid not in resids:
            resids.append(resid)
        if resid not in list(resnamedict.keys()):
            resnamedict[resid] = resname

    #clean the memory
    linecache.clearcache()

    resids.sort()

    for i in resids:
        preconter = []
        for j in atids:
            if (Atoms[j].resid == i) and (j not in preconter):
                preconter.append(j)
        preconter.sort()
        conterdict[i] = preconter

    for i in resids:
        resname = resnamedict[i]
        resconter = conterdict[i]
        Residues[i] = Residue(i, resname, resconter)

    del resnamedict
    del conterdict

    mol = Molecule(Atoms, Residues)

    return mol, atids, resids
コード例 #4
0
ファイル: PdbSearcher.py プロジェクト: aslyons/pymsmt
                    reso = float(line[-2])
                except:
                    reso = 'UNKNOWN'
        elif 'EXPERIMENT TYPE' in line:
            line = line.split()
            exptyp = line[-1]
            if line[-1] == 'DIFFRACTION' and line[-2] == 'X-RAY':
                exptyp = 'X-RAY'
    fp1.close()

    #Get the metal ion which is the ion user want to process
    metallist = []
    for i in atids:
        resname = mol.residues[mol.atoms[i].resid].resname
        atname = mol.atoms[i].atname
        if (resname, atname) in list(METAL_PDB.keys()):
            if METAL_PDB[(resname, atname)][0] == ionname:
                metallist.append(i)

    #for each metal ion in the metal list, print the metal center
    for i in metallist:

        mccrds = []  #The crds of metal site
        crdi = mol.atoms[i].crd
        elmti = mol.atoms[i].element
        residi = mol.atoms[i].resid
        atnamei = mol.atoms[i].atname
        resnamei = mol.residues[residi].resname
        radiusi = CoRadiiDict[elmti]
        mcresids = []  #MetalCenter residue IDs