jszopi / repESP

Reproducing molecular ESP from partial charges and more
GNU General Public License v3.0
6 stars 7 forks source link

resp_helpers cant import some .resp files #15

Closed RFogarty1 closed 7 years ago

RFogarty1 commented 7 years ago

Hey Jan,

I think im supposed to use pull request for this kinda thing, but i dont really understand it so i'm using "issues" for now.

So resp_helpers.py cant import .resp format files (i.e those from ambertools espgen) if number of atoms>10 and number of fit points>10000. In this case the header string will look something like: " 3419443" for 34 atoms and 19443 fit points. resp_helpers.txt

This breaks the "_read_top" and "_read_header_esp" functions, since both rely line.split() to seperate the number of atoms from the number of fit points. Pretty sure i fixed this by just changing the functions to(hopefully file attached):

def _read_top(self, fn, f, line):
    top_line_format_in_esp = FortranRecordWriter('2I5')
    top_line_format_reader = FortranRecordReader('2I5')
    if line == " ESP FILE - ATOMIC UNITS":
        return 'Gaussian'

    try:
        _a, _b = top_line_format_reader.read(line)
    except ValueError:
        self.raiseInputFormatError(fn)

    if line == top_line_format_in_esp.write([int(_a), int(_b)]):
        return 'repESP'
    else:
        self.raiseInputFormatError(fn)

def _read_header_esp(self, line):
    self.atom_count, self.points_count = FortranRecordReader('2I5').read(line)
    self.atom_count = int(self.atom_count)
    self.points_count = int(self.points_count)
jszopi commented 7 years ago

Good catch, good patch. I followed it with some clean-up in #16 and merging now, so you can test.