Skip to content

Commit

Permalink
more explicit fail invalid biosample
Browse files Browse the repository at this point in the history
  • Loading branch information
fraser-combe committed Nov 21, 2024
1 parent 7bcc842 commit 988fc17
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions tasks/utilities/data_handling/task_fetch_srr_accession.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,33 @@ task fetch_srr_accession {
date -u | tee DATE
fastq-dl --version | tee VERSION

# Debug log: Display the sample accession being processed
echo "Fetching metadata for sample accession: ~{sample_accession}"

# Use fastq-dl to fetch metadata for the sample accession
fastq-dl --accession ~{sample_accession} --only-download-metadata --verbose

if [[ -f fastq-run-info.tsv ]]; then
echo "Metadata written for ~{sample_accession}:"
echo "TSV content:"
cat fastq-run-info.tsv
echo "Fetching metadata for sample accession: ~{sample_accession}"
if fastq-dl --accession ~{sample_accession} --only-download-metadata --verbose; then
if [[ -f fastq-run-info.tsv ]]; then
echo "Metadata written for ~{sample_accession}:"
cat fastq-run-info.tsv

# Extract SRR accessions from the TSV file and join them into a comma-separated string
SRR_accessions=$(awk -F'\t' 'NR>1 {print $1}' fastq-run-info.tsv | paste -sd ',' -)
# Extract SRR accessions from the TSV file
SRR_accessions=$(awk -F'\t' 'NR>1 {print $1}' fastq-run-info.tsv | paste -sd ',' -)

# Write the SRR accessions to srr_accession.txt
if [[ -z "${SRR_accessions}" ]]; then
echo "No SRR accession found for ~{sample_accession}" > srr_accession.txt
else
echo "Extracted SRR accessions: ${SRR_accessions}"
echo "${SRR_accessions}" > srr_accession.txt
fi
if [[ -z "${SRR_accessions}" ]]; then
echo "No SRR accession found for ~{sample_accession}" > srr_accession.txt
else
echo "Extracted SRR accessions: ${SRR_accessions}"
echo "${SRR_accessions}" > srr_accession.txt
fi
else
echo "No metadata file found for ~{sample_accession}"
echo "No SRR accession found" > srr_accession.txt
fi
else
# Handle the case where no metadata file is found
echo "No metadata found for ~{sample_accession}"
echo "No SRR accession found" > srr_accession.txt
# Explicitly fail for invalid biosample IDs or SRA
echo "Invalid Biosample ID/SRA or error fetching metadata for ~{sample_accession}"
exit 1
fi
>>>
output {
# Output the extracted SRR accessions and the fastq-dl version
String srr_accession = read_string("srr_accession.txt")
String fastq_dl_version = read_string("VERSION")
}
Expand Down

0 comments on commit 988fc17

Please sign in to comment.