lingzhi227 commited on
Commit
ff6001d
·
verified ·
1 Parent(s): 826317b

Upload tasks/dda-proteomics-simple/run_script.sh with huggingface_hub

Browse files
tasks/dda-proteomics-simple/run_script.sh ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -uo pipefail
3
+
4
+ # =============================================================================
5
+ # Task: DDA Label-Free Quantitative Proteomics
6
+ #
7
+ # DAG structure (depth 10, 3 convergence points):
8
+ #
9
+ # L0: mzML mass spec file + protein FASTA database
10
+ # L1: DecoyDatabase (add reverse decoys)
11
+ # L2: PeakPickerHiRes (centroid if profile mode)
12
+ # L3: CometAdapter (database search — peptide-spectrum matching)
13
+ # L4: PeptideIndexer (map peptides to protein sequences)
14
+ # L5: FalseDiscoveryRate (target-decoy FDR estimation)
15
+ # ├──────────────────────────────────────────────────┐
16
+ # L6: IDFilter (1% PSM FDR) FDR statistics
17
+ # │ │
18
+ # L7: TextExporter (idXML → TSV) QC metrics
19
+ # │ │
20
+ # L8: Parse protein/peptide/PSM counts ◄────────────────┘ [CONVERGENCE 1+2]
21
+ # L9: MERGE [CONVERGENCE 3]
22
+ # =============================================================================
23
+
24
+ THREADS=$(( $(nproc) > 8 ? 8 : $(nproc) ))
25
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26
+ DATA="${SCRIPT_DIR}/data"
27
+ REF="${SCRIPT_DIR}/reference"
28
+ OUT="${SCRIPT_DIR}/outputs"
29
+ RES="${SCRIPT_DIR}/results"
30
+
31
+ MZML="${DATA}/sample.mzML"
32
+ DATABASE="${REF}/database.fasta"
33
+
34
+ log_step() { echo "== STEP: $1 == $(date)"; }
35
+ mkdir -p "${OUT}"/{decoy,picked,search_comet,indexed,fdr,filtered,quant} "${RES}"
36
+
37
+ # L1: Add decoy sequences
38
+ log_step "L1: DecoyDatabase"
39
+ if [ ! -f "${OUT}/decoy/target_decoy.fasta" ]; then
40
+ DecoyDatabase -in "${DATABASE}" -out "${OUT}/decoy/target_decoy.fasta" \
41
+ -decoy_string "DECOY_" -decoy_string_position prefix
42
+ fi
43
+
44
+ # L2: Peak picking
45
+ log_step "L2: PeakPickerHiRes"
46
+ if [ ! -f "${OUT}/picked/picked.mzML" ]; then
47
+ PeakPickerHiRes -in "${MZML}" -out "${OUT}/picked/picked.mzML" \
48
+ -algorithm:ms_levels 1 2 2>/dev/null || {
49
+ echo "Data already centroided, using as-is"
50
+ cp "${MZML}" "${OUT}/picked/picked.mzML"
51
+ }
52
+ fi
53
+
54
+ # L3: Comet database search
55
+ log_step "L3: CometAdapter"
56
+ if [ ! -f "${OUT}/search_comet/comet.idXML" ]; then
57
+ CometAdapter -in "${OUT}/picked/picked.mzML" \
58
+ -database "${OUT}/decoy/target_decoy.fasta" \
59
+ -out "${OUT}/search_comet/comet.idXML" \
60
+ -precursor_mass_tolerance 10 \
61
+ -precursor_error_units ppm \
62
+ -fragment_mass_tolerance 0.02 \
63
+ -threads ${THREADS} 2>&1 || true
64
+ fi
65
+
66
+ # L4: PeptideIndexer
67
+ log_step "L4: PeptideIndexer"
68
+ if [ ! -f "${OUT}/indexed/indexed.idXML" ]; then
69
+ PeptideIndexer -in "${OUT}/search_comet/comet.idXML" \
70
+ -fasta "${OUT}/decoy/target_decoy.fasta" \
71
+ -out "${OUT}/indexed/indexed.idXML" \
72
+ -decoy_string "DECOY_" -decoy_string_position prefix \
73
+ -enzyme:name Trypsin
74
+ fi
75
+
76
+ # L5: FDR
77
+ log_step "L5: FalseDiscoveryRate"
78
+ if [ ! -f "${OUT}/fdr/fdr.idXML" ]; then
79
+ FalseDiscoveryRate -in "${OUT}/indexed/indexed.idXML" \
80
+ -out "${OUT}/fdr/fdr.idXML" -force
81
+ fi
82
+
83
+ # L6: Filter at 1% FDR
84
+ log_step "L6: IDFilter"
85
+ if [ ! -f "${OUT}/filtered/filtered.idXML" ]; then
86
+ IDFilter -in "${OUT}/fdr/fdr.idXML" \
87
+ -out "${OUT}/filtered/filtered.idXML" \
88
+ -score:psm 0.01
89
+ fi
90
+
91
+ # L7: Export
92
+ log_step "L7: TextExporter"
93
+ if [ ! -f "${OUT}/quant/results.tsv" ]; then
94
+ TextExporter -in "${OUT}/filtered/filtered.idXML" \
95
+ -out "${OUT}/quant/results.tsv"
96
+ fi
97
+
98
+ # MERGE
99
+ log_step "MERGE"
100
+ SPECTRA=$(grep -c "<spectrum " "${OUT}/picked/picked.mzML" 2>/dev/null || true)
101
+ SPECTRA=${SPECTRA:-0}
102
+ DB_SIZE=$(grep -c "^>" "${OUT}/decoy/target_decoy.fasta" 2>/dev/null || true)
103
+ DB_SIZE=${DB_SIZE:-0}
104
+ SEARCH_HITS=$(grep -c "PeptideHit" "${OUT}/search_comet/comet.idXML" 2>/dev/null || true)
105
+ SEARCH_HITS=${SEARCH_HITS:-0}
106
+ PSMS=$(grep -c "^PEPTIDE" "${OUT}/quant/results.tsv" 2>/dev/null || true)
107
+ PSMS=${PSMS:-0}
108
+ PEPTIDES=$(grep "^PEPTIDE" "${OUT}/quant/results.tsv" 2>/dev/null | awk '{print $2}' | sort -u | wc -l | tr -d ' ')
109
+ PROTEINS=$(grep -c "^PROTEIN" "${OUT}/quant/results.tsv" 2>/dev/null || true)
110
+ PROTEINS=${PROTEINS:-0}
111
+
112
+ cat > "${RES}/proteomics_report.csv" << CSVEOF
113
+ metric,value
114
+ total_spectra,${SPECTRA}
115
+ database_size_with_decoys,${DB_SIZE}
116
+ search_engine_hits,${SEARCH_HITS}
117
+ psms_after_fdr,${PSMS}
118
+ unique_peptides,${PEPTIDES}
119
+ proteins_identified,${PROTEINS}
120
+ CSVEOF
121
+
122
+ echo ""
123
+ echo "=== Pipeline complete ==="
124
+ cat "${RES}/proteomics_report.csv"