@@ -285,8 +285,68 @@ public boolean isSortable()
285285
286286 private HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType )
287287 {
288- String gctFileUrl = getDavUrl () + "GCT/" + PageFlowUtil .encodePath (fileName );
289- return LincsDataTable .externalHeatmapViewerLink (fileName , assayType , gctFileUrl );
288+ return externalHeatmapViewerLink (fileName , assayType , getGctDavUrl (fileName ));
289+ }
290+
291+ private static String getAnalyticsScript (String eventAction , String fileName , boolean addWaitTime )
292+ {
293+ if (!StringUtils .isBlank (AnalyticsService .getTrackingScript ()))
294+ {
295+ // http://www.blastam.com/blog/how-to-track-downloads-in-google-analytics
296+ // Tell the browser to wait 400ms before going to the download. This is to ensure
297+ // that the GA tracking request goes through. Some browsers will interrupt the tracking
298+ // request if the download opens on the same page.
299+ String timeout = addWaitTime ? "that=this; setTimeout(function(){location.href=that.href;},400);return false;" : "" ;
300+
301+ // GA4 variant
302+ String onClickScript = "try {gtag('event', 'Lincs', {eventAction: " + PageFlowUtil .qh (eventAction ) + ", fileName: " + PageFlowUtil .qh (fileName ) + "}); } catch(err) {}" ;
303+ onClickScript += timeout ;
304+ return onClickScript ;
305+ }
306+ return null ;
307+ }
308+
309+ public static HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType , String gctFileDavUrl )
310+ {
311+ String morpheusUrl = getMorpheusUrl (gctFileDavUrl , assayType );
312+
313+ String analyticsScript = getAnalyticsScript ("Morpheus" , fileName , false );
314+
315+ String imgUrl = AppProps .getInstance ().getContextPath () + "/lincs/GENE-E_icon.png" ;
316+
317+ LinkBuilder viewInMorpheusLink = LinkBuilder .simpleLink ("View in Morpheus" , morpheusUrl ).target ("_blank" );
318+ if (analyticsScript != null )
319+ {
320+ viewInMorpheusLink .onClick (analyticsScript );
321+ }
322+
323+ return HtmlString .of (DOM .SPAN ("[" ,
324+ HtmlString .NBSP ,
325+ viewInMorpheusLink ,
326+ HtmlString .NBSP ,
327+ IMG (at (src , imgUrl ).at (width , 13 ).at (height , 13 )),
328+ HtmlString .NBSP ,
329+ "]" ));
330+ }
331+
332+ private static String getMorpheusUrl (String gctFileUrl , LincsModule .LincsAssay assayType )
333+ {
334+ String morpheusJson = "{\" dataset\" :\" " + gctFileUrl + "\" ," ;
335+ if (assayType == LincsModule .LincsAssay .P100 )
336+ {
337+ morpheusJson += "\" rows\" :[{\" field\" :\" pr_p100_modified_peptide_code\" ,\" display\" :\" Text\" },{\" field\" :\" pr_gene_symbol\" ,\" display\" :\" Text\" },{\" field\" :\" pr_p100_phosphosite\" ,\" display\" :\" Text\" },{\" field\" :\" pr_uniprot_id\" ,\" display\" :\" Text\" }]," ;
338+ }
339+ if (assayType == LincsModule .LincsAssay .GCP )
340+ {
341+ morpheusJson += "\" rows\" :[{\" field\" :\" pr_gcp_histone_mark\" ,\" display\" :\" Text\" },{\" field\" :\" pr_gcp_modified_peptide_code\" ,\" display\" :\" Text\" }]," ;
342+ }
343+ morpheusJson += "\" columns\" :[{\" field\" :\" pert_iname\" ,\" display\" :\" Text\" },{\" field\" :\" det_well\" ,\" display\" :\" Text\" }]," ;
344+ morpheusJson += "\" colorScheme\" :{\" type\" :\" fixed\" ,\" map\" :[{\" value\" :-3,\" color\" :\" blue\" },{\" value\" :0,\" color\" :\" white\" },{\" value\" :3,\" color\" :\" red\" }]}" ;
345+ morpheusJson += "}" ;
346+
347+ String morpheusUrl = "http://www.broadinstitute.org/cancer/software/morpheus/?json=" ;
348+ morpheusUrl += PageFlowUtil .encodeURIComponent (morpheusJson );
349+ return morpheusUrl ;
290350 }
291351
292352 @ Override
@@ -441,65 +501,4 @@ public Object getDisplayValue(RenderContext ctx)
441501 return getValue (ctx );
442502 }
443503 }
444-
445- private static String getAnalyticsScript (String eventAction , String fileName , boolean addWaitTime )
446- {
447- if (!StringUtils .isBlank (AnalyticsService .getTrackingScript ()))
448- {
449- // http://www.blastam.com/blog/how-to-track-downloads-in-google-analytics
450- // Tell the browser to wait 400ms before going to the download. This is to ensure
451- // that the GA tracking request goes through. Some browsers will interrupt the tracking
452- // request if the download opens on the same page.
453- String timeout = addWaitTime ? "that=this; setTimeout(function(){location.href=that.href;},400);return false;" : "" ;
454-
455- // GA4 variant
456- String onClickScript = "try {gtag('event', 'Lincs', {eventAction: " + PageFlowUtil .qh (eventAction ) + ", fileName: " + PageFlowUtil .qh (fileName ) + "}); } catch(err) {}" ;
457- onClickScript += timeout ;
458- return onClickScript ;
459- }
460- return null ;
461- }
462-
463- public static HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType , String gctFileDavUrl )
464- {
465- String morpheusUrl = getMorpheusUrl (gctFileDavUrl , assayType );
466-
467- String analyticsScript = getAnalyticsScript ("Morpheus" , fileName , false );
468-
469- String imgUrl = AppProps .getInstance ().getContextPath () + "/lincs/GENE-E_icon.png" ;
470-
471- LinkBuilder viewInMorpheusLink = LinkBuilder .simpleLink ("View in Morpheus" , morpheusUrl ).target ("_blank" );
472- if (analyticsScript != null )
473- {
474- viewInMorpheusLink .onClick (analyticsScript );
475- }
476-
477- return HtmlString .of (DOM .SPAN ("[" ,
478- HtmlString .NBSP ,
479- viewInMorpheusLink ,
480- HtmlString .NBSP ,
481- IMG (at (src , imgUrl ).at (width , 13 ).at (height , 13 )),
482- HtmlString .NBSP ,
483- "]" ));
484- }
485-
486- private static String getMorpheusUrl (String gctFileUrl , LincsModule .LincsAssay assayType )
487- {
488- String morpheusJson = "{\" dataset\" :\" " + gctFileUrl + "\" ," ;
489- if (assayType == LincsModule .LincsAssay .P100 )
490- {
491- morpheusJson += "\" rows\" :[{\" field\" :\" pr_p100_modified_peptide_code\" ,\" display\" :\" Text\" },{\" field\" :\" pr_gene_symbol\" ,\" display\" :\" Text\" },{\" field\" :\" pr_p100_phosphosite\" ,\" display\" :\" Text\" },{\" field\" :\" pr_uniprot_id\" ,\" display\" :\" Text\" }]," ;
492- }
493- if (assayType == LincsModule .LincsAssay .GCP )
494- {
495- morpheusJson += "\" rows\" :[{\" field\" :\" pr_gcp_histone_mark\" ,\" display\" :\" Text\" },{\" field\" :\" pr_gcp_modified_peptide_code\" ,\" display\" :\" Text\" }]," ;
496- }
497- morpheusJson += "\" columns\" :[{\" field\" :\" pert_iname\" ,\" display\" :\" Text\" },{\" field\" :\" det_well\" ,\" display\" :\" Text\" }]," ;
498- morpheusJson += "\" colorScheme\" :{\" type\" :\" fixed\" ,\" map\" :[{\" value\" :-3,\" color\" :\" blue\" },{\" value\" :0,\" color\" :\" white\" },{\" value\" :3,\" color\" :\" red\" }]}" ;
499- morpheusJson += "}" ;
500-
501- String morpheusUrl = "http://www.broadinstitute.org/cancer/software/morpheus/?json=" ;
502- morpheusUrl += PageFlowUtil .encodeURIComponent (morpheusJson );
503- return morpheusUrl ;
504- }
505504}
0 commit comments