mirror of
https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local
synced 2024-11-01 03:33:46 +01:00
Add check_validity.py
This commit is contained in:
parent
29f7adaa3f
commit
2c6a77cbf8
@ -14,7 +14,7 @@ Usage:
|
|||||||
[--atom=<atom_name>...]
|
[--atom=<atom_name>...]
|
||||||
[--db_path=<db_path>]
|
[--db_path=<db_path>]
|
||||||
[(--save [--path=<path>])]
|
[(--save [--path=<path>])]
|
||||||
[--check]
|
[--check=<program_name>]
|
||||||
[--treat_l]
|
[--treat_l]
|
||||||
EMSL_api.py list_formats
|
EMSL_api.py list_formats
|
||||||
EMSL_api.py create_db --db_path=<db_path>
|
EMSL_api.py create_db --db_path=<db_path>
|
||||||
|
@ -85,38 +85,6 @@ def string_to_nb_mo(str_type):
|
|||||||
else:
|
else:
|
||||||
raise BaseException
|
raise BaseException
|
||||||
|
|
||||||
|
|
||||||
# _
|
|
||||||
# / |_ _ _ | _. | o _| o _|_
|
|
||||||
# \_ | | (/_ (_ |< \/ (_| | | (_| | |_ \/
|
|
||||||
# /
|
|
||||||
|
|
||||||
def check_gamess(str_type):
|
|
||||||
"""Check is the orbital type is handle by gamess"""
|
|
||||||
|
|
||||||
assert len(str_type) == 1
|
|
||||||
|
|
||||||
if str_type in "S P D".split():
|
|
||||||
return True
|
|
||||||
elif str_type == "L":
|
|
||||||
raise BaseException
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def check_NWChem(str_type):
|
|
||||||
"""Check is the orbital type is handle by gamess"""
|
|
||||||
|
|
||||||
assert len(str_type) == 1
|
|
||||||
|
|
||||||
if str_type in "S P D".split():
|
|
||||||
return True
|
|
||||||
elif str_type > "I" or str_type in "K L M".split():
|
|
||||||
raise BaseException
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
# _ __
|
# _ __
|
||||||
# |_ |\/| (_ | | _ _ _. |
|
# |_ |\/| (_ | | _ _ _. |
|
||||||
# |_ | | __) |_ |_ (_) (_ (_| |
|
# |_ | | __) |_ |_ (_) (_ (_| |
|
||||||
@ -224,10 +192,10 @@ class EMSL_local:
|
|||||||
dict_info = OrderedDict()
|
dict_info = OrderedDict()
|
||||||
# Description : dict_info[name] = [description, nb_mo, nb_ele]
|
# Description : dict_info[name] = [description, nb_mo, nb_ele]
|
||||||
|
|
||||||
from src.parser import get_symemetry_function
|
from src.parser import get_symmetry_function
|
||||||
if average_mo_number:
|
if average_mo_number:
|
||||||
|
|
||||||
f_symmetry = get_symemetry_function(self.format)
|
f_symmetry = get_symmetry_function(self.format)
|
||||||
|
|
||||||
for name, description, atom_basis in info:
|
for name, description, atom_basis in info:
|
||||||
|
|
||||||
@ -277,7 +245,7 @@ class EMSL_local:
|
|||||||
|
|
||||||
def get_basis(self,
|
def get_basis(self,
|
||||||
basis_name, elts=None,
|
basis_name, elts=None,
|
||||||
handle_l_format=False, check_format=False):
|
handle_l_format=False, check_format=None):
|
||||||
"""
|
"""
|
||||||
Return the data from the basis set
|
Return the data from the basis set
|
||||||
"""
|
"""
|
||||||
@ -299,40 +267,32 @@ class EMSL_local:
|
|||||||
# h a n d l e _ f #
|
# h a n d l e _ f #
|
||||||
# ~#~#~#~#~#~#~#~ #
|
# ~#~#~#~#~#~#~#~ #
|
||||||
if handle_l_format:
|
if handle_l_format:
|
||||||
from src.parser import handle_l_dict
|
from src.parser import get_handle_l_function
|
||||||
try:
|
f = get_handle_l_function(self.format)
|
||||||
f = handle_l_dict[self.format]
|
l_atom_basis = f(l_atom_basis)
|
||||||
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_l_dict.keys()
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
l_atom_basis = f(l_atom_basis)
|
|
||||||
|
|
||||||
# ~#~#~#~#~ #
|
# ~#~#~#~#~ #
|
||||||
# C h e c k #
|
# C h e c k #
|
||||||
# ~#~#~#~#~ #
|
# ~#~#~#~#~ #
|
||||||
|
|
||||||
d_check = {"GAMESS-US": check_gamess,
|
|
||||||
"NWChem": check_NWChem}
|
|
||||||
|
|
||||||
if check_format:
|
if check_format:
|
||||||
try:
|
|
||||||
f = d_check[self.format]
|
from src.parser import get_symmetry_function
|
||||||
except KeyError:
|
from src.check_validity import get_check_function
|
||||||
str_ = """This format is not handle. Chose one of : {}"""
|
|
||||||
print >>sys.stderr, str_.format(format(str(d_check.keys())))
|
f = get_check_function(check_format)
|
||||||
sys.exit(1)
|
f_symmetry = get_symmetry_function(self.format)
|
||||||
else:
|
|
||||||
from src.parser import get_symemetry_function
|
|
||||||
f_symmetry = get_symemetry_function(self.format)
|
|
||||||
|
|
||||||
for atom_basis in l_atom_basis:
|
for atom_basis in l_atom_basis:
|
||||||
lines = atom_basis.split("\n")
|
lines = atom_basis.split("\n")
|
||||||
for type_, _, _ in f_symmetry(lines):
|
for type_, _, _ in f_symmetry(lines):
|
||||||
f(type_)
|
try:
|
||||||
|
f(type_)
|
||||||
|
except AssertionError:
|
||||||
|
print "False. You have somme special function like SP"
|
||||||
|
sys.exit(1)
|
||||||
|
except BaseException:
|
||||||
|
print "Fail !"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# ~#~#~#~#~#~ #
|
# ~#~#~#~#~#~ #
|
||||||
# R e t u r n #
|
# R e t u r n #
|
||||||
|
52
src/check_validity.py
Normal file
52
src/check_validity.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# _
|
||||||
|
# / |_ _ _ | _. | o _| o _|_
|
||||||
|
# \_ | | (/_ (_ |< \/ (_| | | (_| | |_ \/
|
||||||
|
# /
|
||||||
|
# Do this After the L special case traitement.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def check_gamess(str_type):
|
||||||
|
"""Check is the orbital type is handle by gamess"""
|
||||||
|
|
||||||
|
assert len(str_type) == 1
|
||||||
|
|
||||||
|
if str_type in "S P D".split():
|
||||||
|
return True
|
||||||
|
elif str_type == "SP":
|
||||||
|
raise BaseException
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def check_NWChem(str_type):
|
||||||
|
"""Check is the orbital type is handle by gamess"""
|
||||||
|
|
||||||
|
assert len(str_type) == 1
|
||||||
|
|
||||||
|
if str_type in "S P D".split():
|
||||||
|
return True
|
||||||
|
elif str_type > "I" or str_type in "K L M".split():
|
||||||
|
raise BaseException
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
d_check = {"GAMESS-US": check_gamess,
|
||||||
|
"NWChem": check_NWChem}
|
||||||
|
|
||||||
|
|
||||||
|
def get_check_function(name_program):
|
||||||
|
"""
|
||||||
|
Tranforme SP special function (create using get_symmetry_function)
|
||||||
|
into S and P
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
f = d_check[name_program]
|
||||||
|
except KeyError:
|
||||||
|
str_ = "You need to add a check funtion for your program {0}"
|
||||||
|
print >> sys.stderr, str_.format(name_program)
|
||||||
|
print >> sys.stderr, "This one are avalaible {0}".format(d_check.keys())
|
||||||
|
sys.exit(1)
|
||||||
|
return f
|
@ -191,17 +191,28 @@ format_dict = {"Gaussian94": None,
|
|||||||
# __/ | __/ |
|
# __/ | __/ |
|
||||||
# |___/ |___/
|
# |___/ |___/
|
||||||
|
|
||||||
|
"""
|
||||||
|
Return the begin and the end of all the type of orbital
|
||||||
|
input: atom_basis = [name, S 1, 12 0.12 12212, ...]
|
||||||
|
output: [ [type, begin, end], ...]
|
||||||
|
"""
|
||||||
|
|
||||||
symmetry_dict = {"GAMESS-US": l_symmetry_gamess_us}
|
symmetry_dict = {"GAMESS-US": l_symmetry_gamess_us}
|
||||||
|
|
||||||
|
|
||||||
def get_symemetry_function(format):
|
def get_symmetry_function(format):
|
||||||
try:
|
"""
|
||||||
l_symmetry = symmetry_dict[format]
|
Return the begin and the end of all the type of orbital
|
||||||
except KeyError:
|
input: atom_basis = [name, S 1, 12 0.12 12212, ...]
|
||||||
print >> sys.stderr, "You need to add a function in symmetry_dict"
|
output: [ [type, begin, end], ...]
|
||||||
print >> sys.stderr, "for your format ({0})".format(format)
|
"""
|
||||||
sys.exit(1)
|
try:
|
||||||
return l_symmetry
|
f = 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 f
|
||||||
|
|
||||||
# _ _ _ _ _ _ _ _ _ ______ _ _
|
# _ _ _ _ _ _ _ _ _ ______ _ _
|
||||||
# | | | | | | | ( | ) | ( | ) | _ (_) | |
|
# | | | | | | | ( | ) | ( | ) | _ (_) | |
|
||||||
@ -210,4 +221,22 @@ def get_symemetry_function(format):
|
|||||||
# | | | | (_| | | | | (_| | | __/ | |____ | |/ /| | (__| |_
|
# | | | | (_| | | | | (_| | | __/ | |____ | |/ /| | (__| |_
|
||||||
# \_| |_/\__,_|_| |_|\__,_|_|\___| \_____/ |___/ |_|\___|\__|
|
# \_| |_/\__,_|_| |_|\__,_|_|\___| \_____/ |___/ |_|\___|\__|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Tranforme SP special function (create using get_symmetry_function) into S and P
|
||||||
|
"""
|
||||||
|
|
||||||
handle_l_dict = {"GAMESS-US": handle_l_gamess_us}
|
handle_l_dict = {"GAMESS-US": handle_l_gamess_us}
|
||||||
|
|
||||||
|
|
||||||
|
def get_handle_l_function(format):
|
||||||
|
"""
|
||||||
|
Tranforme SP special function (create using get_symmetry_function)
|
||||||
|
into S and P
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
f = handle_l_dict[format]
|
||||||
|
except KeyError:
|
||||||
|
print >> sys.stderr, "You need to add a function in handle_l_dict"
|
||||||
|
print >> sys.stderr, "for your format ({0})".format(format)
|
||||||
|
sys.exit(1)
|
||||||
|
return f
|
||||||
|
Loading…
Reference in New Issue
Block a user