<commit_before>/*jslint browser: true, nomen: true */

(function (flow, $, girder) {
    'use strict';

    $(document).ready(function () {
        girder.apiRoot = '/girder/api/v1';
        var app = new flow.App();

        // Lookup the ID of the analysis that we wish to perform.
        app.analysisName = "cophylo-app";
        girder.restRequest({
            path: 'resource/search',
            data: {
                q: app.analysisName,
                types: JSON.stringify(["item"])
            }
        }).done(function (results) {
            app.analysisId = results["item"][0]._id;
            app.readyToAnalyze();
        });

        app.readyToAnalyze = function () {
            if ("tree1" in this && "tree2" in this && "analysisId" in this) {
                d3.select("#analyze").classed('disabled', false);
            }
        };

        function toggleInputTablePreview() {
            if ($("#table-preview-icon").hasClass("glyphicon-folder-close")) {
                $("#table-preview-icon").removeClass("glyphicon-folder-close");
                $("#table-preview-icon").addClass("glyphicon-folder-open");
                $("#table-preview-text").text(" Hide input table preview");
            }
            else {
                $("#table-preview-icon").removeClass("glyphicon-folder-open");
                $("#table-preview-icon").addClass("glyphicon-folder-close");
                $("#table-preview-text").text(" Show input table preview");
            }

            $("#input-table-vis").toggle('slow');
        }

        // override upload function for simple mode
        app.datasetsView.upload = function (file) {
            var reader = new FileReader();

            reader.onload = _.bind(function (e) {
                var dataset = {
                        name: file.name,
                        data: e.target.result
                    },
                    extension = file.name.split('.');

                extension = extension[extension.length - 1];
                _.extend(dataset, flow.extensionToType[extension]);
                dataset = new Backbone.Model(dataset);


                if (flow.extensionToType[extension].type == "tree") {
                    app.tree1 = dataset.get('data');
                    d3.select("#tree1-name").html('Tree 1: ' + file.name + ' <span class="glyphicon glyphicon-ok-circle"></span>');
                }
                app.readyToAnalyze();

                this.datasets.off('add', null, 'set-collection').add(dataset);
            }, this);

            reader.readAsText(file);
        };

        app.datasetsView.upload2 = function (file) {
            var reader = new FileReader();

            reader.onload = _.bind(function (e) {
                var dataset = {
                        name: file.name,
                        data: e.target.result
                    },
                    extension = file.name.split('.');

                extension = extension[extension.length - 1];
                _.extend(dataset, flow.extensionToType[extension]);
                dataset = new Backbone.Model(dataset);


                if (flow.extensionToType[extension].type == "tree") {
                    app.tree2 = dataset.get('data');
                    d3.select("#tree2-name").html('Tree 2: ' + file.name + ' <span class="glyphicon glyphicon-ok-circle"></span>');
                }
                app.readyToAnalyze();

                this.datasets.off('add', null, 'set-collection').add(dataset);
            }, this);

            reader.readAsText(file);
        };


        $("#analyze").click(function() {
            $("#analyze").attr("disabled", "disabled");
            $("#analyze").text("Re-run");
            $("#notice").text("Performing analysis...");

            var inputs = {
                tree1:   {type: "tree",   format: "newick",           data: app.tree},
                tree2:   {type: "tree",   format: "newick",           data: app.tree},
            };

            var outputs = {
                cophyloPlot: {type: "image", format: "png.base64"},
            };

            flow.performAnalysis(app.analysisId, inputs, outputs,<commit_msg>try this<commit_after>/*jslint browser: true, nomen: true */

(function (flow, $, girder) {
    'use strict';

    $(document).ready(function () {
        girder.apiRoot = '/girder/api/v1';
        var app = new flow.App();

        // Lookup the ID of the analysis that we wish to perform.
        app.analysisName = "cophylo-app";
        girder.restRequest({
            path: 'resource/search',
            data: {
                q: app.analysisName,
                types: JSON.stringify(["item"])
            }
        }).done(function (results) {
            app.analysisId = results["item"][0]._id;
            app.readyToAnalyze();
        });

        app.readyToAnalyze = function () {
            if ("tree1" in this && "tree2" in this && "analysisId" in this) {
                d3.select("#analyze").classed('disabled', false);
            }
        };

        function toggleInputTablePreview() {
            if ($("#table-preview-icon").hasClass("glyphicon-folder-close")) {
                $("#table-preview-icon").removeClass("glyphicon-folder-close");
                $("#table-preview-icon").addClass("glyphicon-folder-open");
                $("#table-preview-text").text(" Hide input table preview");
            }
            else {
                $("#table-preview-icon").removeClass("glyphicon-folder-open");
                $("#table-preview-icon").addClass("glyphicon-folder-close");
                $("#table-preview-text").text(" Show input table preview");
            }

            $("#input-table-vis").toggle('slow');
        }

        // override upload function for simple mode
        app.datasetsView.upload = function (file) {
            var reader = new FileReader();

            reader.onload = _.bind(function (e) {
                var dataset = {
                        name: file.name,
                        data: e.target.result
                    },
                    extension = file.name.split('.');

                extension = extension[extension.length - 1];
                _.extend(dataset, flow.extensionToType[extension]);
                dataset = new Backbone.Model(dataset);


                if (flow.extensionToType[extension].type == "tree") {
                    app.tree1 = dataset.get('data');
                    d3.select("#tree1-name").html('Tree 1: ' + file.name + ' <span class="glyphicon glyphicon-ok-circle"></span>');
                }
                app.readyToAnalyze();

                this.datasets.off('add', null, 'set-collection').add(dataset);
            }, this);

            reader.readAsText(file);
        };

        // app.datasetsView.upload2 = function (file) {
        //     var reader = new FileReader();
        //
        //     reader.onload = _.bind(function (e) {
        //         var dataset = {
        //                 name: file.name,
        //                 data: e.target.result
        //             },
        //             extension = file.name.split('.');
        //
        //         extension = extension[extension.length - 1];
        //         _.extend(dataset, flow.extensionToType[extension]);
        //         dataset = new Backbone.Model(dataset);
        //
        //
        //         if (flow.extensionToType[extension].type == "tree") {
        //             app.tree2 = dataset.get('data');
        //             d3.select("#tree2-name").html('Tree 2: ' + file.name + ' <span class="glyphicon glyphicon-ok-circle"></span>');
        //         }
        //         app.readyToAnalyze();
        //
        //         this.datasets.off('add', null, 'set-collection').add(dataset);
        //     }, this);
        //
        //     reader.readAsText(file);
        // };


        $("#analyze").click(function() {
            $("#analyze").attr("disabled", "disabled");
            $("#analyze").text("Re-run");
            $("#notice").text("Performing analysis...");

            var inputs = {
                tree1:   {type: "tree",   format: "newick",           data: app.tree},
                tree2:   {type: "tree",   format: "newick",           data: app.tree},
            };

            var outputs = {
                cophyloPlot: {type: "image", format: "png.base64"},
            };

            flow.performAnalysis(app.analysisId, inputs, outputs,
{'fraction_non_alphanumeric': 0.15576177610713027, 'fraction_numerical': 0.0046986961118289676, 'mean_word_length': 1.4822157434402332, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '1632414', 'n_tokens_mistral': 2310, 'n_tokens_neox': 2201, 'n_words': 402}