djay0529 / mdanalysis

Automatically exported from code.google.com/p/mdanalysis
0 stars 0 forks source link

AtomGroup.set_resnum & set_resname #202

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In [83]: u = mda.Universe('adk.psf','adk_dims.dcd')

In [84]: ag = ag[:10]

In [85]: u = mda.Universe('adk.psf','adk_dims.dcd')

In [86]: ag = u.atoms[:10]

In [87]: ag.set_resnum(10)

In [88]: ag.resnums()
Out[88]: array([1])

In [89]: ag.set_resname(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'])

In [90]: ag.resnames()
Out[90]: 
array(['MET'], 
      dtype='|S3')

This is all tied in with how residues are built in MDA.  I couldn't see a 
simple an easy fix, so I thought I'd open it for discussion

I've added tests for this (that currently fail) into develop.

Original issue reported on code.google.com by richardjgowers on 19 Nov 2014 at 12:56

GoogleCodeExporter commented 9 years ago
Doing some reading, this might tie in with Issue 193 too, looking at more than 
resids when building residues.

Original comment by richardjgowers on 19 Nov 2014 at 4:50

GoogleCodeExporter commented 9 years ago
https://code.google.com/p/mdanalysis/source/detail?r=a5f30fb67db976209e564cb7ee6
d86dcf3518fb5&name=feature-residues

I've pushed a very experimental feature branch which eventually will fix this.

Stuff that needs discussion:

Creating Residue/Segment objects now adds them to Universe, is this ugly? or a 
good way of making sure that nothing gets lost.  The idea here is that 
everything should live in Universe.

Propagating information between levels.  Does changing an Atom's residue level 
information (resname, resid) indicate that the Residue should be changed?

ie Atom.set_resname == Atom.residue.set_resname

Or should resname be read only, and the only Residue level information I can 
change be resid, which actually moves the Atom into a new Residue?  
To change resname instead

Atom.residue.set_resname(new)

Then if I changed an Atom's segid, does this change
1) Only the atom? (current behaviour)
2) The Residue it belongs to? Then changing all Atoms in the same Residue?
3) The entire segment and all Res & Atom within?

Or should segid be read-only from an Atom and instead only Residues can change 
this as the method for moving them into new Segments?

Also, Residues/Segments now lazily built, but this should ideally be impossible 
to notice!

Original comment by richardjgowers on 25 Nov 2014 at 3:15

GoogleCodeExporter commented 9 years ago
Everything is still a bit buggy, but it's getting there.

In [1]: import MDAnalysis as mda

In [2]: u = mda.Universe('adk.psf','adk_dims.dcd')

In [3]: r1 = u.residues[0]

In [4]: r2 = u.residues[1]

In [5]: ag = u.atoms[:10]

In [6]: len(r1)
Out[6]: 19

In [7]: len(r2)
Out[7]: 24

In [8]: ag.set_resid(2)

In [9]: len(r1)
Out[9]: 9

In [10]: len(r2)
Out[10]: 34

In [11]: r1.set_resid(215)

In [12]: len(r1)
Out[12]: 0

In [13]: rg = u.residues[:10]

In [14]: rg.set_segid('ABC')

In [15]: u.ABC
Out[15]: <Segment 'ABC'>

Original comment by richardjgowers on 2 Dec 2014 at 10:41

GoogleCodeExporter commented 9 years ago

Original comment by richardjgowers on 12 Feb 2015 at 9:21