<commit_before><!doctype html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<!-- phytomineOrthologDisplayer.jsp -->
<div id="phytomineOrtholog_displayer" class="collection-table">
<div class="header">
<h3>Phytozome Homologs</h3>
<p>Data Source: <a target="_blank" href="/${WEB_PROPERTIES['webapp.path']}/portal.do?class=DataSet&externalids=Phytozome+Homologs">Phytozome</a></p>
</div>

<c:set var="object" value="${reportObject.object}"/>

<c:choose>
<c:when test="${((!empty object.chromosomeLocation && !empty object.chromosome)
                || className == 'Chromosome') && className != 'ChromosomeBand'}">
<br />

<div id="InParanoidDisplayer" class="collection-table imtables-dashboard container-fluid imtables">
  <c:set var="name" value="${object.primaryIdentifier}"/>

  <c:choose>
  <c:when test="${WEB_PROPERTIES['phytomine.homolog.prefix'] != null}">
<link rel="stylesheet" type="text/css" href="https://cdn.araport.org/js/intermine/im-tables/latest/imtables.css">
 <div id="phytomine-homolog-container">
 <!-- temporarily removed
   <p class="apology">
     Please be patient while the results of your query are retrieved.
   </p>
   -->
 </div>

 <script type="text/javascript">

   var geneId = "${name}";
   // for local test only
   // var webapp_root_url="http://phytozome.jgi.doe.gov/phytomine/";
   var webapp_root_url = "${WEB_PROPERTIES['phytomine.homolog.prefix']}";

   var options = {
     type: 'table',
     url: webapp_root_url,
     query: {"model":{"name":"genomic"},"select":["Homolog.gene2.name","Homolog.organism2.shortName","Homolog.gene2.briefDescription"],"constraintLogic":"A and B","where":[{"path":"Homolog.organism1.taxonId","op":"=","code":"A","value":"3702"},{"path":"Homolog.gene1.name","op":"=","code":"B","value":geneId}]},
     properties: { pageSize: 10 }
    };

   var wrapSpan = function(text){
       return '<span>'+text+'</span>';
    };

   var formatLink = function(url, text, target, cls){
     target = target || "_self";
     text = text || url;

    if (cls == 'extlink') {
          return '<a class="'+cls+'" href="'+url+'" target="'+target+'">' + text + '</a>';
       } else {
          return '<a href="'+url+'" target="'+target+'">' + text + '</a>';
       }
     };

   var formatGeneLink = function(id) {
       var thalemine_url = '/${WEB_PROPERTIES['webapp.path']}' + '/portal.do?class=Gene&externalids=' + id;
       var phytomine_url = '${WEB_PROPERTIES['intermines.phytomine.url']}' + '/portal.do?class=Gene&externalids=' + id;
       var re = new RegExp("^AT");
          if (re.test(id)) {
             url = thalemine_url;
             return formatLink(url, wrapSpan(id), "_blank", 'internal');
          } else {
             url = phytomine_url;
              return formatLink(url, wrapSpan(id), "_blank", 'extlink');
            }
     };

   var phytomineGeneFormatter = function(o) {
        return formatGeneLink(o.get('name'));
     };

    // new way for using imtables
    imtables.formatting
                .registerFormatter(phytomineGeneFormatter, 'genomic', 'Gene', [ 'name' ]);

    // note: imtables.loadTable delivers a table without controls (only pagination)
    imtables.loadDash('#phytomine-homolog-container',
        {start : 0, size : 25},
        {service : {root : options.url},
            query : options.query}
        ).then(<commit_msg>+ Fix link outs from Phytomine homologs table (MINE-933)<commit_after><!doctype html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<!-- phytomineOrthologDisplayer.jsp -->
<div id="phytomineOrtholog_displayer" class="collection-table">
<div class="header">
<h3>Phytozome Homologs</h3>
<p>Data Source: <a target="_blank" href="/${WEB_PROPERTIES['webapp.path']}/portal.do?class=DataSet&externalids=Phytozome+Homologs">Phytozome</a></p>
</div>

<c:set var="object" value="${reportObject.object}"/>

<c:choose>
<c:when test="${((!empty object.chromosomeLocation && !empty object.chromosome)
                || className == 'Chromosome') && className != 'ChromosomeBand'}">
<br />

<div id="InParanoidDisplayer" class="collection-table imtables-dashboard container-fluid imtables">
  <c:set var="name" value="${object.primaryIdentifier}"/>

  <c:choose>
  <c:when test="${WEB_PROPERTIES['phytomine.homolog.prefix'] != null}">
<link rel="stylesheet" type="text/css" href="https://cdn.araport.org/js/intermine/im-tables/latest/imtables.css">
 <div id="phytomine-homolog-container">
 <!-- temporarily removed
   <p class="apology">
     Please be patient while the results of your query are retrieved.
   </p>
   -->
 </div>

 <script type="text/javascript">

   var geneId = "${name}";
   // for local test only
   // var webapp_root_url="http://phytozome.jgi.doe.gov/phytomine/";
   var webapp_root_url = "${WEB_PROPERTIES['phytomine.homolog.prefix']}";

   var options = {
     type: 'table',
     url: webapp_root_url,
     query: {"model":{"name":"genomic"},"select":["Homolog.gene2.name","Homolog.organism2.shortName","Homolog.gene2.briefDescription"],"constraintLogic":"A and B","where":[{"path":"Homolog.organism1.taxonId","op":"=","code":"A","value":"3702"},{"path":"Homolog.gene1.name","op":"=","code":"B","value":geneId}]},
     properties: { pageSize: 10 }
    };

   var wrapSpan = function(text){
       return '<span>'+text+'</span>';
    };

   var formatLink = function(url, text, target, cls){
     target = target || "_self";
     text = text || url;

    if (cls == 'extlink') {
          return '<a class="'+cls+'" href="'+url+'" target="'+target+'">' + text + '</a>';
       } else {
          return '<a href="'+url+'" target="'+target+'">' + text + '</a>';
       }
     };

    var formatPhytomineLink = function(id, dataClass, pattern, value) {
        var thalemine_url = '/${WEB_PROPERTIES['webapp.path']}' + '/portal.do?class=' + dataClass + '&externalids=' + id;
        var phytomine_url = '${WEB_PROPERTIES['intermines.phytomine.url']}' + '/portal.do?class=' + dataClass + '&externalids=' + id;
        if (typeof value === 'undefined') {
            value = id;
        }
        var re = new RegExp(pattern);
        if (re.test(id)) {
            return formatLink(thalemine_url, wrapSpan(value), "_blank", 'internal');
        } else {
            return formatLink(phytomine_url, wrapSpan(value), "_blank", 'extlink');
        }
    };

    var phytomineGeneFormatter = function(o) {
        return formatPhytomineLink(o.get('name'), "Gene", "^AT", undefined);
    };

    var phytomineOrganismFormatter = function(o) {
        return formatPhytomineLink(o.get('shortName'), "Organism", "thaliana$", undefined);
    };

    var phytomineDeflineFormatter = function(o) {
        return formatPhytomineLink(o.get('name'), "Gene", "^AT", o.get('briefDescription'));
    };

    // new way for using imtables
    imtables.formatting
                .registerFormatter(phytomineGeneFormatter, 'genomic', 'Gene', [ 'name' ]);

    imtables.formatting
                .registerFormatter(phytomineOrganismFormatter, 'genomic', 'Organism', [ 'shortName' ]);

    imtables.formatting
                .registerFormatter(phytomineDeflineFormatter, 'genomic', 'Gene', [ 'briefDescription' ]);


    // note: imtables.loadTable delivers a table without controls (only pagination)
    imtables.loadDash('#phytomine-homolog-container',
        {start : 0, size : 25},
        {service : {root : options.url},
            query : options.query}
        ).then(
{'fraction_non_alphanumeric': 0.19513437778626927, 'fraction_numerical': 0.004458030824098841, 'mean_word_length': 3.6961722488038276, 'pattern_counts': {'":': 26, '<': 75, '<?xml version=': 0, '>': 75, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '259743', 'n_tokens_mistral': 2748, 'n_tokens_neox': 2625, 'n_words': 461}