mirror of
https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local
synced 2024-12-22 12:23:39 +01:00
Add dict for testing
This commit is contained in:
parent
ec0fc43bf8
commit
29f7adaa3f
13
EMSL_api.py
13
EMSL_api.py
@ -77,15 +77,11 @@ if __name__ == '__main__':
|
||||
if arguments["list_basis"]:
|
||||
e = EMSL_local(db_path=db_path)
|
||||
|
||||
elts = arguments["--atom"]
|
||||
l = e.list_basis_available(arguments["--atom"],
|
||||
arguments["--basis"],
|
||||
arguments["--average_mo_number"])
|
||||
|
||||
amn = arguments["--average_mo_number"]
|
||||
|
||||
l = e.get_list_basis_available(elts,
|
||||
arguments["--basis"],
|
||||
average_mo_number=amn)
|
||||
|
||||
if amn:
|
||||
if arguments["--average_mo_number"]:
|
||||
for name, des, avg in l:
|
||||
print "- '{}' ({}) || {:<50}".format(name, avg, des)
|
||||
else:
|
||||
@ -127,6 +123,7 @@ if __name__ == '__main__':
|
||||
if arguments["--path"]:
|
||||
path = arguments["--path"]
|
||||
else:
|
||||
# The defaut path is bais
|
||||
path = "_".join([basis_name, ".".join(elts)])
|
||||
path = "/tmp/" + path + ".bs"
|
||||
|
||||
|
@ -34,7 +34,7 @@ def checkSQLite3(db_path):
|
||||
# Check if the file system allows I/O on sqlite3 (lustre)
|
||||
# If not, copy on /dev/shm and remove after opening
|
||||
try:
|
||||
EMSL_local(db_path=db_path).get_list_basis_available()
|
||||
EMSL_local(db_path=db_path).list_basis_available()
|
||||
except sqlite3.OperationalError:
|
||||
print >>sys.stderr, "I/O Error for you file system"
|
||||
print >>sys.stderr, "Try some fixe"
|
||||
@ -47,7 +47,7 @@ def checkSQLite3(db_path):
|
||||
|
||||
# Try again to check
|
||||
try:
|
||||
EMSL_local(db_path=db_path).get_list_basis_available()
|
||||
EMSL_local(db_path=db_path).list_basis_available()
|
||||
except:
|
||||
print >>sys.stderr, "Sorry..."
|
||||
os.system("rm -f /dev/shm/%d.db" % (os.getpid()))
|
||||
@ -136,10 +136,10 @@ class EMSL_local:
|
||||
self.c.execute("SELECT * from format_tab")
|
||||
self.format = self.c.fetchone()[0]
|
||||
|
||||
def get_list_basis_available(self,
|
||||
elts=[],
|
||||
basis=[],
|
||||
average_mo_number=False):
|
||||
def list_basis_available(self,
|
||||
elts=[],
|
||||
basis=[],
|
||||
average_mo_number=False):
|
||||
"""
|
||||
return all the basis name who contant all the elts
|
||||
"""
|
||||
@ -224,15 +224,10 @@ class EMSL_local:
|
||||
dict_info = OrderedDict()
|
||||
# Description : dict_info[name] = [description, nb_mo, nb_ele]
|
||||
|
||||
from src.parser import symmetry_dict
|
||||
from src.parser import get_symemetry_function
|
||||
if average_mo_number:
|
||||
|
||||
try:
|
||||
l_symmetry = symmetry_dict[self.format]
|
||||
except KeyError:
|
||||
print >> sys.stderr, "You need to add a function in symmetry_dict"
|
||||
print >> sys.stderr, "for your format ({0})".format(self.format)
|
||||
sys.exit(1)
|
||||
f_symmetry = get_symemetry_function(self.format)
|
||||
|
||||
for name, description, atom_basis in info:
|
||||
|
||||
@ -240,7 +235,7 @@ class EMSL_local:
|
||||
|
||||
line = atom_basis.split("\n")
|
||||
|
||||
for type_, _, _ in l_symmetry(line):
|
||||
for type_, _, _ in f_symmetry(line):
|
||||
|
||||
nb_mo += string_to_nb_mo(type_)
|
||||
try:
|
||||
@ -282,7 +277,7 @@ class EMSL_local:
|
||||
|
||||
def get_basis(self,
|
||||
basis_name, elts=None,
|
||||
handle_f_format="GAMESS-US", check_format=None):
|
||||
handle_l_format=False, check_format=False):
|
||||
"""
|
||||
Return the data from the basis set
|
||||
"""
|
||||
@ -303,18 +298,18 @@ class EMSL_local:
|
||||
# ~#~#~#~#~#~#~#~ #
|
||||
# h a n d l e _ f #
|
||||
# ~#~#~#~#~#~#~#~ #
|
||||
if handle_f_format:
|
||||
from src.parser import handle_f_dict
|
||||
if handle_l_format:
|
||||
from src.parser import handle_l_dict
|
||||
try:
|
||||
f = handle_f_dict[self.format]
|
||||
f = handle_l_dict[self.format]
|
||||
except KeyError:
|
||||
str_ = "You cannot handle f function with {0} format"
|
||||
print >> sys.stderr, str_.format(self.format)
|
||||
print >> sys.stderr, "Choose in:"
|
||||
print >> sys.stderr, handle_f_dict.keys()
|
||||
print >> sys.stderr, handle_l_dict.keys()
|
||||
sys.exit(1)
|
||||
else:
|
||||
l_atom_basis = f(l_atom_basis, self.get_list_symetry)
|
||||
l_atom_basis = f(l_atom_basis)
|
||||
|
||||
# ~#~#~#~#~ #
|
||||
# C h e c k #
|
||||
@ -331,9 +326,12 @@ class EMSL_local:
|
||||
print >>sys.stderr, str_.format(format(str(d_check.keys())))
|
||||
sys.exit(1)
|
||||
else:
|
||||
from src.parser import get_symemetry_function
|
||||
f_symmetry = get_symemetry_function(self.format)
|
||||
|
||||
for atom_basis in l_atom_basis:
|
||||
lines = atom_basis.split("\n")
|
||||
for type_, _, _ in self.get_list_symetry(lines):
|
||||
for type_, _, _ in f_symmetry(lines):
|
||||
f(type_)
|
||||
|
||||
# ~#~#~#~#~#~ #
|
||||
|
@ -112,7 +112,7 @@ def l_symmetry_gamess_us(atom_basis):
|
||||
return l
|
||||
|
||||
|
||||
def handle_f_gamess_us(l_atom_basis):
|
||||
def handle_l_gamess_us(l_atom_basis):
|
||||
"""
|
||||
Read l_atom_basis and change the SP in L and P
|
||||
"""
|
||||
@ -192,3 +192,22 @@ format_dict = {"Gaussian94": None,
|
||||
# |___/ |___/
|
||||
|
||||
symmetry_dict = {"GAMESS-US": l_symmetry_gamess_us}
|
||||
|
||||
|
||||
def get_symemetry_function(format):
|
||||
try:
|
||||
l_symmetry = symmetry_dict[format]
|
||||
except KeyError:
|
||||
print >> sys.stderr, "You need to add a function in symmetry_dict"
|
||||
print >> sys.stderr, "for your format ({0})".format(format)
|
||||
sys.exit(1)
|
||||
return l_symmetry
|
||||
|
||||
# _ _ _ _ _ _ _ _ _ ______ _ _
|
||||
# | | | | | | | ( | ) | ( | ) | _ (_) | |
|
||||
# | |_| | __ _ _ __ __| | | ___ V V| | V V | | | |_ ___| |_
|
||||
# | _ |/ _` | '_ \ / _` | |/ _ \ | | | | | | |/ __| __|
|
||||
# | | | | (_| | | | | (_| | | __/ | |____ | |/ /| | (__| |_
|
||||
# \_| |_/\__,_|_| |_|\__,_|_|\___| \_____/ |___/ |_|\___|\__|
|
||||
|
||||
handle_l_dict = {"GAMESS-US": handle_l_gamess_us}
|
||||
|
Loading…
Reference in New Issue
Block a user