<commit_before>function initDatasets() {
    var datasetLoader = constructDatasetLoader();

    // add progress bar when submitting form
    $("#search-multi-form").click(function () {
        $("#search_button").hide();
        $("#form-progress").removeClass("hide");
    });

    // hide more options + set up action to show is
    $("#more_options_form").hide();
    $("#more_options a").click(function () {
        $("#more_options_form").slideDown("slow");
        $("#more_options").hide("fast");
        return false;
    });

    // track the use of the export checkbox
    $("#export").change(function () {
        logToGoogle("Multi Peptide", "Export");
    });

    $("#qs").on("paste", function () {
        setTimeout(datasetLoader.checkDatasetSize, 0);
    });

    // load a dataset from the local database
    $(".load-dataset").click(function () {
        $(this).button('loading');
        // set the vars
        var id = $(this).parent().find("select").val(),
            name = $(this).parent().find("select option:selected").text();

        logToGoogle("Datasets", "Load", "Database - " + name);

        // load the datasets
        datasetLoader.loadDataset("internal", id, name, $(this));
        return false;
    });

    // load a PRIDE dataset
    $(".load-pride").click(function () {
        // set the vars
        var experiment = $("#pride_exp_id").val(),
            name = "PRIDE assay " + experiment;

        if (experiment === "") {
            info("Please enter a PRIDE assay id");
            return false;
        }

        $(this).button('loading');

        logToGoogle("Datasets", "Load", "Pride - " + name);

        // load the datasets
        datasetLoader.loadDataset("pride", experiment, name, $(this));
        return false;
    });
}

function initPreload(type, id) {
    // show full form
    $("#more_options").hide();

    var datasetLoader = constructDatasetLoader();

    if (type === "database") {
        datasetLoader.loadDataset("internal", id, "Dataset " + id);
    } else {
        datasetLoader.loadDataset("pride", id, "Pride assay " + id);
    }
}

function constructDatasetLoader() {
    var that = {};

    /************** private methods *************/

    /**
     * Loads a dataset from the database
     *
     * @param <Integer> id The id of the dataset(item) we want to load
     * @param <Function> done The callback function that gets executed when
     *          everything succeeds
     * @param <Function> done The callback function that gets executed when
     *          loading the dataset fails
     * @param <Function always The callback function that gets always gets
     *          executed
     */
    function loadInternalDataset(id, done, fail, always) {
        $.get("/dataset_items/" + id)
            .done(done)
            .fail(fail)
            .always(always);
    }

    /**
     * Loads a dataset from PRIDE using the PRIDE API
     *
     * @param <Integer> id The id of the assay we want to load
     * @param <Function> done The callback function that gets executed when
     *          everything succeeds
     * @param <Function> done The callback function that gets executed when
     *          loading the dataset fails
     * @param <Function always The callback function that gets always gets
     *          executed
     */
    function loadPrideDataset(id, done, fail, always) {
        var batchSize = 1000,
            page = 0,
            peptides = [],
            datasetSize;

        $("#pride-progress").show("fast");
        $("#pride-progress .progress-bar").css("width", "0%");
        $.get("http://www.ebi.ac.uk:80/pride/ws/archive/peptide/count/assay/" + id)
            .done(function (data) {
                datasetSize = data;
                loadNextBatch();
            })
            .fail(prideFail);

            function loadNextBatch() {
                $("#pride-progress .progress-bar").css("width", (100 * page * batchSize) / datasetSize + "%");
                if (page * batchSize > datasetSize) { // we're done
                    $("#pride-progress").hide("fast");
                    done.call(this, peptides.join("\n"));
                    always.call(this);
                } else { // load next batch
                    $.get("http://www.ebi.ac.uk:80/pride/ws/archive/peptide/list/assay/" + id + "?show=" + batchSize + "&page=" + page)
                        .done(function (data) {
                            data = data.list.map(function (d) {return d.sequence; });
                            peptides = peptides.concat(data);
                            page++;<commit_msg>let progress bar start from 10%<commit_after>function initDatasets() {
    var datasetLoader = constructDatasetLoader();

    // add progress bar when submitting form
    $("#search-multi-form").click(function () {
        $("#search_button").hide();
        $("#form-progress").removeClass("hide");
    });

    // hide more options + set up action to show is
    $("#more_options_form").hide();
    $("#more_options a").click(function () {
        $("#more_options_form").slideDown("slow");
        $("#more_options").hide("fast");
        return false;
    });

    // track the use of the export checkbox
    $("#export").change(function () {
        logToGoogle("Multi Peptide", "Export");
    });

    $("#qs").on("paste", function () {
        setTimeout(datasetLoader.checkDatasetSize, 0);
    });

    // load a dataset from the local database
    $(".load-dataset").click(function () {
        $(this).button('loading');
        // set the vars
        var id = $(this).parent().find("select").val(),
            name = $(this).parent().find("select option:selected").text();

        logToGoogle("Datasets", "Load", "Database - " + name);

        // load the datasets
        datasetLoader.loadDataset("internal", id, name, $(this));
        return false;
    });

    // load a PRIDE dataset
    $(".load-pride").click(function () {
        // set the vars
        var experiment = $("#pride_exp_id").val(),
            name = "PRIDE assay " + experiment;

        if (experiment === "") {
            info("Please enter a PRIDE assay id");
            return false;
        }

        $(this).button('loading');

        logToGoogle("Datasets", "Load", "Pride - " + name);

        // load the datasets
        datasetLoader.loadDataset("pride", experiment, name, $(this));
        return false;
    });
}

function initPreload(type, id) {
    // show full form
    $("#more_options").hide();

    var datasetLoader = constructDatasetLoader();

    if (type === "database") {
        datasetLoader.loadDataset("internal", id, "Dataset " + id);
    } else {
        datasetLoader.loadDataset("pride", id, "Pride assay " + id);
    }
}

function constructDatasetLoader() {
    var that = {};

    /************** private methods *************/

    /**
     * Loads a dataset from the database
     *
     * @param <Integer> id The id of the dataset(item) we want to load
     * @param <Function> done The callback function that gets executed when
     *          everything succeeds
     * @param <Function> done The callback function that gets executed when
     *          loading the dataset fails
     * @param <Function always The callback function that gets always gets
     *          executed
     */
    function loadInternalDataset(id, done, fail, always) {
        $.get("/dataset_items/" + id)
            .done(done)
            .fail(fail)
            .always(always);
    }

    /**
     * Loads a dataset from PRIDE using the PRIDE API
     *
     * @param <Integer> id The id of the assay we want to load
     * @param <Function> done The callback function that gets executed when
     *          everything succeeds
     * @param <Function> done The callback function that gets executed when
     *          loading the dataset fails
     * @param <Function always The callback function that gets always gets
     *          executed
     */
    function loadPrideDataset(id, done, fail, always) {
        var batchSize = 1000,
            page = 0,
            peptides = [],
            datasetSize;

        $("#pride-progress").show("fast");
        $("#pride-progress .progress-bar").css("width", "10%");
        $.get("http://www.ebi.ac.uk:80/pride/ws/archive/peptide/count/assay/" + id)
            .done(function (data) {
                datasetSize = data;
                loadNextBatch();
            })
            .fail(prideFail);

            function loadNextBatch() {
                $("#pride-progress .progress-bar").css("width", 10 + (90 * page * batchSize) / datasetSize + "%");
                if (page * batchSize > datasetSize) { // we're done
                    $("#pride-progress").hide("fast");
                    done.call(this, peptides.join("\n"));
                    always.call(this);
                } else { // load next batch
                    $.get("http://www.ebi.ac.uk:80/pride/ws/archive/peptide/list/assay/" + id + "?show=" + batchSize + "&page=" + page)
                        .done(function (data) {
                            data = data.list.map(function (d) {return d.sequence; });
                            peptides = peptides.concat(data);
                            page++;
{'fraction_non_alphanumeric': 0.1516292074416604, 'fraction_numerical': 0.0034412302398107325, 'mean_word_length': 1.9942047649710237, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '4649314', 'n_tokens_mistral': 2533, 'n_tokens_neox': 2470, 'n_words': 663}