コード例 #1
0
def resp_fitting(stpdbf, lgpdbf, stfpf, lgfpf, mklogf, ionids,\
           ffchoice, mol2fs, metcenres2, chgmod, fixchg_resids, g0x, lgchg):

    print "******************************************************************"
    print "*                                                                *"
    print "*======================RESP Charge fitting=======================*"
    print "*                                                                *"
    print "******************************************************************"

    gene_resp_input_file(lgpdbf, ionids, stfpf, ffchoice, mol2fs,
                         chgmod, fixchg_resids, lgchg)

    #-------------------------------------------------------------------------
    ####################RESP charge fitting###################################
    #-------------------------------------------------------------------------

    print '***Doing the RESP charge fiting...'

    espf = mklogf.strip('.log') + '.esp'

    if g0x in ['g03', 'g09']:
      get_esp_from_gau(mklogf, espf)
    elif g0x == 'gms':
      get_esp_from_gms(mklogf, espf)

    os.system("resp -O -i resp1.in -o resp1.out -p resp1.pch -t resp1.chg \
               -e %s -s resp1_calc.esp" %espf)
    os.system("resp -O -i resp2.in -o resp2.out -p resp2.pch -q resp1.chg \
              -t resp2.chg -e %s -s resp2_calc.esp" %espf)

    #-------------------------------------------------------------------------
    ####################Collecting the atom type and charge data##############
    #-------------------------------------------------------------------------

    #------------Atom type----------
    sddict = {} #get the atom type information from standard model
    scf = open(stfpf, 'r')
    for line in scf:
      if line[0:4] != "LINK":
        line = line.strip('\n')
        line = line.split(' ')
        line = [i for i in line if i != '']
        if len(line[-1]) == 1:
          line[-1] = line[-1] + ' '
        sddict[line[0]] = line[-1]
    scf.close()

    #------------Charge-------------
    chgs = read_resp_file('resp2.chg')

    metcenres1 = [] #original name of the metal center residue
    stlist = [] #get the atom name list from the standard model
    stf = open(stfpf, 'r')
    for line in stf:
      if line[0:4] != "LINK":
        line = line.strip('\n')
        line = line.split()
        stlist.append(line[0])
        line = line[0].split('-')
        lresname = line[0] + '-' + line[1]
        if lresname not in metcenres1:
          metcenres1.append(lresname)
    stf.close()

    llist = [] #get the atom name list from the large model
    lf = open(lgfpf, 'r')
    for line in lf:
      line = line.strip('\n')
      llist.append(line)
    lf.close()

    ldict = {} #get charge of the large model, one-to-one relationship
    for i in range(0, len(llist)):
      ldict[llist[i]] = chgs[i]

    stdict = {} #get the charge of the standard model
    for i in ldict.keys():
      if i in stlist:
        stdict[i] = ldict[i]

    #-------------------------------------------------------------------------
    ####################Checking Models#########################
    #-------------------------------------------------------------------------

    print "=========================Checking models=========================="
    print '***Check the large model...'
    if len(chgs) != len(llist):
      raise pymsmtError('Error: the charges and atom numbers are mismatch '
                        'for the large model!')
    else:
      print 'Good. The charges and atom numbers are match for the ' + \
            'large model.'
      print 'Good. There are ' + str(len(llist)) + ' atoms in the ' + \
            'large model.'

    print '***Check the standard model...'
    if len(stlist) != len(stdict):
      raise pymsmtError('Error: the charges and atom numbers are mismatch '
                        'for the standard model!')
    else:
      print 'Good. The charges and atom numbers are match for the ' + \
            'standard model.'
      print 'Good. There are ' + str(len(stlist)) + ' atoms in the ' + \
            'standard model.'

    print '***Check the residue names provided...'
    if len(metcenres1) != len(metcenres2):
      print 'You gave the residue names: ', str(metcenres2)
      print 'Database had them: ', str(metcenres1)
      raise pymsmtError('Error: The number of the residue names given is '
                        'mismatch the database!')
    else:
      print 'Good. The number of the residue names given matches ' + \
            'the database.'

    #-------------------------------------------------------------------------
    ####################Building mol2 files for modeling######################
    #-------------------------------------------------------------------------
 
    #Load the force field
    libdict, chargedict = get_lib_dict(ffchoice)

    for mol2f in mol2fs:
      libdict1, chargedict1 = get_lib_dict(mol2f)
      libdict.update(libdict1)
      chargedict.update(chargedict1)

    ##get the bondlist
    mol, atids, resids = get_atominfo_fpdb(stpdbf) #from standard pdb

    blist = get_mc_blist(mol, atids, ionids, stfpf)

    blist2 = [(i[0], i[1]) for i in blist]

    print "=======================Building mol2 files========================"
    #for each residue, print out the mol2 file
    for i in range(0, len(resids)):

      resconter = mol.residues[resids[i]].resconter #atom ids in the residue
      resname1 =  mol.residues[resids[i]].resname #load residue name
      resname2 = metcenres2[i] #new residue name

      #Backbone atoms use AMBER backbone atom types
      #if resname1 in resnamel:
      #  for bbatm in ['N', 'H', 'CA', 'HA','C', 'O']:
      #    key1 = str(resids[i]) + '-' + resname1 + '-' + bbatm
      #    key2 = resname1 + '-' + bbatm
      #    sddict[key1] = libdict[key2][0]

      #New id dict
      iddict1 = {}
      for j in range(0, len(resconter)):
        iddict1[resconter[j]] = j + 1

      #Bond list for each residue with new atom ids
      blist_each = []
      for k in blist2:
        if set(resconter) & set(k) == set(k):
          blist_each.append((iddict1[k[0]], iddict1[k[1]]))

      print_mol2f(resids[i], resname1, resname2, resconter, mol, iddict1, \
                  sddict, stdict, blist_each)
コード例 #2
0
ファイル: espgen.py プロジェクト: hainm/pymsmt
This is a module for generate the esp points from the Gaussian/GAMESS-US
output file.
"""
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------

from pymsmtmol.gauio import get_esp_from_gau
from pymsmtmol.gmsio import get_esp_from_gms
from optparse import OptionParser

parser = OptionParser("usage: -i input_file -o output_file [-v software]")

parser.set_defaults(softversion='gau')

parser.add_option("-i", dest="inputfile", type='string',
                  help="Input file name")
parser.add_option("-o", dest="outputfile", type='string',
                  help="Output file name")
parser.add_option("-v", dest="softversion", type='string',
                  help="Software version [Default is gau (means Gaussian), \n"
                       "           other option is gms (means GAMESS-US)]")
(options, args) = parser.parse_args()

if options.softversion == 'gau':
    get_esp_from_gau(options.inputfile, options.outputfile)
elif options.softversion == 'gms':
    get_esp_from_gms(options.inputfile, options.outputfile)

quit()

コード例 #3
0
ファイル: espgen.py プロジェクト: RichardYin1996/pymsmt
from pymsmtmol.gauio import get_esp_from_gau
from pymsmtmol.gmsio import get_esp_from_gms
from optparse import OptionParser

parser = OptionParser("usage: -i input_file -o output_file [-v software]")

parser.set_defaults(softversion='gau')

parser.add_option("-i",
                  dest="inputfile",
                  type='string',
                  help="Input file name")
parser.add_option("-o",
                  dest="outputfile",
                  type='string',
                  help="Output file name")
parser.add_option("-v",
                  dest="softversion",
                  type='string',
                  help="Software version [Default is gau (means Gaussian), \n"
                  "           other option is gms (means GAMESS-US)]")
(options, args) = parser.parse_args()

if options.softversion == 'gau':
    get_esp_from_gau(options.inputfile, options.outputfile)
elif options.softversion == 'gms':
    get_esp_from_gms(options.inputfile, options.outputfile)

quit()