<commit_before>package net.maizegenetics.stats.MLM;

import net.maizegenetics.pal.distance.DistanceMatrix;
import net.maizegenetics.pal.distance.IBSDistanceMatrix;

import net.maizegenetics.pal.alignment.Alignment;
import net.maizegenetics.pal.alignment.AlignmentUtils;
import net.maizegenetics.pal.alignment.SimplePhenotype;

import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: Zhiwu
 * Date: Apr 29, 2007
 * Time: 4:21:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class Kinship extends DistanceMatrix {

    Frame parentFrame;
    DistanceMatrix dm;
    Alignment mar;
    SimplePhenotype ped;
    int[][] parents;
    private double kMin = 99999;
    private double kMax = -99999;
    private double kAvg = 0;
    private double kSD = 0;
    private double cutOff = 2;
    private int numSeqs;

    public Kinship(Alignment mar) {
        this(mar, false, true);
    }

    public Kinship(Alignment mar, boolean areHetsRelated, boolean rescaleKinship) {
        this.mar = mar;
        numSeqs = this.mar.getIdGroup().getIdCount();
        buildFromMarker();
    }

    public Kinship(SimplePhenotype ped) {
        this.ped = ped;
        buildFromPed();
    }

    public Kinship(DistanceMatrix dm) {
        this.dm = dm;
    }

    public void buildFromMarker() {

    	IBSDistanceMatrix adm = new IBSDistanceMatrix(mar);
    	dm = new DistanceMatrix(adm.getDistance(), mar.getIdGroup());
    	toSimilarity();
    	getKStatistics();
    	pullBackExtrem();
    	//cutOff();
    	rescale();
    	System.out.println("Kinship was built from markers");
    }

    public void buildFromPed() {
        // get data from ped (SimplePhenotype) to parents (int[][]);
        //to do;
        System.out.println("Building Kinship From pedigree");
        parents = new int[ped.getNumberOfTaxa()][ped.getNumberOfTraits()];
        try {
            for (int row = 0; row < ped.getNumberOfTaxa(); row++) {
                for (int col = 0; col < ped.getNumberOfTraits(); col++) {
                    parents[row][col] = (int) ped.getData(row, col);
                }
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }

        dm = new DistanceMatrix(kinshipRelation(parents), ped.getTaxa());

        System.out.println("Kinship was build from pedigree");
    }<commit_msg>calculate diagonal as true IBS<commit_after>package net.maizegenetics.stats.MLM;

import net.maizegenetics.pal.distance.DistanceMatrix;
import net.maizegenetics.pal.distance.IBSDistanceMatrix;

import net.maizegenetics.pal.alignment.Alignment;
import net.maizegenetics.pal.alignment.AlignmentUtils;
import net.maizegenetics.pal.alignment.SimplePhenotype;

import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: Zhiwu
 * Date: Apr 29, 2007
 * Time: 4:21:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class Kinship extends DistanceMatrix {

    Frame parentFrame;
    DistanceMatrix dm;
    Alignment mar;
    SimplePhenotype ped;
    int[][] parents;
    private double kMin = 99999;
    private double kMax = -99999;
    private double kAvg = 0;
    private double kSD = 0;
    private double cutOff = 2;
    private int numSeqs;

    public Kinship(Alignment mar) {
        this(mar, false, true);
    }

    public Kinship(Alignment mar, boolean areHetsRelated, boolean rescaleKinship) {
        this.mar = mar;
        numSeqs = this.mar.getIdGroup().getIdCount();
        buildFromMarker();
    }

    public Kinship(SimplePhenotype ped) {
        this.ped = ped;
        buildFromPed();
    }

    public Kinship(DistanceMatrix dm) {
        this.dm = dm;
    }

    public void buildFromMarker() {

    	IBSDistanceMatrix adm = new IBSDistanceMatrix(mar, 0, true, null);
    	dm = new DistanceMatrix(adm.getDistance(), mar.getIdGroup());
    	toSimilarity();
    	getKStatistics();
//    	pullBackExtrem();
    	//cutOff();
    	rescale();
    	System.out.println("Kinship was built from markers");
    }

    public void buildFromPed() {
        // get data from ped (SimplePhenotype) to parents (int[][]);
        //to do;
        System.out.println("Building Kinship From pedigree");
        parents = new int[ped.getNumberOfTaxa()][ped.getNumberOfTraits()];
        try {
            for (int row = 0; row < ped.getNumberOfTaxa(); row++) {
                for (int col = 0; col < ped.getNumberOfTraits(); col++) {
                    parents[row][col] = (int) ped.getData(row, col);
                }
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }

        dm = new DistanceMatrix(kinshipRelation(parents), ped.getTaxa());

        System.out.println("Kinship was build from pedigree");
    }
{'fraction_non_alphanumeric': 0.11439966414777498, 'fraction_numerical': 0.01112510495382032, 'mean_word_length': 2.6429663608562692, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '1075111', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1446, 'n_words': 359}