10
0
mirror of https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local synced 2024-12-22 20:34:23 +01:00

Merge pull request #1 from TApplencourt/master

Merge
This commit is contained in:
Anthony Scemama 2015-01-15 22:56:23 +01:00
commit 13b8c56766
3 changed files with 179 additions and 18 deletions

View File

@ -5,30 +5,39 @@ EMSL_Basis_Set_Exchange_Local
Create of Local Copy of the famous [EMSL Basis Set Exchange](https://bse.pnl.gov/bse/portal) and use it easily with the API. Create of Local Copy of the famous [EMSL Basis Set Exchange](https://bse.pnl.gov/bse/portal) and use it easily with the API.
* Make a slight copy (40Mo Sqlite3 database) of the EMSL Basis Set Exchange website (One database for all the basis set of one format); * Make a slight copy (40Mo Sqlite3 database) of the EMSL Basis Set Exchange website (One database for all the basis set of one format);
* API for scripting ; * API for scripting;
* Quick local access without delay ; * Quick local access without delay;
* Only need [Python](https://www.python.org/) and [Request](http://docs.python-requests.org/en/latest/) module. * Only need [Python](https://www.python.org/)
##Dependancy ##Dependency
* Python >2.6 * Python >2.6
* Request ```pip install requests```
###### Optional
If you plan to download manually some database -not using the pre existing one- you need :
* [Request](http://docs.python-requests.org/en/latest/) python module. ```$pip install requests``` (do it in a virtual env or with sudo)
##Installation ##Installation
* Download the git (```$ git clone https://github.com/TApplencourt/EMSL_Basis_Set_Exchange_Local.git``` for example) * Download the git repertory (```$git clone https://github.com/TApplencourt/EMSL_Basis_Set_Exchange_Local.git``` for example)
* ```cd``` into & run ```$ ./setup.py``` * That all! You can now, use ```EMSL_api.py```
* ```source EMSL_api.rc```
* Done ! You can now, use ```EMSL_api.py``` or use all the python fonction inside ```./src```
##Usage ##Usage
``` ```
EMSL Api. EMSL Api.
Usage: Usage:
EMSL_api.py get_list_basis <db_path> EMSL_api.py list_basis [--atom=<atom_name>...]
EMSL_api.py get_list_elements <db_path> <basis_name> [--db_path=<db_path>]
EMSL_api.py get_basis_data <db_path> <basis_name> <elts>... EMSL_api.py list_atoms --basis=<basis_name>
EMSL_api.py get_list_formats [--db_path=<db_path>]
EMSL_api.py create_db <db_path> <format> [--no-contraction] EMSL_api.py get_basis_data --basis=<basis_name>
[--atom=<atom_name>...]
[--db_path=<db_path>]
[--with_l]
[(--save [--path=<path>])]
EMSL_api.py list_formats
EMSL_api.py create_db --db_path=<db_path>
--format=<format>
[--no-contraction]
EMSL_api.py (-h | --help) EMSL_api.py (-h | --help)
EMSL_api.py --version EMSL_api.py --version
@ -38,7 +47,13 @@ Options:
--no-contraction Basis functions are not contracted --no-contraction Basis functions are not contracted
<db_path> is the path to the SQLite3 file containing the Basis sets. <db_path> is the path to the SQLite3 file containing the Basis sets.
By default is $EMSL_API_ROOT/db/Gausian_uk.db
``` ```
##Demonstration
![](http://fat.gfycat.com/WelcomePerkyChrysomelid.gif)
(For a beter quality see the [Source](https://asciinema.org/api/asciicasts/15380))
##To do ##To do
For now we can only parse Gaussian-US basis set type file. (Look at ```./src/EMSL_utility.py#EMSL_dump.basis_data_row_to_array```) For now we can only parse Gaussian-US basis set type file. (Look at ```./src/EMSL_utility.py#EMSL_dump.basis_data_row_to_array```)

View File

@ -19,6 +19,29 @@ for i in data:
dict_ele[l[1].strip().lower()] = l[2].strip().lower() dict_ele[l[1].strip().lower()] = l[2].strip().lower()
def install_with_pip(name):
ins = False
d = {'y': True,
'n': False}
while True:
choice = raw_input('Do you want to install it ? [Y/N]')
try:
ins = d[choice.lower()]
break
except:
print "not a valid choice"
if ins:
try:
import pip
pip.main(['install', name])
except:
print "You need pip, (http://pip.readthedocs.org/en/latest/installing.html)"
sys.exit(1)
def cond_sql_or(table_name, l_value): def cond_sql_or(table_name, l_value):
l = [] l = []
@ -36,7 +59,12 @@ class EMSL_dump:
self.format = format self.format = format
self.contraction = str(contraction) self.contraction = str(contraction)
try:
import requests import requests
except:
print "You need the requests package"
install_with_pip("requests")
finally:
self.requests = requests self.requests = requests
def set_db_path(self, path): def set_db_path(self, path):
@ -132,7 +160,7 @@ class EMSL_dump:
data = data.replace("D+", "E+") data = data.replace("D+", "E+")
data = data.replace("D-", "E-") data = data.replace("D-", "E-")
data = data[b + 5:e-1].split('\n\n') data = data[b + 5:e - 1].split('\n\n')
for (elt, data_elt) in zip(elts, data): for (elt, data_elt) in zip(elts, data):
@ -193,7 +221,7 @@ class EMSL_dump:
q_out.put(([name, url, des, elts], basis_data)) q_out.put(([name, url, des, elts], basis_data))
q_in.task_done() q_in.task_done()
except: except:
print name,url,des print name, url, des
raise raise
def enqueue(): def enqueue():

118
src/elts_abrev.dat Normal file
View File

@ -0,0 +1,118 @@
1 - H - Hydrogen
2 - He - Helium
3 - Li - Lithium
4 - Be - Beryllium
5 - B - Boron
6 - C - Carbon
7 - N - Nitrogen
8 - O - Oxygen
9 - F - Fluorine
10 - Ne - Neon
11 - Na - Sodium
12 - Mg - Magnesium
13 - Al - Aluminum
14 - Si - Silicon
15 - P - Phosphorus
16 - S - Sulfur
17 - Cl - Chlorine
18 - Ar - Argon
19 - K - Potassium
20 - Ca - Calcium
21 - Sc - Scandium
22 - Ti - Titanium
23 - V - Vanadium
24 - Cr - Chromium
25 - Mn - Manganese
26 - Fe - Iron
27 - Co - Cobalt
28 - Ni - Nickel
29 - Cu - Copper
30 - Zn - Zinc
31 - Ga - Gallium
32 - Ge - Germanium
33 - As - Arsenic
34 - Se - Selenium
35 - Br - Bromine
36 - Kr - Krypton
37 - Rb - Rubidium
38 - Sr - Strontium
39 - Y - Yttrium
40 - Zr - Zirconium
41 - Nb - Niobium
42 - Mo - Molybdenum
43 - Tc - Technetium
44 - Ru - Ruthenium
45 - Rh - Rhodium
46 - Pd - Palladium
47 - Ag - Silver
48 - Cd - Cadmium
49 - In - Indium
50 - Sn - Tin
51 - Sb - Antimony
52 - Te - Tellurium
53 - I - Iodine
54 - Xe - Xenon
55 - Cs - Cesium
56 - Ba - Barium
57 - La - Lanthanum
58 - Ce - Cerium
59 - Pr - Praseodymium
60 - Nd - Neodymium
61 - Pm - Promethium
62 - Sm - Samarium
63 - Eu - Europium
64 - Gd - Gadolinium
65 - Tb - Terbium
66 - Dy - Dysprosium
67 - Ho - Holmium
68 - Er - Erbium
69 - Tm - Thulium
70 - Yb - Ytterbium
71 - Lu - Lutetium
72 - Hf - Hafnium
73 - Ta - Tantalum
74 - W - Tungsten
75 - Re - Rhenium
76 - Os - Osmium
77 - Ir - Iridium
78 - Pt - Platinum
79 - Au - Gold
80 - Hg - Mercury
81 - Tl - Thallium
82 - Pb - Lead
83 - Bi - Bismuth
84 - Po - Polonium
85 - At - Astatine
86 - Rn - Radon
87 - Fr - Francium
88 - Ra - Radium
89 - Ac - Actinium
90 - Th - Thorium
91 - Pa - Protactinium
92 - U - Uranium
93 - Np - Neptunium
94 - Pu - Plutonium
95 - Am - Americium
96 - Cm - Curium
97 - Bk - Berkelium
98 - Cf - Californium
99 - Es - Einsteinium
100 - Fm - Fermium
101 - Md - Mendelevium
102 - No - Nobelium
103 - Lr - Lawrencium
104 - Rf - Rutherfordium
105 - Db - Dubnium
106 - Sg - Seaborgium
107 - Bh - Bohrium
108 - Hs - Hassium
109 - Mt - Meitnerium
110 - Ds - Darmstadtium
111 - Rg - Roentgenium
112 - Cn - Copernicium
113 - Uut - Ununtrium
114 - Fl - Flerovium
115 - Uup - Ununpentium
116 - Lv - Livermorium
117 - Uus - Ununseptium
118 - Uuo - Ununoctium