diff --git a/normalizer/normalizer-repo-tags/0.COMMENT_from_Jungho b/normalizer/normalizer-repo-tags/0.COMMENT_from_Jungho deleted file mode 100644 index 2b2a4adc7f3f4dfebfbba984a153741b94fbc51a..0000000000000000000000000000000000000000 --- a/normalizer/normalizer-repo-tags/0.COMMENT_from_Jungho +++ /dev/null @@ -1,9 +0,0 @@ - -(1) New modlue added by Jungho -NomadRepositoryParser: Entire python module of Repository parser from 'git@gitlab.mpcdf.mpg.de:NoMaD/NomadRepositoryParser.git'. This can be considered as submodule. - -(2) New file added by Jungho -convert_2to3.sh: Python 2.7 scripts from the NomadRepositoryParser module needs to conver to that of Python 3.0. Only need to excute when the related files are updated from the git repository. - -(3) New file added by Jungho -requirements.txt: Requirements to import NomadRepositoryParser. diff --git a/normalizer/normalizer-repo-tags/0.GIT_ADD.txt b/normalizer/normalizer-repo-tags/0.GIT_ADD.txt new file mode 100644 index 0000000000000000000000000000000000000000..2285620d4f8f7b0b27a4cceb29887024190d7ce9 --- /dev/null +++ b/normalizer/normalizer-repo-tags/0.GIT_ADD.txt @@ -0,0 +1 @@ +model_base.py? diff --git a/normalizer/normalizer-repo-tags/calculate_repo_tags.py b/normalizer/normalizer-repo-tags/calculate_repo_tags.py index 9f9efa590ebb843594ce7087f5037dc23d8b26d9..f1d057df14e2bb87fbb9bee029abdfb27e9550c1 100644 --- a/normalizer/normalizer-repo-tags/calculate_repo_tags.py +++ b/normalizer/normalizer-repo-tags/calculate_repo_tags.py @@ -18,24 +18,21 @@ def calculateTags(inputDict, backend, calcUri): backend.openContext(calcUri) repoSect = backend.openSection("section_repository_info") - # fill out i.e. backend.addValue unsing input Dict - # "repository_checksum", - # "repository_chemical_formula", - # "repository_parser_id", - # "repository_atomic_elements", - # "repository_basis_set_type", - # "repository_code_version", - # "repository_crystal_system", - # "repository_program_name", - # "repository_spacegroup_nr", - # "repository_system_type", - # "repository_xc_treatment" - # add more? - #print("\n*** inputDict %s *** \n", inputDict) - work = API() - for calc, error in work._parse(inputDict, "normalizerRepo") - print("\n*** calc %s *** \n", calc) + for calc, error in work._parse("/nomad/jshin/work/normalizer/scalaOut1.txt", "normalizerRepo"): + calc, error = work.classify(calc) + + backend.addValue("repository_checksum", calc.get_checksum()) + backend.addValue("repository_chemical_formula", calc.info['formula'] + #backend.addValue("repository_parser_id", value) + backend.addValue("repository_atomic_elements", calc.info['elements']) + backend.addValue("repository_basis_set_type", calc.info['ansatz']) + #backend.addValue("repository_code_version", value) + backend.addValue("repository_crystal_system", calc.info['symmetry']) + #backend.addValue("repository_program_name", calc.info['']) + backend.addValue("repository_spacegroup_nr", calc.info['ng']) + backend.addValue("repository_system_type", calc.info['periodicity']) + backend.addValue("repository_xc_treatment", calc.info['H_types']) if repoSectUri: backend.closeContext(repoSectUri) diff --git a/normalizer/normalizer-repo-tags/convert_2to3.sh b/normalizer/normalizer-repo-tags/convert_2to3.sh index 7a882e54fedde8312627a2f08582336be18ff290..3f78ed083b2ce9c7e2c6f6b78e7eabc45f2ed242 100755 --- a/normalizer/normalizer-repo-tags/convert_2to3.sh +++ b/normalizer/normalizer-repo-tags/convert_2to3.sh @@ -1 +1,6 @@ -2to3 -w NomadRepositoryParser/python/nomadrepo/core/settings.py +#!/bin/bash + +for python_file in NomadRepositoryParser/python/nomadrepo/core/settings.py NomadRepositoryParser/python/nomadrepo/core/symmetry.py +do + 2to3 -w $python_file +done diff --git a/normalizer/normalizer-repo-tags/normalizer/__init__.py b/normalizer/normalizer-repo-tags/normalizer/__init__.py new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/normalizer/normalizer-repo-tags/normalizer/manifest.json b/normalizer/normalizer-repo-tags/normalizer/manifest.json new file mode 100755 index 0000000000000000000000000000000000000000..9d14f69a85cd7130ae6e50ee6f8eb12e1bb52468 --- /dev/null +++ b/normalizer/normalizer-repo-tags/normalizer/manifest.json @@ -0,0 +1 @@ +{"enabled": 1} diff --git a/normalizer/normalizer-repo-tags/normalizer/normalizer.py b/normalizer/normalizer-repo-tags/normalizer/normalizer.py new file mode 100644 index 0000000000000000000000000000000000000000..be188aec379a4dbcea93a3e1298940c8a424a33f --- /dev/null +++ b/normalizer/normalizer-repo-tags/normalizer/normalizer.py @@ -0,0 +1,65 @@ +from ase import Atoms +from nomadrepo.parsers import Output +from numpy import array + +class normalizerRepo(Output): + + def __init__(self, filename, **kwargs): + Output.__init__(self, filename) + + # fill out i.e. backend.addValue unsing input Dict + # "repository_checksum", + # "repository_chemical_formula", + # "repository_parser_id", + # "repository_atomic_elements", + # "repository_basis_set_type", + # "repository_code_version", + # "repository_crystal_system", + # "repository_program_name", + # "repository_spacegroup_nr", + # "repository_system_type", + # "repository_xc_treatment" + # add more? + + filename_f = open(filename, 'r') + import json + inputDict = json.load(filename_f)[0] + filename_f.close() + + atom_symbols = inputDict['section_system.last']['atom_labels']['flatData'] + + ## Change these ## + simulation_cell = [50.0, 50.0, 50.0] + configuration_periodic_dimensions = [False, False, False] + #### + + atom_positions_flat = inputDict['section_system.last']['atom_positions']['flatData'] + atom_positions_shape = inputDict['section_system.last']['atom_positions']['shape'] + + atom_positions_list = [] + for atom_i in range(0, atom_positions_shape[0]): + atom_i_start = atom_i*atom_positions_shape[1] + atom_positions_list.append(atom_positions_flat[atom_i_start:atom_i_start+atom_positions_shape[1]]) + atom_positions = array(atom_positions_list) + + self.structures.append(Atoms(symbols = atom_symbols, + cell = simulation_cell, + positions = atom_positions, + pbc = configuration_periodic_dimensions)) + + self.info['energy'] = inputDict['energy_total.last'] + self.info['prog'] = inputDict['program_name'][0] + ' ' + inputDict['program_version'][0] + ## Need the path of mainly parsed file. + + from nomadrepo.parsers.LAB.LAB import ParsingContext + from nomadrepo.parsers.LAB.LAB import save_xcFunctional + context = ParsingContext() + self.electrons['type'] = context.toDict_bs_type()[inputDict['program_name'][0]] + save_xcFunctional(self, inputDict['XC_functional_name']) + + # "repository_xc_treatment" + + @staticmethod + def fingerprints(test_string, file=None): + # fake method + return False diff --git a/normalizer/normalizer-repo-tags/requirements.txt b/normalizer/normalizer-repo-tags/requirements.txt index c9e1328d858f914d1f13a892fcb6317e5479a9c9..477ad42e0c6693f5e0f918fb42e8d8a5d167e082 100755 --- a/normalizer/normalizer-repo-tags/requirements.txt +++ b/normalizer/normalizer-repo-tags/requirements.txt @@ -1 +1,3 @@ sqlalchemy == 1.0.6 +httplib2 +bcrypt diff --git a/normalizer/normalizer-repo-tags/setup_paths.py b/normalizer/normalizer-repo-tags/setup_paths.py index a683d3fbed711fce496825a2c0f1aa0a7d6cb43b..b3214e691ccc511cc774ab7a88e162af90e70edf 100644 --- a/normalizer/normalizer-repo-tags/setup_paths.py +++ b/normalizer/normalizer-repo-tags/setup_paths.py @@ -1,10 +1,14 @@ import sys, os, os.path baseDir = os.path.dirname(os.path.abspath(__file__)) commonDir = os.path.normpath(os.path.join(baseDir,"../../../../python-common/common/python")) -repoParserDir = os.path.normpath(os.path.join(baseDir,"NomadRepositoryParser/python/")) +repoParserDir = os.path.normpath(os.path.join(baseDir,"/u/jungho/myscratch/NomadRepositoryParser/python/")) +#repoParserCoreDir = os.path.normpath(os.path.join(baseDir,"NomadRepositoryParser/python/nomadrepo/core/")) if not commonDir in sys.path: sys.path.insert(0, commonDir) if not repoParserDir in sys.path: sys.path.insert(0, repoParserDir) + +#if not repoParserCoreDir in sys.path: +# sys.path.insert(0, repoParserCoreDir)