Get attributes#

Querying the set of topological and structural attributes supported by a molecular system form.

The function molsysmt.form.get_attributes() returns a boolean dictionary or list of all attributes that a given form name can store or provide.

Added in version 1.0.0.

Basic usage#

Let’s query the supported attributes for standard native and third-party forms:

import molsysmt as msm
attrs_molsys = msm.form.get_attributes('molsysmt.MolSys', output_type='list')
print('Total attributes in molsysmt.MolSys:', len(attrs_molsys))
print('First 10 attributes:', attrs_molsys[:10])
Total attributes in molsysmt.MolSys: 115
First 10 attributes: ['atom_index', 'atom_name', 'atom_id', 'atom_type', 'isotope', 'chemical_state_index', 'chemical_state_id', 'n_chemical_states', 'reference_chemical_state_index', 'connectivity_completeness']

Comparing attributes across forms#

Let’s compare the attributes present in a topology form versus a trajectory file form:

dict_top = msm.form.get_attributes('openmm.Topology')
dict_xtc = msm.form.get_attributes('file:xtc')

print('Coordinates in openmm.Topology?:', dict_top.get('coordinates', False))
print('Coordinates in file:xtc?:', dict_xtc.get('coordinates', False))
print('Atom names in openmm.Topology?:', dict_top.get('atom_name', False))
print('Atom names in file:xtc?:', dict_xtc.get('atom_name', False))
Coordinates in openmm.Topology?: False
Coordinates in file:xtc?: True
Atom names in openmm.Topology?: True
Atom names in file:xtc?: False