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-asap
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nomad-lab
parser-asap
Commits
dd555aad
Commit
dd555aad
authored
May 04, 2020
by
Markus Scheidgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more parsers to NOMAD
parent
f240bd2d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
138 deletions
+113
-138
.gitignore
.gitignore
+2
-0
asapparser/__init__.py
asapparser/__init__.py
+1
-0
asapparser/constraint_conversion.py
asapparser/constraint_conversion.py
+0
-0
asapparser/metainfo/__init__.py
asapparser/metainfo/__init__.py
+13
-0
asapparser/metainfo/asap.py
asapparser/metainfo/asap.py
+54
-0
asapparser/parser_asap.py
asapparser/parser_asap.py
+20
-22
setup.py
setup.py
+23
-9
src/main/scala/eu/nomad_lab/parsers/AsapParser.scala
src/main/scala/eu/nomad_lab/parsers/AsapParser.scala
+0
-65
src/test/scala/eu/nomad_lab/parsers/AsapParserSpec.scala
src/test/scala/eu/nomad_lab/parsers/AsapParserSpec.scala
+0
-42
No files found.
.gitignore
View file @
dd555aad
...
...
@@ -52,3 +52,5 @@ TAGS
lib/
env/
*.egg-info/
\ No newline at end of file
asapparser/__init__.py
0 → 100644
View file @
dd555aad
from
.parser_asap
import
AsapParser
\ No newline at end of file
parser/parser-asap
/constraint_conversion.py
→
asapparser
/constraint_conversion.py
View file @
dd555aad
File moved
asapparser/metainfo/__init__.py
0 → 100644
View file @
dd555aad
import
sys
from
nomad.metainfo
import
Environment
from
nomad.metainfo.legacy
import
LegacyMetainfoEnvironment
import
asapparser.metainfo.asap
import
nomad.datamodel.metainfo.common
import
nomad.datamodel.metainfo.public
import
nomad.datamodel.metainfo.general
m_env
=
LegacyMetainfoEnvironment
()
m_env
.
m_add_sub_section
(
Environment
.
packages
,
sys
.
modules
[
'asapparser.metainfo.asap'
].
m_package
)
# type: ignore
m_env
.
m_add_sub_section
(
Environment
.
packages
,
sys
.
modules
[
'nomad.datamodel.metainfo.common'
].
m_package
)
# type: ignore
m_env
.
m_add_sub_section
(
Environment
.
packages
,
sys
.
modules
[
'nomad.datamodel.metainfo.public'
].
m_package
)
# type: ignore
m_env
.
m_add_sub_section
(
Environment
.
packages
,
sys
.
modules
[
'nomad.datamodel.metainfo.general'
].
m_package
)
# type: ignore
asapparser/metainfo/asap.py
0 → 100644
View file @
dd555aad
import
numpy
as
np
# pylint: disable=unused-import
import
typing
# pylint: disable=unused-import
from
nomad.metainfo
import
(
# pylint: disable=unused-import
MSection
,
MCategory
,
Category
,
Package
,
Quantity
,
Section
,
SubSection
,
SectionProxy
,
Reference
)
from
nomad.metainfo.legacy
import
LegacyDefinition
from
nomad.datamodel.metainfo
import
public
m_package
=
Package
(
name
=
'asap_nomadmetainfo_json'
,
description
=
'None'
,
a_legacy
=
LegacyDefinition
(
name
=
'asap.nomadmetainfo.json'
))
class
section_sampling_method
(
public
.
section_sampling_method
):
m_def
=
Section
(
validate
=
False
,
extends_base_section
=
True
,
a_legacy
=
LegacyDefinition
(
name
=
'section_sampling_method'
))
x_asap_langevin_friction
=
Quantity
(
type
=
np
.
dtype
(
np
.
float64
),
shape
=
[],
description
=
'''
Friction coeffient used in Langevin dynamics
'''
,
a_legacy
=
LegacyDefinition
(
name
=
'x_asap_langevin_friction'
))
x_asap_maxstep
=
Quantity
(
type
=
np
.
dtype
(
np
.
float64
),
shape
=
[],
description
=
'''
Maxstep in Angstrom for geometry optimization
'''
,
a_legacy
=
LegacyDefinition
(
name
=
'x_asap_maxstep'
))
x_asap_temperature
=
Quantity
(
type
=
np
.
dtype
(
np
.
float64
),
shape
=
[],
description
=
'''
Temperature used in molecular-dynamics
'''
,
a_legacy
=
LegacyDefinition
(
name
=
'x_asap_temperature'
))
x_asap_timestep
=
Quantity
(
type
=
np
.
dtype
(
np
.
float64
),
shape
=
[],
description
=
'''
Timestep in molecular dynamics
'''
,
a_legacy
=
LegacyDefinition
(
name
=
'x_asap_timestep'
))
m_package
.
__init_metainfo__
()
parser/parser-asap
/parser_asap.py
→
asapparser
/parser_asap.py
View file @
dd555aad
# Copyright 2016-2018 Mikkel Strange, Fawzi Mohamed
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
...
@@ -18,11 +18,9 @@ from contextlib import contextmanager
import
numpy
as
np
from
ase.io.trajectory
import
Trajectory
from
ase
import
units
import
setup_paths
from
constraint_conversion
import
get_nomad_name
from
.constraint_conversion
import
get_nomad_name
from
nomadcore.unit_conversion.unit_conversion
import
convert_unit
as
cu
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
import
logging
@
contextmanager
...
...
@@ -39,18 +37,9 @@ def c(value, unit=None):
parser_info
=
{
"name"
:
"parser_asap"
,
"version"
:
"1.0"
}
path
=
'../../../../nomad-meta-info/meta_info/nomad_meta_info/'
+
\
'asap.nomadmetainfo.json'
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
path
))
metaInfoEnv
,
warns
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
def
parse
(
filename
):
def
parse
(
filename
,
backend
):
t
=
Trajectory
(
filename
,
'r'
)
# some sanity checks
if
hasattr
(
t
.
backend
,
'calculator'
):
...
...
@@ -62,7 +51,7 @@ def parse(filename):
else
:
ds
=
{}
p
=
JsonParseEventsWriterBackend
(
metaInfoEnv
)
p
=
backend
o
=
open_section
p
.
startedParsingSession
(
filename
,
parser_info
)
with
o
(
p
,
'section_run'
):
...
...
@@ -159,7 +148,16 @@ def parse(filename):
p
.
finishedParsingSession
(
"ParseSuccess"
,
None
)
if
__name__
==
'__main__'
:
import
sys
filename
=
sys
.
argv
[
1
]
parse
(
filename
)
class
AsapParser
():
""" A proper class envolop for running this parser from within python. """
def
__init__
(
self
,
backend
,
**
kwargs
):
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
logging
.
info
(
'asap parser started'
)
logging
.
getLogger
(
'nomadcore'
).
setLevel
(
logging
.
WARNING
)
backend
=
self
.
backend_factory
(
"asap.nomadmetainfo.json"
)
parserInfo
=
parser_info
parse
(
mainfile
,
backend
)
return
backend
\ No newline at end of file
parser/parser-asap/setup_paths
.py
→
setup
.py
View file @
dd555aad
# Copyright 201
6-2018 Mikkel Strange, Fawzi Mohamed
#
# Copyright 201
5-2018
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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"
))
from
setuptools
import
setup
,
find_packages
if
not
commonDir
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
commonDir
)
def
main
():
setup
(
name
=
'asapparser'
,
version
=
'0.1'
,
description
=
'NOMAD parser implementation for asap.'
,
license
=
'APACHE 2.0'
,
package_dir
=
{
''
:
'./'
},
packages
=
find_packages
(),
install_requires
=
[
'nomadcore'
,
'nomad'
],
)
if
__name__
==
'__main__'
:
main
()
src/main/scala/eu/nomad_lab/parsers/AsapParser.scala
deleted
100644 → 0
View file @
f240bd2d
/*
* Copyright 2016-2018 Mikkel Strange, Fawzi Mohamed
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
eu.nomad_lab.parsers
import
eu.
{
nomad_lab
=>
lab
}
import
eu.nomad_lab.DefaultPythonInterpreter
import
org.
{
json4s
=>
jn
}
import
scala.collection.breakOut
import
java.nio.charset.StandardCharsets
object
AsapParser
extends
SimpleExternalParserGenerator
(
name
=
"AsapParser"
,
parserInfo
=
jn
.
JObject
(
(
"name"
->
jn
.
JString
(
"AsapParser"
))
::
(
"parserId"
->
jn
.
JString
(
"AsapParser"
+
lab
.
AsapVersionInfo
.
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
.
AsapVersionInfo
.
toMap
.
map
{
case
(
key
,
value
)
=>
(
key
->
jn
.
JString
(
value
.
toString
))
}(
breakOut
)
:
List
[(
String
,
jn.JString
)])
))
::
Nil
),
mainFileTypes
=
Seq
(
"application/octet-stream"
),
cmd
=
Seq
(
DefaultPythonInterpreter
.
pythonExe
(),
"${envDir}/parsers/asap/parser/parser-asap/parser_asap.py"
,
"${mainFilePath}"
),
mainFileRe
=
""
.
r
,
resList
=
Seq
(
"parser-asap/setup_paths.py"
,
"parser-asap/parser_asap.py"
,
"parser-asap/constraint_conversion.py"
,
"nomad_meta_info/public.nomadmetainfo.json"
,
"nomad_meta_info/common.nomadmetainfo.json"
,
"nomad_meta_info/meta_types.nomadmetainfo.json"
,
"nomad_meta_info/asap.nomadmetainfo.json"
)
++
DefaultPythonInterpreter
.
commonFiles
(),
dirMap
=
Map
(
"parser-asap"
->
"parsers/asap/parser/parser-asap"
,
"nomad_meta_info"
->
"nomad-meta-info/meta_info/nomad_meta_info"
)
++
DefaultPythonInterpreter
.
commonDirMapping
(),
metaInfoEnv
=
Some
(
lab
.
meta
.
KnownMetaInfoEnvs
.
asap
)
)
{
override
def
isMainFile
(
filePath
:
String
,
bytePrefix
:
Array
[
Byte
],
stringPrefix
:
Option
[
String
])
:
Option
[
ParserMatch
]
=
{
if
(
bytePrefix
.
startsWith
(
"AFFormatASE-Trajectory"
.
getBytes
(
StandardCharsets
.
US_ASCII
)))
Some
(
ParserMatch
(
mainFileMatchPriority
,
mainFileMatchWeak
))
else
None
}
}
src/test/scala/eu/nomad_lab/parsers/AsapParserSpec.scala
deleted
100644 → 0
View file @
f240bd2d
/*
* Copyright 2016-2018 Mikkel Strange, Fawzi Mohamed
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
eu.nomad_lab.parsers
import
org.specs2.mutable.Specification
object
AsapParserSpec
extends
Specification
{
"AsapParserTest"
>>
{
"test moldyn1 with json-events"
>>
{
ParserRun
.
parse
(
AsapParser
,
"parsers/asap/test/examples/moldyn1.traj"
,
"json-events"
)
must_==
ParseResult
.
ParseSuccess
}
"test moldyn1 with json"
>>
{
ParserRun
.
parse
(
AsapParser
,
"parsers/asap/test/examples/moldyn1.traj"
,
"json"
)
must_==
ParseResult
.
ParseSuccess
}
"test moldyn2 with json-events"
>>
{
ParserRun
.
parse
(
AsapParser
,
"parsers/asap/test/examples/moldyn2.traj"
,
"json-events"
)
must_==
ParseResult
.
ParseSuccess
}
"test moldyn2 with json"
>>
{
ParserRun
.
parse
(
AsapParser
,
"parsers/asap/test/examples/moldyn2.traj"
,
"json"
)
must_==
ParseResult
.
ParseSuccess
}
"test geo_opt1 with json-events"
>>
{
ParserRun
.
parse
(
AsapParser
,
"parsers/asap/test/examples/geo_opt1.traj"
,
"json-events"
)
must_==
ParseResult
.
ParseSuccess
}
"test geo_opt1 with json"
>>
{
ParserRun
.
parse
(
AsapParser
,
"parsers/asap/test/examples/geo_opt1.traj"
,
"json"
)
must_==
ParseResult
.
ParseSuccess
}
}
}
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