Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream updates #138

Merged
merged 3 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 28 additions & 36 deletions pipes/WDL/tasks/tasks_ncbi_tools.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,37 @@ task Fetch_SRA_to_BAM {
}

command {
set -euxo pipefail
# pull reads from SRA and make a fully annotated BAM -- must succeed
set -ex
/opt/docker/scripts/sra_to_ubam.sh "${SRA_ID}" "${SRA_ID}.bam"

# pull reads from SRA and make a fully annotated BAM
/opt/docker/scripts/sra_to_ubam.sh ${SRA_ID} ${SRA_ID}.bam
# pull most metadata from BAM header
set +e
samtools view -H "${SRA_ID}.bam" | grep ^@RG | head -1 | tr '\t' '\n' > header.txt
grep CN header.txt | cut -f 2- -d : | tee OUT_CENTER
grep PL header.txt | cut -f 2- -d : | tee OUT_PLATFORM
grep SM header.txt | cut -f 2- -d : | tee OUT_BIOSAMPLE
grep LB header.txt | cut -f 2- -d : | tee OUT_LIBRARY
grep DT header.txt | cut -f 2 -d : | cut -f 1 -d T | tee OUT_RUNDATE

# pull other metadata from SRA
esearch -db sra -q "${SRA_ID}" | efetch -mode json -json > ${SRA_ID}.json

cat ${SRA_ID}.json | jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.SUBMISSION.center_name' \
| tee OUT_CENTER
cat ${SRA_ID}.json | jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.EXPERIMENT.PLATFORM | keys[] as $k | "\($k)"' \
| tee OUT_PLATFORM
cat ${SRA_ID}.json | jq -r \
.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.EXPERIMENT.PLATFORM.$(<OUT_PLATFORM).INSTRUMENT_MODEL \
| tee OUT_MODEL
cat ${SRA_ID}.json | jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.SAMPLE.IDENTIFIERS.EXTERNAL_ID|select(.namespace == "BioSample")|.content' \
| tee OUT_BIOSAMPLE
cat ${SRA_ID}.json | jq -r \
.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.EXPERIMENT.DESIGN.LIBRARY_DESCRIPTOR.LIBRARY_NAME \
| tee OUT_LIBRARY
cat ${SRA_ID}.json | jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.RUN_SET.RUN.SRAFiles.SRAFile[]|select(.supertype == "Original")|.date' \
| cut -f 1 -d ' ' \
| tee OUT_RUNDATE
cat ${SRA_ID}.json | jq -r \
# pull other metadata from SRA -- allow for silent failures here!
touch OUT_MODEL OUT_COLLECTION_DATE OUT_STRAIN OUT_COLLECTED_BY OUT_GEO_LOC
esearch -db sra -q "${SRA_ID}" | efetch -mode json -json > SRA.json
jq -r \
.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.EXPERIMENT.PLATFORM."$(<OUT_PLATFORM)".INSTRUMENT_MODEL \
SRA.json | tee OUT_MODEL
jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.SAMPLE.SAMPLE_ATTRIBUTES.SAMPLE_ATTRIBUTE[]|select(.TAG == "collection_date")|.VALUE' \
| tee OUT_COLLECTION_DATE
cat ${SRA_ID}.json | jq -r \
SRA.json | tee OUT_COLLECTION_DATE
jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.SAMPLE.SAMPLE_ATTRIBUTES.SAMPLE_ATTRIBUTE[]|select(.TAG == "strain")|.VALUE' \
| tee OUT_STRAIN
cat ${SRA_ID}.json | jq -r \
SRA.json | tee OUT_STRAIN
jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.SAMPLE.SAMPLE_ATTRIBUTES.SAMPLE_ATTRIBUTE[]|select(.TAG == "collected_by")|.VALUE' \
| tee OUT_COLLECTED_BY
cat ${SRA_ID}.json | jq -r \
SRA.json | tee OUT_COLLECTED_BY
jq -r \
'.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE.SAMPLE.SAMPLE_ATTRIBUTES.SAMPLE_ATTRIBUTE[]|select(.TAG == "geo_loc_name")|.VALUE' \
| tee OUT_GEO_LOC
SRA.json | tee OUT_GEO_LOC
}

output {
Expand All @@ -67,10 +59,10 @@ task Fetch_SRA_to_BAM {
}

runtime {
cpu: 4
memory: select_first([machine_mem_gb, 15]) + " GB"
cpu: 2
memory: select_first([machine_mem_gb, 6]) + " GB"
disks: "local-disk 750 LOCAL"
dx_instance_type: "mem2_ssd1_v2_x4"
dx_instance_type: "mem2_ssd1_v2_x2"
docker: "${docker}"
}
}
4 changes: 2 additions & 2 deletions requirements-modules.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
broadinstitute/viral-core=2.1.7
broadinstitute/viral-core=2.1.8
broadinstitute/viral-assemble=2.1.4.0
broadinstitute/viral-classify=2.1.4.0
broadinstitute/viral-phylo=2.1.4.0
broadinstitute/beast-beagle-cuda=1.10.5pre
broadinstitute/ncbi-tools=2.10.7.0
broadinstitute/ncbi-tools=2.10.7.1
nextstrain/base=build-20200629T201240Z
andersenlabapps/ivar=1.2.2