File Info

Filename
.command.sh
Full Path
s3://natera-rnd-pltf-dev-nextflow-scratch-01/work/85/14ef8df755e14f564cdf06e173118f/.command.sh
Size
1.9 KB
Attempt
#!/bin/bash -euo pipefail
# The file is staged by Nextflow from pattern */*_full_basic_stats.tsv
# GM24385_0001_RNA_0001_23H5VFLT4_s40_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 "GM24385_0001_RNA_0001_23H5VFLT4_s40_full_basic_stats.tsv" ]; then
    TSV_FILE="GM24385_0001_RNA_0001_23H5VFLT4_s40_full_basic_stats.tsv"
# Try the expected subdirectory structure
elif [ -f "GM24385_0001_RNA_0001_23H5VFLT4_s40/GM24385_0001_RNA_0001_23H5VFLT4_s40_full_basic_stats.tsv" ]; then
    TSV_FILE="GM24385_0001_RNA_0001_23H5VFLT4_s40/GM24385_0001_RNA_0001_23H5VFLT4_s40_full_basic_stats.tsv"
# Search for the file
else
    TSV_FILE=$(find . -name "GM24385_0001_RNA_0001_23H5VFLT4_s40_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: GM24385_0001_RNA_0001_23H5VFLT4_s40_full_basic_stats.tsv, GM24385_0001_RNA_0001_23H5VFLT4_s40/GM24385_0001_RNA_0001_23H5VFLT4_s40_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" \
    "GM24385_0001_RNA_0001_23H5VFLT4_s40_seqtool_mqc.tsv" \
    --sample-id "GM24385_0001_RNA_0001_23H5VFLT4_s40"

# 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