Datasets:
ArXiv:
License:
Download Code/lmdb_access.py from divelab/PubChemQCR: direct link, hf CLI and curl.
- Browser
- Download file 978 Bytes
-
https://huggingface.co/datasets/divelab/PubChemQCR/resolve/main/Code/lmdb_access.py
- Command line
-
hf download hf://datasets/divelab/PubChemQCR/Code/lmdb_access.py
-
curl -L -o lmdb_access.py https://huggingface.co/datasets/divelab/PubChemQCR/resolve/main/Code/lmdb_access.py
978 Bytes
| import lmdb | |
| import pickle | |
| import gzip | |
| lmdb_file = '/path/to/lmdb/dir/hokusai2017.lmdb' | |
| with lmdb.open(lmdb_file, readonly=True, subdir=False) as env: | |
| with env.begin() as txn: | |
| val = pickle.loads(gzip.decompress((txn.get(b'000000984')))) | |
| pm3_val = val['pm3'] | |
| hf_val = val['hf'] | |
| dft1st_val = val['DFT_1st'] | |
| dft2nd_val = val['DFT_2nd'] | |
| for step in dft1st_val: | |
| # coords & grad is a list of dictionaries that stores the relevant information of each atom | |
| # energy is a scalar representing the energy for that conformer | |
| coords = step['coordinates'] | |
| energy = step['energy'] | |
| grad = step['gradient'] | |
| for atom in coords: | |
| # access atom's attributes | |
| element = atom['atom'] | |
| x = atom['x'] | |
| y = atom['y'] | |
| z = atom['z'] | |
| for atom in grad: | |
| # access atom's attributes | |
| element = atom['atom'] | |
| dx = atom['dx'] | |
| dy = atom['dy'] | |
| dz = atom['dz'] | |