marrink-lab / vermouth-martinize

Describe and apply transformation on molecular structures and topologies
Apache License 2.0
95 stars 43 forks source link

parameterizing ATP and MG+ #570

Closed Nancyarvin closed 8 months ago

Nancyarvin commented 8 months ago

Hi, I am trying to parameterize ATP and mg+ in order to coarse grain it from charmm to martini2. Pasting down the error below:

Traceback (most recent call last):
  File "/home/arvin/miniconda3/envs/python3.6.3_env/bin/martinize2", line 1110, in <module>
    entry()
  File "/home/arvin/miniconda3/envs/python3.6.3_env/bin/martinize2", line 761, in entry
    Path(DATA_PATH) / "mappings", known_force_fields
  File "/home/arvin/miniconda3/envs/python3.6.3_env/lib/python3.6/site-packages/vermouth/map_input.py", line 426, in read_mapping_directory
    new_mappings = read_backmapping_file(infile, force_fields)
  File "/home/arvin/miniconda3/envs/python3.6.3_env/lib/python3.6/site-packages/vermouth/map_input.py", line 87, in read_backmapping_file
    full_mapping = _read_mapping_partial(lines, line_number + 1)
  File "/home/arvin/miniconda3/envs/python3.6.3_env/lib/python3.6/site-packages/vermouth/map_input.py", line 338, in _read_mapping_partial
    _, from_atom, *to_atoms = cleaned.split()
ValueError: not enough values to unpack (expected at least 2, got 1)

It would be great if someone would help me in this regard. Zipped all the required files

Regards, Arvin

ATP and MG.zip

pckroon commented 8 months ago

I have the idea this is only a partial traceback/error. Could you provide the full screen output?

Nancyarvin commented 8 months ago

I did not get any output file. However, adding the screenshot of the error down below. Also check added the zip file of all the input files attached above error

pckroon commented 8 months ago

Hmmn, I was expecting more useful screen output from martinize, but alas.

Your MG mapping looks off. The atoms section should look like:

[ atoms ]
MG MG

Indicating that you want to map the charmm atom called MG (left) to the Martini22 bead MG (right)

Nancyarvin commented 8 months ago

I just had this much of output error on the screen. Here is the edited charmm36.map file of MG as per your suggestion: edited mg_charmm It is giving error: error2

pckroon commented 8 months ago

Alright, thanks. That should be an easy enough fix (the mass is simply not listed). I need to deep dive into the code next week anyway, so I'll also tackle this then.

There's something else going wrong with your charmm MG.rtp in combination with the pdb file. My guess (haven't looked at the files again) is that you need to specify the element column for the Mg ions in the pdb file. I'll get back to you on this next week.

PS. Please put text as text rather than figures, that helps in searching and makes everything easier to read.

Nancyarvin commented 8 months ago

Okay, thank you very much! Let me give the clarification so that you can fix it charmm rtp is:

[ bondedtypes ]
; Col 1: Type of bond 
; Col 2: Type of angles 
; Col 3: Type of proper dihedrals 
; Col 4: Type of improper dihedrals 
; Col 5: Generate all dihedrals if 1, only heavy atoms of 0. 
; Col 6: Number of excluded neighbors for nonbonded interactions 
; Col 7: Generate 1,4 interactions between pairs of hydrogens if 1 
; Col 8: Remove propers over the same bond as an improper if it is 1 
; bonds  angles  dihedrals  impropers  all_dihedrals  nrexcl  HH14  RemoveDih 
    1       5        9          2            1           3      1       0
[ MG ]
; Magnesium Ion
 [ atoms ]
    MG  MG  2.00    1

The martini22.ff is:

;;;;;; HYDRATED MAGNESIUM ION 
[moleculetype]
; molname   nrexcl
  MG        1
[atoms]
;id     type    resnr   residu  atom    cgnr    charge
 1  Qd  1   ION     MG  1   2.0 

For above I added the mass for MG in /vermouth/processors/attach_mass.py: line23 ATOM_MASSES = {'H': 1, 'C': 12, 'N': 14, 'O': 16, 'S': 32, 'P': 31, 'M': 0, 'MG': 24}

Still getting error:

(python3.6.3_env) arvin@iiitd:/10tb-storage/arvin/CG-ED-ATPboundABCA1$ martinize2 -f MG.pdb -dssp /usr/local/bin/dssp -x ATPboundABCA1_cg.pdb -o protein.top -p backbone -cys auto -elastic -ef 500.0 -el 0.5 -eu 0.9 -ff martini22 -from charmm
    INFO - general - Read 1 molecules from PDB file MG.pdb
    INFO - step - Guessing the bonds.
    INFO - general - 2 molecules after guessing bonds
    INFO - step - Repairing the graph.
   ERROR - inconsistent-data - Can't find isomorphism between A-MG2504 and its reference.
   ERROR - inconsistent-data - Can't find isomorphism between A-MG2505 and its reference.
    INFO - step - Dealing with modifications.
Traceback (most recent call last):
  File "/home/arvin/miniconda3/envs/python3.6.3_env/bin/martinize2", line 1110, in <module>
    entry()
  File "/home/arvin/miniconda3/envs/python3.6.3_env/bin/martinize2", line 885, in entry
    write_canon=args.write_canon,
  File "/home/arvin/miniconda3/envs/python3.6.3_env/bin/martinize2", line 166, in pdb_to_universal
    vermouth.AttachMass(attribute="mass").run_system(canonicalized)
  File "/home/arvin/miniconda3/envs/python3.6.3_env/lib/python3.6/site-packages/vermouth/processors/processor.py", line 37, in run_system
    mols.append(self.run_molecule(molecule))
  File "/home/arvin/miniconda3/envs/python3.6.3_env/lib/python3.6/site-packages/vermouth/processors/attach_mass.py", line 48, in run_molecule
    attach_mass(molecule, attribute=self.attribute)
  File "/home/arvin/miniconda3/envs/python3.6.3_env/lib/python3.6/site-packages/vermouth/processors/attach_mass.py", line 39, in attach_mass
    node[attribute] = ATOM_MASSES[node['element']]
KeyError: 'Mg'
pckroon commented 8 months ago

For above I added the mass for MG in /vermouth/processors/attach_mass.py: line23 ATOM_MASSES = {'H': 1, 'C': 12, 'N': 14, 'O': 16, 'S': 32, 'P': 31, 'M': 0, 'MG': 24}

'MG' is not the same as 'Mg' ;)

Nancyarvin commented 8 months ago

Oh okay! I changed that but Mg is not known to charmm, How can this be solved?

Error: (python3.6.3_env) arvin@iiitd:/10tb-storage/arvin/CG-ED-protein$ martinize2 -f protein.pdb -dssp /usr/local/bin/dssp -x protein_cg.pdb -o protein.top -p backbone -cys auto -elastic -ef 500.0 -el 0.5 -eu 0.9 -ff martini22 -from charmm -ff martini22
    INFO - general - Read 2 molecules from PDB file protein.pdb
    INFO - step - Guessing the bonds.
 WARNING - unknown-residue - Can't add bonds based on atom names for residue A-Mg2504 because 'Residue Mg is not known to force field charmm'. Falling back to distance criteria.
 WARNING - unknown-residue - Can't add bonds based on atom names for residue A-Mg2505 because 'Residue Mg is not known to force field charmm'. Falling back to distance criteria.
    INFO - general - 3 molecules after guessing bonds
    INFO - step - Repairing the graph.
    INFO - general - Applying modification N-ter to residue A-MET1
    INFO - general - Applying modification C-ter to residue A-LYS2270
 WARNING - unknown-residue - Cannot recognize residue 'Mg' in  molecule 1. Deleting the molecule.
 WARNING - unknown-residue - Cannot recognize residue 'Mg' in  molecule 2. Deleting the molecule.
    INFO - step - Dealing with modifications.
pckroon commented 8 months ago

Alright, found it :)

1) Your mapping is still off. It should be

[ molecule ]
MG
[from]
charmm
[to]
martini22
[ martini ]
Qd
[ mapping ]
charmm charmm36
[ atoms ]
1 MG MG

2) We're bad at detecting which element a bead/atom is. We just take the first letter, which will break for all metals, including Mg :'). Martinize guesses the the atom named "MG" has the element "M". Because of this you either need to set the element field in the PDB file to "M", or remove the field. This does mean the mass used for the mapping is not going to be 24, but since only one atom maps to the bead it's not a problem.