# 'ligandHybrid' ERROR: fitting mol2 on mol1 failed

**URL:** <https://ask.bioexcel.eu/t/ligandhybrid-error-fitting-mol2-on-mol1-failed/4846>\
**Category:** pmx\
**Created:** [February 17, 2024, 1:14pm UTC](https://ask.bioexcel.eu/t/ligandhybrid-error-fitting-mol2-on-mol1-failed/4846 "2024-02-17T13:14:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yehon](https://avatars.discourse-cdn.com/v4/letter/y/e99b99/32.png) [@yehon](https://ask.bioexcel.eu/u/yehon)\
**Post date:** [February 17, 2024, 1:14pm UTC](https://ask.bioexcel.eu/t/ligandhybrid-error-fitting-mol2-on-mol1-failed/4846/1 "2024-02-17T13:14:03Z")

</div>

Hello, I’ve been working on merging itp files for my ligands using the ‘ligandHybrid’ script, but I’m encountering issues with specific ligands. While the tool works fine for some, others result in errors during the hybrid topology generation process. Here’s a brief overview of the error messages I’m receiving:

> ligandHybridTop\_\_log\_\> ERROR: fitting mol2 on mol1 failed  
> ligandHybridTop\_\_log\_\> Initializing the main object for LigandHybridTopology  
> ligandHybridTop\_\_log\_\> Starting hybrid topology generation  
> ligandHybridTop\_\_log\_\> Making atom pairs…  
> …  
> Violation occurred on line 62 in file /home/conda/feedstock\_root/build\_artifacts/rdkit\_1707396357915/work/Code/GraphMol/Conformer.cpp  
> Failed Expression: 19 \< 7  
> …  
> self.\_make\_atom\_pairs( )  
> File “/usr/people/daniel/yehon/anaconda3/envs/rdkit-env/lib/python3.8/site-packages/pmx/ligand\_alchemy.py”, line 2172, in \_make\_atom\_pairs  
> a4 = self.m4.fetch\_atoms(n2,how=‘byid’)[0]  
> IndexError: list index out of range

The process seems to fail when trying to fit molecule 2 on molecule 1, and eventually throws an IndexError during the creation of atom pairs. I think it might be related to the ‘rdkit’ package, which I installed via Conda following the standard procedure. Furthermore, in the ‘Failed Expression: 19 \< 7’ the number 19 is not constant, it change with the increase of the ligand number of atoms.

I’ve attached the complete error log and the files relevant to the process (PDB files for the ligands, modified itp files, and the pairs.dat file) for reference.  
[error.txt](https://ask.bioexcel.eu/uploads/short-url/c5T2UxJoVrVnz6RH6X4K8ihZzhF.txt) (17.1 KB)

[NC18\_mod.itp.txt](https://ask.bioexcel.eu/uploads/short-url/cxMWielTFoMa84n3XI2gy9Ftvdi.txt) (31.6 KB)  
[NC1\_mod.itp.txt](https://ask.bioexcel.eu/uploads/short-url/iKhErCk2XZUYl35STjMslzNC0vd.txt) (2.6 KB)  
[NC1.pdb](https://ask.bioexcel.eu/uploads/short-url/cvxb8B9yMPkERIHuoaUYTJ0qjde.pdb) (745 Bytes)  
[NC18.pdb](https://ask.bioexcel.eu/uploads/short-url/jWoGDxZM7nGoHxPXUu8Ms9qoEEw.pdb) (4.6 KB)  
[pairs.dat](https://ask.bioexcel.eu/uploads/short-url/lYx3jZYmEkIexbq3OHPwuPJz4gG.dat) (34 Bytes)

The command used was:  
pmx ligandHybrid -i1 NC18.pdb -i2 NC1.pdb -itp1 NC18\_mod.itp -itp2 NC1\_mod.itp -pairs pairs.dat --scDUMd 0.1

Any help will be useful,  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![Sudchem](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@Sudchem](https://ask.bioexcel.eu/u/Sudchem)\
**Post date:** [February 21, 2024, 7:27am UTC](https://ask.bioexcel.eu/t/ligandhybrid-error-fitting-mol2-on-mol1-failed/4846/2 "2024-02-21T07:27:13Z")

</div>

Hi,

It seems like rdkit isn’t finding an appropriate alignment between these two molecules, which could be because of the difference in the two molecules. NC1 contains just two heavy atoms whereas NC18 is a linear chain of 19 heavy atoms.

You could play with the -n1 and -n2 flags of “pmx ligandHybrid” and see.

Also, do you see a similar issue when working with two more similar molecules, say NC1 and NC2?

Best,  
Sudarshan

---

<div class="post-metadata">

**Author:** ![yehon](https://avatars.discourse-cdn.com/v4/letter/y/e99b99/32.png) [@yehon](https://ask.bioexcel.eu/u/yehon)\
**Post date:** [February 21, 2024, 8:57am UTC](https://ask.bioexcel.eu/t/ligandhybrid-error-fitting-mol2-on-mol1-failed/4846/3 "2024-02-21T08:57:14Z")

</div>

Thank you very much, Sudarshan,

I tried using -n1 and -n2 with ndx files created by ‘gmx make\_ndx’ without success; the problem remains the same. I believe this problem is directly related to the number of atoms. For example, in NC18, I get “Failed Expression: 19 \< 7,” while for NC15, I get “Failed Expression: 14 \< 7.” Indeed, it works for the transition of smaller molecules to NC1.

Thanks,  
Yehonatan

---

<div class="post-metadata">

**Author:** ![Sudchem](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@Sudchem](https://ask.bioexcel.eu/u/Sudchem)\
**Post date:** [February 21, 2024, 9:10am UTC](https://ask.bioexcel.eu/t/ligandhybrid-error-fitting-mol2-on-mol1-failed/4846/4 "2024-02-21T09:10:01Z")

</div>

It seems to be an rdkit issue, and I don’t know if there is any workaround.

Even if you succeed in aligning two largely different molecules like NC1 and NC18, it would be hard to get a converged free energy estimate, because of sampling issues. NC18 can have a variety of conformations, and it would not be easy to sample those with nonequilibrium transitions from NC1.

Is it possible to divide the transformation into smaller steps, like NC1-NC3, NC3-NC5, …, NC15-NC17?

Best,  
Sudarshan

---

<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:** [February 21, 2024, 9:53am UTC](https://ask.bioexcel.eu/t/ligandhybrid-error-fitting-mol2-on-mol1-failed/4846/5 "2024-02-21T09:53:47Z")

</div>

You have mixed the order of your molecules in the command line. The pairs.dat file has atoms of NC1 in the first column and atoms of NC18 in the second column. So you need to consistently provide -i1 NC1.pdb and -i2 NC18.pdb (the same with -itp options). The following command works fine:

pmx ligandHybrid -i1 NC1.pdb -i2 NC18.pdb -itp1 NC1\_mod.itp -itp2 NC18\_mod.itp -pairs pairs.dat --scDUMd 0.1
