예제 #1
0
 def test_calculate_snfold_single_hard(self):
     """test the single claculation based on hard coded parameters"""
     input_smiles = (
         "Cc1ccc(cc1Nc2nccc(n2)c3cccnc3)NC(=O)c4ccc(cc4)CN5CCN(CC5)C"  # imatinib
     )
     sa = ScaffoldFoldAssign(nfolds=5, secret="melloddy")
     result_actual = sa.calculate_single(input_smiles)
     result_expected = (
         "O=C(Nc1cccc(Nc2nccc(-c3cccnc3)n2)c1)c1ccc(CN2CCNCC2)cc1",
         "c1ccc(Nc2nccc(-c3cccnc3)n2)cc1",
         2,
         True,
         None,
     )
     self.assertEqual(result_actual, result_expected)
예제 #2
0
    def test_calculate_sn_fold_multiple(self):
        infile = os.path.join(curDir, "input", "test_sn_fold_input.csv")
        outfile = os.path.join(curDir, "output", "tmp", "sn_fold_output.csv")
        output_columns = [
            "murcko_smiles",
            "sn_smiles",
            "fold_id",
            "success",
            "error_message",
        ]
        output_types = ["object", "object", "int", "bool", "object"]

        sa = ScaffoldFoldAssign(
            nfolds=self.config["scaffold_folding"]["nfolds"],
            secret=self.keys["key"])

        dt = DfTransformer(
            sa,
            input_columns={"canonical_smiles": "smiles"},
            output_columns=output_columns,
            output_types=output_types,
        )
        dt.process_file(infile, outfile)
        result = filecmp.cmp(
            os.path.join(curDir, "output", "test_sn_fold_output.csv"),
            os.path.join(outfile),
            shallow=False,
        )
        self.assertEqual(result, True)
예제 #3
0
 def test_calculate_snfold_single_config(self):
     """test the single claculation based on config file conent"""
     input_smiles = (
         "Cc1ccc(cc1Nc2nccc(n2)c3cccnc3)NC(=O)c4ccc(cc4)CN5CCN(CC5)C"  # imatinib
     )
     sa = ScaffoldFoldAssign(
         nfolds=self.config["scaffold_folding"]["nfolds"],
         secret=self.keys["key"])
     result_actual = sa.calculate_single(input_smiles)
     result_expected = (
         "O=C(Nc1cccc(Nc2nccc(-c3cccnc3)n2)c1)c1ccc(CN2CCNCC2)cc1",
         "c1ccc(Nc2nccc(-c3cccnc3)n2)cc1",
         2,
         True,
         None,
     )
     self.assertEqual(result_actual, result_expected)
예제 #4
0
def prepare(args):
    overwriting = True

    load_config(args)
    load_key(args)
    output_dir = make_dir(args, "reference_set", None, overwriting)
    key = SecretDict.get_secrets()["key"]
    method_params_standardizer = ConfigDict.get_parameters()["standardization"]
    st = Standardizer.from_param_dict(
        method_param_dict=method_params_standardizer, verbosity=0)
    outcols_st = ["canonical_smiles", "success", "error_message"]
    out_types_st = ["object", "bool", "object"]
    dt_standarizer = DfTransformer(
        st,
        input_columns={"smiles": "smiles"},
        output_columns=outcols_st,
        output_types=out_types_st,
        success_column="success",
        nproc=1,
        verbosity=0,
    )

    method_params_folding = ConfigDict.get_parameters()["scaffold_folding"]
    sa = ScaffoldFoldAssign.from_param_dict(
        secret=key, method_param_dict=method_params_folding, verbosity=0)
    outcols_sa = [
        "murcko_smiles", "sn_smiles", "fold_id", "success", "error_message"
    ]
    out_types_sa = ["object", "object", "int", "bool", "object"]
    dt_fold = DfTransformer(
        sa,
        input_columns={"canonical_smiles": "smiles"},
        output_columns=outcols_sa,
        output_types=out_types_sa,
        success_column="success",
        nproc=1,
        verbosity=0,
    )

    method_params_descriptor = ConfigDict.get_parameters()["fingerprint"]
    dc = DescriptorCalculator.from_param_dict(
        secret=key, method_param_dict=method_params_descriptor, verbosity=0)
    outcols_dc = ["fp_feat", "fp_val", "success", "error_message"]
    out_types_dc = ["object", "object", "bool", "object"]
    dt_descriptor = DfTransformer(
        dc,
        input_columns={"canonical_smiles": "smiles"},
        output_columns=outcols_dc,
        output_types=out_types_dc,
        success_column="success",
        nproc=1,
        verbosity=0,
    )

    return output_dir, dt_standarizer, dt_fold, dt_descriptor
예제 #5
0
def prepare(args):
    """
    Prepare output directories and instantiate df tansformer object for scaffold based folding

    Args:
        args (dict): argparser arguments

    Returns:
        Tuple(Path, DfTransformer): Path to output directory and instatitaed DfTranfomer for sccaffold folding


    """
    output_dir = make_dir(args, "results_tmp", "folding", args["non_interactive"])
    mapping_table_dir = make_dir(args, "mapping_table", None, args["non_interactive"])

    create_log_files(output_dir)
    create_log_files(mapping_table_dir)

    load_config(args)
    load_key(args)
    key = SecretDict.get_secrets()["key"]
    method_params = ConfigDict.get_parameters()["scaffold_folding"]
    sa = ScaffoldFoldAssign.from_param_dict(
        secret=key, method_param_dict=method_params, verbosity=0
    )
    outcols = ["murcko_smiles", "sn_smiles", "fold_id", "success", "error_message"]
    out_types = ["object", "object", "int", "bool", "object"]
    dt = DfTransformer(
        sa,
        input_columns={"canonical_smiles": "smiles"},
        output_columns=outcols,
        output_types=out_types,
        success_column="success",
        nproc=args["number_cpu"],
        verbosity=0,
    )
    return output_dir, mapping_table_dir, dt