File Info

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

# Try the staged path directly (should be a directory)
if [ -d "tih_rna_sample_00570_B23MVV7LT4_1" ]; then
    # Look for abundance.h5 inside the directory
    if [ -f "tih_rna_sample_00570_B23MVV7LT4_1/abundance.h5" ]; then
        H5_FILE="tih_rna_sample_00570_B23MVV7LT4_1/abundance.h5"
    fi
# Try common patterns
elif [ -f "tih_rna_sample_00570_B23MVV7LT4_1/abundance.h5" ]; then
    H5_FILE="tih_rna_sample_00570_B23MVV7LT4_1/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: tih_rna_sample_00570_B23MVV7LT4_1/abundance.h5, tih_rna_sample_00570_B23MVV7LT4_1/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" \
    "tih_rna_sample_00570_B23MVV7LT4_1_kallisto_mqc.tsv" \
    --sample-id "tih_rna_sample_00570_B23MVV7LT4_1" \
    --sample-qc tih_rna_sample_00570_B23MVV7LT4_1.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