Skip to content

Commit

Permalink
comma sep output as string instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
fraser-combe committed Nov 18, 2024
1 parent 705c766 commit 3ec8105
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/workflows/public_data_sharing/fetch_srr_accession.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This workflow has a single task that performs metadata retrieval for the specifi

| **Variable** | **Type** | **Description**|
|---|---|---|
| srr_accession| String | The SRR accession associated with the input sample accession.|
| srr_accession| String | The SRR accession's associated with the input sample accession.|

## References

Expand Down
14 changes: 7 additions & 7 deletions tasks/utilities/data_handling/task_fetch_srr_accession.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ task fetch_srr_accession {
echo "TSV content:"
cat fastq-run-info.tsv

# Extract the SRR accessions and write them directly to srr_accession.txt
awk -F'\t' 'NR>1 {print $1}' fastq-run-info.tsv > srr_accession.txt
# Extract SRR accessions and join them with commas
SRR_accessions=$(awk -F'\t' 'NR>1 {print $1}' fastq-run-info.tsv | paste -sd ',' -)

# Check if srr_accession.txt is empty (no SRR accessions found)
if [[ ! -s srr_accession.txt ]]; then
# Check if SRR_accessions is empty
if [[ -z "${SRR_accessions}" ]]; then
echo "No SRR accession found for ${sample_accession}" > srr_accession.txt
else
echo "Extracted SRR accessions:"
cat srr_accession.txt
echo "Extracted SRR accessions: ${SRR_accessions}"
echo "${SRR_accessions}" > srr_accession.txt
fi
else
echo "No metadata found for ${sample_accession}"
echo "No SRR accession found" > srr_accession.txt
fi
>>>
output {
Array[String] srr_accession = read_lines("srr_accession.txt")
String srr_accession = read_string("srr_accession.txt")
String fastq_dl_version = read_string("VERSION")
}
runtime {
Expand Down
5 changes: 2 additions & 3 deletions workflows/utilities/data_import/wf_fetch_srr_accession.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version 1.0
import "../../../tasks/utilities/data_handling/task_fetch_srr_accession.wdl" as srr_task
import "../../../tasks/task_versioning.wdl" as versioning_task

workflow wf_retrieve_srr {
workflow fetch_srr_accession {
meta {
description: "This workflow retrieves the Sequence Read Archive (SRA) accession (SRR) associated with a given sample accession. It uses the fastq-dl tool to fetch metadata from SRA and outputs the SRR accession."
}
Expand All @@ -18,8 +18,7 @@ workflow wf_retrieve_srr {
sample_accession = sample_accession
}
output {
Array[String] srr_accession = fetch_srr_accession.srr_accession

String srr_accession = fetch_srr_accession.srr_accession
# Version Captures
String phb_version = version_capture.phb_version
String fetch_srr_date = version_capture.date
Expand Down

0 comments on commit 3ec8105

Please sign in to comment.