Beispiel #1
0
 def add_molecule_from_punfile(self,filename):
   """ Adds a molecule to MolPop from a punfile"""
   a = mtp_tools.molecule()
   a.readfrompunfile(filename)
   a.Calc_locMTP()
   self.molecules.append(a)
   self.nmols += 1
Beispiel #2
0
        "Error: the script will generate a .lpun file, please rename current file."
    )
    exit(1)

# Read prmfile if given

prms = {}
if parmfile != '':
    import numpy
    f = open(parmfile, 'r')
    a = f.readlines()
    f.close()
    for line in a:
        b = line.split()
        prms[(b[0][2:-2], b[1][1:-2])] = numpy.array(
            [float(b[i + 3]) for i in range(len(b) - 3)])

mol = mtp_tools.molecule()
mol.readfrompunfile(punfile)
mol.Calc_locMTP()

if parmfile != '':
    for atom in mol.atoms:
        atom.chrg = prms[(atom.atype, 'chrg')]
        atom.dloc = prms[(atom.atype, 'dloc')]
        atom.Qloc = prms[(atom.atype, 'Qloc')]
    mol.Calc_gloMTP()

mol.adjust_charge()
mol.write_localized_mtp_file(punfile[:punfile.rindex('.')] + '.lpun')
Beispiel #3
0
import copy, os, string
import rdkit
import numpy, math
from rdkit import Chem
    
if basename[-4:] in ['.sdf','.log','.pun','.out']: basename = basename[:-4]

##############
# Get coordinates from the gaussian output file or the punfile
# The Gaussian output file is supposed to end on .log
# If no Gaussian output file that ends on .log is found, a gaussian output file 
#  that ends on .out is searched. If both are not found, the program is exited.

if punxyz == True:
  import mtp_tools, numpy
  mo = mtp_tools.molecule()
  mo.readfromrawpunfile(punchfile)
  xyzblock = []
  for atom in mo.atoms: xyzblock.append([atom.atype, float(atom.coords[0]), float(atom.coords[1]), float(atom.coords[2])])
else:
  outfiles = []
  outfile  = ''
  if os.path.exists(basename+'.log'):
    outfiles.append(basename+'.log')
  elif os.path.exists(basename+'.out'):
    outfiles.append(basename+'.out')

  for fi in outfiles:
    f = open(fi,'r')
    lines = f.readlines()
    for line in lines:
    elif sys.argv[i] == '-pun':    
        pun = sys.argv[i+1]
    elif sys.argv[i] == '-out':
        out = sys.argv[i+1]
    elif sys.argv[i] == '-chg':
        chg = int(sys.argv[i+1])


assert mtp[-4:] == '.txt'
assert pun[-3:] ==  'pun'

#############
# Load molecule

import mtp_tools
mol = mtp_tools.molecule()
if pun[-4:] == '.pun':
    mol.readfrompunfile(pun)
    mol.Calc_locMTP()
elif pun [-5:] == '.lpun':
    mol.readfromlpunfile(pun)
    mol.Calc_gloMTP()
else:
    print "Error. Punfile extension not recognized."
    exit(1)

#############
# Parse MTP parameter file
mtp_coef = {}
# Are there bond increments?
binc = False
Beispiel #5
0
import copy, os, string
import rdkit
from rdkit import Chem
    
if basename[-4:] in ['.sdf','.log','.pun','.out']: basename = basename[:-4]

##############
# Get coordinates from the gaussian output file or the punfile
# The Gaussian output file is supposed to end on .log
# If no Gaussian output file that ends on .log is found, a gaussian output file 
#  that ends on .out is searched. If both are not found, the program is exited.

if punxyz == True:
  import mtp_tools, numpy
  mo = mtp_tools.molecule()
  mo.readfromrawpunfile(basename+'.pun')
  xyzblock = []
  for atom in mo.atoms: xyzblock.append([atom.atype, float(atom.coords[0]), float(atom.coords[1]), float(atom.coords[2])])
else:
  outfiles = []
  outfile  = ''
  if os.path.exists(basename+'.log'):
    outfiles.append(basename+'.log')
  elif os.path.exists(basename+'.out'):
    outfiles.append(basename+'.out')

  for fi in outfiles:
    f = open(fi,'r')
    lines = f.readlines()
    for line in lines: