Pmx ligandHybrid list index out of range error

Hello,

I am currently using pmx to create hybrid topologies and ran into an list index error:
IndexError: list index out of range

I used ligandHybrid from pmx:
pmx ligandHybrid -i1 t1.pdb -i2 t2.pdb -itp1 t1.itp -itp2 t2.itp -pairs pairs2.dat

It was recommended from the other topics to swap the inputs, which resulted in the same list index error:

pmx ligandHybrid -i1 t2.pdb -i2 t1.pdb -itp1 t2.itp -itp2 t1.itp -pairs pairs2.dat

The itp files look like this:
t1:

; Created by cgenff_charmm2gmx.py

[ moleculetype ]
; Name			   nrexcl
SAMPLmol.pdb				 3

[ atoms ]
;	 nr		  type	resnr residue  atom   cgnr	   charge		mass  typeB    chargeB		massB
; residue	 1 SAMPLmol.pdb rtp SAMPLmol.pdb q	qsum
     1      OG311      1 SAMPLmol.pdb     O1      1     -0.537     15.999   ;
     2     CG2R61      1 SAMPLmol.pdb     C1      2      0.419     12.011   ;
     3     CG2R61      1 SAMPLmol.pdb     C2      3     -0.120     12.011   ;
     4     CG2R61      1 SAMPLmol.pdb     C3      4     -0.107     12.011   ;
     5     CG2R61      1 SAMPLmol.pdb     C4      5     -0.009     12.011   ;
     6     CG2R61      1 SAMPLmol.pdb     C5      6     -0.114     12.011   ;
     7     CG2R61      1 SAMPLmol.pdb     C6      7     -0.110     12.011   ;
     8     CG2R61      1 SAMPLmol.pdb     C7      8     -0.104     12.011   ;
     9     CG2R61      1 SAMPLmol.pdb     C8      9     -0.132     12.011   ;
    10     CG2R61      1 SAMPLmol.pdb     C9     10      0.294     12.011   ;
    11     NG2R60      1 SAMPLmol.pdb     N1     11     -0.590     14.007   ;
    12       HGP1      1 SAMPLmol.pdb     H1     12      0.420      1.008   ;
    13      HGR61      1 SAMPLmol.pdb     H2     13      0.115      1.008   ;
    14      HGR61      1 SAMPLmol.pdb     H3     14      0.115      1.008   ;
    15      HGR61      1 SAMPLmol.pdb     H4     15      0.115      1.008   ;
    16      HGR61      1 SAMPLmol.pdb     H5     16      0.115      1.008   ;
    17      HGR61      1 SAMPLmol.pdb     H6     17      0.115      1.008   ;
    18      HGR61      1 SAMPLmol.pdb     H7     18      0.115      1.008   ;

[ bonds ]
;	ai	  aj funct			  c0			c1			  c2			c3
    1     2	 1
    1    12	 1
    2     3	 1
    2    11	 1
    3     4	 1
    3    13	 1
    4     5	 1
    4    14	 1
    5    10	 1
    5     6	 1
    6    15	 1
    6     7	 1
    7    16	 1
    7     8	 1
    8     9	 1
    8    17	 1
    9    10	 1
    9    18	 1
   10    11	 1

[ pairs ]
;	ai	  aj funct			  c0			c1			  c2			c3
    1    10	 1
    1     4	 1
    1    13	 1
    2     9	 1
    2     5	 1
    2    14	 1
    3    10	 1
    3    12	 1
    3     6	 1
    4     9	 1
    4    11	 1
    4     7	 1
    4    15	 1
    5     8	 1
    5    13	 1
    5    18	 1
    5    16	 1
    6     9	 1
    6    17	 1
    6    11	 1
    6    14	 1
    7    10	 1
    7    18	 1
    8    11	 1
    8    15	 1
    9    16	 1
   10    14	 1
   10    15	 1
   10    17	 1
   11    12	 1
   11    13	 1
   11    18	 1
   13    14	 1
   15    16	 1
   16    17	 1
   17    18	 1

[ angles ]
;	ai	  aj	ak funct			c0			  c1			c2			  c3
    2     1    12	5
    1     2     3	5
    1     2    11	5
    3     2    11	5
    2     3     4	5
    2     3    13	5
    4     3    13	5
    3     4     5	5
    3     4    14	5
    5     4    14	5
   10     5     4	5
   10     5     6	5
    4     5     6	5
    5     6    15	5
    5     6     7	5
   15     6     7	5
   16     7     6	5
   16     7     8	5
    6     7     8	5
    9     8    17	5
    9     8     7	5
   17     8     7	5
   10     9    18	5
   10     9     8	5
   18     9     8	5
    9    10    11	5
    9    10     5	5
   11    10     5	5
    2    11    10	5

[ dihedrals ]
;	ai	  aj	ak	  al funct			  c0			c1			  c2			c3			  c4			c5
   12     1     2     3	 9
   12     1     2    11	 9
    1     2     3     4	 9
    1     2     3    13	 9
   11     2     3     4	 9
   11     2     3    13	 9
    1     2    11    10	 9
    3     2    11    10	 9
    2     3     4     5	 9
    2     3     4    14	 9
   13     3     4     5	 9
   13     3     4    14	 9
    3     4     5    10	 9
    3     4     5     6	 9
   14     4     5    10	 9
   14     4     5     6	 9
    4     5    10     9	 9
    4     5    10    11	 9
    6     5    10     9	 9
    6     5    10    11	 9
   10     5     6    15	 9
   10     5     6     7	 9
    4     5     6    15	 9
    4     5     6     7	 9
    5     6     7    16	 9
    5     6     7     8	 9
   15     6     7    16	 9
   15     6     7     8	 9
   16     7     8     9	 9
   16     7     8    17	 9
    6     7     8     9	 9
    6     7     8    17	 9
   17     8     9    10	 9
   17     8     9    18	 9
    7     8     9    10	 9
    7     8     9    18	 9
   18     9    10    11	 9
   18     9    10     5	 9
    8     9    10    11	 9
    8     9    10     5	 9
    9    10    11     2	 9
    5    10    11     2	 9


t2:

; Created by cgenff_charmm2gmx.py

[ moleculetype ]
; Name			   nrexcl
SAMPLmol.pdb				 3

[ atoms ]
;	 nr		  type	resnr residue  atom   cgnr	   charge		mass  typeB    chargeB		massB
; residue	 1 SAMPLmol.pdb rtp SAMPLmol.pdb q	qsum
     1      OG2D4      1 SAMPLmol.pdb     O1      1     -0.470     15.999   ;
     2     CG2R63      1 SAMPLmol.pdb     C1      2      0.183     12.011   ;
     3     NG2R61      1 SAMPLmol.pdb     N1      3     -0.286     14.007   ;
     4     CG2R62      1 SAMPLmol.pdb     C2      4      0.286     12.011   ;
     5     CG2R62      1 SAMPLmol.pdb     C3      5     -0.086     12.011   ;
     6     CG2R61      1 SAMPLmol.pdb     C4      6     -0.108     12.011   ;
     7     CG2R61      1 SAMPLmol.pdb     C5      7     -0.112     12.011   ;
     8     CG2R61      1 SAMPLmol.pdb     C6      8     -0.111     12.011   ;
     9     CG2R61      1 SAMPLmol.pdb     C7      9     -0.108     12.011   ;
    10     CG2R62      1 SAMPLmol.pdb     C8     10     -0.196     12.011   ;
    11     CG2R62      1 SAMPLmol.pdb     C9     11     -0.173     12.011   ;
    12       HGP1      1 SAMPLmol.pdb     H1     12      0.300      1.008   ;
    13      HGR61      1 SAMPLmol.pdb     H2     13      0.115      1.008   ;
    14      HGR61      1 SAMPLmol.pdb     H3     14      0.115      1.008   ;
    15      HGR61      1 SAMPLmol.pdb     H4     15      0.115      1.008   ;
    16      HGR61      1 SAMPLmol.pdb     H5     16      0.115      1.008   ;
    17      HGR62      1 SAMPLmol.pdb     H6     17      0.226      1.008   ;
    18      HGR62      1 SAMPLmol.pdb     H7     18      0.195      1.008   ;

[ bonds ]
;	ai	  aj funct			  c0			c1			  c2			c3
    1     2	 1
    2     3	 1
    2    11	 1
    3    12	 1
    3     4	 1
    4     9	 1
    4     5	 1
    5    10	 1
    5     6	 1
    6    13	 1
    6     7	 1
    7    14	 1
    7     8	 1
    8     9	 1
    8    15	 1
    9    16	 1
   10    17	 1
   10    11	 1
   11    18	 1

[ pairs ]
;	ai	  aj funct			  c0			c1			  c2			c3
    1     4	 1
    1    18	 1
    1    12	 1
    1    10	 1
    2     9	 1
    2    17	 1
    2     5	 1
    3     8	 1
    3    18	 1
    3    16	 1
    3     6	 1
    3    10	 1
    4     7	 1
    4    11	 1
    4    13	 1
    4    15	 1
    4    17	 1
    5     8	 1
    5    12	 1
    5    14	 1
    5    16	 1
    5    18	 1
    6     9	 1
    6    17	 1
    6    11	 1
    6    15	 1
    7    10	 1
    7    16	 1
    8    13	 1
    9    12	 1
    9    14	 1
    9    10	 1
   10    13	 1
   11    12	 1
   13    14	 1
   14    15	 1
   15    16	 1
   17    18	 1

[ angles ]
;	ai	  aj	ak funct			c0			  c1			c2			  c3
    1     2     3	5
    1     2    11	5
    3     2    11	5
   12     3     2	5
   12     3     4	5
    2     3     4	5
    9     4     3	5
    9     4     5	5
    3     4     5	5
   10     5     4	5
   10     5     6	5
    4     5     6	5
   13     6     5	5
   13     6     7	5
    5     6     7	5
   14     7     6	5
   14     7     8	5
    6     7     8	5
    9     8    15	5
    9     8     7	5
   15     8     7	5
   16     9     4	5
   16     9     8	5
    4     9     8	5
   17    10    11	5
   17    10     5	5
   11    10     5	5
    2    11    18	5
    2    11    10	5
   18    11    10	5

[ dihedrals ]
;	ai	  aj	ak	  al funct			  c0			c1			  c2			c3			  c4			c5
    1     2     3    12	 9
    1     2     3     4	 9
   11     2     3    12	 9
   11     2     3     4	 9
    1     2    11    18	 9
    1     2    11    10	 9
    3     2    11    18	 9
    3     2    11    10	 9
   12     3     4     9	 9
   12     3     4     5	 9
    2     3     4     9	 9
    2     3     4     5	 9
    3     4     9    16	 9
    3     4     9     8	 9
    5     4     9    16	 9
    5     4     9     8	 9
    9     4     5    10	 9
    9     4     5     6	 9
    3     4     5    10	 9
    3     4     5     6	 9
    4     5    10    17	 9
    4     5    10    11	 9
    6     5    10    17	 9
    6     5    10    11	 9
   10     5     6    13	 9
   10     5     6     7	 9
    4     5     6    13	 9
    4     5     6     7	 9
   13     6     7    14	 9
   13     6     7     8	 9
    5     6     7    14	 9
    5     6     7     8	 9
   14     7     8     9	 9
   14     7     8    15	 9
    6     7     8     9	 9
    6     7     8    15	 9
   15     8     9    16	 9
   15     8     9     4	 9
    7     8     9    16	 9
    7     8     9     4	 9
   17    10    11     2	 9
   17    10    11    18	 9
    5    10    11     2	 9
    5    10    11    18	 9

[ dihedrals ]
;	ai	  aj	ak	  al funct			  c0			c1			  c2			c3
    2    11     3     1	 2


Hello,

Could you please share the pdb files (t2.pdb, t1.pdb) and the screenshot of the error? It will help me to reproduce and resolve the same.

Thanks,
Sudarshan

Hello,

here are the requested files:

t1.pdb:

HEADER    PROTEIN                                 06-JUL-23   NONE
TITLE     NULL                                                        
COMPND    NULL                                                        
SOURCE    NULL                                                        
KEYWDS    NULL                                                        
EXPDTA    NULL                                                        
AUTHOR    Marvin                                                      
REVDAT   1   06-JUL-23         0                                  
HETATM    1  O   UNK     0       0.000  -3.080   0.000  0.00  0.00           O+0
HETATM    2  C   UNK     0       1.334  -2.310   0.000  0.00  0.00           C+0
HETATM    3  C   UNK     0       1.334  -0.770   0.000  0.00  0.00           C+0
HETATM    4  C   UNK     0       2.667   0.000   0.000  0.00  0.00           C+0
HETATM    5  C   UNK     0       4.001  -0.770   0.000  0.00  0.00           C+0
HETATM    6  C   UNK     0       5.335   0.000   0.000  0.00  0.00           C+0
HETATM    7  C   UNK     0       6.668  -0.770   0.000  0.00  0.00           C+0
HETATM    8  C   UNK     0       6.668  -2.310   0.000  0.00  0.00           C+0
HETATM    9  C   UNK     0       5.335  -3.080   0.000  0.00  0.00           C+0
HETATM   10  C   UNK     0       4.001  -2.310   0.000  0.00  0.00           C+0
HETATM   11  N   UNK     0       2.667  -3.080   0.000  0.00  0.00           N+0
CONECT    1    2                                                            
CONECT    2    1    3   11                                                  
CONECT    3    2    4                                                       
CONECT    4    3    5                                                       
CONECT    5    4    6   10                                                  
CONECT    6    5    7                                                       
CONECT    7    6    8                                                       
CONECT    8    7    9                                                       
CONECT    9    8   10                                                       
CONECT   10    9    5   11                                                  
CONECT   11   10    2                                                       
MASTER        0    0    0    0    0    0    0    0   11    0   24    0
END

t2.pdb:

HEADER    PROTEIN                                 06-JUL-23   NONE
TITLE     NULL                                                        
COMPND    NULL                                                        
SOURCE    NULL                                                        
KEYWDS    NULL                                                        
EXPDTA    NULL                                                        
AUTHOR    Marvin                                                      
REVDAT   1   06-JUL-23         0                                  
HETATM    1  O   UNK     0      -2.667  -3.080   0.000  0.00  0.00           O+0
HETATM    2  C   UNK     0      -1.334  -2.310   0.000  0.00  0.00           C+0
HETATM    3  N   UNK     0       0.000  -3.080   0.000  0.00  0.00           N+0
HETATM    4  C   UNK     0       1.334  -2.310   0.000  0.00  0.00           C+0
HETATM    5  C   UNK     0       1.334  -0.770   0.000  0.00  0.00           C+0
HETATM    6  C   UNK     0       2.667  -0.000   0.000  0.00  0.00           C+0
HETATM    7  C   UNK     0       4.001  -0.770   0.000  0.00  0.00           C+0
HETATM    8  C   UNK     0       4.001  -2.310   0.000  0.00  0.00           C+0
HETATM    9  C   UNK     0       2.667  -3.080   0.000  0.00  0.00           C+0
HETATM   10  C   UNK     0       0.000  -0.000   0.000  0.00  0.00           C+0
HETATM   11  C   UNK     0      -1.334  -0.770   0.000  0.00  0.00           C+0
CONECT    1    2                                                            
CONECT    2    1    3   11                                                  
CONECT    3    2    4                                                       
CONECT    4    3    5    9                                                  
CONECT    5    4    6   10                                                  
CONECT    6    5    7                                                       
CONECT    7    6    8                                                       
CONECT    8    7    9                                                       
CONECT    9    8    4                                                       
CONECT   10    5   11                                                       
CONECT   11   10    2                                                       
MASTER        0    0    0    0    0    0    0    0   11    0   24    0
END

The error:

ligandHybridTop__log_> Reading ligand 1 from: "t1.pdb"
ligandHybridTop__log_> Reading ligand 2 from: "t2.pdb"
ligandHybridTop__log_> Reading topology 1 from: "t1.itp"
ligandHybridTop__log_> Reading topology 2 from: "t2.itp"
ligandHybridTop__log_> Reading file with atom pairs: "pairs2.dat"
ligandHybridTop__log_> Assigning forcefield parameters....
ligandHybridTop__log_> Superimposing mol2 on mol1
ligandHybridTop__log_> Superimposing mol1 on mol2
ligandHybridTop__log_> Initializing the main object for LigandHybridTopology
ligandHybridTop__log_> Starting hybrid topology generation
ligandHybridTop__log_> Making atom pairs.....
ligandHybridTop__log_> Identifying dummies.....
ligandHybridTop__log_> Generated 11 atom-atom pairs
ligandHybridTop__log_> Dummies in state A: 0
ligandHybridTop__log_> Dummies in state B: 0
ligandHybridTop__log_> Making B-states....
ligandHybridTop__log_> Atom....:    1         OG311 |  -0.54 |  16.00 ->        OG2D4 |  -0.47 |  16.00
ligandHybridTop__log_> Atom....:    2        CG2R61 |   0.42 |  12.01 ->       CG2R63 |   0.18 |  12.01
ligandHybridTop__log_> Atom....:   11        NG2R60 |  -0.59 |  14.01 ->       NG2R61 |  -0.29 |  14.01
ligandHybridTop__log_> Atom....:   10        CG2R61 |   0.29 |  12.01 ->       CG2R62 |   0.29 |  12.01
ligandHybridTop__log_> Atom....:    5        CG2R61 |  -0.01 |  12.01 ->       CG2R62 |  -0.09 |  12.01
ligandHybridTop__log_> Atom....:    6        CG2R61 |  -0.11 |  12.01 ->       CG2R61 |  -0.11 |  12.01
ligandHybridTop__log_> Atom....:    7        CG2R61 |  -0.11 |  12.01 ->       CG2R61 |  -0.11 |  12.01
ligandHybridTop__log_> Atom....:    8        CG2R61 |  -0.10 |  12.01 ->       CG2R61 |  -0.11 |  12.01
ligandHybridTop__log_> Atom....:    9        CG2R61 |  -0.13 |  12.01 ->       CG2R61 |  -0.11 |  12.01
ligandHybridTop__log_> Atom....:    4        CG2R61 |  -0.11 |  12.01 ->       CG2R62 |  -0.20 |  12.01
ligandHybridTop__log_> Atom....:    3        CG2R61 |  -0.12 |  12.01 ->       CG2R62 |  -0.17 |  12.01
ligandHybridTop__log_> Constructing dummies....
ligandHybridTop__log_> Dummies in stateA: 
ligandHybridTop__log_> Dummies in stateB: 
ligandHybridTop__log_> Construct bonds....
Traceback (most recent call last):
  File "/bin/pmx", line 33, in <module>
    sys.exit(load_entry_point('pmx==0+untagged.880.g7418dab', 'console_scripts', 'pmx')())
  File "/pmx/scripts/cli.py", line 97, in entry_point
    PmxCli()
  File "/pmx/scripts/cli.py", line 44, in __init__
    getattr(self, args.command)()
  File "/pmx/scripts/cli.py", line 64, in ligandHybrid
    ligandHybrid.entry_point()
  File "/pmx/scripts/ligandHybrid.py", line 189, in entry_point
    main(args)
  File "/pmx/scripts/ligandHybrid.py", line 308, in main
    hybridTop._makeHybridTop( )
  File "/pmx/ligand_alchemy.py", line 2116, in _makeHybridTop
    self._make_bonds()
  File "/lib/python3.10/site-packages/pmx/ligand_alchemy.py", line 2330, in _make_bonds
    entr = self._get_ff_entry([idB1, idB2], self.itp2, what= 'bond')
  File "/lib/python3.10/site-packages/pmx/ligand_alchemy.py", line 2871, in _get_ff_entry
    return(out[3:][0])
IndexError: list index out of range

Best regards,

Limmski

Sorry there, had not seen the previous texts, the itp file needs epsilon and sigma values.
https://ask.bioexcel.eu/t/make-hybrid-py-list-index-out-of-range-error/2488/2?u=s.pallav

Regards,
Pallav.

The itp files need to have the parameters explicitly defined, i.e. bonds, angles and dihedrals need their parameters in the itp files