Esempio n. 1
0
        public void Alu()
        {
            const string vcfLine = "1	645710	ALU_umary_ALU_2	A	<INS:ME:ALU>	100	PASS	AC=35;AF=0.00698882;AN=5008;CS=ALU_umary;MEINFO=AluYa4_5,1,223,-;NS=2504;SVLEN=222;SVTYPE=ALU;TSD=null;DP=12290;EAS_AF=0.0069;AMR_AF=0.0072;AFR_AF=0;EUR_AF=0.0189;SAS_AF=0.0041";
            var          variant = VcfUtilities.GetVariant(vcfLine, _renamer);

            const string expectedVid = "1:645711:645932:MEI";
            var          observedVid = _vid.Create(_renamer, variant.ReferenceName, variant.AlternateAlleles[0]);

            Assert.Equal(expectedVid, observedVid);
        }
Esempio n. 2
0
        public void AssignAlternateAlleles()
        {
            // sanity check: skip reference sites
            if (IsReference)
            {
                var infoEnd = ExtractInfoEnd();
                if (infoEnd != null)
                {
                    VcfReferenceEnd = (int)infoEnd;
                }
                IsSingletonRefSite = VcfReferenceEnd == VcfReferenceBegin || VcfReferenceEnd == -1;

                // basic blank allele for ref sites
                var refSiteAltAllele = new VariantAlternateAllele(VcfReferenceBegin, VcfReferenceEnd,
                                                                  VcfColumns[VcfCommon.RefIndex], ".");

                // create alternative allele for reference no call
                if (IsRefNoCall)
                {
                    // the following are for refNoCall only.
                    refSiteAltAllele.NirvanaVariantType = VariantType.reference_no_call;
                    refSiteAltAllele.VepVariantType     = VariantType.reference_no_call;
                    refSiteAltAllele.VariantId          = _vid.Create(_renamer, ReferenceName, refSiteAltAllele);
                }

                AlternateAlleles.Add(refSiteAltAllele);

                if (_fixGatkGenomeVcf)
                {
                    RecoverGatkNonRefAllele();
                }
                return;
            }

            // split our alternate alleles
            var altAlleles = VcfColumns[VcfCommon.AltIndex].Split(',');

            var genotypeIndex = 1;

            foreach (var altAllele in altAlleles)
            {
                AlternateAlleles.Add(new VariantAlternateAllele(VcfReferenceBegin, VcfReferenceEnd, VcfRefAllele, altAllele, genotypeIndex));
                genotypeIndex++;
            }



            if (IsStructuralVariant)
            {
                FixMantaSvs(VcfColumns[VcfCommon.InfoIndex]);
            }

            if (IsStructuralVariant)
            {
                var infoEnd = ExtractInfoEnd();
                if (infoEnd != null)
                {
                    VcfReferenceEnd = (int)infoEnd;
                }

                var sv         = ParseSvFields();
                int?copyNumber = null;

                if (CopyNumber != null)
                {
                    copyNumber = CopyNumber;
                }
                else
                {
                    if (AlternateAlleles.Count == 1 && AlternateAlleles.First().CopyNumber != null)
                    {
                        int altCopyNumber;
                        if (int.TryParse(AlternateAlleles.First().CopyNumber, out altCopyNumber))
                        {
                            copyNumber = altCopyNumber;
                        }
                    }
                }

                EvaluateCopyNumberType(copyNumber);

                OverlapReferenceBegin = sv.MinBegin;
                OverlapReferenceEnd   = sv.MaxEnd;
            }
            else
            {
                TrimAlternateAlleles();
                AssignVariantTypes();
                AssignVariantIds();
            }

            if (_fixGatkGenomeVcf)
            {
                RecoverGatkNonRefAllele();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// assigns a variant type to the structural variant alternate allele
        /// </summary>
        public void AssignVariantType(VariantAlternateAllele altAllele, IAlleleTrimmer alleleTrimmer)
        {
            // sanity check: ignore unknown SV variant types
            if (_variantType == VariantType.unknown)
            {
                // the only thing we do for unknown SV types is to increment the begin if it has a symbolic allele
                if (altAllele.IsSymbolicAllele)
                {
                    altAllele.Start++;
                }
                return;
            }

            var oldAltAllele = altAllele.AlternateAllele;
            var has1KgCnv    = false;

            // add the copy number if applicable
            if (_variantType == VariantType.copy_number_variation)
            {
                has1KgCnv            = altAllele.IsSymbolicAllele && _copyNumber == "?";
                altAllele.CopyNumber = has1KgCnv
                    ? ExtractCopyNumberFromAltAllele(oldAltAllele)
                    : _copyNumber;
            }

            altAllele.IsStructuralVariant = true;
            altAllele.VepVariantType      = _variantType;
            altAllele.NirvanaVariantType  = _variantType;
            altAllele.AlternateAllele     = has1KgCnv ? ExtractCnvSymbolicAllele(oldAltAllele) : _altAllele;

            // handle breakends
            if (_breakEnds?.Count > 0)
            {
                altAllele.BreakEnds = new List <BreakEnd>();
                altAllele.BreakEnds.AddRange(_breakEnds);
            }

            // update the reference begin position
            //
            // NOTE: If any of the ALT alleles is a symbolic allele (an angle-bracketed
            //       ID String “<ID>”) then the padding base is required and POS denotes
            //       the coordinate of the base preceding the polymorphism.
            if (altAllele.IsSymbolicAllele)
            {
                altAllele.Start++;
            }
            else
            {
                // if the alt allele is not symbolic and its not a breakend, we call the regular trimmer
                if (_variantType != VariantType.translocation_breakend)
                {
                    altAllele.AlternateAllele = oldAltAllele;
                    alleleTrimmer.Trim(new List <VariantAlternateAllele> {
                        altAllele
                    });
                }
            }

            // adjust the end coordinates after adjusted the begin
            if (_svEnd != null)
            {
                altAllele.End = (int)_svEnd;
                MaxEnd        = Math.Max(MaxEnd, (int)_svEnd);
            }
            else if (_svLength != null)
            {
                altAllele.End = altAllele.Start + Math.Abs(_svLength.Value) - 1;
                MaxEnd        = Math.Max(MaxEnd, (int)_svLength);
            }

            // set the VID
            altAllele.VariantId = _vid.Create(_renamer, _referenceName, altAllele);
        }