diff --git a/plasmid/source/html/yeastlabbrowser/plasmid-browser.html b/plasmid/source/html/yeastlabbrowser/plasmid-browser.html index 652ab793de2f689fc9b377e2189903dcadb8c15c..8ad94879275bc2d067a45ee0d65dca933a8ae2f9 100644 --- a/plasmid/source/html/yeastlabbrowser/plasmid-browser.html +++ b/plasmid/source/html/yeastlabbrowser/plasmid-browser.html @@ -1,7 +1,7 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> - <title>YeastLab Browser</title> + <title>Plasmid Browser</title> <link type="text/css" rel="stylesheet" href="body-style.css" /> <link type="text/css" rel="stylesheet" href="button.css" /> <script type="text/javascript" src="d3.js"></script> @@ -10,12 +10,20 @@ <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="openbis.js"></script> <!-- To speed development, cache the requests --> - <!-- <script type="text/javascript" src="openbis-request-cache.js"></script> --> + <script type="text/javascript" src="openbis-request-cache.js"></script> <script> /// The openbisServer we use for our data openbisServer = new openbis('https://openbis-csb.ethz.ch/openbis/openbis', 'https://openbis-csb.ethz.ch:443/datastore_server'); +// Some global variables we refer to + +/// All plasmids +var plasmids = null; + +/// The plasmids that are currently being inspected +var inspectedPlasmids = []; + function getAppHeight(){ return Math.max($(window).height() - 50, getVisibleLeafsCountForNode(root) * 30); } @@ -84,6 +92,37 @@ function props_to_pairs(d) return pairs; } +/** Initialize the plasmids variable */ +function initializePlasmids(result) +{ + // Split the plasmids into two groups, the ones that start with FRP in their sample name and the other ones. + var frpPlasmids = [], otherPlasmids = []; + var frpRegex = /^FRP[0-9]+/; + frpRegex.compile(frpRegex); + result.forEach(function(sample) { + if (frpRegex.test(sample.code)) { + frpPlasmids.push(sample); + } else { + otherPlasmids.push(sample); + } + }); + + // Sort each of the groups + otherPlasmids.sort(function(a, b) { + return (a.code < b.code) ? -1 : 1; + }); + + frpPlasmids.sort(function(a, b) { + // Sort based on the FRP number + var frpNumberA = parseInt(a.code.substring(3)); + var frpNumberB = parseInt(b.code.substring(3)); + return (frpNumberA < frpNumberB) ? -1 : 1; + }); + + // Combine the two groups back together to produce the full collection of plasmids + plasmids = frpPlasmids.concat(otherPlasmids); +} + function inspectPlasmid(data) { console.log(data); @@ -100,12 +139,17 @@ function displayReturnedSamples(data) return; } + initializePlasmids(data.result); + // This will show the object in the log -- helpful for debugging // console.log(data.result); - var samplesToShow = data.result + if (plasmids.length < 1) { + vis.append("p").text("No data found."); + return; + } // Pick the table element of the visualization - d3.select("#vis").select("#plasmid-table").selectAll("tr.plasmid-table-data").data(samplesToShow) + d3.select("#vis").select("#plasmid-table").selectAll("tr.plasmid-table-data").data(plasmids) // Code under enter is run if there is no HTML element for a data element .enter() .append("tr")