Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
parser-elk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nomad-lab
parser-elk
Commits
d422d711
Commit
d422d711
authored
Aug 02, 2016
by
Mohamed, Fawzi Roberto (fawzi)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first skeleton for the elk parser
parent
67c62890
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
186 additions
and
0 deletions
+186
-0
.gitignore
.gitignore
+54
-0
parser/parser-elk/parser_elk.py
parser/parser-elk/parser_elk.py
+69
-0
parser/parser-elk/setup_paths.py
parser/parser-elk/setup_paths.py
+6
-0
src/main/scala/eu/nomad_lab/parsers/ElkParser.scala
src/main/scala/eu/nomad_lab/parsers/ElkParser.scala
+42
-0
src/test/scala/eu/nomad_lab/parsers/ElkParserSpec.scala
src/test/scala/eu/nomad_lab/parsers/ElkParserSpec.scala
+14
-0
test/examples/README.md
test/examples/README.md
+1
-0
No files found.
.gitignore
0 → 100644
View file @
d422d711
# use glob syntax.
syntax: glob
*.ser
*.class
*~
*.bak
#*.off
*.old
*.pyc
*.bk
*.swp
.DS_Store
# logging files
detailed.log
# eclipse conf file
.settings
.classpath
.project
.manager
.scala_dependencies
# idea
.idea
*.iml
# building
target
build
null
tmp*
temp*
dist
test-output
build.log
# other scm
.svn
.CVS
.hg*
# switch to regexp syntax.
# syntax: regexp
# ^\.pc/
#SHITTY output not in target directory
build.log
#emacs TAGS
TAGS
lib/
env/
parser/parser-elk/parser_elk.py
0 → 100644
View file @
d422d711
from
builtins
import
object
import
setup_paths
from
nomadcore.simple_parser
import
mainFunction
,
AncillaryParser
,
CachingLevel
from
nomadcore.simple_parser
import
SimpleMatcher
as
SM
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
import
os
,
sys
,
json
class
ElkContext
(
object
):
"""context for elk parser"""
def
__init__
(
self
):
self
.
parser
=
None
def
initialize_values
(
self
):
"""allows to reset values if the same superContext is used to parse different files"""
self
.
metaInfoEnv
=
self
.
parser
.
parserBuilder
.
metaInfoEnv
def
startedParsing
(
self
,
path
,
parser
):
"""called when parsing starts"""
self
.
parser
=
parser
# allows to reset values if the same superContext is used to parse different files
self
.
initialize_values
()
# description of the input
mainFileDescription
=
SM
(
name
=
'root'
,
weak
=
True
,
startReStr
=
""
,
subMatchers
=
[
SM
(
name
=
'newRun'
,
startReStr
=
r"\s*:LABEL[0-9]+: using WIEN2k_(?:[0-9.]+) \(Release (?:[0-9/.]+)\) in "
,
repeats
=
True
,
required
=
True
,
forwardMatch
=
True
,
sections
=
[
'section_run'
,
'section_method'
,
'section_system'
,
'section_single_configuration_calculation'
],
subMatchers
=
[
SM
(
name
=
'header'
,
startReStr
=
r"\s*:LABEL[0-9]+: using WIEN2k_(?P<x_wien2k_version>[0-9.]+) \(Release (?P<x_wien2k_release_date>[0-9/.]+)\) in "
,
sections
=
[
"x_wien2k_header"
],
fixedStartValues
=
{
'program_name'
:
'WIEN2k'
,
'program_basis_set_type'
:
'(L)APW+lo'
}
),
SM
(
name
=
"scf iteration"
,
startReStr
=
r"\s*:ITE(?P<x_wien2k_iteration_number>[0-9]+):\s*[0-9]*. ITERATION"
,
sections
=
[
"section_scf_iteration"
],
repeats
=
True
,
subMatchers
=
[
SM
(
r":NATO :\s*(?P<x_wien2k_number_of_independent_atoms>[0-9]+)INDEPENDENT AND\s*(?P<x_wien2k_total_atoms>[0-9]+)\s*TOTAL ATOMS IN UNITCELL"
),
SM
(
r"\s*SUBSTANCE: (?P<x_wien2k_system_name>.*)"
),
SM
(
r":POT\s*:\s*POTENTIAL OPTION\s*(?P<x_wien2k_potential_option>[0-9]+)"
),
SM
(
r":VOL\s*:\s*UNIT CELL VOLUME\s*=\s*(?P<x_wien2k_unit_cell_volume__angstrom3>[0-9.]+)"
)
]
)
]
)
])
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
parserInfo
=
{
"name"
:
"Elk"
}
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"../../../../nomad-meta-info/meta_info/nomad_meta_info/elk.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
if
__name__
==
"__main__"
:
superContext
=
ElkContext
()
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
parserInfo
,
superContext
=
superContext
)
parser/parser-elk/setup_paths.py
0 → 100644
View file @
d422d711
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"
))
if
not
commonDir
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
commonDir
)
src/main/scala/eu/nomad_lab/parsers/ElkParser.scala
0 → 100644
View file @
d422d711
package
eu.nomad_lab.parsers
import
eu.nomad_lab
import
eu.nomad_lab.DefaultPythonInterpreter
import
org.
{
json4s
=>
jn
}
import
eu.
{
nomad_lab
=>
lab
}
import
scala.collection.breakOut
object
ElkParser
extends
SimpleExternalParserGenerator
(
name
=
"ElkParser"
,
parserInfo
=
jn
.
JObject
(
(
"name"
->
jn
.
JString
(
"Elk"
))
::
(
"parserId"
->
jn
.
JString
(
"Elk"
+
lab
.
ElkVersionInfo
.
version
))
::
(
"versionInfo"
->
jn
.
JObject
(
(
"nomadCoreVersion"
->
jn
.
JObject
(
lab
.
NomadCoreVersionInfo
.
toMap
.
map
{
case
(
k
,
v
)
=>
k
->
jn
.
JString
(
v
.
toString
)
}(
breakOut
)
:
List
[(
String
,
jn.JString
)]))
::
(
lab
.
ElkVersionInfo
.
toMap
.
map
{
case
(
key
,
value
)
=>
(
key
->
jn
.
JString
(
value
.
toString
))
}(
breakOut
)
:
List
[(
String
,
jn.JString
)])
))
::
Nil
),
mainFileTypes
=
Seq
(
"text/.*"
),
mainFileRe
=
""":LABEL[0-9]+: using WIEN2k_(?<version>[0-9.]+) \(Release (?<release>[0-9/.]+)\) in """
.
r
,
cmd
=
Seq
(
DefaultPythonInterpreter
.
pythonExe
(),
"${envDir}/parsers/elk/parser/parser-elk/parser_elk.py"
,
"--uri"
,
"${mainFileUri}"
,
"${mainFilePath}"
),
resList
=
Seq
(
"parser-elk/parser_elk.py"
,
"parser-elk/setup_paths.py"
,
"nomad_meta_info/public.nomadmetainfo.json"
,
"nomad_meta_info/common.nomadmetainfo.json"
,
"nomad_meta_info/meta_types.nomadmetainfo.json"
,
"nomad_meta_info/elk.nomadmetainfo.json"
)
++
DefaultPythonInterpreter
.
commonFiles
(),
dirMap
=
Map
(
"parser-elk"
->
"parsers/elk/parser/parser-elk"
,
"nomad_meta_info"
->
"nomad-meta-info/meta_info/nomad_meta_info"
,
"python"
->
"python-common/common/python/nomadcore"
)
++
DefaultPythonInterpreter
.
commonDirMapping
(),
metaInfoEnv
=
Some
(
lab
.
meta
.
KnownMetaInfoEnvs
.
elk
)
)
src/test/scala/eu/nomad_lab/parsers/ElkParserSpec.scala
0 → 100644
View file @
d422d711
package
eu.nomad_lab.parsers
import
org.specs2.mutable.Specification
object
ElkTests
extends
Specification
{
"ElkParserTest"
>>
{
"test with json-events"
>>
{
ParserRun
.
parse
(
Wien2kParser
,
"parsers/elk/test/examples/ok/ok.scf"
,
"json-events"
)
must_==
ParseResult
.
ParseSuccess
}
"test with json"
>>
{
ParserRun
.
parse
(
Wien2kParser
,
"parsers/elk/test/examples/ok/ok.scf"
,
"json"
)
must_==
ParseResult
.
ParseSuccess
}
}
}
test/examples/README.md
0 → 100644
View file @
d422d711
sample files to test the parser
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment