tests package
Submodules
tests.test_CompareTargetMolecule module
Test the task CompareTargetMolecule
- class tests.test_CompareTargetMolecule.TestCompareTargetMolecule(methodName='runTest')
Bases:
TestCase
- smiles_seq_to_xl_or_csv(ftype, property_seq=None, name_seq=None, feature_arr=None)
Helper method to convert a SMILES sequence or arbitrary features to Excel or CSV files.
- Parameters
ftype (str) – String label to denote the filetype. ‘csv’ or ‘excel’.
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses. Defaults to None.
name_seq (list or np.ndarray, optional) – Optional sequence of molecular names. Defaults to None.
feature_arr (np.ndarray, optional) – Optional array of molecular descriptor values. Defaults to None.
- Raises
ValueError – Invalid file type specified.
- Returns
Path to created file.
- Return type
str
- classmethod tearDownClass()
Delete temporary file used in testing.
- test_get_molecule_least_similar_to()
Test for get_molecule_least_similar_to functionality.
- test_get_molecule_most_similar_to()
tests.test_Descriptor module
Tests for the Descriptor class
- class tests.test_Descriptor.TestDescriptor(methodName='runTest')
Bases:
TestCase
Tests for methods of the Descriptor class.
- Parameters
unittest (unittest) – Python unittest module.
- test_bad_descriptors_padelpy_descriptors()
Test ability to pass through invalid descriptors to padelpy.
- test_ccbmlib_descriptors()
Test ability to passthrough descriptors to ccbmlib.
- test_descriptor_arbitrary_list_init()
Test to verify creation of Descriptor object initialized by arbitrary list.
- test_descriptor_arbitrary_numpy_init()
Test to verify creation of Descriptor object initialized by arbitrary numpy array.
- test_descriptor_empty_init()
Test to verify empty Descriptor object can be created.
- test_descriptor_make_fingerprint()
Test to verify creation of Descriptor object by creating molecular fingerprints from the molecule graph.
- test_exptl_descriptors()
Test ability to use experimental descriptors.
- test_fingerprint_folding()
Create arbitrary fingerprint vector to check fold method
- test_minhash_fingerprint()
Test creation of minhash fingerprint
- test_mordred_descriptors()
Test ability to passthrough descriptors to Mordred.
- test_nonexistent_mordred_descriptors()
Test ability to pass through descriptors to Mordred.
- test_padelpy_descriptors()
Test ability to passthrough descriptors to PadelPy.
- test_topological_fprint_min_path_lesser_than_atoms()
tests.test_LoadingErrorException module
Test the LoadingError Exception
- class tests.test_LoadingErrorException.TestLoadingERrorException(methodName='runTest')
Bases:
TestCase
Tests for LoadingError custom exception.
- test_invalid_pdb()
Invalid PDB files should raise a LoadingError.
- test_invalid_smiles()
Invalid SMILES strings should raise a LoadingError.
- test_missing_pdb()
Missing PDB files should raise a LoadingError.
- test_missing_smiles()
Missing smiles strings should raise a LoadingError.
tests.test_MeasureSearch module
Test the MeasureSearch class.
- class tests.test_MeasureSearch.TestMeasureSearch(methodName='runTest')
Bases:
TestCase
- smiles_seq_to_textfile(property_seq=None)
Helper method to convert a SMILES sequence to a text file.
- Parameters
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses.. Defaults to None.
- Returns
Path to created file.
- Return type
str
- test_error_optim_algo()
Measure search should error with invalid optimization algorithm.
- test_fixed_SimilarityMeasure()
MeasureSearch should search for ideal fingerprint when metric is already chosen.
- test_fixed_fprint()
MeasureSearch should search for ideal metric when fingerprint is already chosen.
- test_logfile_generation()
When configured to do so, MeasureSearch should create a log file.
- test_max_optim_algo()
Measure search using the “maximum” optimization algorithm.
- test_min_optim_algo()
Measure search using the “minimum” optimization algorithm.
- test_msearch_completion()
MeasureSearch should complete running, though output cannot be directly tested.
- test_msearch_init()
Basic initialization test for the MeasureSearch class.
- test_msearch_init_error()
Erroneous confirgurations should raise a config error.
- test_only_metric_fixed_fprint_search()
Check that this configuration option is able to execute.
- test_only_metric_fixed_measure_search()
Check that this configuration option is able to execute.
- test_only_metric_search()
Check that this configuration option is able to execute.
- test_smiles = ['CCCCCCC', 'CCCC', 'CCC', 'CO', 'CN', 'C1=CC=CC=C1', 'CC1=CC=CC=C1', 'C(=O)(N)N']
- test_verbose_output()
Ensure execution does not raise an exception with verbose and show_top.
tests.test_Molecule module
Test the methods of the Molecule class
- class tests.test_Molecule.TestMolecule(methodName='runTest')
Bases:
TestCase
Tests for methods of Molecule class.
- test_get_name()
Retrieve the name from the molecule.
- test_get_property_value()
Retrieve the property value from the molecule
- test_is_same()
Two identical molecules should be identifed as such.
- test_match_fprint_error()
Trying to match fingerprint from molecule w/o graph should throw an error.
- test_mol_mol_similarity_w_morgan_tanimoto()
Test that the tanimoto similarity of the morgan fingerprints of two Molecules are in (0, 1).
- test_mol_smiles_loadingerror()
Error in mol_smiles should raise LoadingError
- test_mol_src_pdb_loadingerror()
Error in mol_src should raise LoadingError
- test_mol_src_txt_loadingerror()
Error in mol_src should raise LoadingError
- test_molecule_created_w_attributes()
Test to create Molecule object with descriptor value (list) and a response scalar.
- test_molecule_created_with_no_attributes()
Test for creation of empty Molecule object with no attributes.
- test_molecule_draw()
Test to draw molecule stored in Molecule object.
- test_molecule_graph_similar_to_itself_morgan_dice()
Test that the morgan fingerprint of a Molecule object is similar to itself using dice similarity.
- test_molecule_graph_similar_to_itself_morgan_l0()
Test that the morgan fingerprint of a Molecule object is similar to itself using L0 norm similarity.
- test_molecule_graph_similar_to_itself_morgan_tanimoto()
Test that the morgan fingerprint of a Molecule object is similar to itself using Tanimoto similarity.
- test_set_molecule_from_file()
Test to create Molecule object by reading the contents of a file.
Case #1: text file Case #2: PDB file
- test_set_molecule_from_smiles()
Test to create Molecule object by reading SMILES string.
tests.test_MoleculeSet module
Test the MoleculeSet class.
- class tests.test_MoleculeSet.TestMoleculeSet(methodName='runTest')
Bases:
TestCase
- get_feature_set(dimensionality=10)
- smarts_seq_to_smiles_file(property_seq=None)
Helper method to convert a SMARTS sequence to a .SMILES file.
- Parameters
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses. Defaults to None.
- Returns
Path to created file.
- Return type
str
- smiles_seq_to_pdb_dir(property_seq=None)
Helper method to convert a SMILES sequence to a pdb files stored in a directory.
- Parameters
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses. Defaults to None.
- Returns
Path to created directory.
- Return type
str
- smiles_seq_to_smi_file(property_seq=None)
Helper method to convert a SMILES sequence to a .smi file.
- Parameters
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses. Defaults to None.
- Returns
Path to created file.
- Return type
str
- smiles_seq_to_smiles_file(property_seq=None)
Helper method to convert a SMILES sequence to a .SMILES file.
- Parameters
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses. Defaults to None.
- Returns
Path to created file.
- Return type
str
- smiles_seq_to_textfile(property_seq=None)
Helper method to convert a SMILES sequence to a text file.
- Parameters
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses.. Defaults to None.
- Returns
Path to created file.
- Return type
str
- smiles_seq_to_xl_or_csv(ftype, property_seq=None, name_seq=None, feature_arr=None)
Helper method to convert a SMILES sequence or arbitrary features to Excel or CSV files.
- Parameters
ftype (str) – String label to denote the filetype. ‘csv’ or ‘excel’.
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses. Defaults to None.
name_seq (list or np.ndarray, optional) – Optional sequence of molecular names. Defaults to None.
feature_arr (np.ndarray, optional) – Optional array of molecular descriptor values. Defaults to None.
- Raises
ValueError – Invalid file type specified.
- Returns
Path to created file.
- Return type
str
- test_clustering_fingerprints()
Test the clustering of molecules featurized by their fingerprints.
- test_get_most_dissimilar_pairs()
Test that all combinations of fingerprint_type and similarity measure works with the MoleculeSet.get_most_dissimilar_pairs() method.
- test_get_most_similar_pairs()
Test that all combinations of fingerprint_type and similarity measure works with the MoleculeSet.get_most_similar_pairs() method.
- test_invalid_transform_error()
Using an invalid or unimplemented dimensionality reduction method should throw an error.
- test_isomap_transform()
Test the unsupervised transformation of molecules in MoleculSet using Isomap.
- test_mds_transform()
Test the unsupervised transformation of molecules in MoleculSet using MDS.
- test_molecule_set_getters()
Retrieve names and properties of mols using MoleculeSet.
- test_molecule_set_sim_getters()
Get the properties for most and least similar molecule pairs.
- test_pca_transform()
Test the unsupervised transformation of molecules in MoleculSet using Principal Component Analysis.
- test_set_molecule_database_fingerprint_from_csv()
Verify that a TypeError is raised if no similarity_measure is specified when instantiating a MoleculeSet object.
- test_set_molecule_database_from_csv()
Test to create MoleculeSet object by reading molecule database and molecular responses from a CSV file.
- test_set_molecule_database_from_excel()
Test to create MoleculeSet object by reading molecule database from an Excel file.
- test_set_molecule_database_from_excel_without_smiles_name()
- test_set_molecule_database_from_pdb_dir()
Test to create MoleculeSet object by reading molecule database from a directory of pdb files.
- test_set_molecule_database_from_smarts_file()
Test to create MoleculeSet object by reading molecule database from a SMILES file containing SMARTS strings.
- test_set_molecule_database_from_smi_file()
Test to create MoleculeSet object by reading molecule database from a smi file.
- test_set_molecule_database_from_smiles_file()
Test to create MoleculeSet object by reading molecule database from a SMILES file.
- test_set_molecule_database_from_textfile()
Test to create MoleculeSet object by reading molecule database from a textfile.
- test_set_molecule_database_w_descriptor_property_from_csv()
Test to create MoleculeSet object by reading molecule database containing arbitrary molecular descriptors and molecular responses from a CSV file.
- test_set_molecule_database_w_descriptor_property_from_excel()
Test to create MoleculeSet object by reading molecule database containing arbitrary molecular descriptor values from an Excel file.
- test_set_molecule_database_w_fingerprint_similarity_from_csv()
Test all combinations of fingerprints and similarity measures with the MoleculeSet class.
- test_set_molecule_database_w_property_from_csv()
Test to create MoleculeSet object by reading molecule database and molecular responses from a CSV file.
- test_set_molecule_database_w_property_from_excel()
Test to create MoleculeSet object by reading molecule database and molecular responses from an Excel file.
- test_set_molecule_database_w_property_from_textfile()
Test to create MoleculeSet object by reading molecule database and molecular responses from a textfile.
- test_set_molecule_database_w_similarity_from_csv()
Verify that a NotInitializedError is raised if no fingerprint_type is specified when instantiating a MoleculeSet object.
- test_smarts = ['[CH3:1][S:2][c:3]1[cH:4][cH:5][c:6]([B:7]([OH:8])[OH:9])[cH:10][cH:11]1', '[NH:1]1[CH2:2][CH2:3][O:4][CH2:5][CH2:6]1.[O:7]=[S:8]=[O:9]']
- test_smiles = ['CCCCCCC', 'CCCC', 'CCC', 'CO', 'CN', 'C1=CC=CC=C1', 'CC1=CC=CC=C1', 'C(=O)(N)N']
- test_spectral_embedding_transform()
Test the unsupervised transformation of molecules in MoleculSet using Isomap.
- test_subsample_molecule_database_from_csv()
Test to randomly subsample a molecule database loaded from an CSV file.
- test_subsample_molecule_database_from_excel()
Test to randomly subsample a molecule database loaded from an Excel file.
- test_subsample_molecule_database_from_pdb_dir()
Test to randomly subsample a molecule database loaded from a directory of pdb files.
- test_subsample_molecule_database_from_textfile()
Test to randomly subsample a molecule database loaded from a textfile.
- test_tsne_transform()
Test the unsupervised transformation of molecules in MoleculSet using TSNE.
tests.test_SimilarityMeasure module
Test the SimilarityMEasure class
- class tests.test_SimilarityMeasure.TestSimilarityMeasure(methodName='runTest')
Bases:
TestCase
- smiles_seq_to_xl_or_csv(ftype, property_seq=None, name_seq=None, feature_arr=None)
Helper method to convert a SMILES sequence or arbitrary features to Excel or CSV files.
- Parameters
ftype (str) – String label to denote the filetype. ‘csv’ or ‘excel’.
property_seq (list or np.ndarray, optional) – Optional sequence of molecular responses. Defaults to None.
name_seq (list or np.ndarray, optional) – Optional sequence of molecular names. Defaults to None.
feature_arr (np.ndarray, optional) – Optional array of molecular descriptor values. Defaults to None.
- Raises
ValueError – Invalid file type specified.
- Returns
Path to created file.
- Return type
str
- test_all_supported_measures()
- test_get_abcd()
- test_similarity_measure_limits()
tests.test_SimilarityMeasureValueErrors module
Test the ValueError exceptions in SimilarityMeasure
- class tests.test_SimilarityMeasureValueErrors.TestSimilarityMeasureValueError(methodName='runTest')
Bases:
TestCase
Tests for Value Error exception in SimilarityMeasure
- test_binary_only_metrics()
Metrics which only allow bit vectors should raise a value error on other inputs.
- test_compatible_metrics()
Test get_compatible_metrics basic functionailty.
- test_empty_fprints()
Empty fingerprints cannot be compared.
- test_invalid_metric()
Initializing with a non-existent metric should throw an error.
- test_vectornorm_length_errors()
Vector norm-based similarities should only work with descriptors of the same length, otherwise it should raise a value error.
tests.test_TaskManager module
Test the TaskManager class.
- class tests.test_TaskManager.TestTaskManager(methodName='runTest')
Bases:
TestCase
- classmethod setUpClass()
Hook method for setting up class fixture before running tests in the class.
- test_no_tasks_task_manager()
Instant stop test for TaskManager class.
- test_task_manager()
Complete run test for TaskManager class.
tests.test_ToolTip module
Test the ToolTip package (and all UI packages)
tests.test_multithreading module
Test multithreading to ensure consistent behavior with serial implementation.
- class tests.test_multithreading.TestMultithreading(methodName='runTest')
Bases:
TestCase
Unit tests to ensure consistency when running AIMSim as a single process or when using multiprocessing.
- classmethod setUpClass()
Create a SMILES database to use for comparisons and find the similarity matrices and execution times.
- classmethod tearDownClass()
Delete temporary files used in testing.
- test_multithreading_autoconfig()
Ensure that MoleculeSet can automatically configure multiprocessing..
- test_multithreading_consistency_10_threads()
Ensure that the similarity matrix produced with 10 threads is identical to that produced using a single thread and the serial implementation.
- test_multithreading_consistency_2_threads()
Ensure that the similarity matrix produced with 2 threads is identical to that produced using a single thread and the serial implementation.
- test_multithreading_consistency_3_threads()
Ensure that the similarity matrix produced with 3 threads is identical to that produced using a single thread and the serial implementation.
- test_multithreading_consistency_4_threads()
Ensure that the similarity matrix produced with 4 threads is identical to that produced using a single thread and the serial implementation.
- test_multithreading_consistency_5_threads()
Ensure that the similarity matrix produced with 5 threads is identical to that produced using a single thread and the serial implementation.
- test_multithreading_consistency_6_threads()
Ensure that the similarity matrix produced with 6 threads is identical to that produced using a single thread and the serial implementation.
- test_multithreading_consistency_7_threads()
Ensure that the similarity matrix produced with 7 threads is identical to that produced using a single thread and the serial implementation.
- test_speedup_efficiency_cosine()
Evaluate the speedup and efficieny of the multiprocessing approach with a more complex metric.
- test_speedup_efficiency_tanimoto()
Evaluate the speedup and efficieny of the multiprocessing approach.