Exemplo n.º 1
0
        public IVariant[] CreateVariants(IChromosome chromosome, int start, int end, string refAllele,
                                         string[] altAlleles, IInfoData infoData, bool[] isDecomposed, bool isRecomposed, List <string>[] linkedVids, string globalMajorAllele)
        {
            string firstAltAllele   = altAlleles[0];
            bool   isReference      = globalMajorAllele != null;
            bool   isSymbolicAllele = IsSymbolicAllele(firstAltAllele);
            var    variantCategory  = GetVariantCategory(firstAltAllele, isReference, isSymbolicAllele, infoData.SvType);

            if (isReference)
            {
                return new[] { GetVariant(chromosome, start, end, refAllele, firstAltAllele, infoData, variantCategory, isDecomposed[0], isRecomposed, linkedVids?[0]?.ToArray(), globalMajorAllele) }
            }
            ;

            _sequenceProvider.LoadChromosome(chromosome);
            var variants = new List <IVariant>();

            for (var i = 0; i < altAlleles.Length; i++)
            {
#if (!NI_ALLELE)
                if (VcfCommon.IsNonInformativeAltAllele(altAlleles[i]))
                {
                    continue;
                }
#endif
                bool isDecomposedVar = isDecomposed[i];
                (int shiftedStart, string shiftedRef, string shiftedAlt) =
                    VariantUtils.TrimAndLeftAlign(start, refAllele, altAlleles[i], _sequenceProvider.Sequence);

                variants.Add(GetVariant(chromosome, shiftedStart, end - (start - shiftedStart), shiftedRef, shiftedAlt, infoData, variantCategory, isDecomposedVar, isRecomposed, linkedVids?[i]?.ToArray(), null));
            }

            return(variants.Count == 0 ? null : variants.ToArray());
        }
Exemplo n.º 2
0
        public static VariantType GetVariantType(string refAllele, string altAllele)
        {
            if (VcfCommon.IsNonInformativeAltAllele(altAllele))
            {
                return(VariantType.non_informative_allele);
            }

            int referenceAlleleLen = refAllele.Length;
            int alternateAlleleLen = altAllele.Length;

            if (alternateAlleleLen != referenceAlleleLen)
            {
                if (alternateAlleleLen == 0 && referenceAlleleLen > 0)
                {
                    return(VariantType.deletion);
                }
                if (alternateAlleleLen > 0 && referenceAlleleLen == 0)
                {
                    return(VariantType.insertion);
                }

                return(VariantType.indel);
            }

            var variantType = alternateAlleleLen == 1 ? VariantType.SNV : VariantType.MNV;

            return(variantType);
        }
Exemplo n.º 3
0
        public IVariant[] CreateVariants(IChromosome chromosome, int start, int end, string refAllele,
                                         string[] altAlleles, IInfoData infoData, bool[] isDecomposedByAllele, bool isRecomposed, List <string>[] linkedVids, string globalMajorAllele)
        {
            bool isReference = globalMajorAllele != null;

            if (isReference)
            {
                return(ReferenceVariantCreator.Create(_vidCreator, _sequence, chromosome, start, end, refAllele, altAlleles[0], globalMajorAllele));
            }

            var variantCategory = GetVariantCategory(altAlleles[0], infoData.SvType);

            var variants = new List <IVariant>(altAlleles.Length);

            for (var i = 0; i < altAlleles.Length; i++)
            {
#if (!NI_ALLELE)
                if (VcfCommon.IsNonInformativeAltAllele(altAlleles[i]))
                {
                    continue;
                }
#endif
                string altAllele = altAlleles[i];

                bool isDecomposed = isDecomposedByAllele[i];
                if (isDecomposed && isRecomposed)
                {
                    throw new InvalidDataException("A variant can't be both decomposed and recomposed");
                }

                (int shiftedStart, string shiftedRef, string shiftedAlt) =
                    VariantUtils.TrimAndLeftAlign(start, refAllele, altAllele, _sequence);

                if (variantCategory == VariantCategory.SmallVariant || variantCategory == VariantCategory.Reference)
                {
                    end = shiftedStart + shiftedRef.Length - 1;
                }

                variants.Add(GetVariant(chromosome, shiftedStart, end, shiftedRef, shiftedAlt, infoData, variantCategory,
                                        isDecomposed, isRecomposed, linkedVids?[i]?.ToArray()));
            }

            return(variants.Count == 0 ? null : variants.ToArray());
        }
Exemplo n.º 4
0
 private static bool IsSymbolicAllele(string altAllele) =>
 altAllele.OptimizedStartsWith('<') && altAllele.OptimizedEndsWith('>') && !VcfCommon.IsNonInformativeAltAllele(altAllele);