Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local cache of ZINC dataset, since original URL is not available anymore #58

Merged
merged 2 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
use local cache of ZINC dataset, since original URL is not available …
…anymore
  • Loading branch information
daniil-polykovskiy-insilico committed Oct 23, 2019
commit 0e9a3156905cfd6deb45313ba23aefea6f79475b
3 changes: 3 additions & 0 deletions data/11_p0.smi.gz
Git LFS file not shown
17 changes: 8 additions & 9 deletions scripts/prepare_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def get_parser():
'--seed', type=int, default=0, help='Random state'
)
parser.add_argument(
'--url', type=str,
default='http://zinc.docking.org/db/bysubset/11/11_p0.smi.gz',
help='url to .smi.gz file with smiles'
'--zinc', type=str,
default='../data/11_p0.smi.gz',
help='path to .smi.gz file with ZINC smiles'
)
parser.add_argument(
'--n_jobs', type=int, default=1,
Expand All @@ -41,7 +41,7 @@ def get_parser():
)
parser.add_argument(
'--isomeric', action='store_true', default=False,
help='Save non-isomeric SMILES'
help='Save isomeric SMILES (non-isomeric by default)'
)
return parser

Expand All @@ -56,10 +56,9 @@ def process_molecule(mol_row, isomeric):
return _id, smiles


def download_dataset(url):
logger.info('Downloading from {}'.format(url))
req = requests.get(url)
with gzip.open(BytesIO(req.content)) as smi:
def unzip_dataset(path):
logger.info("Unzipping dataset")
with gzip.open(path) as smi:
lines = smi.readlines()
return lines

Expand Down Expand Up @@ -104,7 +103,7 @@ def split_dataset(dataset, seed):


def main(config):
lines = download_dataset(config.url)
lines = unzip_dataset(config.zinc)
dataset = filter_lines(lines, config.n_jobs, config.isomeric)
dataset = split_dataset(dataset, config.seed)
if not config.keep_ids:
Expand Down