alanwilter / acpype

OFFICIAL: AnteChamber PYthon Parser interfacE
https://alanwilter.github.io/acpype/
GNU General Public License v3.0
201 stars 46 forks source link

ACPYPE fails with "Substring not found" error #7

Closed sukritsingh closed 5 years ago

sukritsingh commented 5 years ago

Hi,

I have a .prm and a .crd file for use in AMBER that I would like to convert to gromacs, however when I run the following command:

acpype.py -x mol_coord.crd -p mol-tor.prm -n 0 -o gmx

I get the following error in the output:

========================================================================================
| ACPYPE: AnteChamber PYthon Parser interfacE v. 2018-09-20T16:44:17UTC (c) 2019 AWSdS |
========================================================================================
Converting Amber input files to Gromacs ...
ACPYPE FAILED: substring not found
Total time of execution: less than a second

I subsequently ran the same command using the -d flag to get more details and got the following:

========================================================================================
| ACPYPE: AnteChamber PYthon Parser interfacE v. 2018-09-20T16:44:17UTC (c) 2019 AWSdS |
========================================================================================
DEBUG: Python Version 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
Converting Amber input files to Gromacs ...
ACPYPE FAILED: substring not found
  File "./acpype/acpype.py", line 3690, in <module>
    is_sorted=args.sorted, chiral=args.chiral)
  File "./acpype/acpype.py", line 3478, in __init__
    self.topo14Data.read_amber_topology(''.join(self.topFileData))
  File "./acpype/acpype.py", line 605, in read_amber_topology
    setattr(self, attributes[i], self.p7_array_read(buff, flag_strings[i]))
  File "./acpype/acpype.py", line 618, in p7_array_read
    i = buff.index(flag_string)
Total time of execution: less than a second

Could you provide any insight into why this might be happening and what the fix is?

Thanks! -Sukrit

alanwilter commented 5 years ago

It seems that your PRM file is missing something. Can you send me your input files so I can test and debug them here please?

alanwilter commented 5 years ago

To be more specific, your PRM file should contain all these flags:

        flag_strings = ["%FLAG POINTERS",
                        "%FLAG CHARGE",
                        "%FLAG ATOM_TYPE_INDEX",
                        "%FLAG NONBONDED_PARM_INDEX",
                        "%FLAG SCEE_SCALE_FACTOR",
                        "%FLAG SCNB_SCALE_FACTOR",
                        "%FLAG DIHEDRAL_FORCE_CONSTANT",
                        "%FLAG DIHEDRAL_PERIODICITY",
                        "%FLAG DIHEDRAL_PHASE",
                        "%FLAG DIHEDRALS_INC_HYDROGEN",
                        "%FLAG DIHEDRALS_WITHOUT_HYDROGEN",
                        "%FLAG LENNARD_JONES_ACOEF",
                        "%FLAG LENNARD_JONES_BCOEF"]

It seems your PRM file is missing at least one of them.

sukritsingh commented 5 years ago

Hi,

Thanks for the information! It turns out that a previous conversion in my pipeline had been unable to add the % for some of the flag_strings.

However, once that got fixed I hit upon another error when I ran acpype on the same .prmtop and .inpcrd files:

ACPYPE FAILED: array index out of range
  File "acpype.py", line 3631, in <module>
    system.writeGromacsTopolFiles(amb2gmx=True)
  File "acpype.py", line 2185, in writeGromacsTopolFiles
    self.writeGromacsTop(amb2gmx=amb2gmx)
  File "acpype.py", line 2865, in writeGromacsTop
    topText = self.topo14Data.patch_gmx_topol14(''.join(topText))
  File "acpype.py", line 668, in patch_gmx_topol14
    pair_buff = self.print_gmx_pairs()
  File "acpype.py", line 632, in print_gmx_pairs
    qi = self.charge[ai] / 18.222615

This writes the .GRO file out, but not the .TOP file.

I have attached the two input files, as well as the complete output log file into a zip. The command that caused this is: python acpype.py -x mol_start.inpcrd -p mol-tor.prmtop -n 0 -o gmx -d > ap_log.dat

acpype_log.zip

Thanks once again!

alanwilter commented 5 years ago

Please try the latest version. What happened is that your code is generating %COMMENT lines and our code was not aware of that, but I made it aware of. Thanks for helping us to make ACPYPE better.