Esempio n. 1
0
        private static GenotypeLikelihoodsAllelePair[] calculatePLcache(int altAlleles)
        {
            int numLikelihoods = GenotypeLikelihoods.numLikelihoods(1 + altAlleles, 2);

            GenotypeLikelihoodsAllelePair[] cache = new GenotypeLikelihoodsAllelePair[numLikelihoods];

            // for all possible combinations of 2 alleles
            for (int allele1 = 0; allele1 <= altAlleles; allele1++)
            {
                for (int allele2 = allele1; allele2 <= altAlleles; allele2++)
                {
                    cache[calculatePLindex(allele1, allele2)] = new GenotypeLikelihoodsAllelePair(allele1, allele2);
                }
            }

            // a bit of sanity checking
            for (int i = 0; i < cache.Length; i++)
            {
                if (cache[i] == null)
                {
                    throw new Exception("BUG: cache entry " + i + " is unexpected null");
                }
            }

            return(cache);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the number of values expected for this header field, given the properties of VariantContext vc
        ///
        /// If the count is a fixed count, return that.  For example, a field with size of 1 in the header returns 1
        /// If the count is of type A, return vc.getNAlleles - 1
        /// If the count is of type G, return the expected number of genotypes given the number of alleles in VC and the
        ///   max ploidy among all samples.  Note that if the max ploidy of the VC is 0 (there's no GT information
        ///   at all, then implicitly assume diploid samples when computing G values.
        /// If the count is UNBOUNDED return -1
        /// </summary>
        /// <param name="vc">
        /// @return </param>
        public virtual int getCount(VariantContext vc)
        {
            switch (countType)
            {
            case Bio.VCF.VCFHeaderLineCount.INTEGER:
                return(count);

            case Bio.VCF.VCFHeaderLineCount.UNBOUNDED:
                return(-1);

            case Bio.VCF.VCFHeaderLineCount.A:
                return(vc.NAlleles - 1);

            case Bio.VCF.VCFHeaderLineCount.G:
                int ploidy = vc.GetMaxPloidy(2);
                return(GenotypeLikelihoods.numLikelihoods(vc.NAlleles, ploidy));

            default:
                throw new VCFParsingError("Unknown count type: " + countType);
            }
        }