<commit_before>package com.binatechnologies.varsim;

/**
 *
 */
import org.apache.log4j.Logger;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.util.HashMap;
import java.util.Map;

/**
 * @author johnmu
 */

class Stats_record {
    int[] bin_counts; // the last bin is for anything larger
    int total_count;
    int[] bin_breaks = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 19, 29, 39, 49, 99,
            199, 399, 799, 1599, 3199, 6399, 12799, 25599, 51199, 102399, 500000, 1000000};
    int num_bins;

    Stats_record() {
        num_bins = bin_breaks.length + 1;
        bin_counts = new int[num_bins];
        total_count = 0;
    }

    /**
     * Increments the bin that val belongs in
     *
     * @param val value to be added
     */
    public void add(int val) {
        total_count++;
        for (int i = 0; i < bin_breaks.length; i++) {
            if (val <= bin_breaks[i]) {
                bin_counts[i]++;
                return;
            }
        }
        bin_counts[num_bins - 1]++;
    }

    public int getTotal_count() {
        return total_count;
    }

    public String toString() {
        return toString(bin_breaks[bin_breaks.length - 1] + 1);
    }

    public String toString(int max_len) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        sb.append(1);
        sb.append(",");
        sb.append(bin_breaks[0]);
        sb.append("]");
        sb.append(':');
        sb.append(bin_counts[0]);
        sb.append('\n');
        for (int i = 1; i < bin_breaks.length; i++) {

            if (bin_breaks[i] > max_len) {
                break;
            }

            sb.append("[");
            sb.append(bin_breaks[i - 1] + 1);
            sb.append(",");
            sb.append(bin_breaks[i]);
            sb.append("]");
            sb.append(':');
            sb.append(bin_counts[i]);
            sb.append('\n');
        }
        if (bin_breaks[bin_breaks.length - 1] < max_len) {
            sb.append("[");
            sb.append(bin_breaks[bin_breaks.length - 1] + 1);
            sb.append(",");
            sb.append("inf");
            sb.append("]");
            sb.append(':');
            sb.append(bin_counts[num_bins - 1]);
            sb.append('\n');
        }
        return sb.toString();
    }
}

class Type_record<T extends Enum> {
    HashMap<T, Stats_record> data;

    Type_record() {
        data = new HashMap<T, Stats_record>();
    }

    /**
     * Increments the bin (of type) that val belongs in
     *
     * @param type type of bin
     * @param val  value to be incremented
     */
    public void add(T type, int val) {
        if (data.containsKey(type)) {
            Stats_record rec = data.get(type);
            rec.add(val);
        } else {
            Stats_record rec = new Stats_record();
            rec.add(val);
            data.put(type, rec);
        }
    }

    public int getTotal_nonref() {
        int total = 0;
        for (Map.Entry<T, Stats_record> entry : data.entrySet()) {
            total += entry.getValue().getTotal_count();
        }
        return total;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<T, Stats_record> entry : data.entrySet()) {
            sb.append(entry.getKey().name());
            sb.append("Total: " + entry.getValue().getTotal_count());
            sb.append('\n');
            if (entry.getKey() == Variant.Type.SNP){
                sb.append(entry.getValue().toString(1));
            } else {
                sb.append(entry.getValue());
            }
        }
        return sb.toString();
    }
}

/**
 * Stores the data for each haplotype separately
 */
class Parent_record {
    // 0 = paternal, 1 = maternal
    public final static int PATERNAL = 0;
    public final static int MATERNAL = 1;
    Type_record<Variant.Type>[] data;
    Type_record<Variant.OverallType> overall_data;
    int total_count;

    Parent_record() {
        data = new Type_record[2];
        data[PATERNAL] = new Type_record();
        data[MATERNAL] = new Type_record();
        overall_data = new Type_record<Variant.OverallType>();
        total_count = 0;
    }<commit_msg>formatting issues<commit_after>package com.binatechnologies.varsim;

/**
 *
 */
import org.apache.log4j.Logger;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.util.HashMap;
import java.util.Map;

/**
 * @author johnmu
 */

class Stats_record {
    int[] bin_counts; // the last bin is for anything larger
    int total_count;
    int[] bin_breaks = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 19, 29, 39, 49, 99,
            199, 399, 799, 1599, 3199, 6399, 12799, 25599, 51199, 102399, 500000, 1000000};
    int num_bins;

    Stats_record() {
        num_bins = bin_breaks.length + 1;
        bin_counts = new int[num_bins];
        total_count = 0;
    }

    /**
     * Increments the bin that val belongs in
     *
     * @param val value to be added
     */
    public void add(int val) {
        total_count++;
        for (int i = 0; i < bin_breaks.length; i++) {
            if (val <= bin_breaks[i]) {
                bin_counts[i]++;
                return;
            }
        }
        bin_counts[num_bins - 1]++;
    }

    public int getTotal_count() {
        return total_count;
    }

    public String toString() {
        return toString(bin_breaks[bin_breaks.length - 1] + 1);
    }

    public String toString(int max_len) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        sb.append(1);
        sb.append(",");
        sb.append(bin_breaks[0]);
        sb.append("]");
        sb.append(':');
        sb.append(bin_counts[0]);
        sb.append('\n');
        for (int i = 1; i < bin_breaks.length; i++) {

            if (bin_breaks[i] > max_len) {
                break;
            }

            sb.append("[");
            sb.append(bin_breaks[i - 1] + 1);
            sb.append(",");
            sb.append(bin_breaks[i]);
            sb.append("]");
            sb.append(':');
            sb.append(bin_counts[i]);
            sb.append('\n');
        }
        if (bin_breaks[bin_breaks.length - 1] < max_len) {
            sb.append("[");
            sb.append(bin_breaks[bin_breaks.length - 1] + 1);
            sb.append(",");
            sb.append("inf");
            sb.append("]");
            sb.append(':');
            sb.append(bin_counts[num_bins - 1]);
            sb.append('\n');
        }
        return sb.toString();
    }
}

class Type_record<T extends Enum> {
    HashMap<T, Stats_record> data;

    Type_record() {
        data = new HashMap<T, Stats_record>();
    }

    /**
     * Increments the bin (of type) that val belongs in
     *
     * @param type type of bin
     * @param val  value to be incremented
     */
    public void add(T type, int val) {
        if (data.containsKey(type)) {
            Stats_record rec = data.get(type);
            rec.add(val);
        } else {
            Stats_record rec = new Stats_record();
            rec.add(val);
            data.put(type, rec);
        }
    }

    public int getTotal_nonref() {
        int total = 0;
        for (Map.Entry<T, Stats_record> entry : data.entrySet()) {
            total += entry.getValue().getTotal_count();
        }
        return total;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<T, Stats_record> entry : data.entrySet()) {
            sb.append(entry.getKey().name());
            sb.append(" total: " + entry.getValue().getTotal_count());
            sb.append('\n');
            if (entry.getKey() == Variant.Type.SNP){
                sb.append(entry.getValue().toString(1));
            } else {
                sb.append(entry.getValue());
            }
        }
        return sb.toString();
    }
}

/**
 * Stores the data for each haplotype separately
 */
class Parent_record {
    // 0 = paternal, 1 = maternal
    public final static int PATERNAL = 0;
    public final static int MATERNAL = 1;
    Type_record<Variant.Type>[] data;
    Type_record<Variant.OverallType> overall_data;
    int total_count;

    Parent_record() {
        data = new Type_record[2];
        data[PATERNAL] = new Type_record();
        data[MATERNAL] = new Type_record();
        overall_data = new Type_record<Variant.OverallType>();
        total_count = 0;
    }
{'fraction_non_alphanumeric': 0.1406304933786476, 'fraction_numerical': 0.024375952185632252, 'mean_word_length': 1.8174314955430835, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3628945', 'n_tokens_mistral': 2923, 'n_tokens_neox': 2717, 'n_words': 610}