Commit 616aed25 authored by htyao's avatar htyao
Browse files

Dump and load parameters in yaml format

parent 64c0abf1
# 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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment