Skip to content

Commit

Permalink
Merge pull request #285 from AjitPS/master
Browse files Browse the repository at this point in the history
latest
  • Loading branch information
AjitPS authored Jul 23, 2018
2 parents 4e5d632 + 88dd033 commit c62aef9
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 175 deletions.
2 changes: 2 additions & 0 deletions common/client-base/src/main/webapp/html/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ a.contact-button :hover {
/* Gene View: interactive evidence summary filter */
#evidenceSummary2 {cursor:pointer; padding-top:5px; padding-bottom:5px;}
#loadingDiv_GeneView {float:right; color:darkOrange; font-size:15px; font-weight:bold; width:120px; height:25px; display:none;}
#revertGeneView.unhover { cursor:pointer; border: none; width:30px; height:30px; background:url("../image/reset_filter.png") no-repeat; }
#revertGeneView.hover { cursor:pointer; border: none; width:30px; height:30px; background:url("../image/reset_filter_hover.png") no-repeat; }

/* Suggestor box */
/* #suggestor_search_area {} */
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 87 additions & 29 deletions common/client-base/src/main/webapp/html/javascript/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,15 +817,15 @@ function searchKeyword(){

activateButton('resultsTable');
createGenesTable(data.geneTable, keyword, candidateGenes);
createEvidenceTable(data.evidenceTable);
createEvidenceTable(data.evidenceTable, keyword);
}
});
}
}

/*
* Function
* Generates the new lightweight Network graph, using cytoscapeJS.
* Generates the network using KnetMaps
* @author: Ajit Singh.
*/
function generateCyJSNetwork(url,requestParams){
Expand Down Expand Up @@ -938,7 +938,7 @@ var table = "";
table = table + '<p class="margin_left"><a download="genes.tsv" href="data:application/octet-stream;base64,'+btoa(text)+'" target="_blank">Download as TAB delimited file</a><br />';
table = table + 'Select gene(s) and click "View Network" button to see the network.<span id="hintSortableTable" class="hint hint-small" ></span></p>';
table = table + '<form name="checkbox_form">';
table = table + 'Max number of genes to show: ';
table = table + '<u>Max</u> number of genes to show: ';
table = table + '<select value="'+rows+'" id="numGenes">';
//table = table + '<select value="'+results+'" id="numGenes">';
table = table + '<option value="1000"'+(rows==1000?'selected':'')+'>1000</option>';
Expand All @@ -955,7 +955,8 @@ var table = "";
// dynamic Evidence Summary to be displayed above Gene View table
// table = table + interactive_summary_Legend;
table = table + '<div id="evidence_Summary_Legend" class="evidenceSummary">'+ interactive_summary_Legend +
'<input id="revertGeneView" type="button" value="Undo All" title= "Revert all filtering changes">'+'</div>';
'<input id="revertGeneView" type="button" value="" class="unhover" title= "Revert all filtering/sorting changes">'+'</div>';

table = table + '<div id= "geneViewTable" class = "scrollTable">';
table = table + '<table id = "tablesorter" class="tablesorter">';
table = table + '<thead>';
Expand All @@ -970,11 +971,11 @@ var table = "";
table = table + '<th width="60">'+values[3]+'</th>';
table = table + '<th width="70">'+values[4]+'</th>';
}
//table = table + '<th width="70">'+values[5]+'</th>';
table = table + '<th width="70">'+values[6]+'</th>';
//table = table + '<th width="70">'+values[5]+'</th>'; // hide TAXID (if single organism)
// table = table + '<th width="70">'+values[6]+'</th>'; // hide score for now (18/07/18)
// table = table + '<th width="85">'+values[7]+'</th>'; // user yes/no; DISABLED (13/09/17)
if(reference_genome == true){ //QTL
table = table + '<th width="70">'+values[8]+'</th>';
//table = table + '<th width="70">'+values[8]+'</th>'; // hide QTL for now (18/07/18)
}
table = table + '<th width="220">'+values[9]+'</th>';
table = table + '<th width="70">Select</th>';
Expand Down Expand Up @@ -1134,7 +1135,7 @@ var table = "";

var select = '<td><input id="checkboxGene_'+i+'" type="checkbox" name= "candidates" value="'+values[1]+'"></td>';
//table = table + gene + chr + start + end + score + withinQTL + usersList + evidence + select;
table = table + gene + geneName + taxid + chr + start + score + /*usersList +*/ withinQTL + evidence + select;
table = table + gene + geneName + taxid + chr + start + /*score + /*usersList +*/ /*withinQTL +*/ evidence + select; // hide score & QTL for now (18/07/18)
table = table + '</tr>';
}
table = table+'</tbody>';
Expand Down Expand Up @@ -1213,6 +1214,14 @@ var table = "";
// $("#loadingDiv_GeneView").css("display","none"); // clear
});

$("#revertGeneView").mouseenter(function(e) {
$("#revertGeneView").removeClass('unhover').addClass('hover');
});

$("#revertGeneView").mouseout(function(e) {
$("#revertGeneView").removeClass('hover').addClass('unhover');
});

/*
* if select all targets is checked find all targets and check them.
*/
Expand Down Expand Up @@ -1285,7 +1294,7 @@ function containsKey(keyToTest, array){
* Function
*
*/
function createEvidenceTable(text){
function createEvidenceTable(text, keyword){
var table = "";
var summaryArr = new Array();
var summaryText = '';
Expand All @@ -1307,7 +1316,7 @@ function createEvidenceTable(text){
table = table + '<th width="78">'+header[2]+'</th>';
table = table + '<th width="60">'+header[3]+'</th>';
table = table + '<th width="103">'+header[4]+'</th>';
table = table + '<th width="50">'+header[5]+'</th>';
// table = table + '<th width="50">'+header[5]+'</th>'; // hide QTL for now (18/07/18)
table = table + '</tr>';
table = table + '</thead>';
table = table + '<tbody class="scrollTable">';
Expand All @@ -1332,10 +1341,28 @@ function createEvidenceTable(text){
} */
table = table + '<td>'+evidenceValue+'</td>';
table = table + '<td>'+values[2]+'</td>';

//table = table + '<td><a href="javascript:;" onclick="evidencePath('+values[6]+');">'+values[3]+'</a></td>';
table = table + '<td><a href="javascript:;" class="generateEvidencePath" title="Display in the new KnetMaps" id="generateEvidencePath_'+ev_i+'">'+values[3]+'</a></td>';
table = table + '<td>'+values[4]+'</td>'; // user genes
table = table + '<td>'+values[5]+'</td>';
table = table + '<td><a href="javascript:;" class="generateEvidencePath" title="Display in KnetMaps" id="generateEvidencePath_'+ev_i+'">'+values[3]+'</a></td>'; // all genes

// table = table + '<td>'+values[4]+'</td>'; // user genes
// For user genes, add option to visualize their Networks in KnetMaps via web services (api_url)
var userGenes= 0;
if(values[4].length > 0) {
userGenes= 1; // i.e., min. 1 user gene found
values[4]= values[4].trim();
if(values[4].includes(",")) { // for multiple user genes
userGenes= values[4].split(",").length; // total user genes found
}
// launch evidence network using 'userGenes'.
table = table + '<td><a href="javascript:;" class="userGenes_evidenceNetwork" title="Display in KnetMaps" id="userGenes_evidenceNetwork_'+ev_i+'">'+userGenes+'</a></td>';
}
else {
userGenes= 0;
table = table + '<td>'+userGenes+'</td>'; // zero user genes
}

// table = table + '<td>'+values[5]+'</td>'; // hide QTL for now (18/07/18)
table = table + '</tr>';
//Calculates the summary box
if (containsKey(values[0],summaryArr)){
Expand Down Expand Up @@ -1377,25 +1404,56 @@ function createEvidenceTable(text){
evidencePath(values[6]);
});

/*
* click handler for generating the evidence path network for user genes (using user_genes and search keywords, passed to api_url
* @author: Ajit Singh (19/07/2018)
*/
$(".userGenes_evidenceNetwork").bind("click", {x: evidenceTable}, function(e) {
e.preventDefault();
var evidenceNum = $(e.target).attr("id").replace("userGenes_evidenceNetwork_","");
var values = e.data.x[evidenceNum].split("\t");

var evi_userGenes= values[4].trim(); // user gene(s) provided
// Add comma-separated user genes to a new (candidates) list
var ug_list= [];
if(evi_userGenes.includes(",")) {
var vals= evi_userGenes.split(",");
for(var i=0; i < vals.length; i++) {
ug_list.push(vals[i]);
}
}
else {
ug_list.push(evi_userGenes);
}

var search_keywords= keyword.trim(); // user search keyword(s) used
// search_keywords= search_keywords.replace(/"/g, '\"').trim(); // replace all keyword double quotes with separator/quote

// console.log("generate userGenes_evidenceNetwork: keywords: "+ search_keywords +", userGenes_list: "+ ug_list);
// Generate Network
generateCyJSNetwork(api_url+'/network', {keyword:search_keywords, list:ug_list});
});

$("#tablesorterEvidence").tablesorter({
sortList: [[3,1]], //sort by score in decending order
textExtraction: function(node) { // Sort TYPE column
var attr = $(node).attr('type-sort-value');
if (typeof attr !== 'undefined' && attr !== false) {
return attr;
}
return $(node).text();
}
});
sortList: [[3,1]], //sort by score in decending order
textExtraction: function(node) { // Sort TYPE column
var attr = $(node).attr('type-sort-value');
if (typeof attr !== 'undefined' && attr !== false) {
return attr;
}
return $(node).text();
}
});

//Shows the evidence summary box
for(key in summaryArr){
var contype= key.trim();
//if (key !== "Trait") {
summaryText = summaryText+'<div class="evidenceSummaryItem"><div class="evidence_item evidence_item_'+key+' title="'+key+'"></div>'+summaryArr[key]+'</div>';
/* }
else { // For Trait, display tooltip text as GWAS instead.
summaryText = summaryText+'<div class="evidenceSummaryItem"><div class="evidence_item evidence_item_'+key+'" title="GWAS"></div>'+summaryArr[key]+'</div>';
} */
var contype= key.trim();
// if (key !== "Trait") {
summaryText= summaryText+'<div class="evidenceSummaryItem"><div class="evidence_item evidence_item_'+key+' title="'+key+'"></div>'+summaryArr[key]+'</div>';
/* }
else { // For Trait, display tooltip text as GWAS instead.
summaryText= summaryText+'<div class="evidenceSummaryItem"><div class="evidence_item evidence_item_'+key+'" title="GWAS"></div>'+summaryArr[key]+'</div>';
}*/

}

Expand Down
1 change: 1 addition & 0 deletions common/server-datasource-ondexlocal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<dependency>
<groupId>net.sourceforge.ondex.modules</groupId>
<artifactId>cyjs_json</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ from user gene list (Set<ONDEXConcept> userGenes) */

// temporary...
/* String genomaps_filename= Paths.get(this.getProperty("DataPath"), System.currentTimeMillis()+"_genomaps.xml").toString();
this.ondexServiceProvider.writeGenomapsFile(genomaps_filename, xmlGViewer);
this.ondexServiceProvider.writeResultsFile(genomaps_filename, xmlGViewer);
*/

log.debug("1.) Genomaps annotation ");
Expand All @@ -223,11 +223,19 @@ from user gene list (Set<ONDEXConcept> userGenes) */
// Gene table file
String geneTable = this.ondexServiceProvider.writeGeneTable(genes, userGenes, request.getQtl(),
request.getListMode());
// temporary...
/* String gv_filename= Paths.get(this.getProperty("DataPath"), System.currentTimeMillis()+"_GeneTable.tab").toString();
this.ondexServiceProvider.writeResultsFile(gv_filename, geneTable); */

log.debug("2.) Gene table ");

// Evidence table file
String evidenceTable = this.ondexServiceProvider.writeEvidenceTable(qtlnetminerResults.getLuceneConcepts(),
userGenes, request.getQtl());
// temporary...
/* String ev_filename= Paths.get(this.getProperty("DataPath"), System.currentTimeMillis()+"_EvidenceTable.tab").toString();
this.ondexServiceProvider.writeResultsFile(ev_filename, evidenceTable); */

log.debug("3.) Evidence table ");

// Document count (only related with genes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ public String writeAnnotationXML(String api_url, ArrayList<ONDEXConcept> genes,
}

// temporary...
public void writeGenomapsFile(String filename, String sb_string) {
public void writeResultsFile(String filename, String sb_string) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(filename));
out.write(sb_string);
Expand Down Expand Up @@ -2174,15 +2174,35 @@ public String writeEvidenceTable(HashMap<ONDEXConcept, Float> luceneConcepts, Se
Set<Integer> listOfGenes = mapConcept2Genes.get(lc.getId());
Integer numberOfGenes = listOfGenes.size();
// Creates numberOfUserGenes and numberOfQTL
Integer numberOfUserGenes = 0;
//Integer numberOfUserGenes = 0;
String user_genes="";
Integer numberOfQTL = 0;

for (int log : listOfGenes) {

ONDEXConcept gene = graph.getConcept(log);
if ((userGenes != null) && (gene != null) && (userGenes.contains(gene))) {
numberOfUserGenes++;
}
// numberOfUserGenes++;
// retain gene Accession/Name (18/07/18)
String geneAcc="";
for(ConceptAccession acc : gene.getConceptAccessions()) {
String accValue= acc.getAccession();
geneAcc = accValue;
if(acc.getElementOf().getId().equalsIgnoreCase("TAIR") && accValue.startsWith("AT")
&& (accValue.indexOf(".") == -1)) {
geneAcc = accValue;
break;
}
else if(acc.getElementOf().getId().equalsIgnoreCase("PHYTOZOME")) {
geneAcc = accValue;
break;
}
}
// use shortest preferred concept name
/* String geneName = getShortestPreferedName(gene.getConceptNames());
geneAcc= geneName; */
user_genes= user_genes + geneAcc +",";
}

if (mapGene2QTL.containsKey(log)) {
numberOfQTL++;
Expand Down Expand Up @@ -2307,8 +2327,13 @@ public String writeEvidenceTable(HashMap<ONDEXConcept, Float> luceneConcepts, Se
// }
// }
}

// omit last comma from user_genes String
if(user_genes.contains(",")) {
user_genes= user_genes.substring(0, user_genes.length()-1);
}
// writes the row
out.append(type + "\t" + name + "\t" + fmt.format(score) + "\t" + numberOfGenes + "\t" + numberOfUserGenes
out.append(type + "\t" + name + "\t" + fmt.format(score) + "\t" + numberOfGenes + "\t" + /*numberOfUserGenes*/ user_genes
+ "\t" + numberOfQTL + "\t" + ondexId + "\n");
}
//log.info("Evidence table generated...");
Expand Down
Loading

0 comments on commit c62aef9

Please sign in to comment.