molsysmt.basic.remove#
- molsysmt.basic.remove(molecular_system, selection=None, structure_indices=None, to_form=None, syntax='MolSysMT', in_place=True, skip_digestion=False)[source]#
Removing atoms or structures from a molecular system.
This function returns a new molecular system after removing the atoms and/or structures specified via selection and structure_indices. If selection is None, no atoms are removed. If structure_indices is None, no structures are removed. Optionally, the resulting system can be returned in a different form with to_form.
- Parameters:
molecular_system (molecular system) – Molecular system in any supported MolSysMT format.
selection (str, list, tuple, or numpy.ndarray, default=None) – Selection string or boolean/integer array specifying elements.
structure_indices (int, list, tuple, or numpy.ndarray, default=None) – Structure indices (0-based) to include or process.
to_form (str, list of str, or None, default=None) – Target molecular-system form; None preserves or infers the input form.
syntax (str, default='MolSysMT') – Selection syntax used to evaluate selection (e.g., ‘MolSysMT’, ‘MDTraj’).
in_place (bool, default=True) – Whether to modify the input molecular system in place.
skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.
- Returns:
A new molecular system with the selected atoms and/or structures removed. The form of the returned system is either specified by to_form or inferred from the input.
- Return type:
molecular system
- Raises:
NotSupportedFormError – If the molecular system is provided in an unsupported form.
ArgumentError – If the selection or structure_indices are invalid or incompatible with the system. Explicit structure indices are range checked.
Notes
Supported molecular-system forms are summarized in Items and Forms.
Selection strings must follow one of the syntaxes described in Selection syntaxes.
Removal is implemented by selecting the complementary indices and delegating to
molsysmt.basic.extract(), minimizing data copies when possible.
See also
molsysmt.select()Select atoms or structures from a molecular system.
molsysmt.basic.extract()Extract a subset of atoms/structures into a new molecular system.
Examples
>>> import molsysmt as msm >>> system = msm.convert('1B3T') >>> msm.get(system, n_chains=True) 8 >>> new_system = msm.remove(system, selection='chain_id=="A" or chain_id=="B"') >>> msm.get(new_system, n_chains=True) 6
Tutorial with more examples
See the following tutorial for a practical demonstration of how to use this function, along with additional examples: Remove.
Added in version 1.0.0.