Skip to content

Commit

Permalink
Change parsing method for /params/mmff.prm to be more pythonic.
Browse files Browse the repository at this point in the history
This fixes a bug where the first line (or first lines, I did not test how many were missing) of the atom types did not
get pulled into atomtypes/atomnums properly.
  • Loading branch information
zjp committed May 22, 2020
1 parent db88539 commit e0acdc5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Tinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import os
import shlex
import shutil
import sys
import subprocess
Expand Down Expand Up @@ -127,18 +128,14 @@ def ReadConformers(TinkerOutputs, Isomers, settings):
#Reads force field parameter file to understand atom notation in the output
def ExtractAtomTypes(settings):
# open settings.TinkerPath + 'params/mmff.prm
paramfile = open(settings.TinkerPath + '/params/mmff.prm', 'r')
paramdata = paramfile.readlines()
paramfile.close()
atomtypes = []
atomnums = []
for line in paramdata[75:]:
data = [_f for _f in line.split(' ') if _f]
if len(data) < 3:
break
atomtypes.append(data[3])
atomnums.append(int(data[5]))

with open(settings.TinkerPath + '/params/mmff.prm', 'r') as f:
for line in f:
if line.split(' ')[0] == 'atom':
data = shlex.split(line, posix=False)
atomtypes.append(data[3])
atomnums.append(int(data[-3]))
return atomtypes, atomnums

#Reads the relevant tinker geometry files
Expand Down

0 comments on commit e0acdc5

Please sign in to comment.