Skip to content

Commit

Permalink
first working selenium tests: formats yeast data and does a serach fo…
Browse files Browse the repository at this point in the history
…r one of the gene names using the search box
  • Loading branch information
rbuels committed Jan 10, 2012
1 parent cf96632 commit fa4885a
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 7 deletions.
Empty file added sample_data/json/.exists
Empty file.
7 changes: 0 additions & 7 deletions sample_data/json/Makefile

This file was deleted.

40 changes: 40 additions & 0 deletions sample_data/raw/yeast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"description": "Yeast Example Database",
"db_adaptor": "Bio::DB::SeqFeature::Store",
"db_args": {
"-adaptor": "memory",
"-dir": "../raw/yeast_chr1+2"
},
"TRACK DEFAULTS": {
"class": "feature",
"autocomplete": "all"
},
"tracks": [
{
"track": "Genes",
"feature": ["gene"],
"class": "feature5",
"key": "Protein-coding genes",
"subfeatures": true,
"subfeature_classes": {
"CDS": "transcript-CDS"
},
"arrowheadClass": "transcript-arrowhead",
"category": "Genes"
},
{
"track": "Transcript",
"feature": ["mRNA"],
"description": 1,
"class": "transcript",
"subfeatures": true,
"subfeature_classes": {
"CDS": "transcript-CDS",
"UTR": "transcript-UTR"
},
"arrowheadClass": "transcript-arrowhead",
"key": "Exonerate predictions",
"category": "Genes"
}
]
}
76 changes: 76 additions & 0 deletions test_harness.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- This HTML file is for use by the JBrowse integration tests only. -->

<head>
<title>JBrowse</title>
<link rel="stylesheet" type="text/css" href="jslib/dijit/themes/tundra/tundra.css"></link>
<link rel="stylesheet" type="text/css" href="jslib/dojo/resources/dojo.css"></link>
<link rel="stylesheet" type="text/css" href="genome.css"></link>
<style type="text/css">
html, body { height: 100%; width: 100%; padding: 0; border: 0; }
</style>

<script type="text/javascript" src="jslib/dojo/dojo.js" djConfig="isDebug: false"></script>
<script type="text/javascript" src="jslib/dojo/jbrowse_dojo.js" ></script>

<!-- js_source_files -->
<!-- the files between the "js_source_files" comments get replaced
when the JS gets minified (see the minification rule in the Makefile) -->
<script type="text/javascript" src="js/Browser.js"></script>
<script type="text/javascript" src="js/Util.js"></script>
<script type="text/javascript" src="js/NCList.js"></script>
<script type="text/javascript" src="js/LazyPatricia.js"></script>
<script type="text/javascript" src="js/LazyArray.js"></script>
<script type="text/javascript" src="js/Track.js"></script>
<script type="text/javascript" src="js/SequenceTrack.js"></script>
<script type="text/javascript" src="js/Layout.js"></script>
<script type="text/javascript" src="js/FeatureTrack.js"></script>
<script type="text/javascript" src="js/UITracks.js"></script>
<script type="text/javascript" src="js/ImageTrack.js"></script>
<script type="text/javascript" src="js/GenomeView.js"></script>
<!-- js_source_files -->
</head>

<body>
<div id="GenomeBrowser" style="height: 100%; width: 100%; padding: 0; border: 0;"></div>
<script type="text/javascript">
/* <![CDATA[ */
var queryParams = dojo.queryToObject(window.location.search.slice(1));

// load the proper refSeqs and trackInfo based on the data path passed as a query arg
var dataRoot = queryParams.data || 'data';
dojo.forEach( ['refSeqs.js','trackInfo.js'], function(file) {
dojo.xhrGet({
url: dataRoot + '/' + file,
handleAs: 'javascript',
sync: true
});
});

var bookmarkCallback = function(brwsr) {
return window.location.protocol
+ "//" + window.location.host
+ window.location.pathname
+ "?loc=" + brwsr.visibleRegion()
+ "&tracks=" + brwsr.visibleTracks();
}
var b = new Browser({
containerID: "GenomeBrowser",
refSeqs: refSeqs,
trackData: trackInfo,
defaultTracks: "DNA,gene,mRNA,noncodingRNA",
location: queryParams.loc,
tracks: queryParams.tracks,
bookmark: bookmarkCallback,
dataRoot: dataRoot + '/'
});
/* ]]> */
</script>

</body>
</html>
92 changes: 92 additions & 0 deletions tests/selenium_tests/yeast_biodb_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from subprocess import check_call as call
import os
import shutil
import time

def test_yeast():
format_yeast()
browser = webdriver.Firefox() # Get local session of firefox
browser.get("file://%s/test_harness.html?data=sample_data/json/yeast" % os.getcwd() ) # Load page

# check a good browser title
assert "chrI" in browser.title

# check that we have the appropriate tracks
genes_track = assert_element( browser, '//div[@class="tracklist-label"]' )
assert genes_track.text == 'Protein-coding genes', "first track was called %s instead of %s" % (first_track.text, 'Protein-coding genes')

# do a test where we search for a certain gene using the search box
search_yal024c(browser)

def search_yal024c(browser):

# check that a YAL024C feature label is not yet in the DOM
yal024_xpath = "//div[@class='feature-label'][contains(.,'YAL024C')]"
try:
browser.find_element_by_xpath( yal024_xpath )
assert 0, ( "YAL024C is already in the DOM at load time, something is wrong" )
except NoSuchElementException:
pass

# Find the query box and put YAL024C into it and hit enter
qbox = browser.find_element_by_id("location")
qbox.clear()
qbox.send_keys( "YAL024C" + Keys.RETURN )

# test that YAL024C appeared in the DOM (TODO: check that it's
# actually centered in the window), and that the protein-coding
# genes track is now selected
label = assert_element( browser, yal024_xpath )
assert label.text == 'YAL024C';

browser.close()
pass;

def assert_element( browser, xpathExpression ):
try:
el = browser.find_element_by_xpath( xpathExpression )
except NoSuchElementException:
assert 0, ( "can't find %s" % xpathExpression )
return el

def format_yeast():
os.chdir('sample_data/json')
os.environ['PATH'] = "../../bin:" + os.environ['PATH']
call( "rm -rf yeast/", shell=True )
call( "prepare-refseqs.pl --fasta ../raw/yeast_scaffolds/chr1.fa --fasta ../raw/yeast_scaffolds/chr2.fa --out yeast/", shell=True )
call( "biodb-to-json.pl --conf ../raw/yeast.json --out yeast/", shell=True )
call( "generate-names.pl --dir yeast/", shell=True )
os.chdir('../..')


# $ENV{PATH} = "../../bin:$ENV{PATH}";

# chdir 'sample_data/json';

# system 'rm -rf yeast/';
# system qw( prepare-refseqs.pl
# --fasta ../raw/yeast_scaffolds/chr1.fa
# --fasta ../raw/yeast_scaffolds/chr2.fa
# --out yeast/
# );
# system qw(
# );

# # system qw( flatfile-to-json.pl
# # --gff ../raw/yeast_chr1+2/yeast_chr1+2.gff3
# # --tracklabel Genes
# # --cssClass feature5
# # --type gene
# # --
# # --out yeast/
# # );
# # flatfile-to-json.pl --gff ../raw/yeast_chr1+2/yeast_chr1+2.gff3 --autocomplete all --tracklabel Genes --getSubs --type gene --getLabel --urltemplate 'http://example.com/foo/genes/{id}' --out yeast/;
# # flatfile-to-json.pl --gff ../raw/yeast_chr1+2/yeast_chr1+2.gff3 --autocomplete all --tracklabel Repeats --getSubs --type repeat_region --getLabel --urltemplate 'http://example.com/foo/repeats/{id}' --out yeast/;

# system qw( generate-names.pl --dir yeast/ );

# ok 1;
# done_testing;

0 comments on commit fa4885a

Please sign in to comment.