File Info

Filename
.command.sh
Full Path
s3://natera-rnd-pltf-dev-nextflow-scratch-01/work/0e/be1bc695a2d3bbaa4b3a862b30fbe0/.command.sh
Size
1.7 KB
Attempt
#!/bin/bash -euo pipefail
# Find the kallisto abundance.h5 file
# KALLISTO_QUANT outputs a directory (BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3) containing abundance.h5
H5_FILE=""

# Try the staged path directly (should be a directory)
if [ -d "BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3" ]; then
    # Look for abundance.h5 inside the directory
    if [ -f "BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3/abundance.h5" ]; then
        H5_FILE="BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3/abundance.h5"
    fi
# Try common patterns
elif [ -f "BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3/abundance.h5" ]; then
    H5_FILE="BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3/abundance.h5"
# Search for the file
else
    H5_FILE=$(find . -name "abundance.h5" -type f | head -n 1)
fi

# Validate file exists
if [ -z "$H5_FILE" ] || [ ! -f "$H5_FILE" ]; then
    echo "Error: Could not find Kallisto abundance.h5 file" >&2
    echo "Searched for: BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3/abundance.h5, BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3/abundance.h5, or abundance.h5" >&2
    echo "In directory: $(pwd)" >&2
    echo "Contents:" >&2
    ls -laR . >&2
    exit 1
fi

echo "Processing Kallisto file: $H5_FILE" >&2


# Convert Kallisto abundance.h5 to MultiQC embedded TSV format (with expression QC columns from sample_qc)
kallisto_to_multiqc.py \
    "$H5_FILE" \
    "BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3_kallisto_mqc.tsv" \
    --sample-id "BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3" \
    --sample-qc BVT_FFPE_TRNA_bst_01_01_A23WKFTLT4_3.sample_qc.tsv

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