-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mccalluc/igvjs visualization (#1349)
* Empty stub page for visualization * IGV demo with hard-coded data * Fix flake8 failure * Find the button Are the data_set ones actually in use? * Link to visualization + pass data * Test failed because $ not defined * declare angular dependency Click works, but params are not actually read. * Better URLs? Vague sense that we may have multiple visualizations, and it would be good to have a home for all of them. * Visualization config passed from view Also removed optional params from JS. * Pull out URL lookup (still fake) * Fetch URL referenced by Node * Hit S3 for reference data ... but have not actually populated S3, pending #1344 * Make json on server side * Use promises for simultaneous API calls (API does not actually have the data we need, yet.) * API calls made in parallel * Helper script to populate S3 * aws s3 sync * FAI creation * cytoband fallback + sync at end * Check for twoBitToFa install * Handle 2bit + better error handling * Stub /api/v2/nodes * v2 URL to get file store URLs * Use the new API Needs testing, but otherwise ready for review. * Correct reference files * Script usage message + double braces are preferred in bash * Fails when just one Node I was also supplying the wrong datastructure to IGV.
- Loading branch information
Showing
12 changed files
with
276 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o nounset | ||
|
||
|
||
### Helper functions | ||
|
||
die() { echo "$@" 1>&2; exit 1; } | ||
warn() { echo "$@" 1>&2; } | ||
|
||
download_and_unzip() { | ||
# $1 will include one parent directory. | ||
BASE=`basename $1` | ||
if [ -e $BASE.gz ] || [ -e $BASE ] | ||
then warn "$BASE.gz or $BASE already exists: skip download" | ||
else ftp ftp://hgdownload.cse.ucsc.edu/goldenPath/$GENOME/$1.gz \ | ||
|| ftp ftp://hgdownload.cse.ucsc.edu/goldenPath/$GENOME/$1 \ | ||
|| warn "neither $1.gz nor $1 is available" | ||
fi | ||
|
||
if [ -e $BASE.gz ]; then | ||
if [ -e $BASE ] | ||
then warn "$BASE already exists: skip unzip" | ||
else gunzip $BASE.gz | ||
fi | ||
fi | ||
} | ||
|
||
|
||
### Check for dependencies | ||
|
||
which faidx > /dev/null || die 'Install faidx: | ||
- "pip install pyfaidx" makes "faidx" available on command line. | ||
- or: | ||
- download source from http://www.htslib.org/download/ | ||
- make and install | ||
- make alias for "samtools faidx"' | ||
|
||
which twoBitToFa > /dev/null || die 'Install twoBitToFa: | ||
Choose the directory of your OS on http://hgdownload.soe.ucsc.edu/admin/exe/, | ||
download "twoBitToFa", and "chmod a+x". (Or build from source.)' | ||
|
||
which aws > /dev/null || die 'Install aws-cli' | ||
|
||
aws s3 ls > /dev/null || die 'Check aws-cli credentials' | ||
|
||
|
||
### Main | ||
|
||
LOCAL=/tmp/genomes | ||
|
||
mkdir -p $LOCAL | ||
|
||
if [[ $# -eq 0 ]]; then | ||
die "USAGE: | ||
$0 GENOME1 [ GENOME2 ... ] | ||
Fetches reference genomes from UCSC, unzips, indexes, and uploads to S3." | ||
fi | ||
|
||
for GENOME in $@; do | ||
echo # Blank line for readability | ||
echo "Starting $GENOME..." | ||
cd $LOCAL | ||
mkdir -p $GENOME | ||
cd $GENOME | ||
|
||
download_and_unzip bigZips/$GENOME.2bit | ||
if [[ -e $GENOME.2bit ]]; then | ||
twoBitToFa $GENOME.2bit $GENOME.fa | ||
fi | ||
|
||
download_and_unzip bigZips/$GENOME.fa | ||
# Replace $GENOME.fa with upstream1000.fa to get a smaller file for testing. | ||
|
||
if [[ -e $GENOME.fa.fai ]] | ||
then warn "$GENOME.fa.fai already exists: will not regenerate" | ||
else faidx $GENOME.fa > /dev/null || warn 'FAI creation failed' | ||
fi | ||
|
||
download_and_unzip database/cytoBand.txt | ||
if [[ ! -e cytoBand.txt ]]; then | ||
# "Ideo" seems to be more detailed? | ||
download_and_unzip database/cytoBandIdeo.txt \ | ||
&& mv cytoBandIdeo.txt cytoBand.txt \ | ||
|| warn "No cytoBand.txt for $GENOME" | ||
# TODO: Make a mock cytoBand, rather than tracking which are not available? | ||
fi | ||
done | ||
|
||
aws s3 sync --exclude "*.gz" --exclude "*.2bit" --region us-east-1 \ | ||
$LOCAL s3://data.cloud.refinery-platform.org/data/igv-reference | ||
|
||
echo 'Delete the cache to free up some disk.' | ||
du -h $LOCAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{% extends "plain.html" %} | ||
|
||
{% block title %} | ||
{{ block.super }} - Visualization | ||
{% endblock %} | ||
|
||
{% block head %} | ||
<!-- jQuery UI CSS --> | ||
<link rel="stylesheet" type="text/css" | ||
href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css"/> | ||
|
||
<!-- Font Awesome CSS --> | ||
<link rel="stylesheet" type="text/css" | ||
href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"/> | ||
|
||
<!-- IGV CSS --> | ||
<link rel="stylesheet" type="text/css" href="//igv.org/web/release/1.0.1/igv-1.0.1.css"> | ||
|
||
<!-- jQuery JS --> | ||
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | ||
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> | ||
|
||
<!-- IGV JS--> | ||
<script type="text/javascript" src="//igv.org/web/release/1.0.1/igv-1.0.1.js"></script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<div id="igv"></div> | ||
|
||
<script type="text/javascript"> | ||
|
||
$(document).ready(function () { | ||
var node_ids = {{ node_ids_json|safe }}; | ||
var ajaxes = $.map(node_ids, function(node_id) { | ||
return $.getJSON('/api/v2/nodes/' + node_id + '/?format=json'); | ||
}); | ||
|
||
// When more than one node is specified, but if only a single node | ||
// is given, the console log below actually returns a 3 element array: | ||
// The AJAX response object is being taken as the array, instead of as | ||
// the first element of a 1-element array. | ||
console.log('ajaxes: ', ajaxes); // TODO | ||
$.when.apply(null, ajaxes).then(function() { | ||
// The elements of ajaxes correspond | ||
// to the elements of the arguments array. | ||
console.log('Array from arguments: ', Array.from(arguments)); // TODO | ||
var tracks = $.map(arguments, function(response){ | ||
return { | ||
name: response[0].full_file_store_item_url.replace(/.*\//, ''), | ||
url: response[0].full_file_store_item_url | ||
}; | ||
}); | ||
var div = $("#igv")[0]; | ||
var options = { | ||
showKaryo: true, // Default is false. | ||
reference: { | ||
fastaURL: '{{ fasta_url|escapejs }}', | ||
indexURL: '{{ index_url|escapejs }}', | ||
cytobandURL: '{{ cytoband_url|escapejs }}' | ||
}, | ||
tracks: tracks | ||
}; | ||
|
||
igv.createBrowser(div, options); | ||
}); | ||
}); | ||
|
||
</script> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
|
||
{% load humanize %} | ||
{% load static %} | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta content="text/html"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="description" content=""> | ||
<meta name="author" content=""> | ||
|
||
<!-- http://www.jonathantneal.com/blog/understand-the-favicon/ --> | ||
<link rel="apple-touch-icon" href="{% static "images/touchicon.png" %}"> | ||
<link rel="icon" href="{% static "images/favicon.png" %}"> | ||
<!--[if IE]><link rel="shortcut icon" href="{% static "images/favicon.ico" %}"><![endif]--> | ||
<!-- IE10 Win 8 --> | ||
<meta name="msapplication-TileColor" content="#FFFFFF"> | ||
<meta name="msapplication-TileImage" content="{% static "images/tileicon.png" %}"> | ||
|
||
<title>{{ REFINERY_INSTANCE_NAME }}{% block title %}{% endblock %}</title> | ||
|
||
{% block head %} | ||
{% endblock %} | ||
</head> | ||
|
||
<body> | ||
|
||
{% block content %} | ||
{% endblock %} | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters