Skip to main content

Fréchet ChemNet Distance on PyTorch

Project description

Fréchet ChemNet Distance on PyTorch

Build Status PyPI version

PyTorch implementation of Fréchet ChemNet Distance ported from the original repository https://github.com/bioinf-jku/FCD. The ported model produces the same outputs as the original Keras implementation and can be used for reproducible research. The PyTorch model of ChemNet weights tenfold less, resulting in faster loading.

Other features:

  • You can precalculate mean and sigma for further usage, useful if you use the statistics from the same dataset multiple times
  • Supports calculation on GPU and selection of GPU device number
  • Multithreaded SMILES parsing

Installation

First, install RDKit: conda install -yq -c rdkit rdkit and then install fcd_torch from pip (pip install fcd_torch), or directly from the source:

git clone https://github.com/insilicomedicine/fcd_torch.git
cd fcd_torch
python setup.py install

Usage

Import the module from fcd_torch import FCD. You can run calculation directly or precalculate statistics to reuse them on the test set (see example below). If you run FCD on GPU, the GPU memory will be allocated only during calculation of FCD.

# Example 1:
    fcd = FCD(device='cuda:0', n_jobs=8)
    smiles_list1 = ['COc1cccc(NC(=O)Cc2coc3ccc(OC)cc23)c1', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
    smiles_list2 = ['Oc1ccccc1-c1cccc2cnccc12', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
    fcd(smiles_list1, smiles_list2)
# Example 2:
    fcd = FCD(device='cuda:0', n_jobs=8)
    smiles_list1 = ['COc1cccc(NC(=O)Cc2coc3ccc(OC)cc23)c1', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
    smiles_list2 = ['Oc1ccccc1-c1cccc2cnccc12', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
    pgen = fcd.precalc(smiles_list2)
    fcd(smiles_list1, pgen=pgen)

For the constructor, you can pass the device as device='cpu' for CPU and device='cuda:n' for GPU, where n is the GPU device number. n_jobs parameter specifies the number of threads for parsing SMILES. You can also vary the batch_size parameter. Call parameters for FCD are fcd(ref=None, gen=None, pref=None, pgen=None), where you should specify either ref (SMILES list), or pref (precalculated statistics), and the same for gen and pgen.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fcd_torch-1.0.7.tar.gz (5.2 MB view details)

Uploaded Source

Built Distribution

fcd_torch-1.0.7-py3-none-any.whl (5.2 MB view details)

Uploaded Python 3

File details

Details for the file fcd_torch-1.0.7.tar.gz.

File metadata

  • Download URL: fcd_torch-1.0.7.tar.gz
  • Upload date:
  • Size: 5.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for fcd_torch-1.0.7.tar.gz
Algorithm Hash digest
SHA256 7cccb09ce79fbf6be84d2578332f8aa04668b0a34ecae3357e1af3cce3cc13d7
MD5 63f111ef3e86dea547d9a337f2578112
BLAKE2b-256 1ff37dbae532d827a62d95ecfd025774f6c29f917c676034731844c70e1f2b9b

See more details on using hashes here.

File details

Details for the file fcd_torch-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: fcd_torch-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for fcd_torch-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 63a24aae88c554a7ba6422cffdef3ad7c1befec73f835b70ead04097a1ebed6f
MD5 507c45e1680938d47c7ea6c754eb489a
BLAKE2b-256 4845476df503cd87d28486af12c37b2e71fc5d0b2730f9bd0539cf19782678b8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page