<commit_before>define([
  'dojo/_base/declare', 'dijit/layout/BorderContainer', 'dojo/on', 'dojo/query',
  'dojo/dom-class', 'dojo/dom-construct', 'dojo/dom-attr',
  './WorkspaceExplorerView', 'dojo/topic', './ItemDetailPanel',
  './ActionBar', 'dojo/_base/Deferred', '../WorkspaceManager', 'dojo/_base/lang', '../util/PathJoin',
  './Confirmation', './SelectionToGroup', 'dijit/Dialog', 'dijit/TooltipDialog',
  'dijit/popup', 'dijit/form/Select', './ContainerActionBar', './GroupExplore', './PerspectiveToolTip',
  'dijit/form/TextBox', './WorkspaceObjectSelector', './PermissionEditor',
  'dojo/promise/all', '../util/encodePath', 'dojo/when', 'dojo/request',

  'dojo/NodeList-traverse'
], function (
  declare, BorderContainer, on, query,
  domClass, domConstruct, domAttr,
  WorkspaceExplorerView, Topic, ItemDetailPanel,
  ActionBar, Deferred, WorkspaceManager, lang, PathJoin,
  Confirmation, SelectionToGroup, Dialog, TooltipDialog,
  popup, Select, ContainerActionBar, GroupExplore, PerspectiveToolTipDialog,
  TextBox, WSObjectSelector, PermissionEditor,
  All, encodePath, when, request
) {

  var mmc = '<div class="wsActionTooltip" rel="dna">Nucleotide</div><div class="wsActionTooltip" rel="protein">Amino Acid</div>';
  var viewMSATT = new TooltipDialog({
    content: mmc,
    onMouseLeave: function () {
      popup.close(viewMSATT);
    }
  });

  on(viewMSATT.domNode, 'click', function (evt) {
    var rel = evt.target.attributes.rel.value;
    var sel = viewMSATT.selection;
    Topic.publish('/navigate', { href: '/view/MSA/' + rel + sel, target: 'blank' });
  });

  return declare([BorderContainer], {
    baseClass: 'WorkspaceBrowser',
    disabled: false,
    path: '/',
    gutters: false,
    navigableTypes: ['parentfolder', 'folder', 'job_result', 'experiment_group',
      'experiment', 'unspecified', 'contigs', 'reads', 'model', 'txt', 'html',
      'pdf', 'string', 'json', 'csv', 'diffexp_experiment',
      'diffexp_expression', 'diffexp_mapping', 'diffexp_sample',
      'diffexp_input_data', 'diffexp_input_metadata', 'svg', 'gif', 'png', 'jpg'],
    design: 'sidebar',
    splitter: false,
    docsServiceURL: window.App.docsServiceURL,
    tutorialLink: 'user_guides/workspaces/workspace.html',
    startup: function () {
      var self = this;

      if (this._started) {
        return;
      }

      this.actionPanel = new ActionBar({
        splitter: false,
        region: 'right',
        layoutPriority: 2,
        style: 'width: 57px; text-align: center;'
      });

      this.browserHeader = new ContainerActionBar({
        region: 'top',
        className: 'BrowserHeader WSBrowserHeader',
        path: this.path,
        layoutPriority: 3
      });

      this.actionPanel.addAction('ToggleItemDetail', 'fa icon-chevron-circle-right fa-2x', {
        label: 'HIDE',
        persistent: true,
        validTypes: ['*'],
        tooltip: 'Toggle Selection Detail'
      }, function (selection) {
        if (self.getChildren().some(function (child) {
          return child === self.itemDetailPanel;
        })) {
          self.removeChild(self.itemDetailPanel);
        } else {
          self.addChild(self.itemDetailPanel);
        }
      }, true);

      // show / hide item detail panel button
      var hideBtn = query('[rel="ToggleItemDetail"]', this.actionPanel.domNode)[0];
      on(hideBtn, 'click', function (e) {
        var icon = query('.fa', hideBtn)[0],
          text = query('.ActionButtonText', hideBtn)[0];

        domClass.toggle(icon, 'icon-chevron-circle-right');
        domClass.toggle(icon, 'icon-chevron-circle-left');

        if (domClass.contains(icon, 'icon-chevron-circle-left'))
        { domAttr.set(text, 'textContent', 'SHOW'); }
        else
        { domAttr.set(text, 'textContent', 'HIDE'); }
      });

      this.actionPanel.addAction('UserGuide', 'fa icon-info-circle fa-2x', {
        label: 'GUIDE <i class="icon-external-link"></i>',
        persistent: true,
        validTypes: ['*'],
        tooltip: 'Open User Guide in a new Tab'
      }, function (selection, container) {
        var type = container && '_resultType' in container ? container._resultType : null;
        var path;
        if (!type) {
          path = self.tutorialLink;
        } else if (type == 'GenomeAssembly') {
          path = 'user_guides/services/genome_assembly_service.html#output-results';
        } else if (type == 'GenomeAnnotation') {
          path = 'user_guides/services/genome_annotation_service.html#output-results';
        } else if (type == 'ComprehensiveGenomeAnalysis') {
          path = 'user_guides/services/comprehensive_genome_analysis_service.html#output-results';
        } else if (type == 'GenomeAlignment') {
          path = 'user_guides/services/genome_alignment_service.html#output-results';
        } else if (type == 'MetagenomeBinning') {
          path = 'user_guides/services/metagenomic_binning_service.html#output-results';
        } else if (type == 'MetagenomicReadMapping') {
          path = 'user_guides/services/metagenomic_read_mapping_service.html#output-results';
        } else if (type == 'TaxonomicClassification') {
          path = 'user_guides/services/taxonomic_classification_service.html#output-results';
        } else if (type == 'PhylogeneticTree') {
          path = 'user_guides/services/phylogenetic_tree_building_service.html#output-results';
        } else if (type == 'RNASeq') {
          path = 'user_guides/services/rna_seq_analysis_service.html#output-results';
        } else if (type == 'TnSeq') {
          path = 'user_guides/services/tn_seq_analysis_service.html#output-results';
        } else if (type == 'Variation') {
          path = 'user_guides/services/variation_analysis_service.html#output-results';
        } else if ('data' in container && container.data.type == 'model') {
          // modeling service uses typed folders
          path = 'user_guides/services/model_reconstruction_service.html#output-results';
        } else if ('_appLabel' in container && container._appLabel == 'Genome Comparison') {
          // _resultType is not set; todo: fix in job result container
          path = 'user_guides/services/proteome_comparison_service.html#output-results';
        } else if ('_appLabel' in container && container._appLabel == 'Differential Expression') {
          // _resultType is not set
          path = 'user_guides/services/expression_data_import_service.html#output-results';
        } else {
          path = self.tutorialLink;
        }

        window.open(PathJoin(self.docsServiceURL, path), '_blank');
      }, true);

      this.actionPanel.addAction('ViewGenomeGroup', 'MultiButton fa icon-selection-GenomeList fa-2x', {
        label: 'VIEW',
        validTypes: ['genome_group'],
        multiple: false,
        tooltip: 'Switch to the Genome Group View.',
        pressAndHold: function (selection, button, opts, evt) {

          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'GenomeGroup',
              perspectiveUrl: '/view/GenomeGroup/' + encodePath(selection[0].path)
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/GenomeGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(genome_id,GenomeGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          Topic.publish('/navigate', { href: '/view/GenomeList/?' + q });
        }
      }, false);

      this.actionPanel.addAction('ViewGenomeGroups', 'MultiButton fa icon-selection-GenomeList fa-2x', {
        label: 'VIEW',
        validTypes: ['genome_group'],
        multiple: true,
        min: 2,
        tooltip: 'Switch to the Genome List View.',
        pressAndHold: function (selection, button, opts, evt) {

          var q = selection.map(function (sel) {
            return 'in(genome_id,GenomeGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'GenomeList',
              perspectiveUrl: '/view/GenomeList/' + q
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/GenomeGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(genome_id,GenomeGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          Topic.publish('/navigate', { href: '/view/GenomeList/?' + q });
        }
      }, false);

      this.actionPanel.addAction('ViewFeatureGroup', 'MultiButton fa icon-selection-FeatureList fa-2x', {
        label: 'VIEW',
        validTypes: ['feature_group'],
        multiple: false,
        tooltip: 'Switch to the Feature Group View.',
        pressAndHold: function (selection, button, opts, evt) {

          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'FeatureGroup',
              perspectiveUrl: '/view/FeatureGroup/' + encodePath(selection[0].path)
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(feature_id,FeatureGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';

          Topic.publish('/navigate', { href: '/view/FeatureList/?' + q });
        }
      });

      this.actionPanel.addAction('ViewFeatureGroups', 'MultiButton fa icon-selection-FeatureList fa-2x', {
        label: 'VIEW',
        validTypes: ['feature_group'],
        multiple: true,
        min: 2,
        tooltip: 'Switch to the Feature List View.',
        pressAndHold: function (selection, button, opts, evt) {

          var q = selection.map(function (sel) {
            return 'in(feature_id,FeatureGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'FeatureList',
              perspectiveUrl: '/view/FeatureList/' + q
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(feature_id,FeatureGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';

          Topic.publish('/navigate', { href: '/view/FeatureList/?' + q });
        }
      });

      this.actionPanel.addAction('ViewFeatureItem', 'MultiButton fa icon-selection-Feature fa-2x', {
        label: 'FEATURE',
        validTypes: ['*'],
        validContainerTypes: ['csvFeature'],    // csv and tsv tables only
        multiple: false,
        tooltip: 'Switch to Feature View.  Press and Hold for more options.',
        pressAndHold: function(selection, button, opts, evt) {
          if (selection[0].Gene_ID) {
            var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
            var query = '?eq(patric_id,' + sel + ')&select(feature_id)';
  
            when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
              handleAs: 'json',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
                'X-Requested-With': null,
                Authorization: (window.App.authorizationToken || '')
              
              }
            }), function(response){
              popup.open ({
                popup: new PerspectiveToolTipDialog ({
                  perspective: 'Feature',
                  perspectiveUrl: '/view/Feature/' + response[0].feature_id
                }),
                around: button,
                orient: ['below']
              });
              //Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
            }); 
          }
        },
      
      }, function (selection) {
        if (selection[0].Gene_ID) {
          var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
          var query = '?eq(patric_id,' + sel + ')&select(feature_id)';

          when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
            handleAs: 'json',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
              'X-Requested-With': null,
              Authorization: (window.App.authorizationToken || '')
            
            }
          }), function(response){
            Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
          }); 
        }       
      });

      this.actionPanel.addAction('ViewFeatureGroups', 'MultiButton fa icon-selection-FeatureList fa-2x', {
        label: 'FEATURES',
        validTypes: ['*'],
        validContainerTypes: ['csvFeature'],
        multiple: true,
        min: 2,
        tooltip: 'Switch to the Feature List View. Press and Hold for more options.',
        pressAndHold: function (selection, button, opts, evt) { 
          if (selection.length == 1) {
            Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
          } else {
            var q = selection.map(function (sel) {
              if (sel.Gene_ID) {
                return (sel.Gene_ID).replace("|", "%7C");
              }
              return "";
            });
  
            // some entries in the table do not have PATRIC_ID, so they cannot be linked to the features list
            var noEmptyFeatureIDs = q.filter(function(elem) {
              return (elem != "");
            });
            
            q = '?in(patric_id,(' + noEmptyFeatureIDs + '))&select(feature_id)';
            when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', q), {
              handleAs: 'json',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
                'X-Requested-With': null,
                Authorization: (window.App.authorizationToken || '')
              
              }
            }), function(response){
              var featureIDs = response.map(function(response) { return response.feature_id; }).join(',');
              var featureList = '?in(feature_id,(' + featureIDs + '))';
              popup.open ({
                popup: new PerspectiveToolTipDialog ({
                  perspective: 'FeatureList',
                  perspectiveUrl: '/view/FeatureList/' + featureList
                }),
                around: button,
                orient: ['below']
              });
              //Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
            }); 
          }
        },    
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            if (sel.Gene_ID) {
              return (sel.Gene_ID).replace("|", "%7C");
            }
            return "";
          });

          // some entries in the table do not have PATRIC_ID, so they cannot be linked to the features list
          var noEmptyFeatureIDs = q.filter(function(elem) {
            return (elem != "");
          });
          
          q = '?in(patric_id,(' + noEmptyFeatureIDs + '))&select(feature_id)';
          when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', q), {
            handleAs: 'json',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
              'X-Requested-With': null,
              Authorization: (window.App.authorizationToken || '')
            
            }
          }), function(response){
            var featureIDs = response.map(function(response) { return response.feature_id; }).join(',');
            var featureList = '?in(feature_id,(' + featureIDs + '))';
            Topic.publish('/navigate', { href: '/view/FeatureList/' +  featureList})
          }); 
        }
      });

      this.actionPanel.addAction('ViewGenomeItem', 'MultiButton fa icon-selection-Genome fa-2x', {
        label: 'GENOME',
        validTypes: ['*'],
        ignoreDataType: true,
        validContainerTypes: ['csvFeature'],    // csv and tsv tables only
        multiple: false,
        tooltip: 'Switch to Genome View.  Press and Hold for more options.',
        pressAndHold: function(selection, button, opts, evt) {
          if (selection[0].Gene_ID) {
            var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
            var query = '?eq(patric_id,' + sel + ')&select(genome_id)';
  
            when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
              handleAs: 'json',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
                'X-Requested-With': null,
                Authorization: (window.App.authorizationToken || '')
              
              }
            }), function(response){
              popup.open ({
                popup: new PerspectiveToolTipDialog ({
                  perspective: 'Genome',
                  perspectiveUrl: '/view/Genome/' + response[0].genome_id
                }),
                around: button,
                orient: ['below']
              });
              //Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
            }); 
          }
        },
      
      }, function (selection) {
        if (selection[0].Gene_ID) {
          var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
          var query = '?eq(patric_id,' + sel + ')&select(genome_id)';

          when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
            handleAs: 'json',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
              'X-Requested-With': null,
              Authorization: (window.App.authorizationToken || '')
            
            }
          }), function(response){
            Topic.publish('/navigate', { href: '/view/Genome/' + response[0].genome_id })
          }); 
        }       
      });
         

      this.actionPanel.addAction('MultipleSeqAlignmentFeatures', 'fa icon-alignment fa-2x', {
        label: 'MSA',
        validTypes: ['feature_group'],
        multiple: false,
        tooltipDialog: viewMSATT,
        tooltip: 'Multiple Sequence Alignment'
      }, function (selection) {
        var q = self.getQuery(selection[0]);
        viewMSATT.selection = q;
        popup.open({
          popup: this._actions.MultipleSeqAlignmentFeatures.options.tooltipDialog,
          around: this._actions.MultipleSeqAlignmentFeatures.button,
          orient: ['below']<commit_msg>Added Genome List button on multiple selection of rows<commit_after>define([
  'dojo/_base/declare', 'dijit/layout/BorderContainer', 'dojo/on', 'dojo/query',
  'dojo/dom-class', 'dojo/dom-construct', 'dojo/dom-attr',
  './WorkspaceExplorerView', 'dojo/topic', './ItemDetailPanel',
  './ActionBar', 'dojo/_base/Deferred', '../WorkspaceManager', 'dojo/_base/lang', '../util/PathJoin',
  './Confirmation', './SelectionToGroup', 'dijit/Dialog', 'dijit/TooltipDialog',
  'dijit/popup', 'dijit/form/Select', './ContainerActionBar', './GroupExplore', './PerspectiveToolTip',
  'dijit/form/TextBox', './WorkspaceObjectSelector', './PermissionEditor',
  'dojo/promise/all', '../util/encodePath', 'dojo/when', 'dojo/request',

  'dojo/NodeList-traverse'
], function (
  declare, BorderContainer, on, query,
  domClass, domConstruct, domAttr,
  WorkspaceExplorerView, Topic, ItemDetailPanel,
  ActionBar, Deferred, WorkspaceManager, lang, PathJoin,
  Confirmation, SelectionToGroup, Dialog, TooltipDialog,
  popup, Select, ContainerActionBar, GroupExplore, PerspectiveToolTipDialog,
  TextBox, WSObjectSelector, PermissionEditor,
  All, encodePath, when, request
) {

  var mmc = '<div class="wsActionTooltip" rel="dna">Nucleotide</div><div class="wsActionTooltip" rel="protein">Amino Acid</div>';
  var viewMSATT = new TooltipDialog({
    content: mmc,
    onMouseLeave: function () {
      popup.close(viewMSATT);
    }
  });

  on(viewMSATT.domNode, 'click', function (evt) {
    var rel = evt.target.attributes.rel.value;
    var sel = viewMSATT.selection;
    Topic.publish('/navigate', { href: '/view/MSA/' + rel + sel, target: 'blank' });
  });

  return declare([BorderContainer], {
    baseClass: 'WorkspaceBrowser',
    disabled: false,
    path: '/',
    gutters: false,
    navigableTypes: ['parentfolder', 'folder', 'job_result', 'experiment_group',
      'experiment', 'unspecified', 'contigs', 'reads', 'model', 'txt', 'html',
      'pdf', 'string', 'json', 'csv', 'diffexp_experiment',
      'diffexp_expression', 'diffexp_mapping', 'diffexp_sample',
      'diffexp_input_data', 'diffexp_input_metadata', 'svg', 'gif', 'png', 'jpg'],
    design: 'sidebar',
    splitter: false,
    docsServiceURL: window.App.docsServiceURL,
    tutorialLink: 'user_guides/workspaces/workspace.html',
    startup: function () {
      var self = this;

      if (this._started) {
        return;
      }

      this.actionPanel = new ActionBar({
        splitter: false,
        region: 'right',
        layoutPriority: 2,
        style: 'width: 57px; text-align: center;'
      });

      this.browserHeader = new ContainerActionBar({
        region: 'top',
        className: 'BrowserHeader WSBrowserHeader',
        path: this.path,
        layoutPriority: 3
      });

      this.actionPanel.addAction('ToggleItemDetail', 'fa icon-chevron-circle-right fa-2x', {
        label: 'HIDE',
        persistent: true,
        validTypes: ['*'],
        tooltip: 'Toggle Selection Detail'
      }, function (selection) {
        if (self.getChildren().some(function (child) {
          return child === self.itemDetailPanel;
        })) {
          self.removeChild(self.itemDetailPanel);
        } else {
          self.addChild(self.itemDetailPanel);
        }
      }, true);

      // show / hide item detail panel button
      var hideBtn = query('[rel="ToggleItemDetail"]', this.actionPanel.domNode)[0];
      on(hideBtn, 'click', function (e) {
        var icon = query('.fa', hideBtn)[0],
          text = query('.ActionButtonText', hideBtn)[0];

        domClass.toggle(icon, 'icon-chevron-circle-right');
        domClass.toggle(icon, 'icon-chevron-circle-left');

        if (domClass.contains(icon, 'icon-chevron-circle-left'))
        { domAttr.set(text, 'textContent', 'SHOW'); }
        else
        { domAttr.set(text, 'textContent', 'HIDE'); }
      });

      this.actionPanel.addAction('UserGuide', 'fa icon-info-circle fa-2x', {
        label: 'GUIDE <i class="icon-external-link"></i>',
        persistent: true,
        validTypes: ['*'],
        tooltip: 'Open User Guide in a new Tab'
      }, function (selection, container) {
        var type = container && '_resultType' in container ? container._resultType : null;
        var path;
        if (!type) {
          path = self.tutorialLink;
        } else if (type == 'GenomeAssembly') {
          path = 'user_guides/services/genome_assembly_service.html#output-results';
        } else if (type == 'GenomeAnnotation') {
          path = 'user_guides/services/genome_annotation_service.html#output-results';
        } else if (type == 'ComprehensiveGenomeAnalysis') {
          path = 'user_guides/services/comprehensive_genome_analysis_service.html#output-results';
        } else if (type == 'GenomeAlignment') {
          path = 'user_guides/services/genome_alignment_service.html#output-results';
        } else if (type == 'MetagenomeBinning') {
          path = 'user_guides/services/metagenomic_binning_service.html#output-results';
        } else if (type == 'MetagenomicReadMapping') {
          path = 'user_guides/services/metagenomic_read_mapping_service.html#output-results';
        } else if (type == 'TaxonomicClassification') {
          path = 'user_guides/services/taxonomic_classification_service.html#output-results';
        } else if (type == 'PhylogeneticTree') {
          path = 'user_guides/services/phylogenetic_tree_building_service.html#output-results';
        } else if (type == 'RNASeq') {
          path = 'user_guides/services/rna_seq_analysis_service.html#output-results';
        } else if (type == 'TnSeq') {
          path = 'user_guides/services/tn_seq_analysis_service.html#output-results';
        } else if (type == 'Variation') {
          path = 'user_guides/services/variation_analysis_service.html#output-results';
        } else if ('data' in container && container.data.type == 'model') {
          // modeling service uses typed folders
          path = 'user_guides/services/model_reconstruction_service.html#output-results';
        } else if ('_appLabel' in container && container._appLabel == 'Genome Comparison') {
          // _resultType is not set; todo: fix in job result container
          path = 'user_guides/services/proteome_comparison_service.html#output-results';
        } else if ('_appLabel' in container && container._appLabel == 'Differential Expression') {
          // _resultType is not set
          path = 'user_guides/services/expression_data_import_service.html#output-results';
        } else {
          path = self.tutorialLink;
        }

        window.open(PathJoin(self.docsServiceURL, path), '_blank');
      }, true);

      this.actionPanel.addAction('ViewGenomeGroup', 'MultiButton fa icon-selection-GenomeList fa-2x', {
        label: 'VIEW',
        validTypes: ['genome_group'],
        multiple: false,
        tooltip: 'Switch to the Genome Group View.',
        pressAndHold: function (selection, button, opts, evt) {

          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'GenomeGroup',
              perspectiveUrl: '/view/GenomeGroup/' + encodePath(selection[0].path)
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/GenomeGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(genome_id,GenomeGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          Topic.publish('/navigate', { href: '/view/GenomeList/?' + q });
        }
      }, false);

      this.actionPanel.addAction('ViewGenomeGroups', 'MultiButton fa icon-selection-GenomeList fa-2x', {
        label: 'VIEW',
        validTypes: ['genome_group'],
        multiple: true,
        min: 2,
        tooltip: 'Switch to the Genome List View.',
        pressAndHold: function (selection, button, opts, evt) {

          var q = selection.map(function (sel) {
            return 'in(genome_id,GenomeGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'GenomeList',
              perspectiveUrl: '/view/GenomeList/' + q
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/GenomeGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(genome_id,GenomeGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          Topic.publish('/navigate', { href: '/view/GenomeList/?' + q });
        }
      }, false);

      this.actionPanel.addAction('ViewFeatureGroup', 'MultiButton fa icon-selection-FeatureList fa-2x', {
        label: 'VIEW',
        validTypes: ['feature_group'],
        multiple: false,
        tooltip: 'Switch to the Feature Group View.',
        pressAndHold: function (selection, button, opts, evt) {

          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'FeatureGroup',
              perspectiveUrl: '/view/FeatureGroup/' + encodePath(selection[0].path)
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(feature_id,FeatureGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';

          Topic.publish('/navigate', { href: '/view/FeatureList/?' + q });
        }
      });

      this.actionPanel.addAction('ViewFeatureGroups', 'MultiButton fa icon-selection-FeatureList fa-2x', {
        label: 'VIEW',
        validTypes: ['feature_group'],
        multiple: true,
        min: 2,
        tooltip: 'Switch to the Feature List View.',
        pressAndHold: function (selection, button, opts, evt) {

          var q = selection.map(function (sel) {
            return 'in(feature_id,FeatureGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';
          popup.open({
            popup: new PerspectiveToolTipDialog({
              perspective: 'FeatureList',
              perspectiveUrl: '/view/FeatureList/' + q
            }),
            around: button,
            orient: ['below']
          });
        }
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            return 'in(feature_id,FeatureGroup(' + encodeURIComponent(sel.path) + '))';
          });
          q = 'or(' + q.join(',') + ')';

          Topic.publish('/navigate', { href: '/view/FeatureList/?' + q });
        }
      });

      this.actionPanel.addAction('ViewFeatureItem', 'MultiButton fa icon-selection-Feature fa-2x', {
        label: 'FEATURE',
        validTypes: ['*'],
        validContainerTypes: ['csvFeature'],    // csv and tsv tables only
        multiple: false,
        tooltip: 'Switch to Feature View.  Press and Hold for more options.',
        pressAndHold: function(selection, button, opts, evt) {
          if (selection[0].Gene_ID) {
            var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
            var query = '?eq(patric_id,' + sel + ')&select(feature_id)';
  
            when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
              handleAs: 'json',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
                'X-Requested-With': null,
                Authorization: (window.App.authorizationToken || '')
              
              }
            }), function(response){
              popup.open ({
                popup: new PerspectiveToolTipDialog ({
                  perspective: 'Feature',
                  perspectiveUrl: '/view/Feature/' + response[0].feature_id
                }),
                around: button,
                orient: ['below']
              });
              //Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
            }); 
          }
        },
      
      }, function (selection) {
        if (selection[0].Gene_ID) {
          var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
          var query = '?eq(patric_id,' + sel + ')&select(feature_id)';

          when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
            handleAs: 'json',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
              'X-Requested-With': null,
              Authorization: (window.App.authorizationToken || '')
            
            }
          }), function(response){
            Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
          }); 
        }       
      });

      this.actionPanel.addAction('ViewFeatureGroups', 'MultiButton fa icon-selection-FeatureList fa-2x', {
        label: 'FEATURES',
        validTypes: ['*'],
        validContainerTypes: ['csvFeature'],
        multiple: true,
        min: 2,
        tooltip: 'Switch to the Feature List View. Press and Hold for more options.',
        pressAndHold: function (selection, button, opts, evt) { 
          if (selection.length == 1) {
            Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
          } else {
            var q = selection.map(function (sel) {
              if (sel.Gene_ID) {
                return (sel.Gene_ID).replace("|", "%7C");
              }
              return "";
            });
  
            // some entries in the table do not have PATRIC_ID, so they cannot be linked to the features list
            var noEmptyFeatureIDs = q.filter(function(elem) {
              return (elem != "");
            });
            
            q = '?in(patric_id,(' + noEmptyFeatureIDs + '))&select(feature_id)';
            when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', q), {
              handleAs: 'json',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
                'X-Requested-With': null,
                Authorization: (window.App.authorizationToken || '')
              
              }
            }), function(response){
              var featureIDs = response.map(function(response) { return response.feature_id; }).join(',');
              var featureList = '?in(feature_id,(' + featureIDs + '))';
              popup.open ({
                popup: new PerspectiveToolTipDialog ({
                  perspective: 'FeatureList',
                  perspectiveUrl: '/view/FeatureList/' + featureList
                }),
                around: button,
                orient: ['below']
              });
              //Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
            }); 
          }
        },    
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/FeatureGroup' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            if (sel.Gene_ID) {
              return (sel.Gene_ID).replace("|", "%7C");
            }
            return "";
          });

          // some entries in the table do not have PATRIC_ID, so they cannot be linked to the features list
          var noEmptyFeatureIDs = q.filter(function(elem) {
            return (elem != "");
          });
          
          q = '?in(patric_id,(' + noEmptyFeatureIDs + '))&select(feature_id)';
          when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', q), {
            handleAs: 'json',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
              'X-Requested-With': null,
              Authorization: (window.App.authorizationToken || '')
            
            }
          }), function(response){
            var featureIDs = response.map(function(response) { return response.feature_id; }).join(',');
            var featureList = '?in(feature_id,(' + featureIDs + '))';
            Topic.publish('/navigate', { href: '/view/FeatureList/' +  featureList})
          }); 
        }
      });

      this.actionPanel.addAction('ViewGenomeItem', 'MultiButton fa icon-selection-Genome fa-2x', {
        label: 'GENOME',
        validTypes: ['*'],
        ignoreDataType: true,
        validContainerTypes: ['csvFeature'],    // csv and tsv tables only
        multiple: false,
        tooltip: 'Switch to Genome View.  Press and Hold for more options.',
        pressAndHold: function(selection, button, opts, evt) {
          if (selection[0].Gene_ID) {
            var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
            var query = '?eq(patric_id,' + sel + ')&select(genome_id)';
  
            when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
              handleAs: 'json',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
                'X-Requested-With': null,
                Authorization: (window.App.authorizationToken || '')
              
              }
            }), function(response){
              popup.open ({
                popup: new PerspectiveToolTipDialog ({
                  perspective: 'Genome',
                  perspectiveUrl: '/view/Genome/' + response[0].genome_id
                }),
                around: button,
                orient: ['below']
              });
              //Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
            }); 
          }
        },
      
      }, function (selection) {
        if (selection[0].Gene_ID) {
          var sel = (selection[0].Gene_ID).replace("|", "%7C");      // if the table has Gene_ID, this should work.
          var query = '?eq(patric_id,' + sel + ')&select(genome_id)';

          when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', query), {
            handleAs: 'json',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
              'X-Requested-With': null,
              Authorization: (window.App.authorizationToken || '')
            
            }
          }), function(response){
            Topic.publish('/navigate', { href: '/view/Genome/' + response[0].genome_id })
          }); 
        }       
      });

      this.actionPanel.addAction('ViewGenomeItems', 'MultiButton fa icon-selection-GenomeList fa-2x', {
        label: 'GENOMES',
        validTypes: ['*'],
        validContainerTypes: ['csvFeature'],
        multiple: true,
        min: 2,
        tooltip: 'Switch to the Genome List View. Press and Hold for more options.',
        pressAndHold: function (selection, button, opts, evt) { 
          if (selection.length == 1) {
            Topic.publish('/navigate', { href: '/view/GenomeList' + encodePath(selection[0].path) });
          } else {
            var q = selection.map(function (sel) {
              if (sel.Gene_ID) {
                return (sel.Gene_ID).replace("|", "%7C");
              }
              return "";
            });
  
            // some entries in the table do not have PATRIC_ID, so they cannot be linked to the features list
            var noEmptyFeatureIDs = q.filter(function(elem) {
              return (elem != "");
            });
            
            q = '?in(patric_id,(' + noEmptyFeatureIDs + '))&select(genome_id)';
            when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', q), {
              handleAs: 'json',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
                'X-Requested-With': null,
                Authorization: (window.App.authorizationToken || '')
              
              }
            }), function(response){
              var featureIDs = response.map(function(response) { return response.genome_id; }).join(',');
              var featureList = '?in(genome_id,(' + featureIDs + '))';
              popup.open ({
                popup: new PerspectiveToolTipDialog ({
                  perspective: 'GenomeList',
                  perspectiveUrl: '/view/GenomeList/' + featureList
                }),
                around: button,
                orient: ['below']
              });
              //Topic.publish('/navigate', { href: '/view/Feature/' + response[0].feature_id })
            }); 
          }
        },    
      }, function (selection) {
        if (selection.length == 1) {
          Topic.publish('/navigate', { href: '/view/GenomeList' + encodePath(selection[0].path) });
        } else {
          var q = selection.map(function (sel) {
            if (sel.Gene_ID) {
              return (sel.Gene_ID).replace("|", "%7C");
            }
            return "";
          });

          // some entries in the table do not have PATRIC_ID, so they cannot be linked to the features list
          var noEmptyFeatureIDs = q.filter(function(elem) {
            return (elem != "");
          });
          
          q = '?in(patric_id,(' + noEmptyFeatureIDs + '))&select(genome_id)';
          when(request.get(PathJoin(window.App.dataAPI, 'genome_feature', q), {
            handleAs: 'json',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/rqlquery+x-www-form-urlencoded',
              'X-Requested-With': null,
              Authorization: (window.App.authorizationToken || '')
            
            }
          }), function(response){
            var featureIDs = response.map(function(response) { return response.genome_id; }).join(',');
            var featureList = '?in(genome_id,(' + featureIDs + '))';
            Topic.publish('/navigate', { href: '/view/GenomeList/' +  featureList})
          }); 
        }
      });
         

      this.actionPanel.addAction('MultipleSeqAlignmentFeatures', 'fa icon-alignment fa-2x', {
        label: 'MSA',
        validTypes: ['feature_group'],
        multiple: false,
        tooltipDialog: viewMSATT,
        tooltip: 'Multiple Sequence Alignment'
      }, function (selection) {
        var q = self.getQuery(selection[0]);
        viewMSATT.selection = q;
        popup.open({
          popup: this._actions.MultipleSeqAlignmentFeatures.options.tooltipDialog,
          around: this._actions.MultipleSeqAlignmentFeatures.button,
          orient: ['below']
{'fraction_non_alphanumeric': 0.14684053072689487, 'fraction_numerical': 0.0027632510447829365, 'mean_word_length': 2.0757884385755427, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, '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': '6425152', 'n_tokens_mistral': 12622, 'n_tokens_neox': 12248, 'n_words': 2487}