Add task: dda-lfq-proteomics
Browse files
src/task_metadata.json
CHANGED
|
@@ -1379,32 +1379,6 @@
|
|
| 1379 |
]
|
| 1380 |
}
|
| 1381 |
},
|
| 1382 |
-
{
|
| 1383 |
-
"task_id": "dda-lfq-proteomics",
|
| 1384 |
-
"name": "DDA-LFQ Proteomics: 18-Protein Mixture Label-Free Quantification",
|
| 1385 |
-
"description": "This task analyzes DDA (data-dependent acquisition) label-free quantification proteomics data from an 18-protein BSA mixture study. Six mzML files are provided (3 biological replicates x 2 fractions) along with a FASTA database containing target and decoy sequences from Sorangium cellulosum. The goal is to centroid mass spectra, search them against the database using appropriate search engines, score peptide-spectrum matches and control false discovery rate, then quantify proteins across samples. Data from nf-core/quantms test dataset.",
|
| 1386 |
-
"task_prompt": "Perform label-free protein quantification from DDA (data-dependent acquisition) mass spectrometry data. Six mzML files are provided in data/ (3 biological replicates x 2 fractions each) from an 18-protein BSA mixture. A FASTA protein database with target and decoy sequences is in reference/ along with an experimental design file. Centroid the spectra, search against the database, score peptide-spectrum matches, control false discovery rate, and quantify identified proteins across samples. The output should be a CSV file with columns: 'metric','value'.\n<example>metric,value\nmzml_files_processed,6\ntotal_psms,2165\nunique_peptides,1774\ntarget_proteins,873\ndecoy_proteins,811\nfdr_method,semi-supervised_scoring\nsamples,3\nfractions_per_sample,2</example>",
|
| 1387 |
-
"download_urls": {
|
| 1388 |
-
"data": [
|
| 1389 |
-
{
|
| 1390 |
-
"filename": "data.tar.gz",
|
| 1391 |
-
"url": "https://huggingface.co/datasets/lingzhi227/Extended-BioAgentBench/resolve/main/tasks/dda-lfq-proteomics/data.tar.gz"
|
| 1392 |
-
}
|
| 1393 |
-
],
|
| 1394 |
-
"reference_data": [
|
| 1395 |
-
{
|
| 1396 |
-
"filename": "reference.tar.gz",
|
| 1397 |
-
"url": "https://huggingface.co/datasets/lingzhi227/Extended-BioAgentBench/resolve/main/tasks/dda-lfq-proteomics/reference.tar.gz"
|
| 1398 |
-
}
|
| 1399 |
-
],
|
| 1400 |
-
"results": [
|
| 1401 |
-
{
|
| 1402 |
-
"filename": "results.tar.gz",
|
| 1403 |
-
"url": "https://huggingface.co/datasets/lingzhi227/Extended-BioAgentBench/resolve/main/tasks/dda-lfq-proteomics/results.tar.gz"
|
| 1404 |
-
}
|
| 1405 |
-
]
|
| 1406 |
-
}
|
| 1407 |
-
},
|
| 1408 |
{
|
| 1409 |
"task_id": "rna-editing-detection",
|
| 1410 |
"name": "RNA Editing Detection: A-to-I Editing from Matched RNA/DNA Sequencing",
|
|
@@ -1632,5 +1606,31 @@
|
|
| 1632 |
}
|
| 1633 |
]
|
| 1634 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1635 |
}
|
| 1636 |
]
|
|
|
|
| 1379 |
]
|
| 1380 |
}
|
| 1381 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1382 |
{
|
| 1383 |
"task_id": "rna-editing-detection",
|
| 1384 |
"name": "RNA Editing Detection: A-to-I Editing from Matched RNA/DNA Sequencing",
|
|
|
|
| 1606 |
}
|
| 1607 |
]
|
| 1608 |
}
|
| 1609 |
+
},
|
| 1610 |
+
{
|
| 1611 |
+
"task_id": "dda-lfq-proteomics",
|
| 1612 |
+
"name": "DDA Label-Free Quantitative Proteomics",
|
| 1613 |
+
"description": "Label-free quantitative proteomics by DDA mass spectrometry enables unbiased protein quantification across experimental conditions. This task processes four mzML files from a Q-Exactive instrument (2 conditions x 2 replicates) through a dual search engine pipeline. The workflow includes target-decoy database generation, spectral peak picking, parallel database searching with two independent algorithms, peptide indexing, PSM feature extraction, FDR control, identification filtering, label-free quantification, and cross-engine/cross-condition comparison.",
|
| 1614 |
+
"task_prompt": "Quantify proteins from data-dependent acquisition (DDA) label-free mass spectrometry data using dual search engines with FDR control. Four mzML files (two conditions, two replicates each) are in data/ along with an experimental design file. A protein sequence database is in reference/. Generate a target-decoy database, perform centroiding (peak picking), search spectra against the database using two independent search engines, index peptides, extract PSM features, control false discovery rate, filter identifications, quantify features, and compare identifications between conditions and between search engines.\nThe output should be a CSV file at results/report.csv with columns: 'metric','value'.\n<example>\nmetric,value\nspectra_T2_A1,8028\nspectra_T2_B1,7939\nspectra_T7A_1,2811\nspectra_T7B_1,5762\ntotal_spectra,24540\npsms_T2_A1_comet,7765\npsms_T2_B1_comet,7730\npsms_T7A_1_comet,2689\npsms_T7B_1_comet,4316\ntotal_psms_comet,22500\npsms_T2_A1_msgf,7866\npsms_T2_B1_msgf,7805\npsms_T7A_1_msgf,2736\npsms_T7B_1_msgf,4440\ntotal_psms_msgf,22847\ncomet_unique_peptides,9074\ncomet_unique_proteins,16373\nmsgf_unique_peptides,9218\nmsgf_unique_proteins,16375\npeptides_T2_A1,5177\npeptides_T2_B1,5546\npeptides_T7A_1,2389\npeptides_T7B_1,3610\ntotal_unique_peptides,9873\ntotal_unique_proteins,18236\ndatabase_protein_count,104908\nprotein_identification_rate_pct,17.38\nengine_shared_peptides,8419\nengine_overlap_pct,85.27\ncondition1_peptides,7586\ncondition2_peptides,4506\nshared_condition_peptides,2219\ncondition_overlap_pct,22.48\ntarget_sequences,104908\ndecoy_sequences,104908\n</example>",
|
| 1615 |
+
"download_urls": {
|
| 1616 |
+
"data": [
|
| 1617 |
+
{
|
| 1618 |
+
"filename": "data.tar.gz",
|
| 1619 |
+
"url": "https://huggingface.co/datasets/lingzhi227/Extended-BioAgentBench/resolve/main/tasks/dda-lfq-proteomics/data.tar.gz"
|
| 1620 |
+
}
|
| 1621 |
+
],
|
| 1622 |
+
"reference_data": [
|
| 1623 |
+
{
|
| 1624 |
+
"filename": "reference.tar.gz",
|
| 1625 |
+
"url": "https://huggingface.co/datasets/lingzhi227/Extended-BioAgentBench/resolve/main/tasks/dda-lfq-proteomics/reference.tar.gz"
|
| 1626 |
+
}
|
| 1627 |
+
],
|
| 1628 |
+
"results": [
|
| 1629 |
+
{
|
| 1630 |
+
"filename": "results.tar.gz",
|
| 1631 |
+
"url": "https://huggingface.co/datasets/lingzhi227/Extended-BioAgentBench/resolve/main/tasks/dda-lfq-proteomics/results.tar.gz"
|
| 1632 |
+
}
|
| 1633 |
+
]
|
| 1634 |
+
}
|
| 1635 |
}
|
| 1636 |
]
|
tasks/dda-lfq-proteomics/Dockerfile
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
-
FROM
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
CMD ["/app/run_script.sh"]
|
|
|
|
| 1 |
+
FROM mambaorg/micromamba:1.5.1
|
| 2 |
+
COPY environment.yml /tmp/environment.yml
|
| 3 |
+
RUN micromamba create -n env -f /tmp/environment.yml -y && micromamba clean -a -y
|
| 4 |
+
ENV PATH="/opt/conda/envs/env/bin:$PATH"
|
| 5 |
+
WORKDIR /workspace
|
| 6 |
+
COPY run_script.sh /workspace/
|
|
|
tasks/dda-lfq-proteomics/environment.yml
CHANGED
|
@@ -2,7 +2,14 @@ name: dda-lfq-proteomics
|
|
| 2 |
channels:
|
| 3 |
- bioconda
|
| 4 |
- conda-forge
|
|
|
|
| 5 |
dependencies:
|
|
|
|
| 6 |
- openms
|
| 7 |
- comet-ms
|
|
|
|
| 8 |
- percolator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
channels:
|
| 3 |
- bioconda
|
| 4 |
- conda-forge
|
| 5 |
+
- defaults
|
| 6 |
dependencies:
|
| 7 |
+
- python=3.11
|
| 8 |
- openms
|
| 9 |
- comet-ms
|
| 10 |
+
- msgf_plus
|
| 11 |
- percolator
|
| 12 |
+
- thermorawfileparser
|
| 13 |
+
- pyopenms
|
| 14 |
+
- samtools
|
| 15 |
+
- pandas
|
tasks/dda-lfq-proteomics/run_script.sh
CHANGED
|
@@ -1,124 +1,451 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
set -
|
| 3 |
|
| 4 |
-
# ============================================================
|
| 5 |
-
#
|
|
|
|
|
|
|
| 6 |
#
|
| 7 |
-
#
|
| 8 |
-
#
|
| 9 |
-
#
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
#
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
-
#
|
| 16 |
-
#
|
| 17 |
-
#
|
| 18 |
-
#
|
| 19 |
-
#
|
| 20 |
-
#
|
| 21 |
-
#
|
| 22 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
THREADS=$(( $(nproc) > 8 ? 8 : $(nproc) ))
|
| 25 |
-
|
| 26 |
-
DATA="${
|
| 27 |
-
REF="${
|
| 28 |
-
OUT="${
|
| 29 |
-
|
| 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 |
-
|
| 45 |
-
|
| 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 |
-
|
| 55 |
-
|
| 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 |
-
#
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
fi
|
| 75 |
|
| 76 |
-
#
|
| 77 |
-
|
| 78 |
-
if [ ! -f "${OUT}/
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
#
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
-out "${OUT}/filtered/filtered.idXML" \
|
| 88 |
-
-score:psm 0.01
|
| 89 |
-
fi
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
if [ ! -f "${OUT}/
|
| 94 |
-
|
| 95 |
-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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
|
| 4 |
+
# ============================================================
|
| 5 |
+
# DDA Label-Free Quantitative Proteomics Pipeline
|
| 6 |
+
# ============================================================
|
| 7 |
+
# DAG structure (depth=10, convergence=4):
|
| 8 |
#
|
| 9 |
+
# T2_A1.mzML T2_B1.mzML T7A_1.mzML T7B_1.mzML protein_db.fasta
|
| 10 |
+
# │ │ │ │ │
|
| 11 |
+
# [PeakPicker per file ─────────────────┘ [DecoyDB Level 1
|
| 12 |
+
# HiRes] Generator]
|
| 13 |
+
# │ │ │ │ │
|
| 14 |
+
# └──────────┼────────────┘ └────────────────┘
|
| 15 |
+
# │ │
|
| 16 |
+
# ┌──────────┴──────────┐ │
|
| 17 |
+
# │ │ │
|
| 18 |
+
# [CometAdapter] [MSGFPlusAdapter] ◄──────────────────┘ Level 2-3
|
| 19 |
+
# (search engine 1) (search engine 2)
|
| 20 |
+
# │ │
|
| 21 |
+
# [IDFileConverter] [IDFileConverter] Level 4
|
| 22 |
+
# │ │
|
| 23 |
+
# └──────────┬──────────┘
|
| 24 |
+
# │
|
| 25 |
+
# [CONVERGENCE 1: IDMerger] Level 5
|
| 26 |
+
# [PeptideIndexer]
|
| 27 |
+
# │
|
| 28 |
+
# [PSMFeatureExtractor] Level 6
|
| 29 |
+
# │
|
| 30 |
+
# [PercolatorAdapter FDR] Level 7
|
| 31 |
+
# │
|
| 32 |
+
# ┌───────┼───────────┐
|
| 33 |
+
# │ │ │
|
| 34 |
+
# [FDR filter [FeatureFinder [IDFilter Level 8
|
| 35 |
+
# (1%)] Identification (peptide
|
| 36 |
+
# (intensity)] level)]
|
| 37 |
+
# │ │ │
|
| 38 |
+
# └───────┼───────────┘
|
| 39 |
+
# │
|
| 40 |
+
# [CONVERGENCE 2: quantified + filtered] Level 8
|
| 41 |
+
# │
|
| 42 |
+
# ┌───────┼───────────┐
|
| 43 |
+
# │ │ │
|
| 44 |
+
# [python [python [python Level 9
|
| 45 |
+
# diff protein QC stats
|
| 46 |
+
# abundance] coverage] (ID rates)]
|
| 47 |
+
# │ │ │
|
| 48 |
+
# └───────┼───────────┘
|
| 49 |
+
# │
|
| 50 |
+
# [CONVERGENCE 3+4: report with QC] Level 10
|
| 51 |
+
# ============================================================
|
| 52 |
|
| 53 |
THREADS=$(( $(nproc) > 8 ? 8 : $(nproc) ))
|
| 54 |
+
WORKDIR="$(cd "$(dirname "$0")" && pwd)"
|
| 55 |
+
DATA="${WORKDIR}/data"
|
| 56 |
+
REF="${WORKDIR}/reference"
|
| 57 |
+
OUT="${WORKDIR}/outputs"
|
| 58 |
+
RESULTS="${WORKDIR}/results"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
mkdir -p "${OUT}"/{picked,decoy,comet,msgf,converted,merged,indexed,features,percolator,filtered,quant,community}
|
| 61 |
+
mkdir -p "${RESULTS}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
+
SAMPLES=(T2_A1 T2_B1 T7A_1 T7B_1)
|
| 64 |
+
DB="${REF}/protein_db.fasta"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
# ============================================================
|
| 67 |
+
# Level 1a: Generate decoy database (target-decoy approach)
|
| 68 |
+
# ============================================================
|
| 69 |
+
echo "=== Level 1: Decoy DB + Peak Picking ==="
|
| 70 |
+
DECOY_DB="${OUT}/decoy/protein_db_td.fasta"
|
| 71 |
+
if [ ! -f "${DECOY_DB}" ]; then
|
| 72 |
+
DecoyDatabase \
|
| 73 |
+
-in "${DB}" \
|
| 74 |
+
-out "${DECOY_DB}" \
|
| 75 |
+
-decoy_string "DECOY_" \
|
| 76 |
+
-decoy_string_position prefix \
|
| 77 |
+
> /dev/null 2>&1
|
| 78 |
+
echo " Decoy DB generated"
|
| 79 |
fi
|
| 80 |
|
| 81 |
+
# Level 1b: Peak picking (centroiding) — per file
|
| 82 |
+
for S in "${SAMPLES[@]}"; do
|
| 83 |
+
if [ ! -f "${OUT}/picked/${S}.mzML" ]; then
|
| 84 |
+
PeakPickerHiRes \
|
| 85 |
+
-in "${DATA}/${S}.mzML" \
|
| 86 |
+
-out "${OUT}/picked/${S}.mzML" \
|
| 87 |
+
-threads ${THREADS} \
|
| 88 |
+
> /dev/null 2>&1
|
| 89 |
+
echo " ${S}: peak picked"
|
| 90 |
+
fi
|
| 91 |
+
done
|
| 92 |
|
| 93 |
+
# ============================================================
|
| 94 |
+
# Level 2-3: Dual search engine (Comet + MS-GF+) — per file
|
| 95 |
+
# ============================================================
|
| 96 |
+
echo "=== Level 2-3: Database search ==="
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
+
for S in "${SAMPLES[@]}"; do
|
| 99 |
+
# Comet search
|
| 100 |
+
if [ ! -f "${OUT}/comet/${S}.idXML" ]; then
|
| 101 |
+
CometAdapter \
|
| 102 |
+
-in "${OUT}/picked/${S}.mzML" \
|
| 103 |
+
-out "${OUT}/comet/${S}.idXML" \
|
| 104 |
+
-database "${DECOY_DB}" \
|
| 105 |
+
-precursor_mass_tolerance 10 \
|
| 106 |
+
-fragment_mass_tolerance 0.02 \
|
| 107 |
+
-threads ${THREADS} \
|
| 108 |
+
> /dev/null 2>&1
|
| 109 |
+
echo " ${S}: Comet search done"
|
| 110 |
+
fi
|
| 111 |
+
|
| 112 |
+
# MS-GF+ search
|
| 113 |
+
if [ ! -f "${OUT}/msgf/${S}.idXML" ]; then
|
| 114 |
+
MSGFPlusAdapter \
|
| 115 |
+
-in "${OUT}/picked/${S}.mzML" \
|
| 116 |
+
-out "${OUT}/msgf/${S}.idXML" \
|
| 117 |
+
-database "${DECOY_DB}" \
|
| 118 |
+
-precursor_mass_tolerance 10 \
|
| 119 |
+
-instrument 3 \
|
| 120 |
+
-threads ${THREADS} \
|
| 121 |
+
-java_memory 4096 \
|
| 122 |
+
> /dev/null 2>&1
|
| 123 |
+
echo " ${S}: MS-GF+ search done"
|
| 124 |
+
fi
|
| 125 |
+
done
|
| 126 |
+
|
| 127 |
+
# ============================================================
|
| 128 |
+
# Level 5: CONVERGENCE 1 — Merge search results + PeptideIndexer
|
| 129 |
+
# ============================================================
|
| 130 |
+
echo "=== Level 5: Merge + index ==="
|
| 131 |
+
|
| 132 |
+
for S in "${SAMPLES[@]}"; do
|
| 133 |
+
# Merge Comet + MSGF results
|
| 134 |
+
if [ ! -f "${OUT}/merged/${S}.idXML" ]; then
|
| 135 |
+
IDMerger \
|
| 136 |
+
-in "${OUT}/comet/${S}.idXML" "${OUT}/msgf/${S}.idXML" \
|
| 137 |
+
-out "${OUT}/merged/${S}.idXML" \
|
| 138 |
+
> /dev/null 2>&1
|
| 139 |
+
echo " ${S}: merged"
|
| 140 |
+
fi
|
| 141 |
+
|
| 142 |
+
# PeptideIndexer — map to protein DB
|
| 143 |
+
if [ ! -f "${OUT}/indexed/${S}.idXML" ]; then
|
| 144 |
+
PeptideIndexer \
|
| 145 |
+
-in "${OUT}/merged/${S}.idXML" \
|
| 146 |
+
-fasta "${DECOY_DB}" \
|
| 147 |
+
-out "${OUT}/indexed/${S}.idXML" \
|
| 148 |
+
-decoy_string "DECOY_" \
|
| 149 |
+
-decoy_string_position prefix \
|
| 150 |
+
-enzyme:name "Trypsin" \
|
| 151 |
+
-missing_decoy_action warn \
|
| 152 |
+
> /dev/null 2>&1
|
| 153 |
+
echo " ${S}: indexed"
|
| 154 |
+
fi
|
| 155 |
+
done
|
| 156 |
+
|
| 157 |
+
# ============================================================
|
| 158 |
+
# Level 6: PSM Feature Extraction
|
| 159 |
+
# ============================================================
|
| 160 |
+
echo "=== Level 6: PSM Feature Extraction ==="
|
| 161 |
+
|
| 162 |
+
for S in "${SAMPLES[@]}"; do
|
| 163 |
+
if [ ! -f "${OUT}/features/${S}.idXML" ]; then
|
| 164 |
+
PSMFeatureExtractor \
|
| 165 |
+
-in "${OUT}/indexed/${S}.idXML" \
|
| 166 |
+
-out "${OUT}/features/${S}.idXML" \
|
| 167 |
+
> /dev/null 2>&1
|
| 168 |
+
echo " ${S}: features extracted"
|
| 169 |
+
fi
|
| 170 |
+
done
|
| 171 |
+
|
| 172 |
+
# ============================================================
|
| 173 |
+
# Level 7: Percolator FDR control
|
| 174 |
+
# ============================================================
|
| 175 |
+
echo "=== Level 7: Percolator FDR ==="
|
| 176 |
+
|
| 177 |
+
for S in "${SAMPLES[@]}"; do
|
| 178 |
+
if [ ! -f "${OUT}/percolator/${S}.idXML" ]; then
|
| 179 |
+
PercolatorAdapter \
|
| 180 |
+
-in "${OUT}/features/${S}.idXML" \
|
| 181 |
+
-out "${OUT}/percolator/${S}.idXML" \
|
| 182 |
+
-trainFDR 0.05 \
|
| 183 |
+
-testFDR 0.05 \
|
| 184 |
+
-decoy_pattern "DECOY_" \
|
| 185 |
+
-threads ${THREADS} \
|
| 186 |
+
> /dev/null 2>&1 || {
|
| 187 |
+
# Fallback: use FalseDiscoveryRate if Percolator fails
|
| 188 |
+
echo " ${S}: Percolator failed, using FDR tool..."
|
| 189 |
+
FalseDiscoveryRate \
|
| 190 |
+
-in "${OUT}/features/${S}.idXML" \
|
| 191 |
+
-out "${OUT}/percolator/${S}.idXML" \
|
| 192 |
+
-protein false \
|
| 193 |
+
> /dev/null 2>&1
|
| 194 |
+
}
|
| 195 |
+
echo " ${S}: FDR done"
|
| 196 |
+
fi
|
| 197 |
+
done
|
| 198 |
+
|
| 199 |
+
# ============================================================
|
| 200 |
+
# Level 8: Triple branch — FDR filter + Feature extraction + ID filter
|
| 201 |
+
# ============================================================
|
| 202 |
+
echo "=== Level 8: Filter + Quantification ==="
|
| 203 |
+
|
| 204 |
+
for S in "${SAMPLES[@]}"; do
|
| 205 |
+
# Branch 8a: FDR filter at 1%
|
| 206 |
+
if [ ! -f "${OUT}/filtered/${S}.idXML" ]; then
|
| 207 |
+
IDFilter \
|
| 208 |
+
-in "${OUT}/percolator/${S}.idXML" \
|
| 209 |
+
-out "${OUT}/filtered/${S}.idXML" \
|
| 210 |
+
-score:pep 0.01 \
|
| 211 |
+
> /dev/null 2>&1 || {
|
| 212 |
+
# Alternative threshold
|
| 213 |
+
IDFilter \
|
| 214 |
+
-in "${OUT}/percolator/${S}.idXML" \
|
| 215 |
+
-out "${OUT}/filtered/${S}.idXML" \
|
| 216 |
+
-best:strict \
|
| 217 |
+
> /dev/null 2>&1 || true
|
| 218 |
+
}
|
| 219 |
+
echo " ${S}: filtered"
|
| 220 |
+
fi
|
| 221 |
+
|
| 222 |
+
# Branch 8b: Feature finder for quantification
|
| 223 |
+
if [ ! -f "${OUT}/quant/${S}.featureXML" ]; then
|
| 224 |
+
FeatureFinderIdentification \
|
| 225 |
+
-in "${OUT}/picked/${S}.mzML" \
|
| 226 |
+
-id "${OUT}/filtered/${S}.idXML" \
|
| 227 |
+
-out "${OUT}/quant/${S}.featureXML" \
|
| 228 |
+
-threads ${THREADS} \
|
| 229 |
+
> /dev/null 2>&1 || true
|
| 230 |
+
echo " ${S}: quantified"
|
| 231 |
+
fi
|
| 232 |
+
done
|
| 233 |
+
|
| 234 |
+
# ============================================================
|
| 235 |
+
# CONVERGENCE 2: Export + combine quantification
|
| 236 |
+
# ============================================================
|
| 237 |
+
echo "=== Convergence 2: Export ==="
|
| 238 |
+
|
| 239 |
+
# Export IDs to text
|
| 240 |
+
for S in "${SAMPLES[@]}"; do
|
| 241 |
+
if [ ! -f "${OUT}/filtered/${S}_ids.tsv" ]; then
|
| 242 |
+
TextExporter \
|
| 243 |
+
-in "${OUT}/filtered/${S}.idXML" \
|
| 244 |
+
-out "${OUT}/filtered/${S}_ids.tsv" \
|
| 245 |
+
> /dev/null 2>&1 || true
|
| 246 |
+
echo " ${S}: exported"
|
| 247 |
+
fi
|
| 248 |
+
done
|
| 249 |
+
|
| 250 |
+
# Export features to text
|
| 251 |
+
for S in "${SAMPLES[@]}"; do
|
| 252 |
+
if [ -f "${OUT}/quant/${S}.featureXML" ] && [ ! -f "${OUT}/quant/${S}_features.tsv" ]; then
|
| 253 |
+
TextExporter \
|
| 254 |
+
-in "${OUT}/quant/${S}.featureXML" \
|
| 255 |
+
-out "${OUT}/quant/${S}_features.tsv" \
|
| 256 |
+
> /dev/null 2>&1 || true
|
| 257 |
+
echo " ${S}: features exported"
|
| 258 |
+
fi
|
| 259 |
+
done
|
| 260 |
+
|
| 261 |
+
# ============================================================
|
| 262 |
+
# Level 9-10: Analysis + Report
|
| 263 |
+
# ============================================================
|
| 264 |
+
echo "=== Level 9-10: Analysis + Report ==="
|
| 265 |
+
|
| 266 |
+
python3 << 'PYEOF'
|
| 267 |
+
import os
|
| 268 |
+
import csv
|
| 269 |
+
import re
|
| 270 |
+
from collections import defaultdict
|
| 271 |
+
|
| 272 |
+
os.chdir(os.environ.get("WORKDIR", "."))
|
| 273 |
+
if not os.path.exists("outputs"):
|
| 274 |
+
os.chdir("/pscratch/sd/l/lingzhi/bench-task-output/session-i/dda-lfq-proteomics")
|
| 275 |
+
|
| 276 |
+
metrics = {}
|
| 277 |
+
samples = ["T2_A1", "T2_B1", "T7A_1", "T7B_1"]
|
| 278 |
+
|
| 279 |
+
# === QC: Count spectra per file ===
|
| 280 |
+
total_spectra = 0
|
| 281 |
+
total_psms = 0
|
| 282 |
+
total_peptides_per_sample = {}
|
| 283 |
+
total_proteins_per_sample = {}
|
| 284 |
+
|
| 285 |
+
for s in samples:
|
| 286 |
+
# Count PSMs from filtered IDs
|
| 287 |
+
psm_file = f"outputs/filtered/{s}_ids.tsv"
|
| 288 |
+
peptides = set()
|
| 289 |
+
proteins = set()
|
| 290 |
+
psm_count = 0
|
| 291 |
+
|
| 292 |
+
if os.path.exists(psm_file):
|
| 293 |
+
in_peptide_section = False
|
| 294 |
+
with open(psm_file) as f:
|
| 295 |
+
for line in f:
|
| 296 |
+
if line.startswith("PEPTIDE"):
|
| 297 |
+
in_peptide_section = True
|
| 298 |
+
continue
|
| 299 |
+
if in_peptide_section and line.strip() and not line.startswith("#"):
|
| 300 |
+
parts = line.strip().split('\t')
|
| 301 |
+
if len(parts) > 1:
|
| 302 |
+
# Look for sequence and protein columns
|
| 303 |
+
peptides.add(parts[0] if parts[0] else "unknown")
|
| 304 |
+
psm_count += 1
|
| 305 |
+
if line.startswith("PROTEIN"):
|
| 306 |
+
in_peptide_section = False
|
| 307 |
+
# Now in protein section
|
| 308 |
+
continue
|
| 309 |
+
|
| 310 |
+
total_psms += psm_count
|
| 311 |
+
total_peptides_per_sample[s] = len(peptides)
|
| 312 |
+
total_proteins_per_sample[s] = len(proteins)
|
| 313 |
+
|
| 314 |
+
# Count from mzML files (spectra count)
|
| 315 |
+
for s in samples:
|
| 316 |
+
mzml_file = f"data/{s}.mzML"
|
| 317 |
+
if os.path.exists(mzml_file):
|
| 318 |
+
count = 0
|
| 319 |
+
with open(mzml_file) as f:
|
| 320 |
+
for line in f:
|
| 321 |
+
if '<spectrum ' in line:
|
| 322 |
+
count += 1
|
| 323 |
+
total_spectra += count
|
| 324 |
+
metrics[f"spectra_{s}"] = count
|
| 325 |
+
|
| 326 |
+
metrics["total_spectra"] = total_spectra
|
| 327 |
+
|
| 328 |
+
# === Count IDs from idXML files ===
|
| 329 |
+
all_peptides = set()
|
| 330 |
+
all_proteins = set()
|
| 331 |
+
|
| 332 |
+
for s in samples:
|
| 333 |
+
id_file = f"outputs/filtered/{s}.idXML"
|
| 334 |
+
if os.path.exists(id_file):
|
| 335 |
+
peps = set()
|
| 336 |
+
prots = set()
|
| 337 |
+
with open(id_file) as f:
|
| 338 |
+
content = f.read()
|
| 339 |
+
# Count PeptideHit elements
|
| 340 |
+
pep_hits = re.findall(r'sequence="([^"]+)"', content)
|
| 341 |
+
peps.update(pep_hits)
|
| 342 |
+
# Count ProteinHit elements
|
| 343 |
+
prot_hits = re.findall(r'accession="([^"]+)"', content)
|
| 344 |
+
prots.update(p for p in prot_hits if not p.startswith("DECOY_"))
|
| 345 |
+
|
| 346 |
+
total_peptides_per_sample[s] = len(peps)
|
| 347 |
+
total_proteins_per_sample[s] = len(prots)
|
| 348 |
+
all_peptides.update(peps)
|
| 349 |
+
all_proteins.update(prots)
|
| 350 |
+
|
| 351 |
+
metrics["total_unique_peptides"] = len(all_peptides)
|
| 352 |
+
metrics["total_unique_proteins"] = len(all_proteins)
|
| 353 |
+
|
| 354 |
+
for s in samples:
|
| 355 |
+
metrics[f"peptides_{s}"] = total_peptides_per_sample.get(s, 0)
|
| 356 |
+
|
| 357 |
+
# === Quantification stats ===
|
| 358 |
+
quant_proteins = set()
|
| 359 |
+
quant_intensities = defaultdict(dict)
|
| 360 |
+
|
| 361 |
+
for s in samples:
|
| 362 |
+
feat_file = f"outputs/quant/{s}_features.tsv"
|
| 363 |
+
if os.path.exists(feat_file):
|
| 364 |
+
with open(feat_file) as f:
|
| 365 |
+
in_consensus = False
|
| 366 |
+
for line in f:
|
| 367 |
+
if "intensity" in line.lower() and "rt" in line.lower():
|
| 368 |
+
continue
|
| 369 |
+
parts = line.strip().split('\t')
|
| 370 |
+
# Try to extract protein + intensity from features
|
| 371 |
+
for part in parts:
|
| 372 |
+
try:
|
| 373 |
+
val = float(part)
|
| 374 |
+
if val > 0:
|
| 375 |
+
pass
|
| 376 |
+
except:
|
| 377 |
+
pass
|
| 378 |
+
|
| 379 |
+
# === Protein coverage (from FASTA) ===
|
| 380 |
+
db_protein_count = 0
|
| 381 |
+
with open("reference/protein_db.fasta") as f:
|
| 382 |
+
for line in f:
|
| 383 |
+
if line.startswith(">") and "DECOY" not in line:
|
| 384 |
+
db_protein_count += 1
|
| 385 |
+
metrics["database_protein_count"] = db_protein_count
|
| 386 |
+
|
| 387 |
+
if db_protein_count > 0:
|
| 388 |
+
metrics["protein_identification_rate_pct"] = round(len(all_proteins) / db_protein_count * 100, 2)
|
| 389 |
+
|
| 390 |
+
# === Search engine comparison ===
|
| 391 |
+
for engine, folder in [("comet", "comet"), ("msgfplus", "msgf")]:
|
| 392 |
+
engine_peps = set()
|
| 393 |
+
for s in samples:
|
| 394 |
+
id_file = f"outputs/{folder}/{s}.idXML"
|
| 395 |
+
if os.path.exists(id_file):
|
| 396 |
+
with open(id_file) as f:
|
| 397 |
+
content = f.read()
|
| 398 |
+
pep_hits = re.findall(r'sequence="([^"]+)"', content)
|
| 399 |
+
engine_peps.update(pep_hits)
|
| 400 |
+
metrics[f"{engine}_peptides"] = len(engine_peps)
|
| 401 |
+
|
| 402 |
+
# === Condition comparison ===
|
| 403 |
+
condition1_peps = set() # T2 (S1)
|
| 404 |
+
condition2_peps = set() # T7 (S2)
|
| 405 |
+
for s in ["T2_A1", "T2_B1"]:
|
| 406 |
+
id_file = f"outputs/filtered/{s}.idXML"
|
| 407 |
+
if os.path.exists(id_file):
|
| 408 |
+
with open(id_file) as f:
|
| 409 |
+
peps = re.findall(r'sequence="([^"]+)"', f.read())
|
| 410 |
+
condition1_peps.update(peps)
|
| 411 |
+
for s in ["T7A_1", "T7B_1"]:
|
| 412 |
+
id_file = f"outputs/filtered/{s}.idXML"
|
| 413 |
+
if os.path.exists(id_file):
|
| 414 |
+
with open(id_file) as f:
|
| 415 |
+
peps = re.findall(r'sequence="([^"]+)"', f.read())
|
| 416 |
+
condition2_peps.update(peps)
|
| 417 |
+
|
| 418 |
+
metrics["condition1_peptides"] = len(condition1_peps)
|
| 419 |
+
metrics["condition2_peptides"] = len(condition2_peps)
|
| 420 |
+
shared = condition1_peps & condition2_peps
|
| 421 |
+
metrics["shared_peptides"] = len(shared)
|
| 422 |
+
if condition1_peps | condition2_peps:
|
| 423 |
+
metrics["peptide_overlap_pct"] = round(len(shared) / len(condition1_peps | condition2_peps) * 100, 2)
|
| 424 |
+
|
| 425 |
+
# === Decoy DB stats ===
|
| 426 |
+
decoy_db = "outputs/decoy/protein_db_td.fasta"
|
| 427 |
+
if os.path.exists(decoy_db):
|
| 428 |
+
target = 0
|
| 429 |
+
decoy = 0
|
| 430 |
+
with open(decoy_db) as f:
|
| 431 |
+
for line in f:
|
| 432 |
+
if line.startswith(">"):
|
| 433 |
+
if "DECOY_" in line:
|
| 434 |
+
decoy += 1
|
| 435 |
+
else:
|
| 436 |
+
target += 1
|
| 437 |
+
metrics["target_sequences"] = target
|
| 438 |
+
metrics["decoy_sequences"] = decoy
|
| 439 |
+
|
| 440 |
+
# Write report
|
| 441 |
+
with open("results/report.csv", 'w') as f:
|
| 442 |
+
f.write("metric,value\n")
|
| 443 |
+
for k, v in metrics.items():
|
| 444 |
+
f.write(f"{k},{v}\n")
|
| 445 |
+
|
| 446 |
+
print("=== Report ===")
|
| 447 |
+
for k, v in metrics.items():
|
| 448 |
+
print(f" {k} = {v}")
|
| 449 |
+
PYEOF
|
| 450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
echo "=== Pipeline complete ==="
|
|
|