Пример #1
0
        public void SingleEntry()
        {
            var infoField = new VcfInfoKeyValue("AF1000G");

            infoField.Add("0.182308");

            var expected = "AF1000G=0.182308";
            var observed = infoField.GetString();

            Assert.Equal(expected, observed);
        }
Пример #2
0
        public void MultipleNullEntries()
        {
            var infoField = new VcfInfoKeyValue("AF1000G");

            infoField.Add(null);
            infoField.Add(null);
            infoField.Add(null);
            infoField.Add(null);

            var observed = infoField.GetString();

            Assert.Null(observed);
        }
Пример #3
0
        public void MultipleEntries()
        {
            var infoField = new VcfInfoKeyValue("AF1000G");

            infoField.Add("0.182308");
            infoField.Add(null);
            infoField.Add("0.282308");
            infoField.Add(null);

            var expected = "AF1000G=0.182308,.,0.282308,.";
            var observed = infoField.GetString();

            Assert.Equal(expected, observed);
        }
Пример #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());
        }