-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefinitions.py
58 lines (49 loc) · 2.33 KB
/
definitions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import json
import os
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
REFERENCE_DATA_DIR = os.path.join(ROOT_DIR, "reference_data")
USER_DATA_DIR = os.path.join(ROOT_DIR, "user_data")
ASSETS_DIR = os.path.join(ROOT_DIR, "assets")
NF_NCOV_VOC_DIR = os.path.join(ROOT_DIR, "nf-ncov-voc")
GENOME_CONFIG_PATH = os.path.join(ASSETS_DIR, "genome_config.json")
DEFAULT_REFERENCE_HIDDEN_STRAINS_PATH = \
os.path.join(ASSETS_DIR, "default_reference_hidden_strains.json")
DEFAULT_REFERENCE_STRAIN_ORDER_PATH = \
os.path.join(ASSETS_DIR, "default_reference_strain_order.json")
REFERENCE_SURVEILLANCE_REPORTS_DIR = \
os.path.join(ROOT_DIR, "reference_surveillance_reports")
USER_SURVEILLANCE_REPORTS_DIR = \
os.path.join(ROOT_DIR, "user_surveillance_reports")
with open(GENOME_CONFIG_PATH) as fp:
GENOME_CONFIG_DICT = json.load(fp)
GENOME_LEN = GENOME_CONFIG_DICT["Src"]["end"]
gene_bar_components = \
[e for e in GENOME_CONFIG_DICT if GENOME_CONFIG_DICT[e]["type"]
in ["CDS", "five_prime_UTR", "three_prime_UTR", "INTERGENIC"]]
GENE_COLORS_DICT = \
{k: GENOME_CONFIG_DICT[k]["color"] for k in gene_bar_components}
GENE_POSITIONS_DICT = \
{k: {x: GENOME_CONFIG_DICT[k][x] for x in ["start", "end"]}
for k in gene_bar_components[:-1]}
first_component = min(GENE_POSITIONS_DICT,
key=lambda k: GENE_POSITIONS_DICT[k]["start"])
if GENE_POSITIONS_DICT[first_component]["start"] == 1:
FIRST_REGION = [1, GENE_POSITIONS_DICT[first_component]["end"]]
else:
FIRST_REGION = [1, GENE_POSITIONS_DICT[first_component]["start"]-1]
last_component = max(GENE_POSITIONS_DICT,
key=lambda k: GENE_POSITIONS_DICT[k]["end"])
if GENE_POSITIONS_DICT[last_component]["end"] == GENOME_LEN:
LAST_REGION = [GENE_POSITIONS_DICT[last_component]["start"], GENOME_LEN]
else:
LAST_REGION = [GENE_POSITIONS_DICT[last_component]["end"]+1, GENOME_LEN]
nsp_bar_components = \
[e for e in GENOME_CONFIG_DICT
if GENOME_CONFIG_DICT[e]["type"] == "mature_protein_region_of_CDS"]
NSP_POSITIONS_DICT = \
{k: {x: GENOME_CONFIG_DICT[k][x] for x in ["start", "end"]}
for k in nsp_bar_components}
with open(DEFAULT_REFERENCE_HIDDEN_STRAINS_PATH) as fp:
DEFAULT_REFERENCE_HIDDEN_STRAINS = json.load(fp)
with open(DEFAULT_REFERENCE_STRAIN_ORDER_PATH) as fp:
DEFAULT_REFERENCE_STRAIN_ORDER = json.load(fp)