Upload local reads files
The following script prompts the user to log in interactively and select a project for which she has at least CONTRIBUTE permission. The script will then sequentially upload each of the files given as arguments and print out the DNAnexus file-id associated with each uploaded file.
# Log in
for file in $@
echo "Uploading $file..."
fileid=$(dx upload $file --brief --wait)
echo "Uploaded file $file. File-id is $fileid"
: In practice, you will probably want to replace the above script with an invocation of the Upload Agent
, giving it as arguments a list of your local files.
Map reads, call variants, and export to a VCF file
The following script prompts the user to log in interactively and select a destination project for which she has at least CONTRIBUTE permission. It expects as arguments either object IDs or paths to the reference genome, a pre-computed index of the reference genome for BWA-MEM, and the reads that will be analyzed. The script will run the necessary jobs to map the reads and call variants on the resulting mappings using Freebayes.
Once the VCF file is ready, it will then be downloaded from the DNAnexus platform to the user's local filesystem.
if [ $# -lt 3 ]
echo "Usage: $0 reference_path BWA_indexed_reference_path fwd_reads_path rev_reads_path" >&2
# Log in
if [ -n "$4" ]
# Run the apps serially using job-based object references
bwa_job=$(dx run bwa_mem_fastq_read_mapper -igenomeindex_targz="$bwa_indexed_reference" -ireads_fastqgz="$reads" $paired_reads -y --brief)
echo "Running BWA: $bwa_job"
freebayes_job=$(dx run freebayes -igenome_fastagz="$reference" -isorted_bams=$bwa_job:sorted_bam -y --brief)
echo "Running freebayes: $freebayes_job"
# Wait for the last job to finish
dx wait $freebayes_job
# Download the resulting VCF file
dx download $freebayes_job:variants_vcfgz