Acellera / htmd

HTMD: Programming Environment for Molecular Discovery
https://software.acellera.com/docs/latest/htmd/index.html
Other
261 stars 59 forks source link

How to construct the dihedrals.projections for RNA to include in adaptive MD ? #1049

Closed vas2201 closed 1 year ago

vas2201 commented 1 year ago

Hello,

I defined dihedrals for RNA for residue-2 as per the documentation. I do have 20 or more residues to include and total 6 angles for each residue that I suppose to define.

d = Dihedral(atom1, atom2, atom3, atom4) ad.projection = MetricDihedral()


How can I include all the dihedrals angles (alpha, beta, gamma, delta, epsilon and zeta)  in ad.projection for residue 2  ?. is there any predefined function to define dihedrals like protein (phi and psi ) ?

and also how can  I include multiple residues in ad.projection = MetricDihedral() . 

should I suppose to add the following  after defining d1,d2 .d3 ... dn as dihedrals for multiple residues ?.
```py
# Define dihedrals for residue 2
d2_alpha = Dihedral(atom1, atom2, atom3, atom4)
d2_beta = Dihedral(atom2, atom3, atom4, atom5)
d2_gamma = Dihedral(atom3, atom4, atom5, atom6)
d2_delta = Dihedral(atom4, atom5, atom6, atom7)
d2_epsilon = Dihedral(atom5, atom6, atom7, atom8)
d2_zeta = Dihedral(atom6, atom7, atom8, atom9)

# Define a list of dihedrals for residue 2
residue2_dihedrals = [d2_alpha, d2_beta, d2_gamma, d2_delta, d2_epsilon, d2_zeta]

# Define dihedrals for residue 3
residue3_dihedrals = [d3_alpha, d3_beta, d3_gamma, d3_delta, d3_epsilon, d3_zeta]

# Include dihedrals for multiple residues in ad.projection
ad.projection = MetricDihedral(residue2_dihedrals, residue3_dihedrals, ...)

Regards Vas

vas2201 commented 1 year ago

I can add two dihedrals to ad.projection, but not able to add more than two. ad.projection = (MetricDihedral(dih_zeta_6, dih_zeta_7, protsel='nucleic')) could you please advise me that how can I add more than two dihedrlas to ad.projection ? Regards Vas

stefdoerr commented 1 year ago

Hi, in the examples section at the end of this document you can see how to pass multiple dihedrals https://software.acellera.com/moleculekit/moleculekit.projections.metricdihedral.html You just need to add them all to one list (not multiple lists)

As for default dihedrals for nucleics, sorry currently there is no such function. But if you pass me some code which does it I can look at integrating it into HTMD as a default.

vas2201 commented 1 year ago

Thank you for your input. I see the end of the document as the following. but I did not find a way to export the manually defined dihedrals in the given example.

please download the python file in which I am defining all 6 angles. https://drive.google.com/file/d/1obvAYJD2fR1eqfk8-kKjsHR9yJgDNG0K/view?usp=share_link

mol = Molecule('3PTB')
mol.filter('not insertion A')
met = MetricDihedral()
met.project(mol)
# More complicated example
dih = []
dih.append(Dihedral.chi1(mol, 45))
dih.append(Dihedral.psi(mol, 29, 30))
met = MetricDihedral(dih, protsel='protein and segid 0')
met.project(mol)
met.getMapping(mol)

I tried to troubleshoot the following way (test-1 & test-2)

test-1 
mol = Molecule('structure.pdb')
met = MetricDihedral()
met.project(mol)
dih =[]
dih.append (dih_alpha_6)
dih.append (dih_alpha_7)
met = MetricDihedral(dih, protsel='nucleic and segid RNAA')

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[20], line 7
      5 dih.append (dih_alpha_6)
      6 dih.append (dih_alpha_7)
----> 7 met = MetricDihedral(dih, protsel='nucleic and segid RNAA')
      8 #ad.projection = (MetricDihedral(dih, protsel='nucleic and segid RNAA'))

File ~/anaconda3/envs/100htmd/lib/python3.9/site-packages/moleculekit/projections/metricdihedral.py:761, in MetricDihedral.__init__(self, dih, sincos, protsel)
    758 super().__init__()
    760 if dih is not None and not isinstance(dih[0], Dihedral):
--> 761     raise RuntimeError(
    762         "Manually passing dihedrals to MetricDihedral requires use of the Dihedral class. Check the example in the documentation"
    763     )
    765 self._protsel = protsel
    766 self._sincos = sincos

RuntimeError: Manually passing dihedrals to MetricDihedral requires use of the Dihedral class. Check the example in the documentation

test-2
mol = Molecule('structure.pdb')
met = MetricDihedral()
met.project(mol)
dih =[]
dih.append (dih_alpha_6(mol))
dih.append (dih_alpha_7(mol))
met = MetricDihedral(dih, protsel='nucleic and segid RNAA')
#ad.projection = (MetricDihedral(dih, protsel='nucleic and segid RNAA'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[21], line 5
      3 met.project(mol)
      4 dih =[]
----> 5 dih.append (dih_alpha_6(mol))
      6 dih.append (dih_alpha_7(mol))
      7 met = MetricDihedral(dih, protsel='nucleic and segid RNAA')

TypeError: 'list' object is not callable

please advise on this matter. I guess that I am missing something here while exporting the manually defined dihedrals.

Regards Vas

vas2201 commented 1 year ago

Hi this is the reference for all 6 angles and other angles (see the table) to include RNA md trajectory. https://pubs.acs.org/doi/10.1021/acs.jctc.6b00870 Thanks for your consdiraion. -Vas

stefdoerr commented 1 year ago

to extend a list in python you can just sum another list to it. If you use append you are creating a list of lists (nested list) which is not what MetricDihedral expects as input. It expects a simple list

met = MetricDihedral(dih_alpha_6+dih_alpha_7, protsel='nucleic and segid RNAA')
vas2201 commented 1 year ago

Thank you.