<commit_before>/**
 * Creates an object of type Biom for showing the projects data using data tables
 * @constructor
 * @param {Object} biomObject - JSON object containing the biom file of a project 
 * @throws Will throw an error if the biomObject does not contain a id
 * @example 
 * // initializes a Biom object 
 * var biom = new Biom(biom)
 */
Biom = function(biomObject){
    if (biomObject.id === undefined){
        throw 'There is no id';
    } else {
        this.id = biomObject.id;
    }
    if (biomObject.format === undefined){
        throw 'There is no name and version of current biom format';
    } else {
        this.format = biomObject.format;
    }
    if (biomObject.format_url === undefined){
        throw 'There is no URL providing format details';
    } else {
        this.format_url = biomObject.format_url;
    }
    if (biomObject.type === undefined){
        throw 'There is no table type';
    } else {
        this.type = biomObject.type;
    }
    if (biomObject.generated_by === undefined){
        throw 'There is no package and revision  that built the table';
    } else {
        this.generated_by = biomObject.generated_by;
    }
    if (biomObject.date === undefined){
        throw 'There is no date the table was built';
    } else {
        this.date = biomObject.date;
    }
    if (biomObject.rows === undefined){
        throw 'There are no rows describing the object';
    } else {
        this.rows = biomObject.rows;
    }
    if (biomObject.columns === undefined){
        throw 'There are no columns describing the object';
    } else {
        this.columns = biomObject.columns;
    }
    if (biomObject.matrix_type === undefined){
        throw 'There is no type of matrix data representation';
    } else {
        this.matrix_type = biomObject.matrix_type;
    }
    if (biomObject.matrix_element_type === undefined){
        throw 'There is no value type in matrix';
    } else {
        this.matrix_element_type = biomObject.matrix_element_type;
    }
    if (biomObject.shape === undefined){
        throw 'There is no shape information';
    } else {
        this.shape = biomObject.shape;
    }
    if (biomObject.data === undefined){
        throw 'There is no data';
    } else {
        this.data = biomObject.data;
    }
};

/**
 * Method of Biom that creates the otu table data of biom object
 * @returns {object} otuTableData Object that contains the data for showing the otu table
 */
Biom.prototype.getOtuTable = function(){
    var that = this;
    var otuTableData = {};
    otuTableData.columns = [
        {
            data: 'OTU'
        }
    ];
    $.each(this.columns, function(key, value){
        otuTableData.columns.push({
            data: value.id.replace(/\./g, "\\."),
            title: value.id,
            type: 'num'
        });
    });
    otuTableData.data = [];
    //all otus are runned through
    $.each(this.rows, function(rowKey, rowValue){
        thisEntry = {"OTU": rowValue.id};
        var data = _.filter(that.data, function(dataEntry){
            return dataEntry[0] === rowKey;
        });
        //all samples are runned through
        $.each(that.columns, function(columnKey, columnValue){
            var columnId = columnValue.id;
            if(data.length > 0){
                _.find(data, function(currentValue){
                    if(currentValue[1] === columnKey){
                        thisEntry[columnId] = currentValue[2];
                    } else {
                        thisEntry[columnId] = 0;
                    }
                });
            } else {
                thisEntry[columnId] = 0;
            }
        });
        otuTableData.data.push(thisEntry);
    });
    return otuTableData;
};<commit_msg>Add limit parameter to getOtuTable<commit_after>/**
 * Creates an object of type Biom for showing the projects data using data tables
 * @constructor
 * @param {Object} biomObject - JSON object containing the biom file of a project 
 * @throws Will throw an error if the biomObject does not contain a id
 * @example 
 * // initializes a Biom object 
 * var biom = new Biom(biom)
 */
Biom = function(biomObject){
    if (biomObject.id === undefined){
        throw 'There is no id';
    } else {
        this.id = biomObject.id;
    }
    if (biomObject.format === undefined){
        throw 'There is no name and version of current biom format';
    } else {
        this.format = biomObject.format;
    }
    if (biomObject.format_url === undefined){
        throw 'There is no URL providing format details';
    } else {
        this.format_url = biomObject.format_url;
    }
    if (biomObject.type === undefined){
        throw 'There is no table type';
    } else {
        this.type = biomObject.type;
    }
    if (biomObject.generated_by === undefined){
        throw 'There is no package and revision  that built the table';
    } else {
        this.generated_by = biomObject.generated_by;
    }
    if (biomObject.date === undefined){
        throw 'There is no date the table was built';
    } else {
        this.date = biomObject.date;
    }
    if (biomObject.rows === undefined){
        throw 'There are no rows describing the object';
    } else {
        this.rows = biomObject.rows;
    }
    if (biomObject.columns === undefined){
        throw 'There are no columns describing the object';
    } else {
        this.columns = biomObject.columns;
    }
    if (biomObject.matrix_type === undefined){
        throw 'There is no type of matrix data representation';
    } else {
        this.matrix_type = biomObject.matrix_type;
    }
    if (biomObject.matrix_element_type === undefined){
        throw 'There is no value type in matrix';
    } else {
        this.matrix_element_type = biomObject.matrix_element_type;
    }
    if (biomObject.shape === undefined){
        throw 'There is no shape information';
    } else {
        this.shape = biomObject.shape;
    }
    if (biomObject.data === undefined){
        throw 'There is no data';
    } else {
        this.data = biomObject.data;
    }
};

/**
 * Method of Biom that creates the otu table data of biom object
 * @returns {object} otuTableData Object that contains the data for showing the otu table
 */
Biom.prototype.getOtuTable = function(otulimit){
    var that = this;
    var otuTableData = {};
    otuTableData.columns = [
        {
            data: 'OTU'
        }
    ];
    $.each(this.columns, function(key, value){
        otuTableData.columns.push({
            data: value.id.replace(/\./g, "\\."),
            title: value.id,
            type: 'num'
        });
    });
    otuTableData.data = [];
    //all otus up to otulimit are runned through
    var otus = 0;
    $.each(this.rows, function(rowKey, rowValue){
        thisEntry = {"OTU": rowValue.id};
        var data = _.filter(that.data, function(dataEntry){
            return dataEntry[0] === rowKey;
        });
        //all samples are runned through
        $.each(that.columns, function(columnKey, columnValue){
            var columnId = columnValue.id;
            if(data.length > 0){
                _.find(data, function(currentValue){
                    if(currentValue[1] === columnKey){
                        thisEntry[columnId] = currentValue[2];
                    } else {
                        thisEntry[columnId] = 0;
                    }
                });
            } else {
                thisEntry[columnId] = 0;
            }
        });
        otuTableData.data.push(thisEntry);
        otus++;
        if(otulimit && otus >= otulimit){
            // break
            return false;
        }
    });
    return otuTableData;
};
{'fraction_non_alphanumeric': 0.1117915309446254, 'fraction_numerical': 0.0016938110749185667, 'mean_word_length': 1.9902610050642773, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 6, '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': '2862009', 'n_tokens_mistral': 2230, 'n_tokens_neox': 2134, 'n_words': 637}