Example #1
0
        private IVariant GetVariant(IChromosome chromosome, string id, int start, int end, string refAllele, string altAllele, IInfoData infoData, VariantCategory category, bool isDecomposedVar, bool isRecomposed)
        {
            switch (category)
            {
            case VariantCategory.Reference:
                var refMinorGlobalMajorAllele = _refMinorProvider?.GetGlobalMajorAlleleForRefMinor(chromosome, start);
                return(ReferenceVariantCreator.Create(chromosome, start, end, refAllele, altAllele, refMinorGlobalMajorAllele));

            case VariantCategory.SmallVariant:
                return(SmallVariantCreator.Create(chromosome, start, refAllele, altAllele, isDecomposedVar, isRecomposed));

            case VariantCategory.SV:
                var svBreakEnds = infoData.SvType == VariantType.translocation_breakend ?
                                  GetTranslocationBreakends(chromosome, refAllele, altAllele, start)
                        : GetSvBreakEnds(chromosome.EnsemblName, start, infoData.SvType, infoData.End, infoData.IsInv3, infoData.IsInv5);
                return(StructuralVariantCreator.Create(chromosome, start, refAllele, altAllele, svBreakEnds, infoData, _enableVerboseTranscript));

            case VariantCategory.CNV:
                return(CnvCreator.Create(chromosome, id, start, refAllele, altAllele, infoData, _enableVerboseTranscript));

            case VariantCategory.RepeatExpansion:
                return(RepeatExpansionCreator.Create(chromosome, start, refAllele, altAllele, infoData));

            default:
                throw new NotImplementedException("Unrecognized variant category.");
            }
        }
Example #2
0
        private IVariant GetVariant(IChromosome chromosome, int start, int end, string refAllele, string altAllele,
                                    IInfoData infoData, VariantCategory category, bool isDecomposedVar, bool isRecomposed, string[] linkedVids, string globalMajorAllele)
        {
            switch (category)
            {
            case VariantCategory.Reference:
                return(ReferenceVariantCreator.Create(chromosome, start, end, refAllele, altAllele, globalMajorAllele));

            case VariantCategory.SmallVariant:
                return(SmallVariantCreator.Create(chromosome, start, refAllele, altAllele, isDecomposedVar, isRecomposed, linkedVids));

            case VariantCategory.ROH:
                return(RohVariantCreator.Create(chromosome, start, refAllele, altAllele, infoData));

            case VariantCategory.SV:
                var svBreakEnds = infoData.SvType == VariantType.translocation_breakend ?
                                  GetTranslocationBreakends(chromosome, refAllele, altAllele, start)
                        : GetSvBreakEnds(chromosome.EnsemblName, start, infoData.SvType, infoData.End);
                return(StructuralVariantCreator.Create(chromosome, start, refAllele, altAllele, svBreakEnds, infoData));

            case VariantCategory.CNV:
                return(CnvCreator.Create(chromosome, start, refAllele, altAllele, infoData));

            case VariantCategory.RepeatExpansion:
                return(RepeatExpansionCreator.Create(chromosome, start, refAllele, altAllele, infoData));

            default:
                throw new NotImplementedException("Unrecognized variant category.");
            }
        }
Example #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());
        }