Exemplo n.º 1
0
        private static string ExtractDbId(IAnnotatedVariant annotatedVariant, string idField)
        {
            var dbSnp = new VcfField();

            var nonDbsnpIds = GetNonDbsnpIds(idField);

            if (nonDbsnpIds != null)
            {
                foreach (var nonDbsnpId in nonDbsnpIds)
                {
                    dbSnp.Add(nonDbsnpId);
                }
            }

            foreach (var altAllele in annotatedVariant.AnnotatedAlternateAlleles)
            {
                if (altAllele.DbSnpIds == null)
                {
                    continue;
                }
                foreach (var id in altAllele.DbSnpIds)
                {
                    dbSnp.Add(id);
                }
            }

            return(dbSnp.GetString(""));
        }
Exemplo n.º 2
0
        public void EmptyDbSnp()
        {
            var dbSnpField = new VcfField();

            var expected = ".";
            var observed = dbSnpField.GetString("");

            Assert.Equal(expected, observed);
        }
Exemplo n.º 3
0
        private void AddInfoField(string infoField, IAnnotatedVariant annotatedVariant, StringBuilder sb)
        {
            var infoEntries = new VcfField();

            if (!string.IsNullOrEmpty(infoField))
            {
                infoEntries.Add(infoField);
            }

            ExtractInfo(annotatedVariant as UnifiedJson, infoEntries);

            infoField = infoEntries.GetString("");

            // remove .
            if (infoField == ".")
            {
                infoField = "";
            }

            sb.Append(infoField);

            var csqs = new List <CsqEntry>();

            ExtractCsqs(annotatedVariant as UnifiedJson, csqs);

            if (csqs.Count != 0)
            {
                if (infoField.Length > 0)
                {
                    sb.Append(";");
                }
            }

            // append CSQ tags using delegate from annotator
            sb.Append(GetCsqtAndCsqrVcfInfo(csqs));

            if (csqs.Count == 0 && infoField.Length == 0)
            {
                sb.Append(".");
            }
        }
Exemplo n.º 4
0
        private static void ExtractInfo(UnifiedJson unifiedJson, VcfField infoEntries)
        {
            var alleleFreq1000G   = new VcfInfoKeyValue("AF1000G");
            var ancestralAllele   = new VcfInfoKeyValue("AA");
            var clinVar           = new VcfInfoKeyValue("clinvar");
            var cosmic            = new VcfInfoKeyValue("cosmic");
            var evs               = new VcfInfoKeyValue("EVS");
            var globalMinorAllele = new VcfInfoKeyValue("GMAF");
            var phyloP            = new VcfInfoKeyValue("phyloP");

            foreach (var jsonVariant in unifiedJson.AnnotatedAlternateAlleles)
            {
                if (jsonVariant.IsReferenceMinor)
                {
                    infoEntries.Add("RefMinor");
                }

                phyloP.Add(jsonVariant.PhylopScore);

                ancestralAllele.Add(jsonVariant.AncestralAllele);

                foreach (var cosmicEntry in jsonVariant.CosmicEntries)
                {
                    if (cosmicEntry.ID == null)
                    {
                        continue;
                    }
                    if (cosmicEntry.SaAltAllele != jsonVariant.SaAltAllele)
                    {
                        continue;
                    }

                    cosmic.Add(jsonVariant.GenotypeIndex.ToString(CultureInfo.InvariantCulture) + '|' + cosmicEntry.ID);
                }

                foreach (var clinVarEntry in jsonVariant.ClinVarEntries)
                {
                    if (clinVarEntry.Significance == null)
                    {
                        continue;
                    }
                    if (clinVarEntry.SaAltAllele != jsonVariant.SaAltAllele)
                    {
                        continue;
                    }

                    clinVar.Add(jsonVariant.GenotypeIndex.ToString(CultureInfo.InvariantCulture) + '|' + RemoveWhiteSpaceAndComma(clinVarEntry.Significance));
                }

                if (jsonVariant.GlobalMinorAllele != null || jsonVariant.GlobalMinorAlleleFrequency != null)
                {
                    globalMinorAllele.Add(jsonVariant.GlobalMinorAllele + '|' + jsonVariant.GlobalMinorAlleleFrequency);
                }
                else
                {
                    // for multi allelic variants, we need to add a . for the entries that do not have a Global minor allele.
                    globalMinorAllele.Add(null);
                }

                alleleFreq1000G.Add(jsonVariant.AlleleFrequencyAll);
                if (jsonVariant.EvsAlleleFrequencyAll != null || jsonVariant.EvsCoverage != null || jsonVariant.EvsSamples != null)
                {
                    evs.Add(jsonVariant.EvsAlleleFrequencyAll + '|' + jsonVariant.EvsCoverage + '|' + jsonVariant.EvsSamples);
                }
                else
                {
                    evs.Add(null);
                }
            }

            infoEntries.Add(ancestralAllele.GetString());
            infoEntries.Add(globalMinorAllele.GetString());
            infoEntries.Add(alleleFreq1000G.GetString());
            infoEntries.Add(evs.GetString());
            infoEntries.Add(phyloP.GetString());
            infoEntries.Add(cosmic.GetString());
            infoEntries.Add(clinVar.GetString());
        }