Source code for deepchem.molnet.load_function.clearance_datasets

"""
clearance dataset loader.
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals

import os
import deepchem


[docs]def load_clearance(featurizer='ECFP', split='random', reload=True): """Load clearance datasets.""" # Featurize clearance dataset print("About to featurize clearance dataset.") print("About to load clearance dataset.") data_dir = deepchem.utils.get_data_dir() if reload: save_dir = os.path.join(data_dir, "clearance/" + featurizer + "/" + split) dataset_file = os.path.join(data_dir, "clearance.csv") if not os.path.exists(dataset_file): deepchem.utils.download_url( 'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/clearance.csv' ) clearance_tasks = ['exp'] if reload: loaded, all_dataset, transformers = deepchem.utils.save.load_dataset_from_disk( save_dir) if loaded: return clearance_tasks, all_dataset, transformers if featurizer == 'ECFP': featurizer = deepchem.feat.CircularFingerprint(size=1024) elif featurizer == 'GraphConv': featurizer = deepchem.feat.ConvMolFeaturizer() elif featurizer == 'Weave': featurizer = deepchem.feat.WeaveFeaturizer() elif featurizer == 'Raw': featurizer = deepchem.feat.RawFeaturizer() loader = deepchem.data.CSVLoader( tasks=clearance_tasks, smiles_field="smiles", featurizer=featurizer) dataset = loader.featurize(dataset_file, shard_size=8192) # Initialize transformers transformers = [ deepchem.trans.NormalizationTransformer( transform_y=True, dataset=dataset) ] print("About to transform data") for transformer in transformers: dataset = transformer.transform(dataset) splitters = { 'index': deepchem.splits.IndexSplitter(), 'random': deepchem.splits.RandomSplitter(), 'scaffold': deepchem.splits.ScaffoldSplitter() } splitter = splitters[split] train, valid, test = splitter.train_valid_test_split(dataset) if reload: deepchem.utils.save.save_dataset_to_disk(save_dir, train, valid, test, transformers) return clearance_tasks, (train, valid, test), transformers