<commit_before>package org.broadinstitute.sting.utils.variantcontext;


import org.broad.tribble.util.ParsingUtils;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;

import java.util.*;

/**
 * This class encompasses all the basic information about a genotype.  It is immutable.
 *
 * @author <NAME>
 */
public class Genotype implements Comparable<Genotype> {

    public final static String PHASED_ALLELE_SEPARATOR = "|";
    public final static String UNPHASED_ALLELE_SEPARATOR = "/";

    protected CommonInfo commonInfo;
    public final static double NO_LOG10_PERROR = CommonInfo.NO_LOG10_PERROR;
    protected List<Allele> alleles = null; // new ArrayList<Allele>();
    protected Type type = null;

    protected boolean isPhased = false;

    public Genotype(String sampleName, List<Allele> alleles, double log10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased) {
        this(sampleName, alleles, log10PError, filters, attributes, isPhased, null);
    }

    public Genotype(String sampleName, List<Allele> alleles, double log10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased, double[] log10Likelihoods) {
        if ( alleles != null )
            this.alleles = Collections.unmodifiableList(alleles);
        commonInfo = new CommonInfo(sampleName, log10PError, filters, attributes);
        if ( log10Likelihoods != null )
            commonInfo.putAttribute(VCFConstants.PHRED_GENOTYPE_LIKELIHOODS_KEY, GenotypeLikelihoods.fromLog10Likelihoods(log10Likelihoods));
        this.isPhased = isPhased;
        validate();
    }

    /**
     * Creates a new Genotype for sampleName with genotype according to alleles.
     * @param sampleName
     * @param alleles
     * @param log10PError the confidence in these alleles
     * @param log10Likelihoods a log10 likelihoods for each of the genotype combinations possible for alleles, in the standard VCF ordering, or null if not known
     */
    public Genotype(String sampleName, List<Allele> alleles, double log10PError, double[] log10Likelihoods) {
        this(sampleName, alleles, log10PError, null, null, false, log10Likelihoods);
    }

    public Genotype(String sampleName, List<Allele> alleles, double log10PError) {
        this(sampleName, alleles, log10PError, null, null, false);
    }
<commit_msg>Drat, missed one: handle null alleles being passed in.<commit_after>package org.broadinstitute.sting.utils.variantcontext;


import org.broad.tribble.util.ParsingUtils;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;

import java.util.*;

/**
 * This class encompasses all the basic information about a genotype.  It is immutable.
 *
 * @author <NAME>
 */
public class Genotype implements Comparable<Genotype> {

    public final static String PHASED_ALLELE_SEPARATOR = "|";
    public final static String UNPHASED_ALLELE_SEPARATOR = "/";

    protected CommonInfo commonInfo;
    public final static double NO_LOG10_PERROR = CommonInfo.NO_LOG10_PERROR;
    protected List<Allele> alleles = null; // new ArrayList<Allele>();
    protected Type type = null;

    protected boolean isPhased = false;

    public Genotype(String sampleName, List<Allele> alleles, double log10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased) {
        this(sampleName, alleles, log10PError, filters, attributes, isPhased, null);
    }

    public Genotype(String sampleName, List<Allele> alleles, double log10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased, double[] log10Likelihoods) {
        if ( alleles == null )
            alleles = new ArrayList<Allele>(0);
        this.alleles = Collections.unmodifiableList(alleles);
        commonInfo = new CommonInfo(sampleName, log10PError, filters, attributes);
        if ( log10Likelihoods != null )
            commonInfo.putAttribute(VCFConstants.PHRED_GENOTYPE_LIKELIHOODS_KEY, GenotypeLikelihoods.fromLog10Likelihoods(log10Likelihoods));
        this.isPhased = isPhased;
        validate();
    }

    /**
     * Creates a new Genotype for sampleName with genotype according to alleles.
     * @param sampleName
     * @param alleles
     * @param log10PError the confidence in these alleles
     * @param log10Likelihoods a log10 likelihoods for each of the genotype combinations possible for alleles, in the standard VCF ordering, or null if not known
     */
    public Genotype(String sampleName, List<Allele> alleles, double log10PError, double[] log10Likelihoods) {
        this(sampleName, alleles, log10PError, null, null, false, log10Likelihoods);
    }

    public Genotype(String sampleName, List<Allele> alleles, double log10PError) {
        this(sampleName, alleles, log10PError, null, null, false);
    }

{'fraction_non_alphanumeric': 0.08636456004877058, 'fraction_numerical': 0.015647226173541962, 'mean_word_length': 4.127083333333333, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '7489955', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1437, 'n_words': 399}