<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.maizegenetics.pal.site;

import net.maizegenetics.pal.alignment.Alignment;
import net.maizegenetics.pal.alignment.Locus;
import java.util.HashMap;

/**
 * Container class for holding information about the site.  This includes information
 * on position, MAF, coverage,
 *
 * @author <NAME>
 */
public class AnnotatedSite {
    public Locus myLocus=null;
    public int myPosition;
    public byte myStrand;
    public byte[] myAlleleFreqOrder=null;
    public int[] myAlleleCnt=null;
    public float myMAF= Float.NaN;;
    public float mySiteCoverage= Float.NaN;;
    public String mySNPIDs=null;
    public byte myReferenceAllele= Alignment.UNKNOWN_ALLELE;
    public byte myAncestralAllele=Alignment.UNKNOWN_ALLELE;
    public byte myMajorAllele=Alignment.UNKNOWN_ALLELE;;
    public byte myHighDepthAllele=Alignment.UNKNOWN_ALLELE;
    private HashMap myAnnoMap=null;


    public AnnotatedSite(Locus locus, int position, byte strand) {
        this.myLocus=locus;
        this.myPosition = position;
        this.myStrand=strand;
    }

    public AnnotatedSite(int position, byte[] myAlleleFreqOrder, int[] myAlleleCnt, float maf, float siteCov, String mySNPIDs) {
        this.myPosition = position;
        this.myAlleleFreqOrder = myAlleleFreqOrder;
        this.myAlleleCnt = myAlleleCnt;
        this.myMAF = maf;
        this.mySiteCoverage = siteCov;
        this.mySNPIDs = mySNPIDs;
    }

    public void addAnnotation(String annoName, String value) {
        if(myAnnoMap==null) myAnnoMap=new HashMap<String,Object>(10);
        myAnnoMap.put(annoName, value);
    }

    public Object getAnnotation(String annoName) {
        if(myAnnoMap==null) return null;
        return myAnnoMap.get(annoName);
    }

    public double getAnnotationAsNumber(String annoName) {
        if(myAnnoMap==null) return Float.NaN;
        Object r=myAnnoMap.get(annoName);
        if(r instanceof Number) return ((Number)r).doubleValue();
        return Float.NaN;
    }

    public String getAnnotationAsString(String annoName) {
        if(myAnnoMap==null) return "";
        Object r=myAnnoMap.get(annoName);
        return r.toString();
    }
    
    public int[][] getAllelesSortedByFrequency() {<commit_msg>Lock down locus, position, and strand<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.maizegenetics.pal.site;

import net.maizegenetics.pal.alignment.Alignment;
import net.maizegenetics.pal.alignment.Locus;
import java.util.HashMap;

/**
 * Container class for holding information about the site.  This includes information
 * on position, MAF, coverage,
 *
 * @author <NAME>
 */
public class AnnotatedSite {
    //Required 
    public final Locus myLocus;
    public final int myPosition;
    public final byte myStrand;
    public String mySNPIDs=null;
    //equals should be based on these
    
    //ideas for locus
    //try to parse to number,  not set to number Int.Max.  Sort by number, text.  
    
    
    public byte[] myAlleleFreqOrder=null;
    public int[] myAlleleCnt=null;
    public float myMAF= Float.NaN;;
    public float mySiteCoverage= Float.NaN;;
    
    public byte myReferenceAllele= Alignment.UNKNOWN_ALLELE;
    public byte myAncestralAllele=Alignment.UNKNOWN_ALLELE;
    public byte myMajorAllele=Alignment.UNKNOWN_ALLELE;;
    public byte myHighDepthAllele=Alignment.UNKNOWN_ALLELE;
    private HashMap myAnnoMap=null;


    public AnnotatedSite(Locus locus, int position, byte strand) {
        this.myLocus=locus;
        this.myPosition = position;
        this.myStrand=strand;
    }

    public AnnotatedSite(int position, byte[] myAlleleFreqOrder, int[] myAlleleCnt, float maf, float siteCov, String mySNPIDs) {
        this(null,position,(byte)1);
        this.myAlleleFreqOrder = myAlleleFreqOrder;
        this.myAlleleCnt = myAlleleCnt;
        this.myMAF = maf;
        this.mySiteCoverage = siteCov;
        this.mySNPIDs = mySNPIDs;
    }

    public void addAnnotation(String annoName, String value) {
        if(myAnnoMap==null) myAnnoMap=new HashMap<String,Object>(10);
        myAnnoMap.put(annoName, value);
    }

    public Object getAnnotation(String annoName) {
        if(myAnnoMap==null) return null;
        return myAnnoMap.get(annoName);
    }

    public double getAnnotationAsNumber(String annoName) {
        if(myAnnoMap==null) return Float.NaN;
        Object r=myAnnoMap.get(annoName);
        if(r instanceof Number) return ((Number)r).doubleValue();
        return Float.NaN;
    }

    public String getAnnotationAsString(String annoName) {
        if(myAnnoMap==null) return "";
        Object r=myAnnoMap.get(annoName);
        return r.toString();
    }
    
    public int[][] getAllelesSortedByFrequency() {
{'fraction_non_alphanumeric': 0.0923391215526047, 'fraction_numerical': 0.0010214504596527069, 'mean_word_length': 3.287215411558669, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5318984', 'n_tokens_mistral': 1590, 'n_tokens_neox': 1553, 'n_words': 371}