<commit_before>/**
 * Output widget for visualization of genome annotation.
 * @author <NAME> <<EMAIL>>
 * @public
 */
define([
    'jquery',
    'bluebird',
    'kb_service/client/workspace',
    'kb_common/html',
    'uuid',
    'lib/domUtils',

    // for effect
    'datatables_bootstrap',
    'kbaseUI/widget/legacy/authenticatedWidget'
], (
    $,
    Promise,
    Workspace,
    html,
    Uuid,
    {domSafeErrorMessage}
) => {
    $.KBWidget({
        name: 'kbaseContigSetView',
        parent: 'kbaseAuthenticatedWidget',
        version: '1.0.0',
        ws_id: null,
        ws_name: null,
        token: null,
        job_id: null,
        options: {
            ws_id: null,
            ws_name: null,
            width: 850
        },
        init(options) {
            this._super(options);

            // TODO: these should be named more sensibly ...
            // for instance, ws_id and obj_id, or workspaceId and objectId.
            // and we should not try to support synonums like ws for ws_id and id for obj_id.
            this.ws_name = options.ws_name;
            this.ws_id = options.ws_id;
            if (options.ws && options.id) {
                this.ws_id = options.id;
                this.ws_name = options.ws;
            }

            this.ws_service = new Workspace(this.runtime.getConfig('services.workspace.url'), {
                token: this.token
            });

            this.render();
            return this;
        },
        render() {
            const self = this;
            const pref = new Uuid(4).format();

            const container = this.$elem;

            const ready = function () {
                container.empty();
                // safe
                container.append(html.loading('loading data...'));

                // var p = kb.req('ws', 'get_object_subset', [{ref: self.ws_name + "/" + self.ws_id, included: ['contigs/[*]/id', 'contigs/[*]/length', 'id', 'name', 'source', 'source_id', 'type']}]);

                Promise.try(
                    self.ws_service.get_object_subset([
                        {
                            ref: `${self.ws_name  }/${  self.ws_id}`,
                            included: [
                                'contigs/[*]/id',
                                'contigs/[*]/length',
                                'id',
                                'name',
                                'source',
                                'source_id',
                                'type'
                            ]
                        }
                    ])
                )
                    .then((data) => {
                        container.empty();
                        const cs = data[0].data,
                            tabNames = ['Overview', 'Contigs'],
                            tabIds = ['overview', 'contigs'],
                            tabs = $(`<ul id="${pref}table-tabs" class="nav nav-tabs"/>`);
                        tabs.append(
                            `<li class="active"><a href="#${pref}${tabIds[0]
                            }" data-toggle="tab" >${tabNames[0]}</a></li>`
                        );
                        for (let i = 1; i < tabIds.length; i += 1) {
                            tabs.append(
                                `<li><a href="#${pref}${tabIds[i]  }" data-toggle="tab">${tabNames[i]}</a></li>`
                            );
                        }
                        // safe
                        container.append(tabs);

                        // tab panel
                        const tab_pane = $(`<div id="${pref}tab-content" class="tab-content"/>`);
                        // safe
                        tab_pane.append(`<div class="tab-pane in active" id="${pref}${tabIds[0]}"/>`);
                        for (let i = 1; i < tabIds.length; i += 1) {
                            tab_pane.append($(`<div class="tab-pane in" id="${pref}${tabIds[i]}"/>`));
                        }
                        // safe
                        container.append(tab_pane);

                        $(`#${  pref  }table-tabs a`).click(function (e) {
                            e.preventDefault();
                            $(this).tab('show');
                        });

                        ////////////////////////////// Overview Tab //////////////////////////////<commit_msg>mark a few more as safe [UIP-5]<commit_after>/**
 * Output widget for visualization of genome annotation.
 * @author <NAME> <<EMAIL>>
 * @public
 */
define([
    'jquery',
    'bluebird',
    'kb_service/client/workspace',
    'kb_common/html',
    'uuid',
    'lib/domUtils',

    // for effect
    'datatables_bootstrap',
    'kbaseUI/widget/legacy/authenticatedWidget'
], (
    $,
    Promise,
    Workspace,
    html,
    Uuid,
    {domSafeErrorMessage}
) => {
    $.KBWidget({
        name: 'kbaseContigSetView',
        parent: 'kbaseAuthenticatedWidget',
        version: '1.0.0',
        ws_id: null,
        ws_name: null,
        token: null,
        job_id: null,
        options: {
            ws_id: null,
            ws_name: null,
            width: 850
        },
        init(options) {
            this._super(options);

            // TODO: these should be named more sensibly ...
            // for instance, ws_id and obj_id, or workspaceId and objectId.
            // and we should not try to support synonums like ws for ws_id and id for obj_id.
            this.ws_name = options.ws_name;
            this.ws_id = options.ws_id;
            if (options.ws && options.id) {
                this.ws_id = options.id;
                this.ws_name = options.ws;
            }

            this.ws_service = new Workspace(this.runtime.getConfig('services.workspace.url'), {
                token: this.token
            });

            this.render();
            return this;
        },
        render() {
            const self = this;
            const pref = new Uuid(4).format();

            const container = this.$elem;

            const ready = function () {
                container.empty();
                // safe
                container.append(html.loading('loading data...'));

                // var p = kb.req('ws', 'get_object_subset', [{ref: self.ws_name + "/" + self.ws_id, included: ['contigs/[*]/id', 'contigs/[*]/length', 'id', 'name', 'source', 'source_id', 'type']}]);

                Promise.try(
                    self.ws_service.get_object_subset([
                        {
                            ref: `${self.ws_name  }/${  self.ws_id}`,
                            included: [
                                'contigs/[*]/id',
                                'contigs/[*]/length',
                                'id',
                                'name',
                                'source',
                                'source_id',
                                'type'
                            ]
                        }
                    ])
                )
                    .then((data) => {
                        container.empty();
                        const cs = data[0].data,
                            tabNames = ['Overview', 'Contigs'],
                            tabIds = ['overview', 'contigs'],
                            tabs = $(`<ul id="${pref}table-tabs" class="nav nav-tabs"/>`);
                        // safe
                        tabs.append(
                            `<li class="active"><a href="#${pref}${tabIds[0]
                            }" data-toggle="tab" >${tabNames[0]}</a></li>`
                        );
                        for (let i = 1; i < tabIds.length; i += 1) {
                            // safe
                            tabs.append(
                                `<li><a href="#${pref}${tabIds[i]  }" data-toggle="tab">${tabNames[i]}</a></li>`
                            );
                        }
                        // safe
                        container.append(tabs);

                        // tab panel
                        const tab_pane = $(`<div id="${pref}tab-content" class="tab-content"/>`);
                        // safe
                        tab_pane.append(`<div class="tab-pane in active" id="${pref}${tabIds[0]}"/>`);
                        for (let i = 1; i < tabIds.length; i += 1) {
                            // safe
                            tab_pane.append($(`<div class="tab-pane in" id="${pref}${tabIds[i]}"/>`));
                        }
                        // safe
                        container.append(tab_pane);

                        $(`#${  pref  }table-tabs a`).click(function (e) {
                            e.preventDefault();
                            $(this).tab('show');
                        });

                        ////////////////////////////// Overview Tab //////////////////////////////
{'fraction_non_alphanumeric': 0.14914836396234873, 'fraction_numerical': 0.003473778574630211, 'mean_word_length': 0.9771821001329198, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '3110832', 'n_tokens_mistral': 2412, 'n_tokens_neox': 2250, 'n_words': 449}