# Problem in using gentop

**URL:** <https://ask.bioexcel.eu/t/problem-in-using-gentop/4073>\
**Category:** pmx\
**Created:** [January 12, 2023, 3:38am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073 "2023-01-12T03:38:02Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 12, 2023, 3:38am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/1 "2023-01-12T03:38:02Z")

</div>

Hi @vgapsys,  
I have been trying my hand in protein mutations and while using the pmx gentop to fill in the B states I have been encountering an error like this:

```auto
pmx gentop -f topol.top -o newtop.top -ff ./mutff45/charmm36mut.ff/

log_> Reading input top file "topol.top"
log_> Making bonds for state B -> 0 bonds with perturbed atoms
log_> Making angles for state B -> 0 angles with perturbed atoms
log_> Making dihedrals for state B -> 0 dihedrals with perturbed atoms
log_> Removed 0 fake dihedrals
log_> Total charge of state A = 0
log_> Total charge of state B = 0

log_> Reading input itp file "topol_Protein_chain_A.itp""
Traceback (most recent call last):
  File "/home/ps004/anaconda3/envs/pmx/bin/pmx", line 8, in <module>
    sys.exit(entry_point())
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/scripts/cli.py", line 97, in entry_point
    PmxCli()
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/scripts/cli.py", line 44, in __init__
    getattr(self, args.command)()
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/scripts/cli.py", line 52, in gentop
    generate_hybrid_topology.entry_point()
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/scripts/generate_hybrid_topology.py", line 180, in entry_point
    main(args)
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/scripts/generate_hybrid_topology.py", line 143, in main
    pmxtop, pmxitps = gen_hybrid_top(topol=topol, recursive=recursive,
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/alchemy.py", line 296, in gen_hybrid_top
    topol2 = Topology(itp_filename, ff=ff, version='new')
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/forcefield.py", line 1750, in __init__
    self.assign_fftypes()
  File "/home/ps004/anaconda3/envs/pmx/lib/python3.10/site-packages/pmx/forcefield.py", line 1787, in assign_fftypes
    atom.type = self.NBParams.atomtypes[atom.atomtype]['bond_type']
KeyError: 'NP'

```

In the above mentioned case, the topol.top does have the include statement pointing towards the force field.

Moreover the same happens with individual itp files for the two chains.  
However, when I use the individual topology files(itp) for both the chains of the protein using the norecursive option, it is able to fill in the b-states.

Regards,  
Pallav

---

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 12, 2023, 4:31am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/2 "2023-01-12T04:31:36Z")

</div>

Hi all,  
I was doing it the wrong way.  
Followed the steps as provided in the tutorial [Mutation free energy](http://pmx.mpibpc.mpg.de/sardinia2019_tutorial1/index.html) to generate the mutant structure and the hybrid topologies and it did pretty well.  
Cheers,  
Pallav

---

<div class="post-metadata">

**Author:** ![vgapsys](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vgapsys](https://ask.bioexcel.eu/u/vgapsys)\
**Post date:** [January 12, 2023, 12:39pm UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/3 "2023-01-12T12:39:58Z")

</div>

Great to see that the issue was resolved.

Did you also identify what exactly was triggering the error earlier? Did you need to modify the command line? Or maybe updated the pmx version?

---

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 16, 2023, 5:29am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/4 "2023-01-16T05:29:37Z")

</div>

Hi @vgapsys,  
I could not identify why it was causing an error.  
The thing I did was copy the force field I was using into the “./data” directory of “pmx” where the force fields resides and simply exported GMXLIB to that directory and used the  
`pmx gentop -f topol.top -o newtop.top`

I could not understand why was it not working from my local directory.

---

<div class="post-metadata">

**Author:** ![vgapsys](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vgapsys](https://ask.bioexcel.eu/u/vgapsys)\
**Post date:** [January 17, 2023, 9:39am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/5 "2023-01-17T09:39:07Z")

</div>

Could it be that the pmx mutation force fields were not in the GMXLIB path?

---

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 17, 2023, 11:54am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/6 "2023-01-17T11:54:36Z")

</div>

I was exporting the GMXLIB path to my local directory where it contained the necessary files such as residuetypes.dat etc.

---

<div class="post-metadata">

**Author:** ![vgapsys](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vgapsys](https://ask.bioexcel.eu/u/vgapsys)\
**Post date:** [January 17, 2023, 12:09pm UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/7 "2023-01-17T12:09:57Z")

</div>

pmx protein mutations use modified force field files which define mutated residues. These force fields need to be in the GMXLIB path

---

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 17, 2023, 12:44pm UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/8 "2023-01-17T12:44:29Z")

</div>

Yes but then there are other residues in my protein, co-factors etc. which are not defined in the pmx mutated force fields where I add those cgenff(such as cgenff.rtp) files from the recent CHARMM port of GROMACS.

---

<div class="post-metadata">

**Author:** ![vgapsys](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vgapsys](https://ask.bioexcel.eu/u/vgapsys)\
**Post date:** [January 17, 2023, 12:57pm UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/9 "2023-01-17T12:57:44Z")

</div>

In this case you will need to add to co-factors and other residues to the pmx force field containing information about the mutations. Or, alternatively, copy mutation information into your force field.

---

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 19, 2023, 4:33am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/10 "2023-01-19T04:33:36Z")

</div>

I wonder why it does not works from the local directory.

---

<div class="post-metadata">

**Author:** ![vgapsys](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vgapsys](https://ask.bioexcel.eu/u/vgapsys)\
**Post date:** [January 19, 2023, 9:26am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/11 "2023-01-19T09:26:40Z")

</div>

How exactly was it set up? Did you take the force field containing mutation residue information, place it in the local folder and then “pmx gentop” was not able to locate the forcefield? I just tested this procedure by running from within the “mutff” folder where all the pmx force fields are. This works even when the $GMXLIB is empty.

---

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 19, 2023, 10:54am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/12 "2023-01-19T10:54:21Z")

</div>

> [@vgapsys](#):
>
> Did you take the force field containing mutation residue information, place it in the local folder and then “pmx gentop” was not able to locate the forcefield

Yes that’s what I had done with a folder containing all the itp/rtp/mtp files for aminoacids or mutres etc. for which I had exported the path for GMXLIB. As you can see in the first post [https://ask.bioexcel.eu/t/problem-in-using-gentop/4073?u=s.pallav](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073) here, I had called the force field from the local directory and $GMXLIB was put to the local directory.  
The only reason for my concern is as I have to go for data generating phase I would have to transfer the files to a cluster where things could go messy with the relative paths of the files.

---

<div class="post-metadata">

**Author:** ![s.pallav](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@s.pallav](https://ask.bioexcel.eu/u/s.pallav)\
**Post date:** [January 20, 2023, 5:01am UTC](https://ask.bioexcel.eu/t/problem-in-using-gentop/4073/13 "2023-01-20T05:01:52Z")

</div>

Probably I was being foolish with GMXLIB path. Have understood it.  
Apologies.  
Regards,  
Pallav.
