Esempio n. 1
0
 private void AddSuppIntervalToJsonObject(JsonObject jsonObject)
 {
     foreach (var si in SupplementaryIntervals)
     {
         jsonObject.AddObjectValue(si.JsonKey, si);
     }
 }
        public void Annotate_RepeatExpansion_ExactMatch_OnePhenotype()
        {
            var variant = new RepeatExpansion(ChromosomeUtilities.Chr3, Start, End, "A", "<STR3>", null, 10, 5);

            var annotatedPosition = GetAnnotatedPosition(variant);

            _provider.Annotate(annotatedPosition);

            var firstVariant = annotatedPosition.AnnotatedVariants[0];

            Assert.NotNull(firstVariant.RepeatExpansionPhenotypes);

            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            jsonObject.AddObjectValue(firstVariant.RepeatExpansionPhenotypes.JsonKey,
                                      firstVariant.RepeatExpansionPhenotypes);

            const string expectedJson = "\"repeatExpansionPhenotypes\":[{\"phenotype\":\"Spinocerebellar ataxia 7\",\"omimId\":164500,\"classifications\":[\"Normal\"],\"percentile\":6.33}]";
            string       observedJson = sb.ToString();

            Assert.Equal(expectedJson, observedJson);
        }
Esempio n. 3
0
        public void SerializeJson(StringBuilder sb)
        {
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("transcript", Transcript.Id.WithVersion);
            jsonObject.AddStringValue("source", Transcript.Source.ToString());
            if (CompleteOverlap.HasValue && !CompleteOverlap.Value)
            {
                jsonObject.AddStringValue("bioType", GetBioType(Transcript.BioType));
            }
            jsonObject.AddStringValue("codons", GetCodonString(ReferenceCodons, AlternateCodons));
            jsonObject.AddStringValue("aminoAcids", GetAminoAcidString(ReferenceAminoAcids, AlternateAminoAcids));

            if (MappedPosition != null)
            {
                jsonObject.AddStringValue("cdnaPos", GetRangeString(MappedPosition.CoveredCdnaStart, MappedPosition.CoveredCdnaEnd));
                jsonObject.AddStringValue("cdsPos", GetRangeString(MappedPosition.CoveredCdsStart, MappedPosition.CoveredCdsEnd));
                jsonObject.AddStringValue("exons", GetFractionString(MappedPosition.ExonStart, MappedPosition.ExonEnd, Transcript.NumExons));
                jsonObject.AddStringValue("introns", GetFractionString(MappedPosition.IntronStart, MappedPosition.IntronEnd, Transcript.NumExons - 1));
                jsonObject.AddStringValue("proteinPos", GetRangeString(MappedPosition.CoveredProteinStart, MappedPosition.CoveredProteinEnd));
            }

            string geneId = Transcript.Source == Source.Ensembl
                ? Transcript.Gene.EnsemblId.ToString()
                : Transcript.Gene.EntrezGeneId.ToString();

            if (CompleteOverlap.HasValue && !CompleteOverlap.Value)
            {
                jsonObject.AddStringValue("geneId", geneId);
            }
            jsonObject.AddStringValue("hgnc", Transcript.Gene.Symbol);

            if (Consequences != null)
            {
                AddConsequences(jsonObject);
            }
            jsonObject.AddStringValue("hgvsc", HgvsCoding);
            jsonObject.AddStringValue("hgvsp", HgvsProtein);

            jsonObject.AddObjectValue("geneFusion", _geneFusion);

            jsonObject.AddBoolValue("isCanonical", Transcript.IsCanonical);

            jsonObject.AddDoubleValue("polyPhenScore", PolyPhen?.Score);

            jsonObject.AddStringValue("polyPhenPrediction", PolyPhen?.Prediction);
            if (CompleteOverlap.HasValue && !CompleteOverlap.Value && Transcript.Translation != null)
            {
                jsonObject.AddStringValue("proteinId", Transcript.Translation.ProteinId.WithVersion);
            }

            jsonObject.AddDoubleValue("siftScore", Sift?.Score);

            jsonObject.AddStringValue("siftPrediction", Sift?.Prediction);

            if (ConservationScores != null && ConservationScores.Count > 0)
            {
                jsonObject.AddObjectValue("aminoAcidConservation", new AnnotatedConservationScore(ConservationScores));
            }

            if (CompleteOverlap.HasValue)
            {
                jsonObject.AddBoolValue("completeOverlap", CompleteOverlap.Value);
            }

            sb.Append(JsonObject.CloseBrace);
        }