Skip to main content

Library for modeling molecules and reactions in torch way

Project description

Chytorch [kʌɪtɔːrtʃ]

Library for modeling molecules and reactions in torch way.

Installation

Use pip install chytorch to install release version.

Or pip install . in source code directory to install DEV version.

Pretrained models

Chytorch main package doesn't include models zoo. Each model has its own named package and can be installed separately. Installed models can be imported as from chytorch.zoo.<model_name> import Model.

Usage

chytorch.nn.MoleculeEncoder - core graphormer layer for molecules encoding. API is combination of torch.nn.TransformerEncoderLayer with torch.nn.TransformerEncoder.

Batch preparation:

chytorch.utils.data.MoleculeDataset - Map-like on-the-fly dataset generators for molecules. Supported chython.MoleculeContainer objects, and PaCh structures.

chytorch.utils.data.collate_molecules - collate function for torch.utils.data.DataLoader.

Note: torch DataLoader automatically do proper collation since 1.13 release.

Example:

from chytorch.utils.data import MoleculeDataset, SMILESDataset
from torch.utils.data import DataLoader

data = ['CCO', 'CC=O']
ds = MoleculeDataset(SMILESDataset(data, cache={}))
dl = DataLoader(ds, batch_size=10)

Forward call:

Molecules coded as tensors of:

  • atoms numbers shifted by 2 (e.g. hydrogen = 3). 0 - reserved for padding, 1 - reserved for CLS token, 2 - extra reservation.

  • neighbors count, including implicit hydrogens shifted by 2 (e.g. CO = CH3OH = [6, 4]). 0 - reserved for padding, 1 - extra reservation, 2 - no-neighbors, 3 - one neighbor.

  • topological distances' matrix shifted by 2 with upper limit. 0 - reserved for padding, 1 - reserved for not-connected graph components coding, 2 - self-loop, 3 - connected atoms.

    from chytorch.nn import MoleculeEncoder

    encoder = MoleculeEncoder() for b in dl: encoder(b)

Combine molecules and labels:

chytorch.utils.data.chained_collate - helper for combining different data parts. Useful for tricky input.

from torch import stack
from torch.utils.data import DataLoader, TensorDataset
from chytorch.utils.data import chained_collate, collate_molecules, MoleculeDataset

dl = DataLoader(TensorDataset(MoleculeDataset(molecules_list), properties_tensor),
    collate_fn=chained_collate(collate_molecules, stack))

Voting NN with single hidden layer:

chytorch.nn.VotingClassifier, chytorch.nn.BinaryVotingClassifier and chytorch.nn.VotingRegressor - speed optimized multiple heads for ensemble predictions.

Helper Modules:

chytorch.nn.Slicer - do tensor slicing. Useful for transformer's CLS token extraction in torch.nn.Sequence.

Data Wrappers:

In chytorch.utils.data module stored different data wrappers for simplifying ML workflows. All wrappers have torch.utils.data.Dataset interface.

  • SizedList - list wrapper with size() method. Useful with torch.utils.data.TensorDataset.
  • SMILESDataset - on-the-fly smiles to chython.MoleculeContainer or chython.ReactionContainer parser.
  • LMDBMapper - LMDB KV storage to dataset mapper.
  • TensorUnpack, StructUnpack, PickleUnpack - bytes to tensor/object unpackers

Publications

1 Bidirectional Graphormer for Reactivity Understanding: Neural Network Trained to Reaction Atom-to-Atom Mapping Task

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chytorch_synplan-1.68-cp312-cp312-win_amd64.whl (134.4 kB view details)

Uploaded CPython 3.12Windows x86-64

chytorch_synplan-1.68-cp312-cp312-manylinux_2_39_x86_64.whl (557.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

chytorch_synplan-1.68-cp312-cp312-macosx_14_0_arm64.whl (214.9 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

chytorch_synplan-1.68-cp311-cp311-win_amd64.whl (133.9 kB view details)

Uploaded CPython 3.11Windows x86-64

chytorch_synplan-1.68-cp311-cp311-manylinux_2_39_x86_64.whl (558.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

chytorch_synplan-1.68-cp311-cp311-macosx_14_0_arm64.whl (213.8 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

chytorch_synplan-1.68-cp310-cp310-win_amd64.whl (134.1 kB view details)

Uploaded CPython 3.10Windows x86-64

chytorch_synplan-1.68-cp310-cp310-manylinux_2_39_x86_64.whl (532.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

chytorch_synplan-1.68-cp310-cp310-macosx_14_0_arm64.whl (213.4 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file chytorch_synplan-1.68-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a2863ff25953261d7cbaeff82910b4a18efde54b9c51f53b2f7eaedd89129404
MD5 7cc4c07246417879307c110057c564cd
BLAKE2b-256 6cef7a9b3d638bb4c1a22541f7893a57f7c869e1edfef545fa1af1b48cb4c09b

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 3921e25eecf358c9de3680b340f24174cca3bb51d2cbfbc325e8f964f5f520d4
MD5 696082325c2b33ac51bccc6a89f5d028
BLAKE2b-256 b2edd6969ad4211134661dc840c19e95bb6772775344c9d7cac374888b1e879c

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6333c60cd6bb56e6352f7c71eeb4278914fc0c7dc02da139338a3400d1caec3f
MD5 aff5c34ac4e55bbba663bd59382049eb
BLAKE2b-256 2248a13b6e2ef881409c46fdb4947035dff68d760b5c61418bd53656f7979ecc

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0808909b8cbcff283f69ceb55895aa427006018c4ea103c90c0dfa57021f2c86
MD5 75f426f9e6e6a09887c5e080cebcb9a4
BLAKE2b-256 7eaa8a03091de8fe4b39f7f2904afe223f9fb19a2dbfac59f063418e48b432de

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 98ec63340d759784ac181f1099a71af752e8425590aae5074e0fa30ee2e2a44b
MD5 555aec262082ea815db7fcfec4425c5e
BLAKE2b-256 6d29e639773f3bba4e3ec022485bb8920d87438cd56d46972405b773352f8870

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 bcd6565ff2b338e027e17e0ecd44cd20d02aa1d300600a03ffb73a5ead3f046a
MD5 e007801a540202baecf02a6b0dd342a9
BLAKE2b-256 1278500528ecec53b46a8c9feff84399e6abde1f9e2a29edbccc6ac1067734ed

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 68c986a10784ff6310720f4eb8c6e9732131cddd111f148d5ed8cda545ff4774
MD5 b2bbd4cffcbaa321a08d9354ca96d861
BLAKE2b-256 02cbd83345a222ee9986769b8684057975c7351abb2041645a8c98aa2fdb312e

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 b7b913ec80f87bc59bcadc2c8b470e81907b7b1a71fb96bd928b731ecc652a8b
MD5 ba322a736535925bfcb95becd0d419c8
BLAKE2b-256 09fffdd332dbc9b8cf49873f530745aa03b5e0c4f4c7e7945580a514efbfe0d6

See more details on using hashes here.

File details

Details for the file chytorch_synplan-1.68-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for chytorch_synplan-1.68-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 537ce153f3798cf196c0be8cd4c55458c562d829aa9a7b67949f3420efa2cdef
MD5 4ea6ec1a317fa7c21e8aebcbe30e8b2e
BLAKE2b-256 1d5090bd43967f3235cede111232d60c58422ddbf323505e1ecf55883277cb81

See more details on using hashes here.

Supported by

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