#648 Remove utils.structure module

Open Matt Thompson mattwthompson Pseudo commit used to compare (42b2ce1...f591ba2)
Missing base report.

Unable to compare commits because the base of the pull request did not upload a coverage report.

Learn more here.

Showing 1 of 5 files from the diff.

@@ -25,7 +25,8 @@
Loading
25 25
    'convert_all_quantities_to_string',
26 26
    'convert_all_strings_to_quantity',
27 27
    'convert_0_1_smirnoff_to_0_2',
28 -
    'convert_0_2_smirnoff_to_0_3'
28 +
    'convert_0_2_smirnoff_to_0_3',
29 +
    'get_molecule_parameterIDs',
29 30
]
30 31
31 32
#=============================================================================================
@@ -38,7 +39,6 @@
Loading
38 39
import logging
39 40
import contextlib
40 41
41 -
42 42
#=============================================================================================
43 43
# CONFIGURE LOGGER
44 44
#=============================================================================================
@@ -881,3 +881,74 @@
Loading
881 881
        pass
882 882
883 883
    return smirnoff_data
884 +
885 +
def get_molecule_parameterIDs(molecules, forcefield):
886 +
    """Process a list of molecules with a specified SMIRNOFF ffxml file and determine which parameters are used by
887 +
    which molecules, returning collated results.
888 +
889 +
    Parameters
890 +
    ----------
891 +
    molecules : list of openforcefield.topology.Molecule
892 +
        List of molecules (with explicit hydrogens) to parse
893 +
    forcefield : openforcefield.typing.engines.smirnoff.ForceField
894 +
        The ForceField to apply
895 +
896 +
    Returns
897 +
    -------
898 +
    parameters_by_molecule : dict
899 +
        Parameter IDs used in each molecule, keyed by isomeric SMILES
900 +
        generated from provided OEMols. Each entry in the dict is a list
901 +
        which does not necessarily have unique entries; i.e. parameter IDs
902 +
        which are used more than once will occur multiple times.
903 +
904 +
    parameters_by_ID : dict
905 +
        Molecules in which each parameter ID occur, keyed by parameter ID.
906 +
        Each entry in the dict is a set of isomeric SMILES for molecules
907 +
        in which that parameter occurs. No frequency information is stored.
908 +
909 +
    """
910 +
911 +
    from openforcefield.topology import Topology
912 +
    # Create storage
913 +
    parameters_by_molecule = dict()
914 +
    parameters_by_ID = dict()
915 +
916 +
    # Generate isomeric SMILES for each molecule, ensuring all molecules are unique
917 +
    isosmiles = [ molecule.to_smiles() for molecule in molecules ]
918 +
    already_seen = set()
919 +
    duplicates = set(smiles for smiles in isosmiles if smiles in already_seen or already_seen.add(smiles))
920 +
    if len(duplicates) > 0:
921 +
        raise ValueError("Error: get_molecule_parameterIDs has been provided a list of oemols which contains some duplicates: {}".format(duplicates))
922 +
923 +
    # Assemble molecules into a Topology
924 +
    topology = Topology()
925 +
    for molecule in molecules:
926 +
        topology.add_molecule(molecule)
927 +
928 +
    # Label molecules
929 +
    labels = forcefield.label_molecules(topology)
930 +
931 +
    # Organize labels into output dictionary by looping over all molecules/smiles
932 +
    for idx in range(len(isosmiles)):
933 +
        # Pull smiles, initialize storage
934 +
        smi = isosmiles[idx]
935 +
        parameters_by_molecule[smi] = []
936 +
937 +
        # Organize data for this molecule
938 +
        data = labels[idx]
939 +
        for force_type in data.keys():
940 +
            for atom_indices, parameter_type in data[force_type].items():
941 +
942 +
                pid = parameter_type.id
943 +
                # Store pid to molecule
944 +
                parameters_by_molecule[smi].append(pid)
945 +
946 +
                # Store which molecule this pid occurred in
947 +
                if pid not in parameters_by_ID:
948 +
                    parameters_by_ID[pid] = set()
949 +
                    parameters_by_ID[pid].add(smi)
950 +
                else:
951 +
                    parameters_by_ID[pid].add(smi)
952 +
953 +
    return parameters_by_molecule, parameters_by_ID
954 +

Learn more Showing 18 files with coverage changes found.

New file openforcefield/topology/__init__.py
New
Loading file...
New file openforcefield/typing/chemistry/environment.py
New
Loading file...
New file openforcefield/utils/toolkits.py
New
Loading file...
New file openforcefield/_version.py
New
Loading file...
New file openforcefield/utils/__init__.py
New
Loading file...
New file openforcefield/typing/chemistry/__init__.py
New
Loading file...
New file openforcefield/topology/molecule.py
New
Loading file...
New file openforcefield/typing/engines/smirnoff/forcefield.py
New
Loading file...
New file openforcefield/typing/engines/smirnoff/__init__.py
New
Loading file...
New file openforcefield/__init__.py
New
Loading file...
New file openforcefield/topology/topology.py
New
Loading file...
New file openforcefield/utils/callback.py
New
Loading file...
New file openforcefield/typing/engines/smirnoff/io.py
New
Loading file...
New file openforcefield/utils/serialization.py
New
Loading file...
New file openforcefield/typing/engines/smirnoff/plugins.py
New
Loading file...
New file openforcefield/typing/engines/smirnoff/parameters.py
New
Loading file...
New file openforcefield/utils/utils.py
New
Loading file...
New file openforcefield/utils/collections.py
New
Loading file...
Files Coverage
openforcefield 86.89%
Project Totals (18 files) 86.89%
Loading