biocrnpyler.core.MonomerCollection

class biocrnpyler.core.MonomerCollection(monomers)[source]

Bases: object

Collection of ordered monomers without any particular structure.

A base container class that holds a collection of OrderedMonomer objects without imposing any ordering or structural constraints. This class serves as a parent class for more structured polymer representations like OrderedPolymer.

Parameters:

monomers (list of OrderedMonomer) – List of OrderedMonomer objects to include in the collection. Each monomer is copied and linked to this collection as its parent.

Attributes:

monomers (tuple of OrderedMonomer) – Tuple containing copies of the input monomers, with each monomer’s parent set to this collection.

See also

OrderedPolymer

A polymer with ordered monomers and directionality.

OrderedMonomer

A unit that can belong to a MonomerCollection.

Notes

Monomers are stored as a tuple (immutable) to prevent direct modification. Each monomer is copied during initialization to ensure the collection maintains its own references.

Examples

Create a collection of monomers:

>>> mon1 = bcp.OrderedMonomer()
>>> mon2 = bcp.OrderedMonomer()
>>> collection = bcp.MonomerCollection([mon1, mon2])
>>> len(collection.monomers)
2

Methods