Mercurial > repos > muon-spectroscopy-computational-project > larch_criteria_report
annotate larch_criteria_report.py @ 0:aa9cb2b42741 draft default tip
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
author | muon-spectroscopy-computational-project |
---|---|
date | Tue, 14 Nov 2023 15:34:55 +0000 |
parents | |
children |
rev | line source |
---|---|
0
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
1 import csv |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
2 import json |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
3 import os |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
4 import sys |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
5 from typing import Iterable |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
6 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
7 import matplotlib.pyplot as plt |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
8 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
9 import numpy as np |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
10 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
11 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
12 def plot(variable: str, column: Iterable[float]): |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
13 variable_stripped = variable.strip() |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
14 path = f"plots/{variable_stripped}.png" |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
15 plt.figure(figsize=(8, 4)) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
16 plt.plot(column) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
17 plt.xlim((0, len(column))) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
18 ticks, _ = plt.xticks() |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
19 plt.xticks(np.array(ticks).astype("int")) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
20 plt.xlabel("Dataset number") |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
21 plt.ylabel(variable_stripped) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
22 plt.savefig(path, format="png") |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
23 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
24 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
25 def load(filepath: str) -> "list[list[str|float]]": |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
26 with open(filepath) as f: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
27 reader = csv.reader(f) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
28 header = next(reader) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
29 columns = [[h] for h in header] |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
30 for row in reader: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
31 for i, value in enumerate(row): |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
32 columns[i].append(float(value)) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
33 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
34 return columns |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
35 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
36 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
37 def parse_reports(input_data: str) -> "dict[str, list[float]]": |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
38 # Need to scrape variables from individual files |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
39 report_criteria = input_values["format"]["report_criteria"] |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
40 data = {c["variable"]: [] for c in report_criteria} |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
41 headers = list(data.keys()) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
42 with open("criteria_report.csv", "w") as f_out: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
43 writer = csv.writer(f_out) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
44 writer.writerow([f"{h:>12s}" for h in headers]) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
45 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
46 if os.path.isdir(input_data): |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
47 input_files = [ |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
48 os.path.join(input_data, f) for f in os.listdir(input_data) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
49 ] |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
50 input_files.sort() |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
51 else: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
52 input_files = input_data.split(",") |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
53 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
54 for input_file in input_files: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
55 row = parse_row(data, headers, input_file) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
56 writer.writerow(row) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
57 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
58 return data |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
59 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
60 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
61 def parse_row( |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
62 data: "dict[str, list[float]]", headers: "list[str]", input_file: str |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
63 ) -> "list[str]": |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
64 row = [None] * len(headers) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
65 with open(input_file) as f_in: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
66 line = f_in.readline() |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
67 while line: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
68 words = line.split() |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
69 try: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
70 variable = words[0] |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
71 value = words[2] |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
72 if variable in headers: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
73 row[headers.index(variable)] = f"{value:>12s}" |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
74 data[variable].append(float(value)) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
75 if all(row): |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
76 return row |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
77 except IndexError: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
78 # Not all lines will have potential variables/values |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
79 # so just pass |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
80 pass |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
81 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
82 line = f_in.readline() |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
83 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
84 # Only reach here if we run out of lines without finding a value for each |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
85 # variable |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
86 raise RuntimeError( |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
87 f"One or more criteria missing, was looking for {headers} but found " |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
88 f"{row}" |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
89 ) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
90 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
91 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
92 if __name__ == "__main__": |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
93 input_data = sys.argv[1] |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
94 input_values = json.load(open(sys.argv[2], "r", encoding="utf-8")) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
95 |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
96 if "report_criteria" in input_values["format"]: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
97 data = parse_reports(input_data) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
98 for variable, column in data.items(): |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
99 plot(variable, column) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
100 else: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
101 columns = load(input_data) |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
102 for column in columns: |
aa9cb2b42741
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_criteria_report commit 5be486890442dedfb327289d597e1c8110240735
muon-spectroscopy-computational-project
parents:
diff
changeset
|
103 plot(column[0], column[1:]) |