-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2023-07-20--sra-growth-cost.py
executable file
·75 lines (56 loc) · 1.64 KB
/
2023-07-20--sra-growth-cost.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
import datetime
costs = []
months = [
"Ignore",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
]
with open("Sequencing Cost - Data Table.tsv") as inf:
for line in inf:
line = line.removesuffix("\n")
bits = line.split("\t")
date, cost_per_mb, cost_per_genome = bits
if date == "Date":
continue
month_full, yy = date.split("-")
month_numeric = months.index(month_full)
yyyy = 2000 + int(yy)
costs.append((
datetime.date(year=yyyy,
month=month_numeric,
day=1),
float(cost_per_mb.removeprefix("$").replace(",", ""))))
def find_cost(year, month):
target_date = datetime.date(year=year, month=month, day=1)
best_cost = None
best_date = None
for candidate_date, cost in costs:
if (best_date is None or
abs((target_date - candidate_date).days) <
abs((target_date - best_date).days)):
best_cost = cost
best_date = candidate_date
return best_cost, best_date
with open("results-20230720-131657 - results-20230720-131657.tsv") as inf:
for line in inf:
line = line.removesuffix("\n")
bits = line.split("\t")
year, month, mbases, *_ = bits
if year == "Year":
continue
year = int(year)
month = int(month)
mbases = int(mbases)
cost, reference_date = find_cost(year, month)
print(year, month, mbases, cost, reference_date, sep="\t")