Re: [AMBER] [parmed.py] chemistry.exceptions.AmberParmError loading topology file

From: Jason Swails <jason.swails.gmail.com>
Date: Wed, 9 Sep 2015 21:50:01 -0400

On Wed, Sep 9, 2015 at 1:34 PM, Eiros Zamora, Juan <
j.eiros-zamora14.imperial.ac.uk> wrote:

> Dear Amber users,
>
> I’m running into the following error when trying to load a topology file
> to parmed.py.
>
> Traceback (most recent call last):
> File "/usr/local/amber15/bin/parmed.py", line 126, in <module>
> amber_prmtop.add_parm(parm)
> File
> "/usr/local/amber15/lib/python2.7/site-packages/ParmedTools/parmlist.py",
> line 34, in add_parm
> parm = load_file(parm)
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/formats/registry.py",
> line 121, in load_file
> return cls.parse(filename, **kws)
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/amberformat.py",
> line 347, in parse
> return LoadParm(filename)
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/readparm.py",
> line 69, in LoadParm
> parm = parm.view(AmberParm)
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/amberformat.py",
> line 411, in view
> return cls.load_from_rawdata(self)
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/_amberparm.py",
> line 240, in load_from_rawdata
> inst.initialize_topology()
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/_amberparm.py",
> line 196, in initialize_topology
> self.load_structure()
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/_amberparm.py",
> line 384, in load_structure
> self._check_section_lengths()
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/_amberparm.py",
> line 1215, in _check_section_lengths
> check_length('ATOMIC_NUMBER', natom, False)
> File
> "/usr/local/amber15/lib/python2.7/site-packages/chemistry/amber/_amberparm.py",
> line 1204, in check_length
> (key, len(self.parm_data[key]), length))
> chemistry.exceptions.AmberParmError: FLAG ATOMIC_NUMBER has 303288
> elements; expected 7425
>

​A couple other people have reported this exact error before, but I've
never been able to figure out *why* they would be getting it. It is clear
what's happening, though -- the ATOMIC_NUMBER section is not having the
values corresponding to the water atoms removed from its list (all other
sections get properly trimmed, but not this one).

I dug through some of the history of the ParmEd development, and was able
to reproduce this behavior with AmberTools version 13, and based on a quick
perusal of the code in AmberTools 14, it appears to happen there as well.

However, the problem has *definitely* been fixed as of AmberTools 15, so
what I suspect happened here is that you used parmed.py from AmberTools 14
to strip out the water residues from your prmtop file and generate a new
one. AmberTools 15 introduced a sanity check to make sure that all of the
prmtop arrays had the expected length, and ATOMIC_NUMBER failed that test.

If you still have the original prmtop file, use parmed.py to strip the
water to generate a prmtop file (rather than using parmed.py from
AmberTools 14).

If you have a little Python savvy, you can use the following script to
patch up your prmtop file:

#!/usr/bin/env python

​from chemistry.amber.readparm import AmberFormat

parm = AmberFormat('your.prmtop') # Substitute your prmtop name
parm.parm_data['ATOMIC_NUMBER'] = parm.parm_data['ATOMIC_NUMBER'][:7425]
parm.writeParm('your.prmtop')

That should fix your prmtop (assuming that all you deleted was water, since
tleap always puts water at the end). In the future, always using
AmberTools 15's ParmEd to strip solvent will avoid this problem.

HTH,
Jason

-- 
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Wed Sep 09 2015 - 19:00:03 PDT
Custom Search