aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorBonfaceKilz2021-05-04 23:34:32 +0300
committerBonfaceKilz2021-05-05 12:26:04 +0300
commit453455b8bc6557c35ad279a208235f0b44aa251e (patch)
tree1646bb68e76b9d056943853c2da27910bf82d1af /wqflask/base
parent5e19a8a505dc7b8fa77fcc836892d1982c6ae36d (diff)
downloadgenenetwork2-453455b8bc6557c35ad279a208235f0b44aa251e.tar.gz
base: species: Rewrite TheSpecies class using a dataclass
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/species.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/wqflask/base/species.py b/wqflask/base/species.py
index 3ec7556d..3865f450 100644
--- a/wqflask/base/species.py
+++ b/wqflask/base/species.py
@@ -1,5 +1,7 @@
import collections
+from dataclasses import dataclass
+from typing import Optional, Dict
from flask import g
@@ -7,13 +9,18 @@ from utility.logger import getLogger
logger = getLogger(__name__)
+@dataclass
class TheSpecies:
- def __init__(self, dataset=None, species_name=None):
- if species_name != None:
- self.name = species_name
+ """Data related to species."""
+ dataset: Optional[Dict] = None
+ species_name: Optional[str] = None
+
+ def __post_init__(self):
+ if self.species_name is not None:
+ self.name = self.species_name
self.chromosomes = Chromosomes(species=self.name)
else:
- self.dataset = dataset
+ self.dataset = self.dataset
self.chromosomes = Chromosomes(dataset=self.dataset)