File Info

Filename
.command.sh
Full Path
s3://natera-rnd-pltf-dev-nextflow-scratch-01/work/18/1af728a6049a7ac6c1df7ba9b4ce7a/.command.sh
Size
1.9 KB
Attempt
#!/bin/bash -euo pipefail
# The file is staged by Nextflow from pattern */*_full_basic_stats.tsv
# aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv should point to the staged file path
# First try the direct path, then search for it
TSV_FILE=""

# Try the staged path directly
if [ -f "aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv" ]; then
    TSV_FILE="aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv"
# Try the expected subdirectory structure
elif [ -f "aih-tih-sc-0fc41c-R1_B23WHYVLT4_1/aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv" ]; then
    TSV_FILE="aih-tih-sc-0fc41c-R1_B23WHYVLT4_1/aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv"
# Search for the file
else
    TSV_FILE=$(find . -name "aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv" -type f | head -n 1)
    if [ -z "$TSV_FILE" ] || [ ! -f "$TSV_FILE" ]; then
        TSV_FILE=$(find . -name "*_full_basic_stats.tsv" -type f | head -n 1)
    fi
fi

# Validate file exists
if [ -z "$TSV_FILE" ] || [ ! -f "$TSV_FILE" ]; then
    echo "Error: Could not find SeqTools TSV file" >&2
    echo "Searched for: aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv, aih-tih-sc-0fc41c-R1_B23WHYVLT4_1/aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_full_basic_stats.tsv, or *_full_basic_stats.tsv" >&2
    echo "In directory: $(pwd)" >&2
    echo "Contents:" >&2
    ls -laR . >&2
    exit 1
fi

echo "Processing SeqTools file: $TSV_FILE" >&2

# Convert SeqTools TSV to MultiQC embedded TSV format
# Note: We don't use -region 'chr20' here as ext.args is configured for SEQTOOL_QC, not this conversion script
seqtool_to_multiqc.py \
    "$TSV_FILE" \
    "aih-tih-sc-0fc41c-R1_B23WHYVLT4_1_seqtool_mqc.tsv" \
    --sample-id "aih-tih-sc-0fc41c-R1_B23WHYVLT4_1"

# Create versions file
cat <<-END_VERSIONS > versions.yml
"NFCORE_RNAFUSION:RNAFUSION:QC_WORKFLOW:SEQTOOL_TO_MULTIQC":
    python: $(python3 --version | sed 's/Python //g')
    seqtool_to_multiqc: 1.0.0
END_VERSIONS