Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AMIBIO
VARNA-api
Commits
616aed25
Commit
616aed25
authored
Jan 01, 2022
by
htyao
Browse files
Dump and load parameters in yaml format
parent
64c0abf1
Changes
1
Hide whitespace changes
Inline
Side-by-side
param.py
View file @
616aed25
# Varna Parameter Setting
from
numbers
import
Real
import
yaml
from
colour
import
Color
# Define yaml-related function for Color object
def
color_representer
(
dumper
,
data
):
return
dumper
.
represent_scalar
(
'!color'
,
data
.
get_hex_l
())
def
color_constructor
(
loader
,
node
):
value
=
loader
.
construct_scalar
(
node
)
return
Color
(
value
)
yaml
.
add_representer
(
Color
,
color_representer
)
yaml
.
add_constructor
(
'!color'
,
color_constructor
)
# HEX = re.compile('^#(?:[0-9a-fA-F]{3}){1,2}$')
#################
...
...
@@ -401,7 +415,6 @@ class VarnaConfig:
except
TypeError
as
e
:
print
(
e
)
def
get_params
(
self
,
complete
=
False
):
"""Get parameters with value in dictionary
By default, only the parameters with value different than the default are returned.
...
...
@@ -452,6 +465,16 @@ class VarnaConfig:
cmd
.
append
(
str
(
val
))
return
cmd
def
dump_param
(
self
,
filename
):
with
open
(
filename
,
'w'
)
as
f
:
yaml
.
dump
(
self
.
get_params
(
complete
=
True
),
f
)
def
load_param
(
self
,
filename
):
with
open
(
filename
,
'r'
)
as
f
:
self
.
update
(
**
yaml
.
load
(
f
,
Loader
=
yaml
.
Loader
))
# def set_zoom_level(self, level:float):
# """Defines the level of zoom and zoom increment used to display the RNA within this panel"""
# self.params['zoom'] = level
...
...
Write
Preview
Supports
Markdown
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