Example #1
0
def get_atominfo(fname):

    #Detect the line numbers of each part information
    fp = open(fname, 'r')
    lnum = 1
    for line in fp:
        if (line == "@<TRIPOS>ATOM\n"):
            atbgin = lnum + 1
        elif (line == "@<TRIPOS>BOND\n"):
            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 Metalpdb.keys():
            element = Metalpdb[(resname, atname)]
        else:
            element = atname[0]

        Atoms[atid] = Atom(gtype, atid, atname, element, atomtype, crd, charge,
                           resid, resname)

        #for the residue part
        if resid not in resids:
            resids.append(resid)
        if resid not in 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
Example #2
0
                    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 Metalpdb.keys():
            if Metalpdb[(resname, atname)] == 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
Example #3
0
                    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 Metalpdb.keys():
            if Metalpdb[(resname, atname)] == 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
Example #4
0
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 Metalpdb.keys():
                element = Metalpdb[(resname, atname)]
            else:
                element = atname[0]

            Atoms[atid] = Atom(gtype, atid, atname, element, atomtype, crd,
                               charge, resid, resname)

            if resid not in resids:
                resids.append(resid)
            if resid not in 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
Example #5
0
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 Metalpdb.keys():
        element = Metalpdb[(resname, atname)]
      else:
        element = atname[0]

      Atoms[atid] = Atom(gtype, atid, atname, element, atomtype, crd, charge, resid, resname)

      if resid not in resids:
        resids.append(resid)
      if resid not in 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
Example #6
0
def get_atominfo(fname):

    #Detect the line numbers of each part information
    fp = open(fname, 'r')
    lnum = 1
    for line in fp:
      if (line == "@<TRIPOS>ATOM\n"):
        atbgin = lnum + 1
      elif (line == "@<TRIPOS>BOND\n"):
        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 Metalpdb.keys():
        element = Metalpdb[(resname, atname)]
      else:
        element = atname[0]

      Atoms[atid] = Atom(gtype, atid, atname, element, atomtype, crd, charge, resid, resname)

      #for the residue part
      if resid not in resids:
        resids.append(resid)
      if resid not in 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