From da966e6c3c8be689b052395f8cca646588c06c77 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 16 Mar 2015 16:54:00 +0100 Subject: [PATCH] Add format --- EMSL_api.py | 3 ++- src/EMSL_local.py | 21 ++++++++++++++++++--- src/parser.py | 1 - 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/EMSL_api.py b/EMSL_api.py index 067d6dd..86e1370 100755 --- a/EMSL_api.py +++ b/EMSL_api.py @@ -5,6 +5,7 @@ Usage: EMSL_api.py list_basis [--basis=...] + --format= [--atom=...] [--db_path=] [--average_mo_number] @@ -76,7 +77,7 @@ if __name__ == '__main__': # \_____/_|___/\__| \____/ \__,_|___/_|___/ if arguments["list_basis"]: - e = EMSL_local(db_path=db_path) + e = EMSL_local(db_path=db_path, format=arguments["--format"]) elts = arguments["--atom"] diff --git a/src/EMSL_local.py b/src/EMSL_local.py index ffe85d0..6d2fef9 100755 --- a/src/EMSL_local.py +++ b/src/EMSL_local.py @@ -252,19 +252,34 @@ class EMSL_local: if average_mo_number: - print "WARNING DO NOT SUPPORT L COUNTING" - print "TREAD L FUNCTION NOT LIKE A SPECIAL ONE" + from src.parser import handle_f_dict + + try: + f = handle_f_dict[self.format] + except KeyError: + str_ = " WARNING Cannot handle counting L function in this format" + print >> sys.stderr, str_ + for name, description, atom_basis in info: + + try: + atom_basis = f([atom_basis], self.get_list_symetry) + atom_basis = "\n\n".join(atom_basis) + except UnboundLocalError: + pass + nb_mo = 0 line = atom_basis.split("\n") + for type_, _, _ in self.get_list_symetry(line): + nb_mo += string_to_nb_mo(type_) try: dict_info[name][1] += nb_mo dict_info[name][2] += 1. - except: + except KeyError: dict_info[name] = [description, nb_mo, 1.] # ~#~#~#~#~#~ # diff --git a/src/parser.py b/src/parser.py index 4f98aeb..5fb968a 100644 --- a/src/parser.py +++ b/src/parser.py @@ -106,7 +106,6 @@ def handle_f_gamess_us(l_atom_basis, list_symetry): """ l_data = [] - for atom_basis in l_atom_basis: # Split the data in line