Skip to content

ResidueGroup and SegmentGroup: methods that return arrays of length len(group.atoms) #411

@dotsdl

Description

@dotsdl

Discussion of this issue originally began on #385.

ResidueGroup and SegmentGroup are subclasses of AtomGroup, and for properties including resids, resnums, and segids they each yield arrays equal in length to themselves e.g.

ag = u.atoms
rg = ag.residues

len(ag.resids) == len(ag)
len(rg.resids) == len(rg)

For properties that refer "downward" in the hierarchy, an array of size equal to the appropriate level is returned e.g.

ag = u.atoms
rg = ag.residues
sg = ag.segments

len(rg.indices) == len(rg.atoms) 
len(sg.resids) == len(sg.residues)

I think this adds some needed consistency. However, there are other properties, such as rg.charges or rg.masses that currently return arrays of len(rg.atoms) but could make sense and be useful as len(rg), where the values for the atoms in each residue are summed.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions