molsysmt.basic.merge#

molsysmt.basic.merge(molecular_systems, selections='all', structure_indices='all', keep_ids=True, syntax='MolSysMT', to_form=None, skip_digestion=False)[source]#

Merging elements from multiple molecular systems into a new one.

This function builds a new molecular system by merging selected elements from several input systems. All inputs must be compatible in their number of structures; otherwise, structure_indices must be provided to align the structures that will be merged. You can also provide per-system atom selections via selections. The output form can be set with to_form (defaults to the first system’s form).

Parameters:
  • molecular_systems (list or tuple of molecular systems) – Molecular systems to inspect or combine in their given order.

  • selections (str, list, tuple, or numpy.ndarray, default='all') – Atom selection shared by the inputs or one selection per molecular system.

  • structure_indices (int, list, tuple, or numpy.ndarray, default='all') – Structure indices (0-based) to include or process.

  • keep_ids (bool, default=True) – Whether to preserve element identifiers from the input systems.

  • syntax (str, default='MolSysMT') – Selection syntax used to evaluate selection (e.g., ‘MolSysMT’, ‘MDTraj’).

  • to_form (str, list of str, or None, default=None) – Target molecular-system form; None preserves or infers the input form.

  • skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.

Returns:

New molecular system composed of the selected elements from the inputs. Its form is controlled by to_form (or inherited from the first input when None).

Return type:

molecular system

Raises:
  • NotSupportedFormError – If any input molecular system has an unsupported form.

  • ArgumentError – If input arguments are invalid or inconsistent in length or compatibility.

Notes

  • Supported molecular-system forms are summarized in Items and Forms.

  • Selection strings must follow one of the syntaxes described in Selection syntaxes.

  • All input systems must be aligned in number of structures or explicitly aligned via structure_indices. Internal conversions are performed when the input forms differ from the chosen to_form.

  • Lists and tuples always express per-system intent. Use a NumPy array or range when one index collection should be applied to every system.

See also

molsysmt.basic.select()

Select elements from a molecular system.

molsysmt.basic.add()

Add elements from one system to another.

molsysmt.basic.append_structures()

Append structures from one system to another.

molsysmt.basic.concatenate_structures()

Concatenate structures across multiple molecular systems.

Examples

>>> import molsysmt as msm
>>> molsys = msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm']
>>> molsys_A = msm.convert(molsys)
>>> molsys_B = msm.structure.translate(molsys_A, translation='[0.1, 0.1, 0.1] nanometers')
>>> molsys_merged = msm.basic.merge([molsys_A, molsys_B])
>>> msm.basic.get(molsys_merged, n_peptides=True)
2

Tutorial with more examples

See the following tutorial for a practical demonstration of how to use this function, along with additional examples: Merge.

Added in version 1.0.0.