Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to read go database #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
22 changes: 22 additions & 0 deletions examples/tools/13-xyz_from_database_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
# Authors: Nike Dattani ([email protected]) and Vandan Revanur ([email protected])

import requests # First run "pip install requests"
import pyscf
from pyscf.tools.get_xyz import get_xyz

geometry_database = 'https://raw.githubusercontent.com/HPQC-LABS/goDatabase/master/benchmark_sets/gw5000.txt'

molecule_name = 'C10H15NO2S2'
geometry_identifier = 'GW5000'
geometry_version = '0'
geometry_name = molecule_name+':'+geometry_identifier+'.v'+geometry_version

page = requests.get(geometry_database)
data = page.text
molecule_xyz = get_xyz(data, geometry_name)

print(molecule_xyz)
mol = pyscf.M(atom=molecule_xyz, basis='sto-3g', verbose=5, spin=0, charge=0)
print(mol)

8 changes: 8 additions & 0 deletions pyscf/tools/get_xyz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import re

def get_xyz(db_data:str, name:str)-> str:
p = re.compile(f'NAME = {name}(.*?)NAME', flags=re.DOTALL)
result = p.search(db_data)

xyz_info = result.group(1)
return xyz_info