Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IGV S3 to HTTP bridge
#!/bin/bash
##### CONFIG
S3FUSE_MNT=/mnt/igv
IGV_NGINX_MNT=/var/www/igv
IGV_XML_HEAD="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Global name=\"UMCCR AWS IGV server\" version=\"1\">\n<Category name=\"UMCCR Amazon IGV bucket\">"
IGV_XML_BODY_TMPL="<Resource name=\"SAMPLE\" path=\"URL\"></Resource>\n"
IGV_XML_TAIL="</Category>\n</Global>\n"
IGV_XML_BODY_ARRAY=()
IGV_URL_PREFIX="https://igv.dev.umccr.org/igv/"
IGV_XML_REGISTRY_FILE="umccr_registry.xml"
#####
for sample_path in `find $S3FUSE_MNT \( -iname "*.vcf.gz" -o -iname "*.bam" \)`
do
# Creates symlinks from S3 to NGINX
IGV_MNT=$IGV_NGINX_MNT/`basename "$sample_path"`
SAMPLENAME=`basename $sample_path`
if [[ $sample_path == *".bam"* ]]; then
ln -sf $sample_path $IGV_MNT
ln -sf $sample_path.bai $IGV_MNT.bai
elif [[ $sample_path == *".vcf.gz" ]]; then
ln -sf $sample_path $IGV_MNT
ln -sf $sample_path.tbi $IGV_MNT.tbi
fi
# Builds XML body spec (see IGV XML FILE generation below)
IGV_XML_BODY="${IGV_XML_BODY_TMPL/SAMPLE/$SAMPLENAME}"
IGV_XML_BODY="${IGV_XML_BODY/URL/${IGV_URL_PREFIX}${SAMPLENAME}}"
IGV_XML_BODY_ARRAY+="$IGV_XML_BODY"
done
# Generates IGV XML FILE
echo -e "$IGV_XML_HEAD" > "$IGV_XML_REGISTRY_FILE"
for sample_url in "$IGV_XML_BODY_ARRAY"
do
echo -e "$sample_url" >> "$IGV_XML_REGISTRY_FILE"
done
echo -e "$IGV_XML_TAIL" >> "$IGV_XML_REGISTRY_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.