-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshrink.py
More file actions
72 lines (62 loc) · 1.53 KB
/
Copy pathshrink.py
File metadata and controls
72 lines (62 loc) · 1.53 KB
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
#!/usr/bin/env python3
#
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "polars",
# ]
# ///
# Essential Data Extractor
# 2026 (c) Micha Johannes Birklbauer
# https://github.com/michabirklbauer/
# micha.birklbauer@gmail.com
# REQUIREMENTS
# pip install polars
import polars as pl
# version tracking
__version = "1.0.2"
__date = "2026-03-13"
INPUT = "THIDDIAXL003_DIAmethodEval_SN20c4_Report_FM_crosslinking_plusDecoy_allCol.tsv"
OUTPUT = "THIDDIAXL003_DIAmethodEval_SN20c4_Report_FM_crosslinking_plusDecoy_req.csv"
CONDITIONS = ["DIA12_CV486075", "DIA12_CV48"]
COLS = [
"R.FileName",
"R.Condition",
"PG.ProteinNames",
"PG.Cscore",
"EG.Library",
"EG.PrecursorId",
"EG.Cscore",
"FG.Charge",
"FG.Comment",
"F.CalibratedMz",
]
PQVALUES = [
"PG.Pvalue",
"PG.PValue (Run-Wise)",
"PG.Qvalue",
"PG.QValue (Run-Wise)",
"EG.GlobalPrecursorQvalue",
"EG.MaxChannelQvalue",
"EG.MinChannelQvalue",
"EG.Qvalue",
"EG.InSourceFragmentationParentQvalue",
"EG.AvgProfileQvalue",
"EG.MaxProfileQvalue",
"EG.MinProfileQvalue",
"EG.PercentileQvalue",
"FG.Qvalue",
]
def shrink(csv: str, sep: str, conditions: list[str], out: str) -> int:
q = (
pl.scan_csv(csv, separator=sep)
.select(COLS+PQVALUES)
.filter(pl.col("R.Condition").is_in(conditions))
)
df = q.collect()
df.write_csv(out)
return 0
def main():
return shrink(INPUT, sep="\t", conditions=CONDITIONS, out=OUTPUT)
if __name__ == "__main__":
exit(main())