pytheas1 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. pytheas1/__init__.py +10 -0
  2. pytheas1/__main__.py +5 -0
  3. pytheas1/_compat.py +48 -0
  4. pytheas1/cli.py +153 -0
  5. pytheas1/data/Charge_tables/QTOF/charges_MS1.txt +21 -0
  6. pytheas1/data/Charge_tables/QTOF/charges_MS2.txt +21 -0
  7. pytheas1/data/Charge_tables/QTOF_and_other_spectrometers/charges_MS1.txt +21 -0
  8. pytheas1/data/Charge_tables/QTOF_and_other_spectrometers/charges_MS2.txt +21 -0
  9. pytheas1/data/Charge_tables/QTOF_training_set_only/charges_MS1_calibration.txt +21 -0
  10. pytheas1/data/Charge_tables/QTOF_training_set_only/charges_MS2_calibration.txt +21 -0
  11. pytheas1/data/RNAmodifications_template.txt +18 -0
  12. pytheas1/data/charges_MS1.txt +21 -0
  13. pytheas1/data/charges_MS2.txt +21 -0
  14. pytheas1/data/js/color_tables.js +93 -0
  15. pytheas1/data/js/mapping_output.js +109 -0
  16. pytheas1/data/js/sorttable.js +495 -0
  17. pytheas1/data/js/visualize_spectra.js +16 -0
  18. pytheas1/data/nts_heavy.xlsx +0 -0
  19. pytheas1/data/nts_light.xlsx +0 -0
  20. pytheas1/final_report/__init__.py +0 -0
  21. pytheas1/final_report/final_report_library.py +247 -0
  22. pytheas1/gui.py +566 -0
  23. pytheas1/gui_spec.py +402 -0
  24. pytheas1/in_silico_digestion/__init__.py +0 -0
  25. pytheas1/in_silico_digestion/calc_mass_gui.py +1054 -0
  26. pytheas1/in_silico_digestion/consolidate_gui.py +191 -0
  27. pytheas1/in_silico_digestion/consolidate_tools.py +404 -0
  28. pytheas1/in_silico_digestion/decoy_gui.py +143 -0
  29. pytheas1/in_silico_digestion/enzyme_gui.py +371 -0
  30. pytheas1/in_silico_digestion/modify_gui.py +365 -0
  31. pytheas1/matching_scoring/__init__.py +0 -0
  32. pytheas1/matching_scoring/match_library.py +1088 -0
  33. pytheas1/matching_scoring/stats_tools.py +1150 -0
  34. pytheas1/params.py +59 -0
  35. pytheas1/sequence_mapping/__init__.py +0 -0
  36. pytheas1/sequence_mapping/mapping_library.py +462 -0
  37. pytheas1/stages.py +396 -0
  38. pytheas1/statistical_analysis/__init__.py +0 -0
  39. pytheas1/statistical_analysis/statistics_library.py +188 -0
  40. pytheas1/visualization_spectra/__init__.py +0 -0
  41. pytheas1/visualization_spectra/visualization_library.py +881 -0
  42. pytheas1-1.1.0.dist-info/METADATA +305 -0
  43. pytheas1-1.1.0.dist-info/RECORD +47 -0
  44. pytheas1-1.1.0.dist-info/WHEEL +5 -0
  45. pytheas1-1.1.0.dist-info/entry_points.txt +2 -0
  46. pytheas1-1.1.0.dist-info/licenses/LICENSE +21 -0
  47. pytheas1-1.1.0.dist-info/top_level.txt +1 -0
pytheas1/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """Pytheas 1: automated analysis of RNA tandem mass spectrometry data.
2
+
3
+ Refreshed packaging of Pytheas (D'Ascenzo et al., Nature Communications
4
+ 2022; https://github.com/ldascenzo/pytheas, MIT License, (c) 2021 Luigi
5
+ D'Ascenzo). The analysis code is the published library code, ported to
6
+ current Python, numpy, pandas, matplotlib and Biopython without changing its
7
+ algorithms; see PORTING.md for every change.
8
+ """
9
+
10
+ __version__ = "1.1.0"
pytheas1/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())
pytheas1/_compat.py ADDED
@@ -0,0 +1,48 @@
1
+ """Library behaviour that changed under Pytheas 1, reproduced as it was.
2
+
3
+ Each helper keeps an output identical to what the published code produced
4
+ on its original stack (pandas 1.4, numpy 1.23). See PORTING.md.
5
+ """
6
+ import numpy as np
7
+ import pandas as pd
8
+
9
+
10
+ def merge_outer_v1(left, right, on=None):
11
+ """pd.merge(left, right, how='outer') with the row order of pandas < 2.2.
12
+
13
+ pandas 2.2 made outer merges sort their keys lexicographically. Before
14
+ that, keys came in order of first appearance in `left`, followed by keys
15
+ found only in `right` in their order of appearance there; within a key,
16
+ left rows kept their order, each followed by its right matches in order.
17
+ Pytheas 1 depends on that order: the final report and the visualization
18
+ list matches in it, and the sequence map drops rows by position after
19
+ merging, so the new order drops the wrong row.
20
+ """
21
+ if on is None:
22
+ on = [c for c in left.columns if c in right.columns]
23
+ elif isinstance(on, str):
24
+ on = [on]
25
+ lpos, rpos, kpos = "__pytheas1_lpos", "__pytheas1_rpos", "__pytheas1_key"
26
+ out = pd.merge(left.assign(**{lpos: np.arange(len(left))}),
27
+ right.assign(**{rpos: np.arange(len(right))}), on=on, how="outer")
28
+ # number keys in order of first appearance: left, then right-only, as
29
+ # the old factorization did; the output rows take the same numbers
30
+ keys = pd.concat([left[on], right[on], out[on]], ignore_index=True)
31
+ codes = keys.groupby(on, sort=False, dropna=False).ngroup().to_numpy()
32
+ out[kpos] = codes[len(left) + len(right):]
33
+ out = out.sort_values([kpos, lpos, rpos], kind="stable", na_position="last")
34
+ return out.drop(columns=[lpos, rpos, kpos]).reset_index(drop=True)
35
+
36
+
37
+ def series_float(x):
38
+ """float(x) for a one-element Series, as pandas < 2.1 allowed implicitly.
39
+
40
+ The original code passes one-row Series to np.float64() and round(). Old
41
+ pandas converted them to a scalar (and raised for a longer Series);
42
+ pandas 3 returns an array, which round() rejects. Scalars pass through.
43
+ """
44
+ if isinstance(x, pd.Series):
45
+ if len(x) != 1:
46
+ raise TypeError(f"cannot convert a Series of length {len(x)} to float")
47
+ return float(x.iloc[0])
48
+ return x
pytheas1/cli.py ADDED
@@ -0,0 +1,153 @@
1
+ """pytheas1 command line.
2
+
3
+ pytheas1 open the GUI
4
+ pytheas1 --nogui --load_vars --params run.json --digest --match
5
+ pytheas1 --nogui --load_vars --params run.json --all
6
+ pytheas1 --write_params template.json every setting, at its default
7
+
8
+ Stages always run in workflow order (digest, match, stats, report, mapping,
9
+ visualize), whatever order the flags are given in, and stop at the first
10
+ failure. Inputs left unset chain from the stages run before them.
11
+ """
12
+ import argparse
13
+ import datetime
14
+ import json
15
+ import os
16
+ import platform
17
+ import sys
18
+
19
+ from . import __version__
20
+ from .params import default_params, load_params, save_params
21
+ from .stages import RUNS_DIR, STAGES, TITLES, StageError, chain_inputs, run_stage
22
+
23
+ DEFAULT_PARAMS_FILE = "pytheas1_parameters.json"
24
+
25
+
26
+ def _versions():
27
+ import Bio
28
+ import matplotlib
29
+ import numpy
30
+ import pandas
31
+ return {"pytheas1": __version__, "python": platform.python_version(), "numpy": numpy.__version__,
32
+ "pandas": pandas.__version__, "matplotlib": matplotlib.__version__, "biopython": Bio.__version__}
33
+
34
+
35
+ def run_pipeline(params, stages, workdir, records, echo=print):
36
+ """Run the given stages in workflow order, appending one record per stage
37
+ to `records` (a failed stage is recorded too, then StageError is raised)."""
38
+ for stage in [s for s in STAGES if s in stages]:
39
+ stage_params = chain_inputs(stage, params.get(stage, {}), workdir, records, settings=params)
40
+ echo(f"\n=== {TITLES[stage]} ===", flush=True)
41
+ try:
42
+ rec = run_stage(stage, stage_params, workdir)
43
+ except StageError as e:
44
+ records.append({"stage": stage, "status": "failed", "error": str(e), "outputs": [], "params": stage_params})
45
+ raise
46
+ rec["status"] = "ok"
47
+ records.append(rec)
48
+ echo(f"=== {TITLES[stage]}: done in {rec['seconds']} s, {len(rec['outputs'])} file(s) written ===", flush=True)
49
+
50
+
51
+ class _Tee:
52
+ """Write to the console and to the run's log file."""
53
+
54
+ def __init__(self, stream, log):
55
+ self.stream, self.log = stream, log
56
+
57
+ def write(self, text):
58
+ self.stream.write(text)
59
+ self.log.write(text)
60
+ return len(text)
61
+
62
+ def flush(self):
63
+ self.stream.flush()
64
+ self.log.flush()
65
+
66
+ def __getattr__(self, name):
67
+ return getattr(self.stream, name)
68
+
69
+
70
+ def _run_paths(workdir):
71
+ """<workdir>/pytheas1_runs/<time>.json and .log, unique even within a second."""
72
+ folder = os.path.join(workdir, RUNS_DIR)
73
+ os.makedirs(folder, exist_ok=True)
74
+ stamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
75
+ base, i = os.path.join(folder, stamp), 1
76
+ while os.path.exists(base + ".json") or os.path.exists(base + ".log"):
77
+ i += 1
78
+ base = os.path.join(folder, f"{stamp}-{i}")
79
+ return base + ".json", base + ".log"
80
+
81
+
82
+ def _write_record(path, params_path, log_path, records):
83
+ with open(path, "w") as fh:
84
+ json.dump({"params_file": params_path, "log": log_path, "versions": _versions(), "stages": records},
85
+ fh, indent=2, default=str)
86
+ return path
87
+
88
+
89
+ def main(argv=None):
90
+ ap = argparse.ArgumentParser(prog="pytheas1", description="Pytheas 1: RNA MS/MS analysis")
91
+ ap.add_argument("--nogui", action="store_true", help="run from the command line, without the GUI")
92
+ ap.add_argument("--load_vars", action="store_true",
93
+ help=f"load settings from --params (default: {DEFAULT_PARAMS_FILE} in the working folder)")
94
+ ap.add_argument("--params", help="Pytheas 1 parameter file (JSON)")
95
+ ap.add_argument("--workdir", help="working folder for inputs and outputs (overrides the file's working_dir)")
96
+ for stage in STAGES:
97
+ ap.add_argument(f"--{stage}", action="store_true", help=f"run {TITLES[stage]}")
98
+ ap.add_argument("--all", action="store_true", help="run all six stages")
99
+ ap.add_argument("--write_params", metavar="FILE", help="write a parameter file with every default, then exit")
100
+ ap.add_argument("--version", action="version", version=f"pytheas1 {__version__}")
101
+ args = ap.parse_args(argv)
102
+
103
+ if args.write_params:
104
+ save_params(default_params(), args.write_params, only_changed=False)
105
+ print(f"wrote {args.write_params}")
106
+ return 0
107
+
108
+ if not args.nogui:
109
+ try:
110
+ from .gui import main as gui_main
111
+ except ImportError as e:
112
+ print(f"The GUI could not be started ({e}). Use --nogui.", file=sys.stderr)
113
+ return 2
114
+ return gui_main(args)
115
+
116
+ stages = [s for s in STAGES if args.all or getattr(args, s)]
117
+ if not stages:
118
+ ap.error("--nogui: choose stages (" + " ".join(f"--{s}" for s in STAGES) + ") or --all")
119
+
120
+ params_path = args.params
121
+ if params_path is None and args.load_vars:
122
+ params_path = os.path.join(args.workdir or os.getcwd(), DEFAULT_PARAMS_FILE)
123
+ if params_path is None:
124
+ ap.error("--nogui needs settings: --load_vars --params FILE")
125
+ try:
126
+ params = load_params(params_path)
127
+ except (OSError, ValueError) as e:
128
+ print(f"pytheas1: {e}", file=sys.stderr)
129
+ return 2
130
+ workdir = os.path.abspath(args.workdir or params.get("working_dir") or os.getcwd())
131
+
132
+ records = []
133
+ status = 0
134
+ record_path, log_path = _run_paths(workdir)
135
+ out, err = sys.stdout, sys.stderr
136
+ with open(log_path, "w") as log:
137
+ sys.stdout, sys.stderr = _Tee(out, log), _Tee(err, log)
138
+ try:
139
+ print(f"pytheas1 {__version__}: {', '.join(stages)} in {workdir}, settings {os.path.abspath(params_path)}")
140
+ run_pipeline(params, stages, workdir, records)
141
+ except StageError as e:
142
+ print(f"\npytheas1: {e}", file=sys.stderr)
143
+ status = 1
144
+ finally:
145
+ sys.stdout.flush()
146
+ sys.stdout, sys.stderr = out, err
147
+ _write_record(record_path, os.path.abspath(params_path), log_path, records)
148
+ print(f"\nrun record: {record_path}\nlog: {log_path}")
149
+ return status
150
+
151
+
152
+ if __name__ == "__main__":
153
+ sys.exit(main())
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 2 1
4
+ 3 1,2
5
+ 4 1,2
6
+ 5 2
7
+ 6 2,3
8
+ 7 2,3
9
+ 8 2,3
10
+ 9 3,4
11
+ 10 3,4
12
+ 11 3,4
13
+ 12 3,4
14
+ 13 3,4
15
+ 14 4,5
16
+ 15 4,5
17
+ 16 4,5
18
+ 17 4,5,6
19
+ 18 5,6
20
+ 19 5,6
21
+ 20 5,6
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 1 1
4
+ 2 1
5
+ 3 1,2
6
+ 4 1,2
7
+ 5 1,2
8
+ 6 2,3
9
+ 7 2,3
10
+ 8 2,3
11
+ 9 2,3
12
+ 10 2,3,4
13
+ 11 3,4
14
+ 12 3,4
15
+ 13 3,4,5
16
+ 14 4,5
17
+ 15 4,5
18
+ 16 4,5
19
+ 17 5,6
20
+ 18 5,6
21
+ 19 5,6
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 2 1
4
+ 3 1,2
5
+ 4 1,2
6
+ 5 1,2,3
7
+ 6 2,3
8
+ 7 2,3
9
+ 8 2,3,4
10
+ 9 2,3,4
11
+ 10 2,3,4
12
+ 11 2,3,4
13
+ 12 2,3,4
14
+ 13 3,4
15
+ 14 3,4,5
16
+ 15 4,5
17
+ 16 4,5
18
+ 17 4,5,6
19
+ 18 5,6
20
+ 19 5,6
21
+ 20 5,6
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 1 1
4
+ 2 1
5
+ 3 1,2
6
+ 4 1,2
7
+ 5 1,2
8
+ 6 2,3
9
+ 7 2,3
10
+ 8 2,3
11
+ 9 2,3
12
+ 10 2,3,4
13
+ 11 2,3,4
14
+ 12 3,4
15
+ 13 3,4,5
16
+ 14 4,5
17
+ 15 4,5
18
+ 16 4,5
19
+ 17 5,6
20
+ 18 5,6
21
+ 19 5,6
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 2 1
4
+ 3 2
5
+ 4 2
6
+ 5 2
7
+ 6 2
8
+ 7 3
9
+ 8 3
10
+ 9 3
11
+ 10 3
12
+ 11 3
13
+ 12 4
14
+ 13 4
15
+ 14 4
16
+ 15 4
17
+ 16 4,5,6
18
+ 17 4,5,6,7,8
19
+ 18 4,5,6,7,8
20
+ 19 5,6,7,8,9
21
+ 20 5,6,7,8,9
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 1 1
4
+ 2 1
5
+ 3 1,2
6
+ 4 1,2
7
+ 5 1,2
8
+ 6 2,3
9
+ 7 2,3
10
+ 8 2,3
11
+ 9 2,3
12
+ 10 2,3,4
13
+ 11 3,4
14
+ 12 3,4
15
+ 13 3,4,5
16
+ 14 4,5
17
+ 15 4,5
18
+ 16 4,5
19
+ 17 5,6
20
+ 18 5,6
21
+ 19 5,6
@@ -0,0 +1,18 @@
1
+ # template file for specifying positions of modified nucleotides in the input RNA sequences
2
+ # use one line per modification position
3
+ # five fields separated with a space: Molecule Position ID ID_ext Include
4
+ # 1) Molecule: fasta header of the RNA sequence until the first space
5
+ # (e.g. fasta header ">16S.rrsA E.coli" will be "16S.rrsA")
6
+ # 2) Position: sequence position of the modified nucleotide
7
+ # 3) ID: one-letter Pytheas ID for the modified nucleotides. should be consistent with IDs
8
+ # used in the elemental composition input files (default is nts_light.xlsx)
9
+ #4) Id_ext: human-readable code for the modified nucleotides, consistent with ID_exts
10
+ # used in the elemental composition input files (default is nts_light.xlsx)
11
+ #5) Include: set to 0,1 or 2. keep only modified RNA [1],
12
+ # keep both modified and unmodified [2], keep only unmodified [0]
13
+
14
+ Molecule Position ID ID_ext Include
15
+ 16S.rrsA 967 k [mC] 2
16
+ 16S.rrsA 1207 j [mG] 2
17
+ 23S.rrlA 2503 i [mA] 2
18
+ 23S.rrlA 2552 L [Um] 2
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 2 1
4
+ 3 1,2
5
+ 4 1,2
6
+ 5 1,2,3
7
+ 6 2,3
8
+ 7 2,3
9
+ 8 2,3,4
10
+ 9 2,3,4
11
+ 10 2,3,4
12
+ 11 2,3,4
13
+ 12 2,3,4
14
+ 13 3,4
15
+ 14 3,4,5
16
+ 15 4,5
17
+ 16 4,5
18
+ 17 4,5,6
19
+ 18 5,6
20
+ 19 5,6
21
+ 20 5,6
@@ -0,0 +1,21 @@
1
+ Length(nt) Charges
2
+
3
+ 1 1
4
+ 2 1
5
+ 3 1,2
6
+ 4 1,2
7
+ 5 1,2
8
+ 6 2,3
9
+ 7 2,3
10
+ 8 2,3
11
+ 9 2,3
12
+ 10 2,3,4
13
+ 11 2,3,4
14
+ 12 3,4
15
+ 13 3,4,5
16
+ 14 4,5
17
+ 15 4,5
18
+ 16 4,5
19
+ 17 5,6
20
+ 18 5,6
21
+ 19 5,6
@@ -0,0 +1,93 @@
1
+ var tables = document.getElementsByTagName("table");
2
+
3
+
4
+ for(var i = 0; i < tables.length; i++) {
5
+ var table = tables[i];
6
+
7
+ //get all the rows with tag "td"
8
+ var tds = table.getElementsByTagName("td");
9
+
10
+ for (var j = 0; j < tds.length; j++) {
11
+
12
+ var text = tds[j].innerHTML;
13
+
14
+ //Check what is the last character of a cell, to assign the correct color for matching ions
15
+ var reg = /Mclr$/.test(text)
16
+ if (reg) {
17
+
18
+ //Use grey for M ions
19
+ tds[j].style.backgroundColor = "#abb2b9"
20
+
21
+ var newValue = text.split("_")
22
+ tds[j].innerHTML = newValue[0]
23
+ }
24
+
25
+ var reg = /[a|w]clr$/.test(text)
26
+ if (reg) {
27
+
28
+ //Use green for a/w series
29
+ tds[j].style.backgroundColor = "#33CC00"
30
+
31
+ var newValue = text.split("_")
32
+ tds[j].innerHTML = newValue[0]
33
+ }
34
+
35
+ var reg = /[x|b]clr$/.test(text)
36
+ if (reg) {
37
+
38
+ //Use blue for x/b series
39
+ tds[j].style.backgroundColor = "#0099FF"
40
+
41
+ var newValue = text.split("_")
42
+ tds[j].innerHTML = newValue[0]
43
+ }
44
+
45
+ var reg = /[y|c]clr$/.test(text)
46
+ if (reg) {
47
+
48
+ //Use pink for y/c series
49
+ tds[j].style.backgroundColor = "#FF33FF"
50
+
51
+ var newValue = text.split("_")
52
+ tds[j].innerHTML = newValue[0]
53
+ }
54
+
55
+ var reg = /[z|d]clr$/.test(text)
56
+ if (reg) {
57
+
58
+ //Use yellow for z/d series
59
+ tds[j].style.backgroundColor = "#FFCC00"
60
+
61
+ var newValue = text.split("_")
62
+ tds[j].innerHTML = newValue[0]
63
+ }
64
+
65
+ var reg = /[X]$/.test(text)
66
+ if (reg) {
67
+
68
+ //Use cyan for brown for CMC specific series
69
+ tds[j].style.backgroundColor = "#964B00"
70
+
71
+ var newValue = text.split("_")
72
+ tds[j].innerHTML = newValue[0]
73
+ }
74
+
75
+
76
+
77
+ var reg = /decoy$/.test(text)
78
+ if (reg) {
79
+
80
+ //Use red to highlight decoys in the main table
81
+ tds[j].style.backgroundColor = "#FFC4C4"
82
+ tds[j-14].style.backgroundColor = "#FFC4C4"
83
+
84
+
85
+ }
86
+
87
+
88
+ }
89
+
90
+
91
+ }
92
+
93
+
@@ -0,0 +1,109 @@
1
+ var tables = document.getElementsByTagName("table");
2
+
3
+ for(var i = 0; i < tables.length; i++) {
4
+ var table = tables[i];
5
+ var maxSp = 0;
6
+
7
+ //get all the rows with tag "td"
8
+ var tds = table.getElementsByTagName("td");
9
+
10
+ //get all the rows with tag "th"
11
+ var ths = table.getElementsByTagName("th");
12
+
13
+ //Leave only sequence numbers multiple of 10 on the first line
14
+ for (var j = 0; j < ths.length; j++) {
15
+
16
+ var value = ths[j].innerHTML;
17
+
18
+ var reg = /^\d+$/.test(value);
19
+ if (reg) {
20
+
21
+ if (value % 10 != 0 && value != 1) {
22
+
23
+ ths[j].innerHTML = "";
24
+ } else {
25
+ ths[j].style.fontSize = "8px";
26
+ }
27
+ }
28
+
29
+ }
30
+ //Find the max value of the Sp score in the output [maxSp]
31
+ for (var j = 0; j < tds.length; j++) {
32
+
33
+ var text = tds[j].innerHTML;
34
+
35
+ //Find the maximum Sp value for matching occurrences
36
+ var reg = /^[light|heavy]/.test(text)
37
+ if (reg) {
38
+ var textSplit = text.split("_");
39
+
40
+ var Sp = Number(textSplit[2]);
41
+
42
+ if (Sp > maxSp) {
43
+ maxSp = Sp;
44
+ }
45
+ }
46
+
47
+ }
48
+
49
+ //Modify cells by adding residues names, terminal residues and color coding based on Sp score
50
+ for (var j = 0; j < tds.length; j++) {
51
+
52
+ var text = tds[j].innerHTML;
53
+
54
+ //Check if the cell string starts with 'light' or 'heavy'
55
+ var reg = /^[light|heavy]/.test(text)
56
+ if (reg) {
57
+
58
+ // Mark the terminal residues for fragment by bolding residue names
59
+ var at = /[\@]/.test(text);
60
+ if (at) {
61
+ tds[j].style.fontWeight = "bold";
62
+
63
+ var newStr = text.replace("@", "");
64
+ tds[j].innerHTML = newStr;
65
+ }
66
+
67
+ var text = tds[j].innerHTML;
68
+ var ScoreSplit = text.split("_");
69
+
70
+ //Mark the cell with the matched residue name
71
+ tds[j].innerHTML = ScoreSplit[6];
72
+
73
+ //Makes the text bigger and the cell grey if a modified base is found
74
+ if (ScoreSplit[6] != 'C' && ScoreSplit[6] != 'G' && ScoreSplit[6] != 'A' && ScoreSplit[6] != 'U' && ScoreSplit[6] != 'X') {
75
+
76
+ tds[j].style.fontSize = "10px";
77
+ tds[j].style.border = "1px solid black";
78
+
79
+ } else {
80
+
81
+ // Unmodified bases are rendered in grey
82
+ tds[j].style.fontSize = "9px";
83
+ tds[j].style.color = '#3f3f3f';
84
+ tds[j].innerHTML = "";
85
+ }
86
+
87
+ var Sp = Number(ScoreSplit[2]);
88
+ var ratioSp = Number(Sp / maxSp);
89
+
90
+ //Color the cell based on the score, with 3 color levels from lower (yellow) to higher (red)
91
+ if (ratioSp <= 0.33) {
92
+
93
+ tds[j].style.backgroundColor = "#ffff00";
94
+
95
+ } else if (ratioSp > 0.33 && ratioSp < 0.66) {
96
+
97
+ tds[j].style.backgroundColor = "#ff9900";
98
+
99
+ } else if (ratioSp >= 0.66) {
100
+ tds[j].style.backgroundColor = "#ff0000";
101
+ }
102
+
103
+ }
104
+
105
+
106
+ }
107
+
108
+ }
109
+