schrodinger.test.stu.outcomes.structure_comparisons module

Provides functions for comparing structure files. Supersedes the compare_mae_files workup requested in QA-293. This set of workups was requested in QA-1165.

Can be run as a script to compare two files:

$SCHRODINGER/run structure_comparisons.py filename.mae reference_file.mae

@copyright: (c) Schrodinger, LLC All rights reserved.

exception schrodinger.test.stu.outcomes.structure_comparisons.StructureMismatch[source]

Bases: schrodinger.test.stu.outcomes.failures.WorkupFailure

failure_type = 'workup: structure mismatch'
__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception schrodinger.test.stu.outcomes.structure_comparisons.CompositeFailure[source]

Bases: schrodinger.test.stu.outcomes.structure_comparisons.StructureMismatch

Failures with lists or dicts of nested differences.

formattedDetails(width=80, max_number=5)[source]

Return a formatted version of the detailed diffs. If max_number is not -1, only max_number of diffs will be returned.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
failure_type = 'workup: structure mismatch'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

schrodinger.test.stu.outcomes.structure_comparisons.compare_ct_properties(check, reference, *properties, ordered=True, **tolerances)[source]

Check that the values of the CT-level properties in properties match in check and reference across all cts. If no properties are listed, all are compared. Default tolerance is 0.005, but can be overridden with the tolerance keyword “tol”. String properties are required to be identical. If the special tolerance value “IGNORE” appears in the tolerance dictionary, that property is ignored.

examples:

# Compare all CT properties with a tolerance of +/- 0.05
compare_ct_properties('chk.mae', 'ref.mae', tol=0.05)
# Compare r_m_pdb_PDB_R and s_m_source_file with a tolerance of +/-
# 0.05 on numeric comparisons.
compare_ct_properties('chk.mae', 'ref.mae', 'r_m_pdb_PDB_R',
                      's_m_source_file', tol=0.05)
# Compare r_m_pdb_PDB_R and i_m_source_file_index with a tolerance of
# +/- 1 on i_m_source_file_index, use the default tolerance of 0.005 on
# other numeric comparisons.
compare_ct_properties('chk.mae', 'ref.mae', 'r_m_pdb_PDB_R',
                      'i_m_source_file_index', i_m_source_file_index=1)
# Compare all atom properties except the string property
# s_m_source_file.
compare_atom_properties('chk.mae', 'ref.mae', s_m_source_file='IGNORE')
Parameters
  • check (str) – First filename.

  • reference (str) – Reference filename.

  • properties – Properties to check.

  • ordered (bool) – If true, assume the order of the structures in the two files is the same. If False, structures will be matched based on title.

  • tolerances – Tolerances by which each should be compared. Keys are property names, values are tolerances.

Raises

AssertionError – If properties do not match.

Return type

bool

Returns

Did all properties match?

schrodinger.test.stu.outcomes.structure_comparisons.compare_st_file_properties(check, reference, tolerance=0.005)[source]

Alias for older workup.

schrodinger.test.stu.outcomes.structure_comparisons.compare_atom_properties(check, reference, *properties, **tolerances)[source]

Check that the values of the atom-level properties in properties match in in check and reference across all cts. If no properties are listed, all are compared. Default tolerance is 0.005, but can be overridden with the tolerance keyword “tol”. String properties are required to be identical. If the special tolerance value “IGNORE” appears in the tolerance dictionary, that property is ignored.

examples:

# Compare all atom properties with a tolerance of +/- 0.05 on numeric
# comparisons.
compare_atom_properties('chk.mae', 'ref.mae', tol=0.05)
# Compare r_m_pdb_tfactor and s_m_chain_name with a tolerance of +/-
# 0.05 on numeric comparisons (r_m_pdb_tfactor).  The string comparison
# (s_m_chain_name) is still required to match exactly.
compare_atom_properties('chk.mae', 'ref.mae', 'r_m_pdb_tfactor',
                        's_m_chain_name', tol=0.05)
# Compare r_m_pdb_tfactor and i_m_residue_number. Use a tolerance of
# +/- 1 on i_m_residue_number, use the default tolerance of 0.005 on
# other numeric comparisons (that is, r_m_pdb_tfactor).
compare_atom_properties('chk.mae', 'ref.mae', 'r_m_pdb_tfactor',
                        'i_m_residue_number', i_m_residue_number=1)
# Compare all atom properties except the string property s_m_chain_name
compare_atom_properties('chk.mae', 'ref.mae', s_m_chain_name='IGNORE')
Parameters
  • check (str) – First filename.

  • reference (str) – Reference filename.

  • properties – Properties to check.

  • tolerances – Tolerances by which each should be compared. Keys are property names, values are tolerances.

Raises

AssertionError – If properties do not match.

Return type

bool

Returns

Did all properties match?

schrodinger.test.stu.outcomes.structure_comparisons.compare_bond_properties(check, reference, *properties, **tolerances)[source]

Check that the values of the bond-level properties in properties match in check and reference across all cts. If no properties are listed, all are compared. Default tolerance is 0.005, but can be overridden with the tolerance keyword “tol”. String properties are required to be identical. If the special tolerance value “IGNORE” appears in the tolerance dictionary, that property is ignored.

Parameters
  • check (str) – First filename.

  • reference (str) – Reference filename.

  • properties – Properties to check.

  • tolerances – Tolerances by which each should be compared. Keys are property names, values are tolerances.

Raises

AssertionError – If properties do not match.

Return type

bool

Returns

Did all properties match?

schrodinger.test.stu.outcomes.structure_comparisons.rmsd(check, reference, tolerance=0.05, asl='all and NOT atom.element H', check_cts='', use_symmetry=False, in_place=False)[source]

After rotating molecules into the same frame of reference, check that the RMSD between matched cts in check and reference are below tolerance. If asl is provided, only matching atoms are compared. If there are multiple structures in the files, all will be compared unless check_cts is provided. check_cts is a comma separated list of CT indices, starting with ct 1. ‘use_symmetry’ indicates whether the rmsd calculations should take symmetry into account.

If your structures contain dummy atoms, use rmsd_in_place.

schrodinger.test.stu.outcomes.structure_comparisons.rmsd_in_place(check, reference, tolerance=0.05, asl='all and NOT atom.element H', check_cts='', use_symmetry=False)[source]

Check that that RMSD between matched cts in check and reference are below tolerance in their current orientation. This is mostly useful for systems that contain dummy atoms, otherwise you’ll want the rmsd workup. If there are multiple structures in the files, all will be compared unless check_cts is provided. check_cts is a comma separated list of CT indices, starting with ct 1. ‘use_symmetry’ is a boolean to indicate whether or not the RMSD calculation should take symmetry into account.

schrodinger.test.stu.outcomes.structure_comparisons.compare_bonding(check, reference)[source]

Check that the connectivity of each cts in check matches the connectivity of the corresponding ct in reference.

schrodinger.test.stu.outcomes.structure_comparisons.compare_chiralities(check, reference)[source]

Check that the chiralities of each ct in check matches the chirality of the corresponding ct in reference.

Both the chiral label and the CIP ranked list of neighbors are checked.

schrodinger.test.stu.outcomes.structure_comparisons.compare_num_atoms(check, reference, tolerance=0)[source]

Compare number of atoms in every CT of structure file check against reference. The number can differ by as much as tolerance.

schrodinger.test.stu.outcomes.structure_comparisons.compare_mae_files(check, reference, *tolerance_list, **tolerances)[source]

Check that all atom, bond and CT level properties of matched cts in check and reference match within some tolerance. Also check RMSDs between all structures and bond orders. Tolerances should be specified as keyword/value pairs.

Default tolerance is 0.005, but can be overridden with the tolerance keyword “tol”. String properties are required to be identical. If the special tolerance value “IGNORE” appears in the tolerance dictionary, that property is ignored. RMSD tolerance can be specified with the tolerance keyword “rmsd”.

examples::
compare_mae_files(‘chk.mae’, ‘ref.mae’, tol=0.05)

Compare all atom, bond, and CT properties with a tolerance of +/- 0.05. Also compare RMSD and bonding.

compare_mae_files(‘chk.mae’, ‘ref.mae’, tol=0.05, rmsd=0.05)

Compare all atom, bond, and CT properties with a tolerance of +/- 0.05. Also compare RMSD with a tolerance of 0.05, and compare bonding.

compare_mae_files(‘chk.mae’, ‘ref.mae’, r_m_pdb_tfactor=0.05, i_m_source_file_index=1)

Compare all atom, bond, and CT properties, with a tolerance of +-0.05 for r_m_pdb_tfactor and +/-1 for i_m_source_file_index; other numeric comparisons use the default tolerance of 0.005. Also compare RMSD and bonding.

compare_mae_files(‘chk.mae’, ‘ref.mae’, r_m_pdb_tfactor=0.05, s_m_chain_name=’IGNORE’)

Compare all atom, bond, and CT properties except s_m_chain_name, with a tolerance of +-0.05 for r_m_pdb_tfactor; other numeric comparisons use the default tolerance of 0.005. Also compare RMSD and bonding.

Parameters
  • check (str) – First filename.

  • reference (str) – Reference filename.

  • tolerance_list – Tolerances by which each should be compared.

  • tolerances – Tolerances by which each should be compared.

Raises

AssertionError – If properties do not match.

Return type

bool

Returns

Did all properties match?