Skip to content

Commit

Permalink
Config file reading into settings structure works
Browse files Browse the repository at this point in the history
  • Loading branch information
KristapsE committed May 9, 2020
1 parent 203cbe6 commit 40b7ec2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
33 changes: 29 additions & 4 deletions PyDP4.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,10 @@ def main(settings):
# Create isomer data structures
Isomers = [Isomer(f.split('.sdf')[0]) for f in settings.InputFiles]

# Run conformational search, if requested

print("Assuming all computations are done? ... ",settings.AssumeDone )

print("Using preexisting DFT data? ... ",settings.UseExistingInputs)

# Run conformational search, if requested
if ('m' in settings.Workflow) and not (settings.AssumeDone or settings.UseExistingInputs):

print("Performing conformational search using ", end="")
Expand Down Expand Up @@ -507,10 +505,37 @@ def NMR_files(NMR_args):
return


# Read the config file and fill in the corresponding attributes in settings class
def ReadConfig(settings):

configfile = open('settings.cfg', 'r')
config = configfile.readlines()
configfile.close()

# Read in the new settings values from config
newsettings = []
for line in config:
if ('#' in line) or (len(line)<3) or ('=' not in line):
continue

newsettings.append([x.strip() for x in line[:-1].split('=')])
if len(newsettings[-1]) < 2:
newsettings[-1].append('')

print('\n'.join([x[0] + ': ' + x[1] for x in newsettings]))

# Set the attributes in the settings class
for setting in newsettings:
if hasattr(settings, setting[0]):
setattr(settings, setting[0], setting[1])

return settings


if __name__ == '__main__':

# Read config file and fill in settings in from that

settings = ReadConfig(settings)

# These are then overridden by any explicit parameters given through the command line
parser = argparse.ArgumentParser(description='PyDP4 script to setup\
Expand Down
7 changes: 4 additions & 3 deletions settings.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Config file for DP4-AI settings
# Any settings here override the hardcoded defaults in the PyDP4.py
# Empty lines or lines containing # are ignored
# Setting definition starts with settings attribute, followed by equals sign,
# then the value. No quotes, no spaces anywhere

Expand All @@ -8,11 +9,11 @@ SCHRODINGER=

# Define the root folder for Tinker software,
# must contain bin/scan and params/mmff.prm for the process to work
TinkerPath=/home/ah809/Downloads/tinker/
TinkerPath=/home/ke291/Downloads/tinker/

# Path to nwchem executable. If it's in the path, can be just 'nwchem'
# Path to nwchem executable. If it's in the path, can be just nwchem
NWChemPath=nwchem

# Path to Gaussian executable. If it's in the path, can be just 'g09' or 'g16'
# Path to Gaussian executable. If it's in the path, can be just g09 or g16
# If left empty, it will attempt to use g09 in GAUS_EXEDIR environment variable
GausPath=

0 comments on commit 40b7ec2

Please sign in to comment.