Skip to content

Commit

Permalink
Download Built-in model parameters from ASE_ANI (#481)
Browse files Browse the repository at this point in the history
* download resources from ASE_ANI

* update gitignore

* get resources with request

* fix flke8

* rm svn checkout for resources

* update

* fix flake8
  • Loading branch information
farhadrgh committed Jun 10, 2020
1 parent e08bb3d commit 9e7baa6
Show file tree
Hide file tree
Showing 900 changed files with 30 additions and 924,172 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -30,6 +30,9 @@ dist
*.swo
/download
/download.tar.xz
/torchani/resources/*.info
/torchani/resources/ani-1ccx_8x
/torchani/resources/ani-2x_8x
*.qdrep
*.qdstrm
*.zip
Expand Down
1 change: 1 addition & 0 deletions download.sh
@@ -1,4 +1,5 @@
#!/bin/bash

# download the data
wget https://www.dropbox.com/sh/2c8zdqc1hrqsgwy/AAD6l24ngoiFa6DRapF6HPk5a/ -O download.zip
unzip download.zip -d download || [[ $? == 2 ]] # unzip return 2 for dropbox created zip file
35 changes: 26 additions & 9 deletions torchani/models.py
Expand Up @@ -24,10 +24,12 @@
model0.species_to_tensor(['C', 'H', 'H', 'H', 'H'])
"""
import os
import io
import requests
import zipfile
import torch
from torch import Tensor
from typing import Tuple, Optional
from pkg_resources import resource_filename
from . import neurochem
from .nn import SpeciesConverter, SpeciesEnergies
from .aev import AEVComputer
Expand Down Expand Up @@ -70,21 +72,36 @@ def _from_neurochem_resources(cls, info_file_path, periodic_table_index=False, m

@staticmethod
def _parse_neurochem_resources(info_file_path):
def get_resource(file_path):
package_name = '.'.join(__name__.split('.')[:-1])
return resource_filename(package_name, 'resources/' + file_path)

info_file = get_resource(info_file_path)
def get_resource(resource_path, file_path):
return os.path.join(resource_path, 'resources/' + file_path)

resource_path = os.path.dirname(__file__)
local_dir = os.path.expanduser('~/.local/torchani')

if not os.path.isfile(get_resource(resource_path, info_file_path)):
if not os.path.isfile(get_resource(local_dir, info_file_path)):
print('Downloading ANI model parameters ...')
resource_res = requests.get("https://www.dropbox.com/sh/otrzul6yuye8uzs/AABuaihE22vtaB_rdrI0r6TUa?dl=1")
resource_zip = zipfile.ZipFile(io.BytesIO(resource_res.content))
try:
resource_zip.extractall(resource_path)
except PermissionError:
resource_zip.extractall(local_dir)
resource_path = local_dir
else:
resource_path = local_dir

info_file = get_resource(resource_path, info_file_path)

with open(info_file) as f:
# const_file: Path to the file with the builtin constants.
# sae_file: Path to the file with the Self Atomic Energies.
# ensemble_prefix: Prefix of the neurochem resource directories.
lines = [x.strip() for x in f.readlines()][:4]
const_file_path, sae_file_path, ensemble_prefix_path, ensemble_size = lines
const_file = get_resource(const_file_path)
sae_file = get_resource(sae_file_path)
ensemble_prefix = get_resource(ensemble_prefix_path)
const_file = get_resource(resource_path, const_file_path)
sae_file = get_resource(resource_path, sae_file_path)
ensemble_prefix = get_resource(resource_path, ensemble_prefix_path)
ensemble_size = int(ensemble_size)
consts = neurochem.Constants(const_file)
return consts, sae_file, ensemble_prefix, ensemble_size
Expand Down
5 changes: 0 additions & 5 deletions torchani/resources/ani-1ccx_8x.info

This file was deleted.

10 changes: 0 additions & 10 deletions torchani/resources/ani-1ccx_8x/rHCNO-5.2R_16-3.5A_a4-8.params

This file was deleted.

4 changes: 0 additions & 4 deletions torchani/resources/ani-1ccx_8x/sae_linfit.dat

This file was deleted.

Empty file.
2,414 changes: 0 additions & 2,414 deletions torchani/resources/ani-1ccx_8x/train0/cost.dat

This file was deleted.

135 changes: 0 additions & 135 deletions torchani/resources/ani-1ccx_8x/train0/inputtrain.ipt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

0 comments on commit 9e7baa6

Please sign in to comment.