opencadd.structure.core.Structure.add_Residue
- Structure.add_Residue(segment=None, **attrs)
Add a new Residue to this Universe
New Residues will not contain any Atoms, but can be assigned to Atoms as per usual. If the Universe contains multiple segments, this must be specified as a keyword.
- Parameters
segment (MDAnalysis.Segment) – If there are multiple segments, then the Segment that the new Residue will belong in must be specified.
attrs (dict) – For each Residue attribute, the value for the new Residue must be specified
- Return type
A reference to the new Residue
- Raises
NoDataError – If any information was missing. This happens before any changes have been made, ie the change is rolled back.
Example
Adding a new GLY residue, then placing atoms within it:
>>> newres = u.add_Residue(segment=u.segments[0], resid=42, resname='GLY') >>> u.atoms[[1, 2, 3]].residues = newres >>> u.select_atoms('resname GLY and resid 42') <AtomGroup with 3 atoms>