https://github.com/genentech/cdd_chem
https://github.com/genentech/cdd_chem
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/genentech/cdd_chem
- Owner: Genentech
- License: mit
- Created: 2022-12-13T23:42:03.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2023-05-30T23:06:07.000Z (about 3 years ago)
- Last Synced: 2025-02-05T03:27:52.502Z (over 1 year ago)
- Language: Python
- Size: 56.6 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: License.txt
Awesome Lists containing this project
README
# CDD Chem Library
General purpose helper classes around the [RDKit](https://www.rdkit.org/) and
[Openeye](https://www.eyesopen.com/) toolkits for handling molecular input files.
This packages tries to abstract the toolkits away and thus provides a toolkit
independent interface to dealing with molecular files and, to some extend, with
molecule objects.
The underlying toolkit can be set with `cdd_chem.toolkit.set_toolkit`. If it's not
set then the underlying toolkit is taken from the `CDDLIB_TOOLKIT` environment
variable. If this environment variable is not set then the default toolkit will be
`oechem` provided that `oechem` can be imported. Otherwise the toolkit will be set
to `rdkit`.
The package is still under development but here is an example on how to get started:
```
#!/usr/bin/env python3
import argparse
import sys
from cdd_chem.io import get_mol_input_stream, get_mol_output_stream
def main() -> int:
"""Console script"""
args = parse_options()
with get_mol_input_stream(args.input) as in_file, get_mol_output_stream(args.output) as out_file:
for mol in in_file:
# set SD tag data (that has to be a string)
mol['num_atoms'] = str(mol.num_atoms)
out_file.write_mol(mol)
return 0
def parse_options() -> argparse.Namespace:
"""Parse main options."""
parser = argparse.ArgumentParser(description="Command line arguments:")
parser.add_argument('--input', type=str, metavar='molfile', required=True, help='input molecule file')
parser.add_argument('--output', type=str, metavar='molfile', required=True, help='output molecule file')
return parser.parse_args()
if __name__ == "__main__":
sys.exit(main())
```
## Features
Toolkit-agnostic features for:
- Reading and writing molecules to SD files
- Converting between molecules and SMILES
- Setting and retrieving properties of molecules
- Reading and writing pandas dataframes containing representations of molecules with properties
## Credits
This Python package was created with
- [Cookiecutter](https://github.com/audreyr/cookiecutter)