FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
solventmapcreator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yusuf Hamied Department of Chemistry
Hunter Group
SSIPtools
SSIMPLEapps
solventmapcreator
Commits
fd1e0e60
Commit
fd1e0e60
authored
7 years ago
by
M.D. Driver
Browse files
Options
Downloads
Patches
Plain Diff
started work on reader for solvent file.
parent
9570676d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
solventmapcreator/io/solventxmlreader.py
+74
-0
74 additions, 0 deletions
solventmapcreator/io/solventxmlreader.py
with
74 additions
and
0 deletions
solventmapcreator/io/solventxmlreader.py
0 → 100644
+
74
−
0
View file @
fd1e0e60
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script for reading in the solvent XML, and to extract the concentration of
each molecule in a solvent mixture, and the number of SSIPs corresponding to
each molecule.
This allows the calculation of the fractional occupancy of the phase.
@author: mark
"""
import
logging
from
lxml
import
etree
logging
.
basicConfig
()
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
.
setLevel
(
logging
.
WARN
)
PHASE_NAMESPACE_DICT
=
{
"
phase
"
:
"
http://www-hunter.ch.cam.ac.uk/PhaseSchema
"
,
"
ssip
"
:
"
http://www-hunter.ch.cam.ac.uk/SSIP
"
,
'
cml
'
:
'
http://www.xml-cml.org/schema
'
}
def
calculate_freactional_occupancy_for_solvent
(
solvent_element
):
"""
"""
def
calculate_fractional_occupancy_contribution
(
molecule_element
):
"""
"""
def
get_concentration_value
(
molecule_element
):
"""
This extracts the concentration.
"""
xpath_expression
=
"
phase:Concentration
"
concentration_element_list
=
molecule_element
.
xpath
(
xpath_expression
,
namespaces
=
PHASE_NAMESPACE_DICT
)
if
len
(
concentration_element_list
)
==
1
:
return
float
(
concentration_element_list
[
0
].
text
)
else
:
LOGGER
.
debug
(
"
len:
"
)
LOGGER
.
debug
(
len
(
solvent_element_list
))
LOGGER
.
debug
(
solvent_element_list
)
raise
ValueError
(
"
Wrong number of Concentration Elements.
"
)
def
get_number_of_ssips_in_molecule
(
molecule_element
):
"""
This extracts the SSIP elements and return the number.
"""
xpath_expression
=
"
ssip:SSIP
"
ssip_element_list
=
molecule_element
.
xpath
(
xpath_expression
,
namespaces
=
PHASE_NAMESPACE_DICT
)
return
len
(
ssip_element_list
)
def
get_solvent_element_by_id
(
solvent_list_element
,
solvent_id
):
"""
This extracts the solvent element from the information
"""
xpath_expression
=
create_solvent_xpath_expression
(
solvent_id
)
solvent_element_list
=
solvent_list_element
.
xpath
(
xpath_expression
,
namespaces
=
PHASE_NAMESPACE_DICT
)
if
len
(
solvent_element_list
)
==
1
:
return
solvent_element_list
[
0
]
else
:
LOGGER
.
debug
(
"
len:
"
)
LOGGER
.
debug
(
len
(
solvent_element_list
))
LOGGER
.
debug
(
solvent_element_list
)
raise
ValueError
(
"
Wrong number of Solvent Elements.
"
)
def
create_solvent_xpath_expression
(
solvent_id
):
"""
This creates the xpath expression to extract the solvent Element based
on solventID.
"""
return
"
phase:Solvent[@phase:solventID={:s}]
"
.
format
(
solvent_id
)
def
read_element_tree
(
filename
):
"""
This reads in an xml file to an element tree.
"""
return
etree
.
parse
(
filename
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment