Exemple #1
0
        /// <summary>
        /// Compute the end position for this VariantContext from the alleles themselves
        ///
        /// In the trivial case this is a single BP event and end = start (open intervals)
        /// In general the end is start + ref length - 1, handling the case where ref length == 0
        /// However, if alleles contains a symbolic allele then we use endForSymbolicAllele in all cases
        /// </summary>
        /// <param name="alleles"> the list of alleles to consider.  The reference allele must be the first one </param>
        /// <param name="start"> the known start position of this event </param>
        /// <param name="endForSymbolicAlleles"> the end position to use if any of the alleles is symbolic.  Can be -1
        ///                              if no is expected but will throw an error if one is found </param>
        /// <returns> this builder </returns>
        public static int ComputeEndFromAlleles(IList <Allele> alleles, int start, int endForSymbolicAlleles)
        {
            Allele reference = alleles [0];

            if (reference.NonReference)
            {
                throw new Exception("computeEndFromAlleles requires first allele to be reference");
            }
            if (VariantContext.HasSymbolicAlleles(alleles))
            {
                if (endForSymbolicAlleles == -1)
                {
                    throw new Exception("computeEndFromAlleles found a symbolic allele but endForSymbolicAlleles was provided");
                }
                return(endForSymbolicAlleles);
            }
            else
            {
                return(start + Math.Max(reference.Length - 1, 0));
            }
        }