schrodinger.structure module

A module containing the central interface for reading and editing chemical structures.

Structure is a pythonic, object oriented wrapper for the mmct library that provides access to atoms, bonds, and their properties. It provides common methods for inspecting and editing coordinates, e.g. Structure.measure, Structure.adjust, and Structure.merge. The schrodinger.structutils package provides additional functions and classes that operate on Structure objects.

StructureReader provides a convenient iterator to read structures from files, and StructureWriter provides an efficient means of writing many files.

PropertyName provides translation between m2io datanames and user friendly names.

MultiFileStructureReader iterates through all the structure in multiple files using StructureReader.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.structure.PropertyName(dataname=None, type=None, family=None, username=None)

Bases: object

The PropertyName class can be used to display the “user-readable” version of an entry or atom property to the user.

Properties are stored in mae files with names in the form type_family_name, where type is a datatype indicator, family indicates the owner or creator of the property, and name is the name of the property. These strings are used as the keys in the property dictionary attributes of Structure, _StructureAtom, and _StructureBond. Examples include s_m_title, which is a string created by Maestro with the name “title”, and i_m_residue_number, which is an integer created by Maestro with the name “residue number”.

dataName()

Returns the m2io data name of form type_family_name.

This is the fully qualified name that includes the type, owner and name and should be used for all lookup, indexing, etc.

userName()

Returns the user name of this property. User name is the shortened, user-readable name that should only be used when presenting this property to the user, such as in a GUI pull down menu.

Since data names can NOT have spaces in them, while user names can, we have a convention where a space in a user name is represented as an underscore in the data name, and an underscore in the user name has to be escaped with a backslash in the data name.

Replace ‘_’ with ‘_’, and ‘_’ with ‘ ‘ before returning the user name

class schrodinger.structure.Structure(handle, error_handler=None)

Bases: object

A general chemical structure object, which may contain multiple molecules. Structure is an object-oriented wrapper for the underlying MMCT library, where all state is stored.

There are several ways to create Structure instances. The structure.StructureReader provides a way to read Structures from a file, and the schrodinger.maestro.maestro.workspace_get function returns the workspace Structure from a Maestro session. The schrodinger.project module provides access to Structures in a Maestro project.

Properties of the Structure entry can be accessed from the property dictionary using the mae file data name. For example, the Glide score of a docked pose may be accessed as:

glide_score = st.property['r_i_glide_gscore']

A few additional Structure attributes are available as instance attributes (actually, as python properties). For example, the title of the structure can be accessed (and assigned) via the title attribute. See the Structure properties documentation for a full list.

Atom objects are accessed from the list-like schrodinger.structure.Structure.atom attribute. Each atom is an instance of the _StructureAtom class. See the “Properties” section of the schrodinger.structure._StructureAtom documentation for a list of available attributes (implemented again as python properties). For example, the atomic number of the first atom in a structure is accessed as:

atomic_num = st.atom[1].atomic_number

Note that indices used to access atoms and bonds start at 1, not 0 as with regular python lists. Iteration over the atoms and bonds works as expected.

Structure atom properties may also be accessed from the atom’s property dictionary. For example, the x-coordinate of the first atom may be accessed as:

x_coord = st.atom[1].property['r_m_x_coord']

(However, it is preferable to simply use the x attribute - i.e. st.atom[1].x.)

Bond objects are instances of the schrodinger.structure._StructureBond class and are usually accessed via atoms using the schrodinger.structure._StructureAtom.bond attribute. Like atoms, bonds have some built-in attributes and a general property dictionary. Bonds can also be accessed from the schrodinger.structure.Structure.bond iterator, which iterates over all bonds in the Structure.

Iterators for various substructures can be accessed from the molecule, chain, residue, and ring attributes. Each of these yields an object that has a getAtomIndices method to get a list of atom indices, and an extractStructure method that can be used to create a separate Structure instance corresponding to the substructure.

Please see the Python Module Overview for a non-technical introduction and additional examples.

addAtom(element, x, y, z, color=None, atom_type=None)

Add a new atom to the structure. Return the created _StructureAtom object.

addAtoms(num_atoms)

Add the specified number of atoms to this structure.

The following atom attributes will have to be set for each atom afterwards:

  • element
  • x, y, z
  • color
  • atom_type
addBond(atom1, atom2, bond_type)

Add a bond of the specified type between the two atoms atom1 and atom2. The atom parameters can be _StructureAtom objects or integer indices from 1 to the number of atoms in the structure. If the two atoms are already bound then the bond type is just changed.

:param bond_type bond type (legacy integer 0-3 bond order)

addBonds(bonds_list)

Add multiple bonds to this structure. This is much faster than multiple calls to addBond() method when many bonds need to be added. Bonds are specified by a list of integer lists: (atom1, atom2, bond_type).

Example::
st.addBonds([(10, 11, 1), (12, 13, 2)])

This will add a single-order bond between atoms 10 and 11, and a double-order bond between atoms 12 and 13.

adjust(value, atom1, atom2, atom3=None, atom4=None)

Adjust a distance, angle or dihedral angle. If atom3 is None then the distance between atom1 and atom2 will be set to value, atom2 and all atoms attached to that atom will be moved. If atom4 is None then the angle between atom1, atom2 and atom3 will set to value, atom3 and all other atoms attached to that will be moved. If all atoms are specified then the dihedral angle made by atom1, atom2, atom3 and atom4 will be set to value and atom4 and all other atoms attached to that will be moved. All distances are specified in Angstroms, all angles in degrees.

All atom arguments can be integers or _StructureAtom objects. There is no return value for this function.

Raises:AtomsInRingError – if specified atoms are within a ring system. If ring distortion from an adjustment is not an issue, then the moving bitset can be manually created and passed to mmct_atom_set_distance(), mmct_atom_set_bond_angle(), or mmct_atom_set_dihedral_angle().
append(filename, format=None)

Append the structure to the named file.

This method should provided acceptable performance if you are writing a small number of structures, but if you need to write a large number of structures (more than a few hundred) to a file, the StructureWriter class will provide better performance.

Parameters:format (str) – By default, the file format is determined from the filename suffix, but this can be specified explicitly. Supported option values are one of the PDB, MOL2, SD, MAESTRO, SMILES, SMILESCSV module-level constants.
applyStyle(atoms=3, bonds=3, atom_list=None)

Applies the given display styles to the atoms and bonds of the entire structure (by default) or to the atoms (and their bonds) given in atom_list.

Parameters:
  • atoms (int) – Display style for atoms, given by structure module constants ATOM_NOSTYLE, ATOM_CIRCLE, ATOM_CPK, ATOM_BALLNSTICK. Default is ATOM_BALLNSTICK.
  • atoms – Display style for bonds, given by structure module constants BOND_NOSTYLE, BOND_WIRE, BOND_TUBE, BOND_BALLNSTICK. Default is BOND_BALLNSTICK.
  • atom_list (iterable) – An iterable of atom objects or atom indices to apply the given styles to. If not included the styles are applied to all atoms in the structure. Possible examples include:: [1, 3, 5] ring.atom schrodinger.structutils.analyze.evalulate_asl(asl_expr) [structure.atom[x] for x in xrange(50)] maestro.selected_atoms_get()
areBound(atom1, atom2)

Returns True if atom1 and atom2 have a bond of any order between them and False is there is no bond.

atom

An iterable of structure atoms, each of which is a L{_StructureAtom} instance.

Example usage, where C{st} is a Structure instance:

# Access an atom (indices start at 1)
atomobj = st.atom[n]

# Delete an atom
del st.atom[n]

# Find the number of atoms
len(st.atom)

# Iterate over all atoms
for atom in st.atom:
    take_some_action(atom)

@note: As with many other collections, the contents of the atom list should not be modified through additions or deletions while you are iterating over it.

atom_total

Get total number of atoms in this structure

bond

An iterable of structure bonds, each of which is a L{_StructureBond} instance.

To iterate over bonds:

for bond in st.bond:
    take_some_action(bond)

@note: Atoms and bonds should not be added or deleted while you are iterating over bonds. @note: Bonds are not accessible by index.

chain

An iterable of chains in the structure, each of which is a L{_Chain} instance.

Example usage:

# Find the number of chains in the structure
len(st.chain)

# Retrieve a _Chain instance by letter
chain = st.chain[letter]

# Iterate over chains
for chain in st.chain:
    take_some_action(chain)

@note: Atoms and bonds should not be added or deleted while you are iterating over chains.

closeBlockIfNecessary(filehandle)

Used by the Maestro writer to leave the header block if necessary. For Structure objects this is not needed so it only returns

copy()

Returns a copy of the structure.

deleteAtoms(indices, renumber_map=False)

Delete multiple atoms from the Structure. The argument indices must be a sequence or an iterable, and able to be interpreted as ints.

After deletion, indices are renumbered from 1 to len(atoms). Pre-existing references to Structure atoms will not be correct, as they store index values.

If renumber_map is set to True, will return a renumbering dictionary. Keys are atom numbers before deleting, and value for each is the new atom number, or None if that atom was deleted.

deleteBond(atom1, atom2)

Delete the bond between atom1 and atom2. It will be an error if there is no bond between these two.

extend(other_structure)

Add the atoms in other_structure to the end of the current structure. The other_structure is left unchanged.

extract(indices, copy_props=False)

Return a new structure object which contains the atoms of the current structure that appear in the specified list. The argument indices must be a sequence or an iterable, and able to be interpreted as ints.

After extractions, indices are renumbered from 1 to len(atoms). Pre-existing references to Structure atoms will not be correct, as they store index values.

If copy_props is set to True, then the new structure object will inherit Structure-level properties from the source object.

findResidue(query)

Returns a _Residue object matching the given string (e.g. “A:123”). Currently only protein residues are supported.

If no residues were found that match the given string, or if the given string is of improper format, ValueError is raised.

Note:If the structure has more than one matching residue, then only the first match will be returned.
find_rings(sort=True)

Find all rings in the structure using SSSR.

Each ring is returned in connectivity order.

Parameters:sort (bool) – Deprecated and unused
Returns:A list of lists of integers corresponding to the atom indices of the rings.
formal_charge

Get the sum of formal charges for the structure.

Accessing this property is an O(N) operation.

get3dStructure(require_stereo=True)

If the structure is 2D (with stereo annotation properties), return a 3D version of it - volumized using fast3d. Any missing hydrogens will also be added.

Parameters:require_stereo (bool) – Whether to require all chiral centers to have defined stereochemistry via annotation properties. Defaults to True. UndefinedStereochemistry exception is raised if any chiral atom has ambiguous chirality. If set to False, ambiguous chiralities will be expanded arbitrarily.
Return type:Structure.Structure
Returns:Volumized 3D structure.
getAtomIndices()

Return a list of all atom indices in this structure.

getBond(atom1, atom2)

Returns a _StructureBond object for the bond between atom1 and atom2. The atom parameters can be _StructureAtom objects or integer indices from 1 to the number of atoms in the structure.

getChainAtoms(atom)

Return a list of atom objects that are in the same chain as ‘atom’.

getMoleculeAtoms(atom)

Return a list of atom objects that are in the same molecule as ‘atom’.

getMovingAtoms(fixed_atom, moving_atom)

Returns all atoms that would move if <moving_atom> is moved while <fixed_atom> is frozen. This effectively returns all atoms in the same molecule substructure as <moving_atom> (atoms in the same substructure as fixed_atom are excluded).

In other words, if the bond between the moving_atom and fixed_atom (or towards the direction of fixed_atom) were to be broken, the atoms that would be in the same molecule as moving_atom are returned. Can be used for detecting things like residue side-chain atoms, etc.

Note:

If fixed_atom and moving_atom are part of different molecules, then all atoms in the moving_atom’s molecule will be returned. If fixed_atom and moving_atom are not bound directly, the intervening atoms will not be included in the result. If fixed_atom and moving_atom are connected with more than one path (are in a ring), then ValueError is raised.

Parameters:
  • fixed_atom (Atom index or _StructureAtom.) – Atom which is part of the molecule that is to be excluded from the result (frozen, not being moved).
  • moving_atom (Atom index or _StructureAtom.) – Atom of interest (atom to be moved); a set of atoms that would be moved with it (connected to it) will be returned.
Return type:

Set of ints

Returns:

Set of atom indices for atoms “connected” to moving_atom - those atoms that would be moved with it if it was moved. For example, if called with alpha carbon and beta carbon atoms of a protein residue, then all side-chain atoms would be returned. Atom moving_atom will also be included.

Raises ValueError if the given atoms are part of a ring (in other words, moving_atom is connected to fixed_atom via more than one path). This may happen if part of the moving_atom’s “chain” is bonded to something unexpected; e.g. ZOBed to metals, or involved in a di-sulfide bond.

getResidueAtoms(atom)

Return a list of atom objects that are in the same residue as ‘atom’.

getXYZ(copy=True)

Get a numpy array of the xyz coordinates of all atoms in the molecule with shape (atom_total, 3). Note that numpy arrays are indexed starting with 0.

You can avoid copying the underlying data by specifying copy=False, in which case modifying any values will modify the coordinate values in the Structure.

Note that if coordinates are retrieved with copy=False they will become invalid after their source Structure has been garbage collected. Any use of them after this point will likely cause a core dump. This is because the python numpy array provides access directly to the underlying C data.

has3dCoords()

Returns True if any atom in the structure has a non-zero z-coordinate.

inRing(atom1, atom2)
Deprecated:This method can give incorrect results. Do not use it! It is deprecated and will be removed as soon as we can.

If you are looking to see whether atom1-atom2 is a ring bond, prefer using schrodinger.structutils.analyze.find_ring_bonds()

isEquivalent(struct, check_stereo=True)

Return True if the 2 structures are equivalent Return False if the 2 structures are different

struct: Another structure class object

check_stereo: Specifies whether or not to check stereo chemistry.

manual_update

Find whether mmct is in manual update mode.

measure(atom1, atom2, atom3=None, atom4=None)

Return the measurement for the provided atoms. If atom3 is None, return the distance between atom1 and atom2. If atom4 is None, return the angle with atoms 1 through 3, and if all atoms are provided, return the dihedral angle.

All atom arguments can be integers or _StructureAtom objects.

If Periodic Boundary Condition CT-level properties are defined, uses the PBC measurement.

See also the structutil.measure module, which has functions to make measurements between atoms in different structures, and can also measure angles between planes.

merge(other_structure, copy_props=False)

Return a new structure object which contains the atoms of the current structure and the atoms of other_structure.

If copy_props is True, properties from the current structure and other_structure will be added to the new structure. If the same property is specifed in both the current structure and other_structure, the current value will take precedence.

mol_total

Get total number of molecules in this structure

molecule

An iterable of molecules in the structure, each of which is a L{_Molecule} instance.

Example usage:

# Find the number of molecules in the structure
len(st.molecule)

# Retrieve a molecule by number (indices start at 1)
mol = st.molecule[molnum]

# Iterate over all molecules
for mol in st.molecule:
    take_some_action(mol)

@note: Atoms and bonds should not be added or deleted while you are iterating over molecules.

property

Dictionary-like container of Structure-level properties. Keys are strings of the form type_family_name as described in the PropertyName documentation.

putToM2ioFile(filehandle)

Used by the Maestro writer - put a single structure to the (already open) filehandle

static read(filename, index=1, error_handler=None, format=None, ignore_errors=False)

Read a single structure from file ‘filename’, returning a Structure instance.

Parameters:
  • index (int) – For multi-structure formats, the index of the structure to read.
  • error_handler (int) – The handle of the mmerr object to use for error logging. Defaults to schrodinger.infra.mm.error_handler.
  • format (str) – The format of the file, either ‘pdb’, ‘sd’, ‘mol2’, ‘maestro’ or ‘maestro_text’ (determined from file extension by default).
  • ignore_errors (bool) – If True, bad structures will be skipped instead of raising an exception. Currently only used by the SD reader.
residue

An iterable of residues in the structure, each of which is a _Residue instance.

To iterate over all residues:

for residue in st.residue:
    take_some_action(residue)
Note:Atoms and bonds should not be added or deleted while you are iterating over residues.
Note:residues are not accessible by index. See Structure.findResidue()
retype()

Reassign all the MacroModel atom types based on the bond orders and formal charges. This function should be called after either of these have been changed.

ring

An iterable of rings in the structure, each of which is a L{_Ring} instance.

To iterate over rings:

for ring in st.ring:
    take_some_action(ring)

@note: Atoms and bonds should not be added or deleted while you are iterating over rings.

setXYZ(xyz)

Set all xyz coordinates for the molecule from a numpy array.

title

Get the title for this structure

total_weight

The sum of atomic weights for the whole structure.

The weight of implicit hydrogens is automatically included.

Accessing this property is an O(N) operation.

update()

Update the Structure (for manual update mode).

write(filename, format=None)

Write the structure to a file, overwriting any previous content. Format is determined from the file suffix if None is specified, otherwise an explicit value of maestro, sd, pdb, or smiles can be used.

writeToString(format)

Write the structure to a string representation and return the string. The format parameter is required.

class schrodinger.structure.StructureReader(filename=None, index=1, error_handler=None, format=None, ignore_errors=False, input_string=None)

Bases: schrodinger.structure._ReaderWriterContextManager

Read structures from files of various types.

The format is automatically determined from the extension of the specified file, or can be specified via the format option.

Example usage:

# Read the first structure in a file:
st = structure.StructureReader('myfile.pdb').next()

# Read all structures from a file:
for st in structure.StructureReader('myfile.sdf'):
    <do something with st>

# Start reading at the second structure entry in the file
for st in structure.StructureReader('myfile.sdf', index=2):
    <do something with st>

# Assign iterator to a variable and read first 2 structures:
st_reader = structure.StructureReader('myfile.mae')
st1 = st_reader.next()
st2 = st_reader.next()
clearReadErrors()

Clear any queued read errors.

close()
static fromString(input_string, index=1, error_handler=None, format='maestro', ignore_errors=False)

Create a StructureReader from an input string. Currently this is only supported for Maestro and SD format.

Parameters:
  • input_string (str) – The string representation of the Structure.
  • index (int) – The index of the first structure to read.
  • error_handler (int) – The handle of the mmerr object to use for error logging. Defaults to schrodinger.infra.mm.error_handler.
  • format (str) – The format of the file, either SD (‘sd’) or MAESTRO (‘maestro’). Defaults to MAESTRO.
  • ignore_errors (bool) – If True, bad structures will be skipped instead of raising an exception. Currently only used by the SD reader.
getReadErrors()

Return any queued read errors.

next()
class schrodinger.structure.StructureWriter(filename, overwrite=True, format=None, stereo=None)

Bases: schrodinger.structure._ReaderWriterContextManager

A class for efficient writing of multiple structures to a single structure file. If you are writing a single structure, you can more easily use the Structure.write method.

Options that are not supported for all formats can be set with the setOption method, for example:

writer = StructureWriter(filename)
try:
    writer.setOption(stereo=STEREO_FROM_ANNOTATION)
except OptionError:
    # take action based on unsupported option/value here

Currently, the following options are available:

  • stereo
    • This option controls how stereochemical properties are written. It does not affect the output geometry.
    • This option is supported for SD, SMILES, and SMILESCSV, although not all options are supported for SD.
    • Option values are NO_STEREO, STEREO_FROM_ANNOTATION_AND_GEOM, STEREO_FROM_ANNOTATION, and STEREO_FROM_GEOMETRY.
    • The default value is STEREO_FROM_ANNOTATION_AND_GEOM.
    • With STEREO_FROM_ANNOTATION_AND_GEOM, current annotation properties of the Structure are used when present. Chiral atoms without annotation properties will have their stereochemistry determined from geometry (if possible) and will be written with definite stereochemical configuration.
    • With NO_STEREO, no stereochemical information will be written.
    • With STEREO_FROM_ANNOTATION, stereochemical information will be written based only on the current annotations. Use this option to allow for specification of stereochemistry on some centers while leaving others undefined. This should be faster than identifying stereochemistry from the 3D geometry.
    • With STEREO_FROM_GEOMETRY, stereochemistry will be written for all chiral atoms based on the 3D geometry. This option is not supported for SD format.
append(ct)

Append the provided structure to the open file.

close()

Close the file.

extend(cts)

Append all provided structures to the open file.

setOption(option, value)

Set a single option for this writer. This method is meant for options that may not be supported for all writer formats. See the StructureWriter class documentation for details on the available options.

Raises an OptionError subclass (either UnsupportedOption or UnsupportedOptionValue) if unsuccessful.

Parameters:
  • option (str) – The name of the option to set.
  • value – The value for the option. The data type of this parameter depends on the option being set.
schrodinger.structure.count_structures(filename, error_handler=None, format=None)

Returns the number of structures in the specified file. For PDB files, returns the number of MODELs. Optionally an error_handler may be specified (default of mm.error_handler).

schrodinger.structure.create_new_structure(num_atoms=0)

Returns a new Structure object.

If the Structure is created without atoms, they can be added with the Structure.addAtom or Structure.addAtoms methods.

Otherwise, the following atom attributes must be set for each atom afterwards:

  • element
  • x, y, z
  • color
  • atom_type
Parameters:num_atoms – The number of atoms to create the structure with.
schrodinger.structure.read_ct(filename, index=1, error_handler=None)

Read a Structure from file ‘filename’, defaulting to the first one found.

Use the StructureReader or MaestroReader to access multiple structures from a single file.

Deprecated:Use the static Structure.read method instead, as it handles multiple formats and avoids the deprecated ‘ct’ name.
schrodinger.structure.write_ct(ct, filename, mode=2, error_handler=None)

Write a Structure to a Maestro format file.

class schrodinger.structure._AtomBondContainer(ct, atom_index)

Bases: object

The class to provide access to _StructureBond instances for each bond of an atom.

class schrodinger.structure._AtomCollection(st, atoms)

Bases: object

A set of atoms, usually comprising a subset of the total atoms in a Structure. Initialize using a structure and an iterable of current atom indices.

Important methods include extractStructure and getAtomIndices. Use the atom attribute to iterate over all contained atoms. 1-based indexed access to the atoms is also possible using atom (e.g. atom[1] gets the first atom in the _AtomCollection). The number of atoms can be determined via len(self.atom) or len(self).

Intended as a base class for _Ring, _Molecule, and _Chain.

atom

Iterate over all atoms. Also allows 1-based indexed access to the atoms.

extractStructure(copy_props=False)

Return a new Structure containing only the atoms associated with this substructure. Structure properties, including the title, are inherited only if copy_props is set to True.

getAtomIndices()

Return a list of atom indices for all atoms in this object.

Returns:List of atom indicies.
Return type:list of ints
getAtomList()

Deprecated. Use getAtomIndices() method instead.

structure

Return the parent Structure object for this atom collection.

temperature_factor

Average B (temperature) factor for all atoms that have it assigned. Setting this property will set the B factor to the given value for each atom.

class schrodinger.structure._AtomIterator(st, atoms)

Bases: object

Iterates over each _StructureAtom in a _Molecule, _Chain, _Residue or _Ring.

class schrodinger.structure._BaseWriter

Bases: schrodinger.structure._ReaderWriterContextManager

This class provides a common implementation for structure writers.

setOption(option, value)

Set a single option for this writer. This method is meant for options that may not be supported for all writer formats. See the StructureWriter class documentation for details on the available options.

Raises an OptionError subclass (either UnsupportedOption or UnsupportedOptionValue) if unsuccessful.

Parameters:
  • option (str) – The name of the option to set.
  • value – The value for the option. The data type of this parameter depends on the option being set.
class schrodinger.structure._Chain(st, chain, atoms)

Bases: schrodinger.structure._AtomCollection

A class used to return chain information when iterating over chains in a Structure object.

Important methods include extractStructure and getAtomIndices. The atom attribute can be used to iterate over all atoms in the molecule, and the number of atoms can be determined via len(molecule.atom).

The residue iterator allows for iteration over residues of the chain, returning _Residue instances.

applyStyle(atoms=3, bonds=3)

Applies the given display styles to the atoms and bonds of the chain.

Parameters:
  • atoms (int) – display style for atoms given by structure module constants ATOM_NOSTYLE, ATOM_CIRCLE, ATOM_CPK, ATOM_BALLNSTICK. Default is ATOM_BALLNSTICK.
  • atoms – display style for bonds given by structure module constants BOND_NOSTYLE, BOND_WIRE, BOND_TUBE, BOND_BALLNSTICK. Default is BOND_BALLNSTICK.
name

Return name of the chain.

residue

Returns residue iterator for all residues in the chain

class schrodinger.structure._Molecule(st, molnum, atoms)

Bases: schrodinger.structure._AtomCollection

A class used to return molecule information when iterating over molecules in a Structure object.

Important methods include extractStructure and getAtomIndices. The atom attribute can be used to iterate over all atoms in the molecule, and the number of atoms can be determined via len(molecule.atom).

The residue iterator allows for iteration over residues of the molecule, returning _Residue instances.

applyStyle(atoms=3, bonds=3)

Applies the given display styles to the atoms and bonds of the molecule.

Parameters:
  • atoms (int) – display style for atoms given by structure module constants ATOM_NOSTYLE, ATOM_CIRCLE, ATOM_CPK, ATOM_BALLNSTICK. Default is ATOM_BALLNSTICK.
  • atoms – display style for bonds given by structure module constants BOND_NOSTYLE, BOND_WIRE, BOND_TUBE, BOND_BALLNSTICK. Default is BOND_BALLNSTICK.
number

Returns the molecule number of this molecule.

residue

Returns residue iterator for all residues in the molecule.

class schrodinger.structure._NotSortable

Bases: object

Mix-in for classes that shouldn’t be sortable or orderable.

class schrodinger.structure._ReaderWriterContextManager

Bases: object

A mixin to enable context manager usage in reader and writer classes.

class schrodinger.structure._Residue(st, resnum, inscode, chain, atoms=[])

Bases: schrodinger.structure._AtomCollection

A class which is returned by the ResidueIterator and contains information about the residue including the atoms which make it up.

Important methods include extractStructure and getAtomIndices. The atom attribute can be used to iterate over all atoms in the molecule, and the number of atoms can be determined via len(molecule.atom).

applyStyle(atoms=3, bonds=3)

Applies the given display styles to the atoms and bonds of the residue.

Parameters:
  • atoms (int) – display style for atoms given by structure module constants ATOM_NOSTYLE, ATOM_CIRCLE, ATOM_CPK, ATOM_BALLNSTICK. Default is ATOM_BALLNSTICK.
  • atoms – display style for bonds given by structure module constants BOND_NOSTYLE, BOND_WIRE, BOND_TUBE, BOND_BALLNSTICK. Default is BOND_BALLNSTICK.
chain

Return chain name.

getAlphaCarbon()

Returns the backbone alpha carbon atom of this residue, or None. NOTE: For use with protein residues only.

Returns:Alpha carbon atom or None
Return type:_StructureAtom or None
getAtomByPdbName(pdbname)

Returns the atom of this residue that matches the given PDB name, or None if no such atom is found.

Parameters:pdbname (str) – 4-letter PDB atom name. E.g. ” C ” to get the C terminal atom of a protein residue.
Returns:Atom with given PDB name or None
Return type:_StructureAtom or None
getBackboneNitrogen()

Returns the backbone nitrogen of the residue, or None. NOTE: For use with protein residues only.

Returns:Nitrogen atom or None
Return type:_StructureAtom or None
getBackboneOxygen()

Returns the oxygen of the backbone, or None. NOTE: For use with protein residues only.

Returns:Oxygen atom or None
Return type:_StructureAtom or None
getBetaCarbon(gly_hydrogen=False)

Returns the beta carbon atom of this residue, or None. NOTE: For use with protein residues only.

Parameters:gly_hydrogen (bool) – Whether to return the hydrogen atom if the residue is a glycine.
Returns:Beta carbon atom or None
Return type:_StructureAtom or None
getCarbonylCarbon()

Returns the carbonyl backbone carbon of the residue, or None. NOTE: For use with protein residues only.

Returns:Carbon atom or None
Return type:_StructureAtom or None
getCode()

Return the one-letter residue code for this residue.

getDihedralAtoms(angle_name)

Return a list of 4 atom objects for the named dihedral angle in this residue. For backbone bonds, atoms are listed in the N->C order; for side-chain bonds, atoms are listed in order of increasing bond count from the backbone. Omega dihedral is the one to the previous residue (the one bonded to the N atom of this residue).

Parameters:name (str) – Name of the dihedral angle to fine. Supported names are: Phi, Psi, Omega, Chi1, Chi2, Chi3, Chi4, Chi5.
Raises:ValueError – if specified dihedral name is not valid or if it was not found in the database.
hasMissingAtoms()

Returns True is this residue doesn’t have the expected number of heavy atoms. Will return False is this residue has the correct number of heavy atoms or if it is of a type we don’t know

inscode

Returns PDB residue insertion code.

isConnectedToResidue(other_res)

Returns True if the given residue is connected (C->N) to this residue.

If the “C” PDB atom of this residue is connected to the “N” PDB atom of the other_res, then the residues are connected. Otherwise, they are not considered connected.

isStandardResidue()

Returns True if this residue is on the list of standard PDB residues

molecule_number

Return molecule number.

pdbres

Returns PDB residue name.

resnum

Returns PDB residue number.

secondary_structure
class schrodinger.structure._ResidueIterator(st, atoms, sort=True, connectivity_sort=False)

Bases: object

Residue iterator. Each Structure, Chain and Molecule will have one of these.

class schrodinger.structure._Ring(st, ringnum, atoms, iterator)

Bases: schrodinger.structure._AtomCollection

Class representing a ring.

Important methods include extractStructure and getAtomIndices. The atom attribute returns an iterator over all atoms in the ring, and the number of atoms can be determined via len(molecule.atom). The edge attribute works in a similar manner for bonds in the ring.

applyStyle(atoms=3, bonds=3)

Applies the given display styles to the atoms and bonds of the ring.

Parameters:
  • atoms (int) – display style for atoms given by structure module constants ATOM_NOSTYLE, ATOM_CIRCLE, ATOM_CPK, ATOM_BALLNSTICK. Default is ATOM_BALLNSTICK.
  • atoms – display style for bonds given by structure module constants BOND_NOSTYLE, BOND_WIRE, BOND_TUBE, BOND_BALLNSTICK. Default is BOND_BALLNSTICK.
edge

Returns a bond iterator for all edges in the ring.

isAromatic()
isHeteroaromatic()
class schrodinger.structure._RingEdgeIterator(ring)

Bases: object

Iterates over edges(bonds) of a _Ring.

class schrodinger.structure._StructureAtom(ct, index)

Bases: schrodinger.structure._NotSortable

Access of mmct atoms properties pythonically.

addBond(atom2, bond_order)

Add a bond between the current atom and atom2. :param bond_order Takes an integer bond order or a BondType

alt_xyz

Alternative XYZ-coordinates of the atom, if available, otherwise returns None.

atom_name
atom_style
atom_type
atom_type_name

Returns MacroModel atom type name.

atomic_number

“Atomic number of the atom’s element.

atomic_weight

Return the atomic weight of the atom.

If implicit hydrogens are present, these are included with the weight of the atom they are attached to.

bond

List of bonds to the atom (_StructureBond objects).

bond_total

Get total number of bonds to this atom.

bonded_atoms

Iterator for atoms bonded to this atom (_StructureAtom objects).

chain

Returns atom chain name.

chirality

Returns chirality of the atom. R, S, ANR, ANS, undef, or None.

color
deleteBond(atom2)

Delete the bond between the current atom and atom2.

element

Element symbol of the atom.

entry_id

Return maestro entry id, may be None.

formal_charge
getChain()

Return a _Chain object for the molecule that this atom is part of.

getMolecule()

Return a _Molecule object for the molecule that this atom is part of.

getResidue()

Return a _Residue object for the residue that this atom is part of.

growname

Returns Maestro grow name.

index
inscode

Returns PDB residue insertion code.

is_halogen
isotope

Returns mass number charge of the atom.

label_color
label_format
label_user_text
molecule_number
name

Return name of atom.

number_by_entry
number_by_molecule
partial_charge

Return partial charge of the atom.

pdbcode

Returns one-letter PDB residue code.

pdbname

Returns PDB atom name.

pdbres
property

Dictionary-like container of Atom-level properties. Keys are strings of the form type_family_name as described in the “PropertyName documentation.

radius
resnum

Returns PDB residue number.

retype()

Reassign the MacroModel atom type based on the bond orders and formal charge. This function should be called after either of these have been changed.

secondary_structure
setColorRGB(red, green, blue)

Set the RGB color of this atom as a tuple (R,G.B). Each color value should be an integer between 0 and 255.

solvation_charge
structure

Return the parent Structure object for this atom.

style
temperature_factor
vdw_radius
visible
x
xyz

XYZ-coordinates of the atom.

y
z
class schrodinger.structure._StructureAtomContainer(ct)

Bases: object

The class to provide access to _StructureAtom instances.

class schrodinger.structure._StructureAtomProperty(ct, cpp_atom)

Bases: UserDict.DictMixin

Dictionary-like container of atom based properties. These can be accessed via the property name as it appears in the maestro file.

Property names must be m2io data names, which are in the format ‘<type>_<author>_<property_name>’, where ‘<type>’ is a data type prefix, ‘<author>’ is a source specification, and ‘<property_name>’ is the actual name of the data.

The data type prefix can specified as ‘s’ for string, ‘i’ for integer, ‘r’ for real and ‘b’ for boolean. The author specification should be ‘user’ for user created properties. The property name can have embedded underscores.

Some example m2io datanames are ‘r_m_x_coord’, which indicates a real maestro property named ‘x coord’, and ‘i_user_my_count’ which indicates an integer user property named ‘my count’.

keys()

Returns a list of the datanames of all unrequested items.

class schrodinger.structure._StructureBond(ct, atom_index, index)

Bases: schrodinger.structure._NotSortable

A class for pythonic access to bond properties.

Attributes
  • atom1: The first atom, by which the bond is defined.
  • atom2: The atom bonded to atom1.
delete()

Delete this bond. Use with care. Iteration over bonds may be affected.

from_style

Return bond’s “from” style.

length

Length of the bond in angstroms.

order

Return bond order. Returns None for the MMCT_NONE type, integer values for zero through three.

property

Dictionary-like container of Bond properties.

setStyle(style)

Set the bond’s style in both directions (“from” and “to”)

style
to_style

Return bond’s “to” style.

type

:returns schrodinger.structure.BondType

class schrodinger.structure._StructureBondContainer(ct)

Bases: object

The class to provide access to _StructureBond instances for each bond in the structure.

class schrodinger.structure._StructureBondProperty(ct, atomindex, bondnum)

Bases: UserDict.DictMixin

Dictionary-like container of bond based properties. These can be accessed via the property name as it appears in the maestro file.

Property names must be m2io data names, which are in the format ‘<type>_<author>_<property_name>’, where ‘<type>’ is a data type prefix, ‘<author>’ is a source specification, and ‘<property_name>’ is the actual name of the data.

The data type prefix can specified as ‘s’ for string, ‘i’ for integer, ‘r’ for real and ‘b’ for boolean. The author specification should be ‘user’ for user created properties. The property name can have embedded underscores.

Some example m2io datanames are ‘r_m_x_coord’, which indicates a real maestro property named ‘x coord’, and ‘i_user_my_count’ which indicates an integer user property named ‘my count’.

keys()

Returns a list of the datanames of all unrequested items.

class schrodinger.structure._StructureChainIterator(st)

Bases: object

Class for iterating over chains in a Structure.

chainNames()

Return a list of chain letters

recalc()

Obsolete

class schrodinger.structure._StructureMoleculeIterator(st)

Bases: object

Iterates over _Molecule in a Structure.

recalc()

Obsolete

class schrodinger.structure._StructureProperty(st, read_only=False)

Bases: UserDict.DictMixin

Dictionary-like container of Structure based properties, with all dict methods. Properties can be accessed via the m2io dataname as it appears in the maestro file.

Property names must be m2io data names, which are in the format ‘<type>_<author>_<property_name>’, where ‘<type>’ is a data type prefix, ‘<author>’ is a source specification, and ‘<property_name>’ is the actual name of the data.

The data type prefix can specified as ‘s’ for string, ‘i’ for integer, ‘r’ for real and ‘b’ for boolean. The author specification should be ‘user’ for user created properties. The property name can have embedded underscores.

Some example m2io datanames are ‘r_m_x_coord’, which indicates a real maestro property named ‘x coord’, and ‘i_user_my_count’ which indicates an integer user property named ‘my count’.

To convert to the _StructureProperty to a real dictionary::
d = dict(st.property)
To set all properties from dictionary::
st.property = {…}
clear()

Clear all properties (except the title).

keys()

Return a list of the names of all properties.

class schrodinger.structure._StructureRingIterator(st)

Bases: object

Container for all rings in the Structure. Represents a dynamic list of the smallest set of smallest rings (SSSR) in the structure.

recalc()

Obsolete