Repository: marrink-lab/vermouth-martinize (language: python)

Issue:
Problems with -nt -cter and -nter when Martinizing from Charmm36 to M3
### These problems were encountered in the latest development version of martinize2/vermouth which was downloaded 18/10-2022.

I should preface by saying that martinize2 successfully martinizes the terminals if no terminal-relating flags are given (though it results in charged terminals).

**-nt with a proline C-terminal**
Martinization causes the following warning:
"WARNING - unmapped-atom - These atoms are not covered by a mapping. Either your mappings don't describe all atoms (bad idea), or, there's no mapping available for all residues. ['7285A-PRO500:OXT']"

The AA proline C-terminal is shown below though the error persists event if the last three atoms are removed and "7284 NT" is changed to "7284  O" to reflect the standard proline mapping as described in the "pro.charmm36.map" file for martini3001:
ATOM   7271  N   PRO A 500      51.433  37.411  30.113  1.00  0.00           N
ATOM   7272  CD  PRO A 500      50.019  37.684  30.421  1.00  0.00           C
ATOM   7273  HD1 PRO A 500      49.948  38.596  31.013  1.00  0.00           H
ATOM   7274  HD2 PRO A 500      49.572  36.802  30.881  1.00  0.00           H
ATOM   7275  CA  PRO A 500      51.751  37.549  28.681  1.00  0.00           C
ATOM   7276  HA  PRO A 500      52.256  36.651  28.327  1.00  0.00           H
ATOM   7277  CB  PRO A 500      50.381  37.674  28.003  1.00  0.00           C
ATOM   7278  HB1 PRO A 500      50.390  38.528  27.324  1.00  0.00           H
ATOM   7279  HB2 PRO A 500      50.141  36.742  27.492  1.00  0.00           H
ATOM   7280  CG  PRO A 500      49.391  37.913  29.082  1.00  0.00           C
ATOM   7281  HG1 PRO A 500      49.029  38.940  29.021  1.00  0.00           H
ATOM   7282  HG2 PRO A 500      48.547  37.236  28.956  1.00  0.00           H
ATOM   7283  C   PRO A 500      52.596  38.773  28.364  1.00  0.00           C
ATOM   7284  NT  PRO A 500      52.776  38.809  27.381  1.00  0.00           N  
ATOM   7285  HT1 PRO A 500      52.409  38.099  26.780  1.00  0.00           H    
ATOM   7286  HT2 PRO A 500      53.320  39.556  26.999  1.00  0.00           H  
ATOM   7287  O   PRO A 500      52.761  39.663  29.201  1.00  0.00           O

**-nter**
It i martinize using "-nter NCAP-ter" then the following NameError is produced:
"NameError: NCAP-ter is not known as a modification for force field charmm"

**-cter**
Identical problem and error to the one for -nter just with CCAP-ter instead

Am i doing something wrong with the -nter and -cter, because I do not see how it would be possible to use the CCAP and NCAP terminal as described in the force_fields/martini3001/modifications.ff file as it currently works.


Discussion / hints:
@MikkelDA thanks for reporting this. We're on top of this and that's why the dev branch is not released yet. Terminal cappings currently are not working due to missing data files. 

@pckroon not sure what is happening with the Proline; I thought we had fixed that
For the -nter and -cter flags are intended to describe changes to the *atomistic* structure you provide, and as such you should use the modification names in https://github.com/marrink-lab/vermouth-martinize/blob/master/vermouth/data/force_fields/charmm/modifications.ff. Concretely: COOH-ter and NH2-ter for protonated/uncharged termini. If you need CH3 capped termini that's currently not quite possible indeed, since the charmm modifications are missing (PR welcome). In addition, you'll need the appropriate mappings (see https://github.com/marrink-lab/vermouth-martinize/blob/master/vermouth/data/mappings/martini3001/modifications.charmm36.mapping for inspiration). 

What's the full martinize2 output (with -v) for a C-terminal proline with either `-nt` or `-cter COOH-ter`? Does the COOH-ter modification get applied at the atomistic level at least?
My guess is that the modification mapping doesn't apply since it also maps the HN atom, which proline doesn't have.
### Reply to pckroon

**The file "LOG_martinize2_COOHter" contains the martinize2 output with "-cter COOH-ter". Full command shown below (it created the same warning as the other "-cter" and "-nter" flags that i originally posted):**
martinize2 -f 03_prot_editconf.pdb -x 04_output_martinize.pdb -o topol.top -ff martini3001 -from charmm -dssp /mnt/software/dssp/3.1.2/bin/mkdssp -p backbone -elastic -ef 700 -el 0.5 -eu 0.9 -ea 0 -ep 0 -scfix -cys auto -resid input -mutate HSE:HSD -mutate ASP152:ASPP -cter COOH-ter -v
[LOG_martinize2_COOHter.log](https://github.com/marrink-lab/vermouth-martinize/files/9836921/LOG_martinize2_COOHter.log)

**The file "LOG_martinize2_nt" contains the martinize2 output with "-nt". Full command shown below:**
martinize2 -f 03_prot_editconf.pdb -x 04_output_martinize.pdb -o topol.top -ff martini3001 -from charmm -dssp /mnt/software/dssp/3.1.2/bin/mkdssp -p backbone -elastic -ef 700 -el 0.5 -eu 0.9 -ea 0 -ep 0 -scfix -cys auto -resid input -mutate HSE:HSD -mutate ASP152:ASPP -v -nt &> LOG_martinize2_nt
[LOG_martinize2_nt.log](https://github.com/marrink-lab/vermouth-martinize/files/9836955/LOG_martinize2_nt.log)


Fix patch:
diff --git a/vermouth/data/mappings/martini3001/modifications.charmm36.mapping b/vermouth/data/mappings/martini3001/modifications.charmm36.mapping
index 852c13b7..f727d29a 100644
--- a/vermouth/data/mappings/martini3001/modifications.charmm36.mapping
+++ b/vermouth/data/mappings/martini3001/modifications.charmm36.mapping
@@ -11,10 +11,8 @@ C-ter
 
 [ from nodes ]
 N
-HN
 
 [ from edges ]
-HN N
 N CA
 
 [ mapping ]
@@ -63,14 +61,11 @@ COOH-ter
 
 [ from nodes ]
 N
-HN
 
 [ from edges ]
-HN N
 N CA
 
 [ mapping ]
-HN BB
 N BB
 CA BB
 C  BB


Test patch:
diff --git a/vermouth/tests/data/integration_tests/tier-0/dipro-termini/README b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/README
new file mode 100644
index 00000000..e2801e10
--- /dev/null
+++ b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/README
@@ -0,0 +1,1 @@
+# Test with a PRO-PRO dipeptide to make sure neutral termini can be applied to proline
\ No newline at end of file
diff --git a/vermouth/tests/data/integration_tests/tier-0/dipro-termini/aa.pdb b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/aa.pdb
new file mode 100644
index 00000000..33eaa2fe
--- /dev/null
+++ b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/aa.pdb
@@ -0,0 +1,62 @@
+ATOM      1  N   PRO     2       0.649  -0.549   1.064  1.00  0.00           N  
+ATOM      2  CA  PRO     2       1.159   0.454   0.141  1.00  0.00           C  
+ATOM      3  C   PRO     2       1.064   1.870   0.735  1.00  0.00           C  
+ATOM      4  O   PRO     2       0.038   2.239   1.307  1.00  0.00           O  
+ATOM      5  CB  PRO     2       0.249   0.252  -1.080  1.00  0.00           C  
+ATOM      6  CG  PRO     2      -1.068  -0.252  -0.471  1.00  0.00           C  
+ATOM      7  CD  PRO     2      -0.604  -1.157   0.674  1.00  0.00           C  
+ATOM      8  HA  PRO     2       2.202   0.248  -0.110  1.00  0.00           H  
+ATOM      9 2HB  PRO     2       0.674  -0.529  -1.713  1.00  0.00           H  
+ATOM     10 3HB  PRO     2       0.122   1.162  -1.671  1.00  0.00           H  
+ATOM     11 2HG  PRO     2      -1.687  -0.787  -1.194  1.00  0.00           H  
+ATOM     12 3HG  PRO     2      -1.629   0.591  -0.063  1.00  0.00           H  
+ATOM     13 2HD  PRO     2      -0.421  -2.174   0.318  1.00  0.00           H  
+ATOM     14 3HD  PRO     2      -1.313  -1.168   1.504  1.00  0.00           H  
+ATOM     15  N   PRO     3       2.065   2.676   0.631  1.00  0.00           N  
+ATOM     16  CA  PRO     3       2.041   4.028   1.170  1.00  0.00           C  
+ATOM     17  C   PRO     3       1.097   4.940   0.368  1.00  0.00           C  
+ATOM     18  O   PRO     3       0.469   4.496  -0.594  1.00  0.00           O  
+ATOM     19  CB  PRO     3       3.516   4.441   1.055  1.00  0.00           C  
+ATOM     20  CG  PRO     3       4.021   3.647  -0.159  1.00  0.00           C  
+ATOM     21  CD  PRO     3       3.298   2.304  -0.028  1.00  0.00           C  
+ATOM     22  H01 PRO     3       1.032   6.867  -0.035  1.00  0.00           H  
+ATOM     23  O01 PRO     3       0.947   6.312   0.743  1.00  0.00           O  
+ATOM     24  HA  PRO     3       1.718   4.019   2.214  1.00  0.00           H  
+ATOM     25 2HB  PRO     3       4.048   4.108   1.949  1.00  0.00           H  
+ATOM     26 3HB  PRO     3       3.648   5.519   0.942  1.00  0.00           H  
+ATOM     27 2HG  PRO     3       5.107   3.532  -0.162  1.00  0.00           H  
+ATOM     28 3HG  PRO     3       3.703   4.143  -1.078  1.00  0.00           H  
+ATOM     29 2HD  PRO     3       3.860   1.618   0.609  1.00  0.00           H  
+ATOM     30 3HD  PRO     3       3.102   1.845  -1.000  1.00  0.00           H  
+TER   
+CONECT    1    2    7
+CONECT    2    1    3    5    8
+CONECT    3    2    4   15
+CONECT    4    3
+CONECT    5    2    6    9   10
+CONECT    6    5    7   11   12
+CONECT    7    1    6   13   14
+CONECT    8    2
+CONECT    9    5
+CONECT   10    5
+CONECT   11    6
+CONECT   12    6
+CONECT   13    7
+CONECT   14    7
+CONECT   15    3   16   21
+CONECT   16   15   17   19   24
+CONECT   17   16   18   23
+CONECT   18   17
+CONECT   19   16   20   25   26
+CONECT   20   19   21   27   28
+CONECT   21   15   20   29   30
+CONECT   22   23
+CONECT   23   17   22
+CONECT   24   16
+CONECT   25   19
+CONECT   26   19
+CONECT   27   20
+CONECT   28   20
+CONECT   29   21
+CONECT   30   21
+END
diff --git a/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/cg.pdb b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/cg.pdb
new file mode 100644
index 00000000..98b0d213
--- /dev/null
+++ b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/cg.pdb
@@ -0,0 +1,8 @@
+ATOM      1 BB   PRO     1       0.674   1.038   0.858  1.00  0.00              
+ATOM      2 SC1  PRO     1      -0.474  -0.386  -0.292  1.00  0.00              
+ATOM      3 BB   PRO     2       1.271   4.576   0.417  1.00  0.00              
+ATOM      4 SC1  PRO     2       3.612   3.464   0.289  1.00  0.00              
+TER       5      PRO     2 
+CONECT    1    2    3
+CONECT    3    4
+END   
\ No newline at end of file
diff --git a/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/citation b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/citation
new file mode 100644
index 00000000..6209c13b
--- /dev/null
+++ b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/citation
@@ -0,0 +1,1 @@
+Souza, P C T; Alessandri, R; Barnoud, J; Thallmair, S; Faustino, I; Grünewald, F; Patmanidis, I; Abdizadeh, H; Bruininks, B M H; Wassenaar, T A; Kroon, P C; Melcr, J; Nieto, V; Corradi, V; Khan, H M; Domański, J; Javanainen, M; Martinez-Seara, H; Reuter, N; Best, R B; Vattulainen, I; Monticelli, L; Periole, X; Tieleman, D P; de Vries, A H; Marrink, S J;  Nature Methods 2021; 10.1038/s41592-021-01098-3
\ No newline at end of file
diff --git a/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/command b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/command
new file mode 100644
index 00000000..4e096bad
--- /dev/null
+++ b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/command
@@ -0,0 +1,6 @@
+martinize2
+-f ../aa.pdb
+-x cg.pdb
+-o topol.top
+-ff martini3001
+-nt
diff --git a/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/molecule_0.itp b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/molecule_0.itp
new file mode 100644
index 00000000..2b8820b3
--- /dev/null
+++ b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/molecule_0.itp
@@ -0,0 +1,31 @@
+; This file was generated using the following command:
+; /homes/peterkroon/virtualenvs/martinize2/bin/martinize2 -f ../aa.pdb -x cg.pdb -o topol.top -ff martini3001 -nt
+; martinize with vermouth 0.7.4.dev121
+
+; Pleas cite the following papers:
+; Souza, P C T; Alessandri, R; Barnoud, J; Thallmair, S; Faustino, I; Grünewald, F; Patmanidis, I; Abdizadeh, H; Bruininks, B M H; Wassenaar, T A; Kroon, P C; Melcr, J; Nieto, V; Corradi, V; Khan, H M; Domański, J; Javanainen, M; Martinez-Seara, H; Reuter, N; Best, R B; Vattulainen, I; Monticelli, L; Periole, X; Tieleman, D P; de Vries, A H; Marrink, S J;  Nature Methods 2021; 10.1038/s41592-021-01098-3
+
+[ moleculetype ]
+molecule_0 1
+
+[ atoms ]
+1 P6  1 PRO BB  1   0 
+2 SC3 1 PRO SC1 2 0.0 
+3 P6  2 PRO BB  3   0 
+4 SC3 2 PRO SC1 4 0.0 
+
+[ bonds ]
+; Backbone bonds
+1 3 1 0.350 4000
+
+; Side chain bonds
+1 2 1 0.330 7500
+3 4 1 0.330 7500
+
+[ angles ]
+; BBS angles regular martini
+1 3 4 2 100 25
+
+; First SBB regular martini
+2 1 3 2 100 25
+
diff --git a/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/topol.top b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/topol.top
new file mode 100644
index 00000000..a45ed27a
--- /dev/null
+++ b/vermouth/tests/data/integration_tests/tier-0/dipro-termini/martinize2/topol.top
@@ -0,0 +1,9 @@
+
+#include "martini.itp"
+#include "molecule_0.itp"
+
+[ system ]
+Title of the system
+
+[ molecules ]
+molecule_0    1
diff --git a/vermouth/tests/integration_tests/test_integration.py b/vermouth/tests/integration_tests/test_integration.py
index 2e105f8b..9cd793e8 100644
--- a/vermouth/tests/integration_tests/test_integration.py
+++ b/vermouth/tests/integration_tests/test_integration.py
@@ -128,6 +128,7 @@ def _interaction_equal(interaction1, interaction2):
     ['tier-0', 'mini-protein1_betasheet'],
     ['tier-0', 'mini-protein2_helix'],
     ['tier-0', 'mini-protein3_trp-cage'],
+    ['tier-0', 'dipro-termini'],
     ['tier-1', 'bpti'],
     ['tier-1', 'lysozyme'],
     ['tier-1', 'lysozyme_prot'],