-
Notifications
You must be signed in to change notification settings - Fork 646
-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't change segmend ids in a loop for regions of a atomgroup #1683
Comments
copy[0:214].segments.segids = 'A'
copy[214:428].segments.segids = 'B' This is shorter. Here the second line is overwriting the atoms from 0-214 Any idea of why this happens. This makes it pretty hard to build my system currently |
affects 0.16.2 as well |
@kain88-de setting segids won't create new Segments (any more). So I think what's happening is that If you want to add a Segment to the Universe, do |
But wouldn't it be better then if Also you explanation makes sense. It's a bit confusing though that it works only half now. If I change all segids in a atomgroup to the same letter everything seems fine. |
@kain88-de it is a valid way to update segids. You're only running into trouble because you're updating the segid of the same segment twice. See the toy example below where I deliberately create two ags ( There's no real way to disallow setting the segid from an AtomGroup like this, because In [1]: import MDAnalysis as mda
In [2]: u = mda.Universe('adk_oplsaa.gro')
/home/richard/miniconda2/envs/mdadev/lib/python2.7/site-packages/MDAnalysis/topology/guessers.py:56: UserWarning: Failed to guess the mass for the following atom types: M
"".format(', '.join(misses)))
In [3]: u.segments
Out[3]: <SegmentGroup with 1 segment>
In [4]: ag1 = u.segments.atoms[:100]
In [5]: ag2 = u.segments.atoms[100:]
In [6]: seg = u.segments[0]
In [7]: seg.segid
Out[7]: 'SYSTEM'
In [8]: ag1.segments.segids = 'A'
In [9]: ag1.segids
Out[9]:
array(['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'], dtype=object)
In [10]: seg.segid
Out[10]: 'A'
In [11]: ag2.segments.segids = 'B'
In [12]: ag2.segments.segids
Out[12]: array(['B'], dtype=object)
In [13]: ag2.segids
Out[13]: array(['B', 'B', 'B', ..., 'B', 'B', 'B'], dtype=object)
In [14]: seg.segid
Out[14]: 'B'
In [15]: ag1.segids
Out[15]:
array(['B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B'], dtype=object)
|
For docs we need a section on topology manipulation; relabeling is a common theme. |
Expected behaviour
I want to iterate over a atomgroup and change the segids for regions in a loop.
Actual behaviour
Our
getitem
methods doesn't seem to honor the range I specify. So here when i=1all atoms from 0-428 are getting the segid B.
Code to reproduce the behaviour
Currently version of MDAnalysis:
(run
python -c "import MDAnalysis as mda; print(mda.__version__)"
)dev version
The text was updated successfully, but these errors were encountered: