File Info

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

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