Package schrodinger :: Package test :: Package stu :: Package outcomes :: Module structure_comparisons
[hide private]
[frames] | no frames]

Module structure_comparisons

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.

Classes [hide private]
  StructureMismatch
  CompositeFailure
Failures with lists or dicts of nested differences.
Functions [hide private]
bool
compare_ct_properties(check, reference, *properties, **tolerances)
Check that the values of the CT-level properties in properties match in check and reference across all cts.
 
compare_st_file_properties(check, reference, tolerance=0.005)
Alias for older workup.
bool
compare_atom_properties(check, reference, *properties, **tolerances)
Check that the values of the atom-level properties in properties match in check and reference across all cts.
bool
compare_bond_properties(check, reference, *properties, **tolerances)
Check that the values of the bond-level properties in properties match in check and reference across all cts.
 
_move_args_to_kwargs(args, kwargs)
Split arguments with equals in them.
 
_check_properties(check, reference, properties=None, tolerances=None)
Check the property dictionaries of two things, ensuring that the listed properties match.
 
rmsd(check, reference, tolerance=0.05, asl='all and NOT atom.element H', check_cts='')
After rotating molecules into the same frame of reference, check that the RMSD between matched cts in check and reference are below tolerance.
 
rmsd_in_place(check, reference, tolerance=0.05, asl='all and NOT atom.element H')
Check that that RMSD between matched cts in check and reference are below tolerance in their current orientation.
 
compare_bonding(check, reference)
Check that the connectivity of each cts in check matches the connectivity of the corresponding ct in reference.
 
compare_num_atoms(check, reference, tolerance=0)
Compare number of atoms in every CT of structure file check against reference.
bool
compare_mae_files(check, reference, *tolerance_list, **tolerances)
Check that all atom, bond and CT level properties of matched cts in check and reference match within some tolerance.
 
_zip_structures(check, reference)
Iterate over the structures in two files.
Variables [hide private]
  logger = log.get_logger('test_backend')
  _DEFAULT_TOLERANCE = 0.005
  IGNORE = 'IGNORE'
  __package__ = 'schrodinger.test.stu.outcomes'
Function Details [hide private]

compare_ct_properties(check, reference, *properties, **tolerances)

 

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_ct_properties(chk.mae, ref.mae, tol=0.05)
       Compare all CT properties with a tolerance of +/- 0.05
   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 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, i_m_source_file_index, i_m_source_file_index=1)
       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_atom_properties(chk.mae, ref.mae, s_m_source_file=IGNORE)
       Compare all atom properties except the string property
       s_m_source_file.
Parameters:
  • check - First filename.
  • reference - Reference filename.
  • properties - Properties to check.
  • tolerances - Tolerances by which each should be compared. Keys are property names, values are tolerances.
Returns: bool
Did all properties match?
Raises:
  • AssertionError - If properties do not match.

compare_atom_properties(check, reference, *properties, **tolerances)

 

Check that the values of the atom-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_atom_properties(chk.mae, ref.mae, tol=0.05)
       Compare all atom properties with a tolerance of +/- 0.05 on numeric
       comparisons.
   compare_atom_properties(chk.mae, ref.mae, r_m_pdb_tfactor, s_m_chain_name, 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, i_m_residue_number, i_m_residue_number=1)
       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, s_m_chain_name=IGNORE)
       Compare all atom properties except the string property
       s_m_chain_name.
Parameters:
  • check - First filename.
  • reference - Reference filename.
  • properties - Properties to check.
  • tolerances - Tolerances by which each should be compared. Keys are property names, values are tolerances.
Returns: bool
Did all properties match?
Raises:
  • AssertionError - If properties do not match.

compare_bond_properties(check, reference, *properties, **tolerances)

 

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 - First filename.
  • reference - Reference filename.
  • properties - Properties to check.
  • tolerances - Tolerances by which each should be compared. Keys are property names, values are tolerances.
Returns: bool
Did all properties match?
Raises:
  • AssertionError - If properties do not match.

_move_args_to_kwargs(args, kwargs)

 

Split arguments with equals in them. This lets us emulate keyword arguments in STU workups. Returns the updated args list.

Anything in args that has an "=" sign in it is moved to the kwargs dict. This is required because STU workups are not fully parsed to python-like arglist + kwarglist.

_check_properties(check, reference, properties=None, tolerances=None)

 

Check the property dictionaries of two things, ensuring that the listed properties match. If no properties are listed, all are compared. If the special tolerance value "IGNORE" appears in the tolerance dictionary, that property is ignored.

Properties with "=" in the name are considered tolerances, and are split on the "=". This is because of the way the arguments are passed to STU workups.

rmsd(check, reference, tolerance=0.05, asl='all and NOT atom.element H', check_cts='')

 

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.

If your structures contain dummy atoms, use rmsd_in_place.

rmsd_in_place(check, reference, tolerance=0.05, asl='all and NOT atom.element H')

 

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.

compare_num_atoms(check, reference, tolerance=0)

 

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

compare_mae_files(check, reference, *tolerance_list, **tolerances)

 

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 - First filename.
  • reference - Reference filename.
  • tolerance_list - Tolerances by which each should be compared.
  • tolerances - Tolerances by which each should be compared.
Returns: bool
Did all properties match?
Raises:
  • AssertionError - If properties do not match.

_zip_structures(check, reference)

 

Iterate over the structures in two files. If there is a length mismatch, raise an AssertionError.