Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-gpaw
Commits
56354bd3
Commit
56354bd3
authored
Mar 20, 2020
by
Markus Scheidgen
Browse files
Parser optimizations.
parent
a3f52f62
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/scala/eu/nomad_lab/parsers/GpawParser.scala
deleted
100644 → 0
View file @
a3f52f62
/*
* Copyright 2015-2018 Mikkel Strange, Fawzi Mohamed, Ankit Kariryaa, Ask Hjorth Larsen, Jens Jørgen Mortensen
*
* 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
org.
{
json4s
=>
jn
}
import
scala.collection.breakOut
object
GpawParser
extends
SimpleExternalParserGenerator
(
name
=
"GpawParser"
,
parserInfo
=
jn
.
JObject
(
(
"name"
->
jn
.
JString
(
"GpawParser"
))
::
(
"parserId"
->
jn
.
JString
(
"GpawParser"
+
lab
.
GpawVersionInfo
.
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
.
GpawVersionInfo
.
toMap
.
map
{
case
(
key
,
value
)
=>
(
key
->
jn
.
JString
(
value
.
toString
))
}(
breakOut
)
:
List
[(
String
,
jn.JString
)])
))
::
Nil
),
mainFileTypes
=
Seq
(
"application/x-gtar"
),
mainFileRe
=
""
.
r
,
cmd
=
Seq
(
lab
.
DefaultPythonInterpreter
.
pythonExe
(),
"${envDir}/parsers/gpaw/parser/parser-gpaw/parser.py"
,
"${mainFilePath}"
),
resList
=
Seq
(
"parser-gpaw/parser.py"
,
"parser-gpaw/tar.py"
,
"parser-gpaw/versions.py"
,
"parser-gpaw/libxc_names.py"
,
"parser-gpaw/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/gpaw.nomadmetainfo.json"
)
++
lab
.
DefaultPythonInterpreter
.
commonFiles
(),
dirMap
=
Map
(
"parser-gpaw"
->
"parsers/gpaw/parser/parser-gpaw"
,
"nomad_meta_info"
->
"nomad-meta-info/meta_info/nomad_meta_info"
)
++
lab
.
DefaultPythonInterpreter
.
commonDirMapping
()
)
{
override
def
isMainFile
(
filePath
:
String
,
bytePrefix
:
Array
[
Byte
],
stringPrefix
:
Option
[
String
])
:
Option
[
ParserMatch
]
=
{
if
(
filePath
.
endsWith
(
".gpw"
))
Some
(
ParserMatch
(
mainFileMatchPriority
,
mainFileMatchWeak
))
else
None
}
}
src/main/scala/eu/nomad_lab/parsers/GpawParser2.scala
deleted
100644 → 0
View file @
a3f52f62
/*
* Copyright 2015-2018 Mikkel Strange, Fawzi Mohamed, Ankit Kariryaa, Ask Hjorth Larsen, Jens Jørgen Mortensen
*
* 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
org.
{
json4s
=>
jn
}
import
scala.collection.breakOut
object
GpawParser2
extends
SimpleExternalParserGenerator
(
name
=
"GpawParser2"
,
parserInfo
=
jn
.
JObject
(
(
"name"
->
jn
.
JString
(
"GpawParser2"
))
::
(
"parserId"
->
jn
.
JString
(
"GpawParser2"
+
lab
.
GpawVersionInfo
.
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
.
GpawVersionInfo
.
toMap
.
map
{
case
(
key
,
value
)
=>
(
key
->
jn
.
JString
(
value
.
toString
))
}(
breakOut
)
:
List
[(
String
,
jn.JString
)])
))
::
Nil
),
// output file is binary and first 16 bytes is a string containing: 'GPAW'
// In python the check is like this
// is_gpw_file = 'GPAW' in str(open('file.gpw', 'rb').read(16))
// How do we do this in scala?
mainFileTypes
=
Seq
(
"application/x-bin"
),
mainFileRe
=
"- of UlmGPAW|AFFormatGPAW"
.
r
,
cmd
=
Seq
(
lab
.
DefaultPythonInterpreter
.
pythonExe
(),
"${envDir}/parsers/gpaw/parser/parser-gpaw/parser2.py"
,
"${mainFilePath}"
),
resList
=
Seq
(
"parser-gpaw/parser2.py"
,
"parser-gpaw/default_parameters.py"
,
"parser-gpaw/libxc_names.py"
,
"parser-gpaw/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/gpaw.nomadmetainfo.json"
)
++
lab
.
DefaultPythonInterpreter
.
commonFiles
(),
dirMap
=
Map
(
"parser-gpaw"
->
"parsers/gpaw/parser/parser-gpaw"
,
"nomad_meta_info"
->
"nomad-meta-info/meta_info/nomad_meta_info"
)
++
lab
.
DefaultPythonInterpreter
.
commonDirMapping
()
)
{
override
def
isMainFile
(
filePath
:
String
,
bytePrefix
:
Array
[
Byte
],
stringPrefix
:
Option
[
String
])
:
Option
[
ParserMatch
]
=
{
if
(
filePath
.
endsWith
(
".gpw"
))
Some
(
ParserMatch
(
mainFileMatchPriority
,
mainFileMatchWeak
))
else
None
}
}
src/test/scala/eu/nomad_lab/parsers/GpawParserSpec.scala
deleted
100644 → 0
View file @
a3f52f62
/*
* Copyright 2015-2018 Mikkel Strange, Fawzi Mohamed, Ankit Kariryaa, Ask Hjorth Larsen, Jens Jørgen Mortensen
*
* 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
GpawParserSpec
extends
Specification
{
"GpawParserTest"
>>
{
"H2 test with json-events"
>>
{
ParserRun
.
parse
(
GpawParser
,
"parsers/gpaw/test/examples/H2.gpw"
,
"json-events"
)
must_==
ParseResult
.
ParseSuccess
}
"H2 test with json"
>>
{
ParserRun
.
parse
(
GpawParser
,
"parsers/gpaw/test/examples/H2.gpw"
,
"json"
)
must_==
ParseResult
.
ParseSuccess
}
"Fe2 test with json-events"
>>
{
ParserRun
.
parse
(
GpawParser
,
"parsers/gpaw/test/examples/Fe2.gpw"
,
"json-events"
)
must_==
ParseResult
.
ParseSuccess
}
"Fe2 test with json"
>>
{
ParserRun
.
parse
(
GpawParser
,
"parsers/gpaw/test/examples/Fe2.gpw"
,
"json"
)
must_==
ParseResult
.
ParseSuccess
}
"Au test with json-events"
>>
{
ParserRun
.
parse
(
GpawParser2
,
"parsers/gpaw/test/examples/Au.fcc.ulm.gpw"
,
"json-events"
)
must_==
ParseResult
.
ParseSuccess
}
"Au test with json"
>>
{
ParserRun
.
parse
(
GpawParser2
,
"parsers/gpaw/test/examples/Au.fcc.ulm.gpw"
,
"json"
)
must_==
ParseResult
.
ParseSuccess
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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