예제 #1
0
def execute_gypsum_dl(contnrs, params):
    """A function for doing all of the manipulations to each molecule.

    :param contnrs: A list of all molecules.
    :type contnrs: list
    :param params: A dictionary containing all of the parameters.
    :type params: dict
    """
    # Start creating the models.

    # Prepare the smiles. Desalt, consider alternate ionization, tautometeric,
    # stereoisomeric forms, etc.
    prepare_smiles(contnrs, params)

    # Convert the processed SMILES strings to 3D.
    prepare_3d(contnrs, params)

    # Add in name and unique id to each molecule.
    add_mol_id_props(contnrs)

    # Output the current SMILES.
    Utils.print_current_smiles(contnrs)

    # Write any mols that fail entirely to a file.
    deal_with_failed_molecules(contnrs, params)

    # Process the output.
    proccess_output(contnrs, params)
예제 #2
0
def prepare_smiles(contnrs, params):
    """Runs the appropriate steps for processing the SMILES strings.

    :param contnrs: A list of containers (MolContainer.MolContainer).
    :type contnrs: list
    :param params: The user parameters.
    :type params: dict
    """

    # Unpack some of the parameter values.
    min_ph = params["min_ph"]
    max_ph = params["max_ph"]
    std_dev = params["pka_precision"]
    max_variants_per_compound = params["max_variants_per_compound"]
    thoroughness = params["thoroughness"]
    num_procs = params["num_processors"]
    job_manager = params["job_manager"]
    let_tautomers_change_chirality = params["let_tautomers_change_chirality"]
    parallelizer_obj = params["Parallelizer"]

    debug = True

    # Desalt the molecules. Note that the program always desalts (can't turn it
    # off).
    # Utils.log("Begin Desaltings")
    desalt_orig_smi(contnrs, num_procs, job_manager, parallelizer_obj)
    # Utils.log("Done with Desalting")

    # Filter the containers to remove ones that have bad substrings (metal,
    # etc.) in the desalted smiles, assuming durrant lab filter turned on. Note
    # that some compounds aren't filtered until later.
    if params["use_durrant_lab_filters"] == True:
        contnrs = [
            c for c in contnrs if not durrant_lab_contains_bad_substr(c.orig_smi_deslt)
        ]

    if debug:
        Utils.print_current_smiles(contnrs)

    # Add hydrogens for user-specified pH, if requested.
    if not params["skip_adding_hydrogen"]:
        # Utils.log("Ionizing Molecules")
        add_hydrogens(
            contnrs,
            min_ph,
            max_ph,
            std_dev,
            max_variants_per_compound,
            thoroughness,
            num_procs,
            job_manager,
            parallelizer_obj,
        )
        # Utils.log("Done with Ionization")
    else:
        Utils.log("Skipping ionization")
        wrap_molecules(contnrs)

    if debug:
        Utils.print_current_smiles(contnrs)

    # Make alternate tautomeric forms, if requested.
    if not params["skip_making_tautomers"]:
        # Utils.log("Tautomerizing Molecules")
        make_tauts(
            contnrs,
            max_variants_per_compound,
            thoroughness,
            num_procs,
            job_manager,
            let_tautomers_change_chirality,
            parallelizer_obj,
        )
        # Utils.log("Done with Tautomerization")
    else:
        Utils.log("Skipping tautomerization")

    if debug:
        Utils.print_current_smiles(contnrs)

    # Apply Durrant-lab filters if requested
    if params["use_durrant_lab_filters"]:
        # Utils.log("Applying Durrant-Lab Filters")
        durrant_lab_filters(contnrs, num_procs, job_manager, parallelizer_obj)
        # Utils.log("Done Applying Durrant-Lab Filters")
    else:
        Utils.log("Not applying Durrant-lab filters")

    if debug:
        Utils.print_current_smiles(contnrs)

    # Make alternate chiral forms, if requested.
    if not params["skip_enumerate_chiral_mol"]:
        # Utils.log("Enumerating Chirality")
        enumerate_chiral_molecules(
            contnrs,
            max_variants_per_compound,
            thoroughness,
            num_procs,
            job_manager,
            parallelizer_obj,
        )
        # Utils.log("Done with Chirality Enumeration")
    else:
        Utils.log("Skipping chirality enumeration")

    if debug:
        Utils.print_current_smiles(contnrs)

    # Make alternate double-bond isomers, if requested.
    if not params["skip_enumerate_double_bonds"]:
        # Utils.log("Enumerating Double Bonds")
        enumerate_double_bonds(
            contnrs,
            max_variants_per_compound,
            thoroughness,
            num_procs,
            job_manager,
            parallelizer_obj,
        )
        # Utils.log("Done with Double Bond Enumeration")
    else:
        Utils.log("Skipping double bond enumeration")

    if debug:
        Utils.print_current_smiles(contnrs)