cif

Module for interfacing to ASE configuration readers (such as cif and pdb)

It should be possible to extend the CIF reader to include the additional definitions in the mmCIF format.

It is expected that some of the behaviour in ase_read_cif will be extracted into MDMC.readers.configurations.cif when an MDMC CIF reader is implemented.

MDMC.MD.ase.cif.ase_read_cif(file: str, **settings: dict) list[Atom][source]

Reads a configuration file and returns a list of Atom objects.

These Atom objects can optionally have Coulombic interactions and also BondedInteraction objects if bonded interactions are defined in the CIF file.

If names or atom_types is passed, then equivalent interactions (Coulombic and BondedInteraction, if bonded interactions are defined in the CIF file) will be initialized as a single object. For instance if the CIF file includes a benzene ring, then as long as the correct names or atom_types are passed, then there will only be a single C-C Bond object, which will include all 6 of the atom pairs. If both names and atom_types are passed, atom_types will be used to group Atom objects. If neither names or atom_types is passed then each interaction will become a separate object.

Note

Not all CIF files contain bonded interactions (it is only common for biomolecules).

Note

improper dihedrals are not explicitly defined in CIF, so these must be set after initialization of DihedralAngle objects.

Note

CIF reader cannot parse CIF files with user defined text sections, so these must be stripped out before reading.

Parameters
  • file (file, str) – A file, or the absolute file name of the configuration file

  • **settings

    index (int, optional)

    The index of the configuration in the CIF file. Only a single configuration can be read from a CIF file, with the default being the first (index=0) configuration.

    names(list of str)

    A list of names for the atoms in the CIF file. These names must have the same order as the order the atoms in the file. A name must be be provided for each atom in the CIF file.

    atom_types(list of int)

    A list of int for atom types of the atoms in the CIF file. These names must have the same order as the order the atoms in the file. An atom_type must be provided for each atom in the CIF file.

    cutoff(float)

    A distance (in Ang) at which the Coulombic interactions are cutoff. If this is not passed, the cutoff will be set to 10.

    add_bonds(bool, optional)

    Whether or not any bonded interactions defined in the CIF file will be included. By default this is True.

    add_charges(bool, optional)

    Whether or not each atom in the CIF file will be assigned a Coulombic interaction with a Coulomb function. CIF files do not contain charge information, so the charge of the Coulombic interaction will be set to 0. This enables the charges to be set by the application of a ForceField object. By default this is True.

Returns

The Atom objects corresponding to the data in the CIF file

Return type

list of Atom

MDMC.MD.ase.cif.get_bonded_interactions_atoms(ase_atoms_info: dict, cif_geom_def: str, atoms_labels: dict) numpy.ndarray[source]

Gets the atoms for each bonded interaction

Parameters
  • ase_atoms_info (dict) – A dict containing site labels for one or more of bonds, angles, and torsions. The corresponding values are a list with label (str) for each interaction. The number of site label keys is 2 for bonds, 3 for angles and 4 for torsions. For instance, for bonds there should be ‘_geom_bond_atom_site_label_1’ and ‘_geom_bond_atom_site_label_2’, with each being a list containing the first (or second) site label for each interaction.

  • cif_geom_def (str) – Specifies whether the interaction type is a bond, angle, or torsion

  • atoms_labels (dict) – (label:atom) pairs, where label is a str with the _atom_site_label from the CIF file, and atom is the corresponding MDMC Atom object.

Returns

A 2D array with dimensions (n_interactions, n_atoms_per_interaction). So for 5 bond interactions, the dimensions of the array will be (5, 2), with the zeroeth index containing the two Atoms involved in the zeroeth bond, the first index containing the two Atoms involved in the first bond etc. For bond angle and dihedral interactions, the order of the atoms corresponds to the order required for BondAngle and DihedralAngle interactions.

Return type

numpy.ndarray