Source code for deepchem.molnet.load_function.hopv_datasets

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

import os
import deepchem


[docs]def load_hopv(featurizer='ECFP', split='index', reload=True): """Load HOPV datasets. Does not do train/test split""" # Featurize HOPV dataset print("About to featurize HOPV dataset.") data_dir = deepchem.utils.get_data_dir() if reload: save_dir = os.path.join(data_dir, "hopv/" + featurizer + "/" + split) dataset_file = os.path.join(data_dir, "hopv.csv") if not os.path.exists(dataset_file): deepchem.utils.download_url( 'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/hopv.tar.gz' ) deepchem.utils.untargz_file(os.path.join(data_dir, 'hopv.tar.gz'), data_dir) hopv_tasks = [ 'HOMO', 'LUMO', 'electrochemical_gap', 'optical_gap', 'PCE', 'V_OC', 'J_SC', 'fill_factor' ] if reload: loaded, all_dataset, transformers = deepchem.utils.save.load_dataset_from_disk( save_dir) if loaded: return hopv_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=hopv_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(), 'butina': deepchem.splits.ButinaSplitter() } 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 hopv_tasks, (train, valid, test), transformers