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.

schrodinger.structure.get_atom_names_for_chi_angle(res_type, angle_name)

Return atom names for the specified Chi angle in the given residue type.

Parameters:
  • res_type (str) – Residue type (e.g. “ALA “)
  • angle_name (str) – Chi angle name. One of: Chi1, Chi2, Chi3, Chi4, Chi5. See CHI_DIHEDRAL_NAMES.
:raises ValueError if the given angle is invalid, or is not defined for the
given residue.
class schrodinger.structure.BondType

Bases: enum.Enum

These represent varying bond types, which are independent from bond orders.

Zero = 0
Dative = 1
Single = 2
Double = 3
Triple = 4
exception schrodinger.structure.UndefinedStereochemistry

Bases: Exception

Raised by SmilesStructure.getStructure() when atoms with undefined chirality are present.

exception schrodinger.structure.AtomsInRingError

Bases: ValueError

Raised by Structure.adjust() when atoms are in a ring, so adjustment can’t be made without distorting the structure.

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.

copy()

Returns a copy of the structure.

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.

setXYZ(xyz)

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

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.
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.

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.

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.

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.

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.

manual_update

Find whether mmct is in manual update mode.

title

Get the title for this structure

atom_total

Get total number of atoms in this structure

mol_total

Get total number of molecules in this structure

formal_charge

Get the sum of formal charges for the structure.

Accessing this property is an O(N) operation.

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.

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()
property

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

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.

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) – Handle of the mmerr object to use for error logging. Defaults to schrodinger.infra.mm.error_handler.
  • format (str) – 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.
writeToString(format)

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

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.

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.
putToM2ioFile(filehandle)

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

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

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.

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
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.

extend(other_structure)

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

Extending a structure with itself is not allowed.

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.

areBound(atom1, atom2)

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

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.

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.

deleteBond(atom1, atom2)

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

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.

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().
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()

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’.

getMoleculeAtoms(atom)

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

getChainAtoms(atom)

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

getAtomIndices()

Return a list of all atom indices in this structure.

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.

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.
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()
update()

Update the Structure (for manual update mode).

has3dCoords()

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

get3dStructure(require_stereo=True)
Deprecated:Use generate3dConformation() instead.
generate3dConformation(require_stereo=True)

Generate new 3D coordinates for the current structure, and add hydrogens if any are missing. This method is useful for “volumizing” a 2D structure into 3D. NOTE: For 2D inputs, annotation properties must be present for chiral centers to be processed correctly.

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.
class schrodinger.structure.MaestroTextReader(filename, index=1, error_handler=None)

Bases: schrodinger.structure._ReaderWriterContextManager

A class for reading structures from a Maestro format file. The structures returned are TextualStructure objects. These allow read-only access to the Structure-level properties but not to atoms or any properties which rely on atoms.

read_mode = 16
close()

Close the file.

class schrodinger.structure.FormatReader(error_handler)

Bases: schrodinger.structure._ReaderWriterContextManager

This is a base class for all file format readers.

It currently handles the queueing of error messages generated by the underlying file reading libraries.

getErrorHandler()

This method will return the current error handler. It should be defined in any derived class in order to query the appropriate mmlib and return the error handler if there is one.

getReadErrors()

Returns the list of error messages generated from the reading operations since the most recent clearReadErrors() call. Note that this could be an empty list if now errors have beenn encountered.

clearReadErrors()

Clears the list of read errors.

startErrorQueuing()

Queue error messages and suppress printing to the stream.

stopErrorQueuing()

Turn off error queueing and add any error messages to the error_queue attribute. And restore printing to the stream.

class schrodinger.structure.InfraReader(filename)

Bases: schrodinger.structure.FormatReader

Reader which use c++ reader implementation.

NOTE: This is just tested for CIF format for now.

class schrodinger.structure.MaestroReader(filename, index=1, error_handler=None, input_string=None)

Bases: schrodinger.structure.FormatReader

A class for reading structures from a Maestro (M2io) format file.

read_mode = 16
getErrorHandler()

Returns the error handler by querying the m2io library and if the refcount is > 0 then return the error handler that is in use by m2io. Otherwise None is returned.

seek(position)

Set the file position to the given position. This raise an exception for zero size file.

read(position=None)

Return the next Structure object. If position is given, this will be honoured. Otherwise the current position is taken. This raise an exception for zero size file, reading structure beyond end of file indicator and m2io errors.

Raises:
  • EOFError – on EOF or zero size file.
  • Exception – otherwise.
close()

Close the file.

class schrodinger.structure.MaestroReaderWithPositions(filename, positions, error_handler=None)

Bases: schrodinger.structure.MaestroReader

A class for rapid random access to the structures in a Maestro file. Structures are read from a user-specified sequence of file positions (offsets). Here is one how one might use it to sort an input structure by glide score (‘r_i_glide_gscore’):

# Read input file, accumulating a list of glide scores and file
# positions:
reader = structure.MaestroReader('input.mae')
position_list = []
for st in reader:
    position_list.append((st.property['r_i_glide_gscore'],
            reader.last_position))

# Sort by glide score:
position_list.sort()

# Obtain a list of file positions from the sorted list:
positions = [record[1] for record in position_list]

# Read input file in sorted order and write the structures to output:
reader = structure.MaestroReaderWithPositions('input.mae', positions)
writer = structure.MaestroWriter('output.mae')
for st in reader:
    writer.append(st)
exception schrodinger.structure.OptionError

Bases: Exception

A parent exception class to indicate an error in setting an option.

exception schrodinger.structure.UnsupportedOption(option_name, class_name)

Bases: schrodinger.structure.OptionError

An exception class to indicate an attempt to set an option that is not supported.

exception schrodinger.structure.UnsupportedOptionValue(option_name, option_value, class_name)

Bases: schrodinger.structure.OptionError

An exception class to indicate an attempt to set an option to a value that is supported.

class schrodinger.structure.MaestroWriter(filename, overwrite=True)

Bases: schrodinger.structure._BaseWriter

A class for more efficient appending of a large number of structures to a single maestro structure file.

For writing single structures, just use the Structure.write method. For appending a small (less than a thousand) number of structures, the Structure.append method will perform acceptably.

append(ct)

Append the provided structure to the open mae file. Set self.last_position to the file offset just before it was appended.

The use of this class and method should be preferred for large numbers of structures (say, >1000), but for smaller numbers of structures you can use the Structure.append method directly.

close()

Close the file.

class schrodinger.structure.SDWriter(filename, overwrite=True)

Bases: schrodinger.structure._BaseWriter

A class for more efficient appending of a large number of structures to a single SD structure file.

For writing single structures, just use the Structure.write method. For appending a small (less than a thousand) number of structures, the Structure.append method will perform acceptably.

setOption(option, value)

Set an option not supported for all StructureWriter formats.

The only supported option for SDWriter is stereo. See the StructureWriter docstring for details on the option values.

append(ct)

Append the provided structure to the open file.

close()

Close the file.

class schrodinger.structure.Mol2Writer(filename, overwrite=True)

Bases: schrodinger.structure._BaseWriter

Mol2 support for the StructureWriter class.

append(st)

Append the provided structure to the file.

close()
class schrodinger.structure.PDBWriter(filename, reorder_by_sequence=False, first_occ=False, translate_pdb_resnames=True)

Bases: schrodinger.structure._ReaderWriterContextManager

A class for writing PDB-formatted files. Only one structure can be written to a PDB file. While this class overs no speed increase over the Structure.write() method, it provides more options.

write(ct)

Write the provided structure to the PDB file.

append(ct)

Alias to the write() method (for consistency with the other Writer classes).

close()

Does nothing. Added for consistency with other Writer classes.

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.

extend(cts)

Append all provided structures to the open file.

close()

Close the 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.
class schrodinger.structure.PDBReader(filename, index=1, error_handler=None, all_occ=True, allow_obsolete=True, use_strict_resname=False)

Bases: schrodinger.structure.FormatReader

A class for reading structures from a PDB format file.

close()

Close the file.

getErrorHandler()

Returns the error handler by querying the pdb library and if the refcount is > 0 then return the error handler that is in use by pdb. Otherwise None is returned.

class schrodinger.structure.SDReader(filename, index=1, error_handler=None, ignore_errors=False, input_string=None, import_sdprop_as_string=False, import_sdprop_per_file=True, ignore_structureless=True)

Bases: schrodinger.structure.FormatReader

A class for reading structures from a SD format file.

getErrorHandler()

Returns the error handler by querying the mmmdl library and if the refcount is > 0 then return the error handler that is in use by mmmdl. Otherwise None is returned.

close()

Close the file.

class schrodinger.structure.Mol2Reader(filename, index=1, error_handler=None)

Bases: schrodinger.structure.FormatReader

A class for reading structures from a mol2 format file.

close()

Close the file.

getErrorHandler()

Returns the error handler by querying the mmmmol2 library and if the refcount is > 0 then return the error handler that is in use by mmmol2. Otherwise None is returned.

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()
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.
close()
getReadErrors()

Return any queued read errors.

clearReadErrors()

Clear any queued read errors.

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_to_string(ct, error_handler=None)

Return a string representation of the provided Structure, formatted as a Maestro file.

schrodinger.structure.write_ct_to_sd_string(ct, error_handler=None)

Return a string representation of the provided Structure, formatted as an SD file.

schrodinger.structure.write_ct(ct, filename, mode=2, error_handler=None)

Write a Structure to a Maestro format file.

schrodinger.structure.write_cts(cts, filename)

Write multiple structures to a file

Parameters:
  • cts (iter) – An iterable containing the structures to write
  • filename (str) – The filename to write the structures to. File format will be determined from the filename suffix.
schrodinger.structure.write_ct_as_text(ct, filename, mode=2, error_handler=None)

Write a TextualStructure object to a Maestro format file.

schrodinger.structure.write_ct_sd(ct, filename, mode=2, error_handler=None)

Write a Structure to a SD format file.

schrodinger.structure.write_ct_mol2(ct, filename, mode=1, error_handler=None)

Write a Structure to a mol2 format file.

schrodinger.structure.write_ct_pdb(ct, filename, mode='write', error_handler=None)

Write a Structure to a PDB format file.

schrodinger.structure.write_ct_smiles(st, filename, mode='write')

Write a Structure object to a SMILES format file. Assumes that the input is a 3D file. If input is 2D (from SD file), then stereochemistry will be lost

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).

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.TextualStructure(ct, txt)

Bases: schrodinger.structure.Structure

A sub-class of Structure for use when reading from a Maestro format file and only the structure-level properties are needed. The actual atom and bond records are not parsed from the file and so can’t actually be accessed. The only things possible with this type of Strucure are to access the structure level properties or to write it out unchanged to a file. Attempts to access the atom or bond data, directly or indirectly, will raise an exception.

The only useful way to create a TextualStructure object is via the StructureReader with the ‘maestro_text’ format.

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.

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.

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.

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()
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.

property

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

Note:Unlike the Structure.property dictionary, this dictionary is read-only.
write(filename, format=None)

Write the structure to a file, overwriting any previous content. File will only be written to Maestro format.

append(filename, format=None)

Append the structure to the file. File will only be written to Maestro format.

putToM2ioFile(filehandle)

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

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

class schrodinger.structure.SmilesStructure(pattern, properties=None)

Bases: object

SMILES representation of a Structure that is returned by SmilesReader and SmilesCsvReader. When written to a SMILES-formatted file, properties other than the title are not retained.

mmsmiles_initialized = False
write(filename)

Write the structure to a SMILES formatted file.

append(filename)

Append the structure to a SMILES formatted file.

get2dStructure()

Return a 2D Structure object for this SMILES. The structure will have only 2D coordinates, with stereo annotation properties for chiral atoms with specified chirality. NOTE: Use for 2D applications only.

Return type:Structure.Structure
Returns:2D structure.
Raises:ValueError – if self.smiles is set to an invalid SMILES string.
get3dStructure(require_stereo=True)

Return a 3D Structure object for this SMILES with all hydrogens 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.
neutralize()

Neutralize this SMILES structure.

title
class schrodinger.structure.SmilesReader(filename, index=1)

Bases: schrodinger.structure._ReaderWriterContextManager

A class for reading structures from a SMILES formatted file. Returns instances of SmilesStructure.

class schrodinger.structure.SmilesCsvReader(filename, index=1)

Bases: schrodinger.structure._ReaderWriterContextManager

A class for reading structures from a SMILES CSV formatted file. This format is used by Canvas. Returns instances of SmilesStructure.

class schrodinger.structure.SmilesWriter(filename, overwrite=True, stereo=None)

Bases: schrodinger.structure._BaseWriter

More efficient writing of a large number of structures to a single SMILES file.

append(st)

Append the provided structure to the open SMILES file.

close()

Close the file.

class schrodinger.structure.SmilesCsvWriter(filename, stereo=None, props=None)

Bases: schrodinger.structure._BaseWriter

More efficient writing of a large number of structures to a single SMILES CSV file.

append(st)

Append the provided structure to the open SMILES CSV file.

close()

Close the file.

class schrodinger.structure.MultiFileStructureReader(files, *args, **kwargs)

Bases: schrodinger.structure._ReaderWriterContextManager

Provides a single iterator that reads structure from multiple files. Typical usage is idential to typical useage of the StructureReader class except that the class is instantiated with a python list of file names rather than a single file name.

By default, the StructureReader class is used to read the files, but this is customizable with the reacer_class keyword.

API Example:

names = ['file1.mae', 'file2.mae', 'file3.pdb']
reader = MultiFileStructureReader(names)
first_struct = reader.next()
for struct in reader:
    do stuff

By default, the reader skips files that raise Exceptions and stores the list of skipped files in the failed_files property.

The current StructureReader can be accessed with the reader property

reader_class = None

The class used to read files

pass_errors = None

False if exceptions should be raised, True if they should be caught

files = None

List of files remaining to be read

current_filename = None

The file currently being read

index_in_current_file = None

Index of current structure in current file

failed_files = None

List of (failed_file_name, error_message)

reader = None

Current file reader

class schrodinger.structure.MultiFileStructureWriter(basename, extension='.maegz', sts_per_file=100000)

Bases: schrodinger.structure._ReaderWriterContextManager

Similar to StructureWriter, except that it writes to multiple files, while keeping the number of structures per file under sts_per_file.

Files will be named <basename>-NNN<extension>. Default extension is .maegz.

Options:

basename - The base name of the written files extension - The extension of the written files (default “.maegz”) sts_per_file - Maximum number of structures to write to each file

Usage:

writer = MultiFileStructureWriter(out_basename, ".maegz", 50)
for st in sts:
    writer.append(st)
writer.close()
written_files = writer.getFiles()
append(st)
getFiles()

Return a list of file paths for the written files.

getNumStructures()

Return the total number of structures that were written.

close()

Close any open file handles

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.get_residues_by_connectivity(atom_container)

Access residues in N->C connectivity order

Parameters:atom_container (Structure._Chain, Structure._Structure, or Structure._Molecule) – Anything with an atom() method that returns atom indexes
Returns:A residue iterator where the atoms are returned in N->C connectivity order
Return type:Structure._ResidueIterator
schrodinger.structure.get_residues_unsorted(atom_container)

Access residues in the unsorted input order

Parameters:atom_container (Structure._Chain, Structure._Structure, or Structure._Molecule) – Anything with an atom() method that returns atom indexes
Returns:A residue iterator where the atoms are returned in unsorted order
Return type:Structure._ResidueIterator
schrodinger.structure.get_pyatom_from_cppatom(cppatom)

Given a C++ atom object, return the corresponding Python atom.

Parameters:cppatom (schrodinger.infra.structure.StructureAtom) – C++ atom object
Returns:The corresponding Python atom object
Return type:structure._StructureAtom
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.

structure

Return the parent Structure object for this atom collection.

atom

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

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.

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.

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.

residue

Returns residue iterator for all residues in the chain

name

Return name of the chain.

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.
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.

residue

Returns residue iterator for all residues in the molecule.

number

Returns the molecule number of this molecule.

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.
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).

pdbres

Returns PDB residue name.

chain

Return chain name.

resnum

Returns PDB residue number.

inscode

Returns PDB residue insertion code.

molecule_number

Return molecule number.

secondary_structure
getCode()

Return the one-letter residue code for this residue.

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

isStandardResidue()

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

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.

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.
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
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
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
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
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
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.
getAsl()

Return an ASL that uniquely identifies this residue, by chain ID, residue number, and insertion code.

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.

edge

Returns a bond iterator for all edges in the ring.

isAromatic()
isHeteroaromatic()
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.
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.

index
addBond(atom2, bond_order)

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

deleteBond(atom2)

Delete the bond between the current atom and atom2.

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.

getResidue()

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

getMolecule()

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

getChain()

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

structure

Return the parent Structure object for this atom.

bond_total

Get total number of bonds to this atom.

bond

List of bonds to the atom (_StructureBond objects).

bonded_atoms

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

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.

growname

Returns Maestro grow name.

pdbname

Returns PDB atom name.

pdbres
pdbcode

Returns one-letter PDB residue code.

resnum

Returns PDB residue number.

inscode

Returns PDB residue insertion code.

atom_type
atom_type_name

Returns MacroModel atom type name.

color

Get property method for _StructureAtom.color attribute.

:return Color object. :rtype: color.Color

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.

chain

Returns atom chain name.

atom_name
name

Return name of atom.

entry_id

Return maestro entry id, may be None.

element

Element symbol of the atom.

partial_charge

Return partial charge of the atom.

solvation_charge
formal_charge
isotope

Returns mass number charge of the atom.

secondary_structure
temperature_factor
radius
vdw_radius
is_halogen
molecule_number
number_by_molecule
number_by_entry
atomic_number

“Atomic number of the atom’s element.

x
y
z
xyz

XYZ-coordinates of the atom.

alt_xyz

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

chirality

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

atom_style
style
visible
label_format
label_color
label_user_text
property

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

class schrodinger.structure._StructureAtomContainer(ct)

Bases: object

The class to provide access to _StructureAtom instances.

class schrodinger.structure._StructureAtomProperty(ct, cpp_atom)

Bases: collections.abc.MutableMapping

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.

length

Length of the bond in angstroms.

order

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

type

:returns schrodinger.structure.BondType

from_style

Return bond’s “from” style.

to_style

Return bond’s “to” style.

style
setStyle(style)

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

property

Dictionary-like container of Bond properties.

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: collections.abc.MutableMapping

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.

recalc()

Obsolete

chainNames()

Return a list of chain letters

class schrodinger.structure._StructureMoleculeIterator(st)

Bases: object

Iterates over _Molecule in a Structure.

recalc()

Obsolete

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

Bases: collections.abc.MutableMapping

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 = {…}
keys()

Return a list of the names of all properties.

clear()

Clear all properties (except the title).

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