public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); sb.Append(JsonObject.OpenBrace); jsonObject.AddDoubleValue("pLi", _pLI, "0.00e0"); jsonObject.AddDoubleValue("pRec", _pRec, "0.00e0"); jsonObject.AddDoubleValue("pNull", _pNull, "0.00e0"); jsonObject.AddDoubleValue("synZ", _synZ, "0.00e0"); jsonObject.AddDoubleValue("misZ", _misZ, "0.00e0"); jsonObject.AddDoubleValue("loeuf", _loeuf, "0.00e0"); sb.Append(JsonObject.CloseBrace); return(StringBuilderCache.GetStringAndRelease(sb)); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); jsonObject.AddStringValue("chromosome", Chromosome.EnsemblName); jsonObject.AddIntValue("begin", Start); jsonObject.AddIntValue("end", End); jsonObject.AddStringValue("variantType", VariantType.ToString()); jsonObject.AddStringValue("id", Id); jsonObject.AddIntValue("sampleSize", SampleSize); if (ObservedGains != 0) { jsonObject.AddIntValue("observedGains", ObservedGains); } if (ObservedLosses != 0) { jsonObject.AddIntValue("observedLosses", ObservedLosses); } jsonObject.AddDoubleValue("variantFreqAll", VariantFreqAll, "0.#####"); return(StringBuilderCache.GetStringAndRelease(sb)); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); jsonObject.AddStringValue("chromosome", Chromosome.EnsemblName); jsonObject.AddIntValue("begin", Start); jsonObject.AddIntValue("end", End); jsonObject.AddStringValue("variantType", VariantType.ToString()); jsonObject.AddStringValue("id", Id); jsonObject.AddIntValue("allAn", _allAlleleNumber); jsonObject.AddIntValue("allAc", _allAlleleCount); jsonObject.AddDoubleValue("allAf", _allAlleleFrequency, "0.######"); jsonObject.AddDoubleValue("afrAf", _afrAlleleFrequency, "0.######"); jsonObject.AddDoubleValue("amrAf", _amrAlleleFrequency, "0.######"); jsonObject.AddDoubleValue("eurAf", _eurAlleleFrequency, "0.######"); jsonObject.AddDoubleValue("easAf", _easAlleleFrequency, "0.######"); jsonObject.AddDoubleValue("sasAf", _sasAlleleFrequency, "0.######"); return(StringBuilderCache.GetStringAndRelease(sb)); }
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.CdnaStart, MappedPosition.CdnaEnd)); jsonObject.AddStringValue("cdsPos", GetRangeString(MappedPosition.CdsStart, MappedPosition.CdsEnd)); 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.ProteinStart, MappedPosition.ProteinEnd)); } var 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); jsonObject.AddStringValues("consequence", Consequences?.Select(ConsequenceUtil.GetConsequence)); jsonObject.AddStringValue("hgvsc", HgvsCoding); jsonObject.AddStringValue("hgvsp", HgvsProtein); jsonObject.AddStringValue("geneFusion", GeneFusionAnnotation?.ToString(), false); 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 (PluginData != null) { foreach (var pluginData in PluginData) { jsonObject.AddStringValue(pluginData.Name, pluginData.GetJsonString(), false); } } if (CompleteOverlap.HasValue) { jsonObject.AddBoolValue("completeOverlap", CompleteOverlap.Value); } sb.Append(JsonObject.CloseBrace); }
public string GetJsonString(string originalChromName) { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); // data section sb.Append(JsonObject.OpenBrace); jsonObject.AddStringValue("vid", Variant.VariantId); jsonObject.AddStringValue("chromosome", originalChromName); jsonObject.AddIntValue("begin", Variant.Start); jsonObject.AddIntValue("end", Variant.End); jsonObject.AddBoolValue("isReferenceMinorAllele", Variant.IsRefMinor); if (!Variant.IsRefMinor) { jsonObject.AddStringValue("refAllele", string.IsNullOrEmpty(Variant.RefAllele) ? "-" : Variant.RefAllele); jsonObject.AddStringValue("altAllele", string.IsNullOrEmpty(Variant.AltAllele) ? "-" : Variant.AltAllele); } else { jsonObject.AddStringValue("refAllele", string.IsNullOrEmpty(Variant.AltAllele) ? "-" : Variant.AltAllele); } var variantType = GetVariantType(Variant.Type); jsonObject.AddStringValue("variantType", variantType.ToString()); jsonObject.AddBoolValue("isDecomposedVariant", Variant.IsDecomposed); if (variantType.ToString() != "SNV") { jsonObject.AddBoolValue("isRecomposedVariant", Variant.IsRecomposed); } jsonObject.AddStringValue("hgvsg", HgvsgNotation); jsonObject.AddDoubleValue("phylopScore", PhylopScore); if (RegulatoryRegions?.Count > 0) { jsonObject.AddObjectValues("regulatoryRegions", RegulatoryRegions); } if (SupplementaryAnnotations.Count > 0) { AddSAstoJsonObject(jsonObject); } foreach (var pluginData in PluginDataSet) { jsonObject.AddStringValue(pluginData.Name, pluginData.GetJsonString(), false); } if (OverlappingGenes.Count > 0) { jsonObject.AddStringValues("overlappingGenes", OverlappingGenes); } if (OverlappingTranscripts.Count > 0) { jsonObject.AddObjectValues("overlappingTranscripts", OverlappingTranscripts); } if (EnsemblTranscripts?.Count > 0 || RefSeqTranscripts?.Count > 0) { jsonObject.AddGroupedObjectValues("transcripts", TranscriptLabels, RefSeqTranscripts, EnsemblTranscripts); } sb.Append(JsonObject.CloseBrace); return(StringBuilderCache.GetStringAndRelease(sb)); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); jsonObject.AddStringValue("hgnc", Hgnc); if (IsSpliceAdjacent) { jsonObject.AddDoubleValue("acceptorGainScore", AcceptorGainScore, "0.#"); jsonObject.AddDoubleValue("acceptorGainDistance", AcceptorGainPosition); jsonObject.AddDoubleValue("acceptorLossScore", AcceptorLossScore, "0.#"); jsonObject.AddDoubleValue("acceptorLossDistance", AcceptorLossPosition); jsonObject.AddDoubleValue("donorGainScore", DonorGainScore, "0.#"); jsonObject.AddDoubleValue("donorGainDistance", DonorGainPosition); jsonObject.AddDoubleValue("donorLossScore", DonorLossScore, "0.#"); jsonObject.AddDoubleValue("donorLossDistance", DonorLossPosition); } else { if (AcceptorGainScore >= MinSpliceAiScore) { jsonObject.AddDoubleValue("acceptorGainScore", AcceptorGainScore, "0.#"); jsonObject.AddDoubleValue("acceptorGainDistance", AcceptorGainPosition); } if (AcceptorLossScore >= MinSpliceAiScore) { jsonObject.AddDoubleValue("acceptorLossScore", AcceptorLossScore, "0.#"); jsonObject.AddDoubleValue("acceptorLossDistance", AcceptorLossPosition); } if (DonorGainScore >= MinSpliceAiScore) { jsonObject.AddDoubleValue("donorGainScore", DonorGainScore, "0.#"); jsonObject.AddDoubleValue("donorGainDistance", DonorGainPosition); } if (DonorLossScore >= MinSpliceAiScore) { jsonObject.AddDoubleValue("donorLossScore", DonorLossScore, "0.#"); jsonObject.AddDoubleValue("donorLossDistance", DonorLossPosition); } } return(StringBuilderCache.GetStringAndRelease(sb)); }
public string GetJsonString() { if (AnnotatedVariants == null || AnnotatedVariants.Length == 0) { return(null); } var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); sb.Append(JsonObject.OpenBrace); string originalChromName = Position.VcfFields[0]; jsonObject.AddStringValue("chromosome", originalChromName); jsonObject.AddIntValue("position", Position.Start); if (Position.HasShortTandemRepeat) { jsonObject.AddStringValue("repeatUnit", Position.InfoData?.RepeatUnit); jsonObject.AddIntValue("refRepeatCount", Position.InfoData?.RefRepeatCount); } if (Position.HasStructuralVariant) { jsonObject.AddIntValue("svEnd", Position.InfoData?.End); } jsonObject.AddStringValue("refAllele", Position.RefAllele); jsonObject.AddStringValues("altAlleles", Position.AltAlleles); jsonObject.AddDoubleValue("quality", Position.Quality); jsonObject.AddStringValues("filters", Position.Filters); jsonObject.AddIntValues("ciPos", Position.InfoData?.CiPos); jsonObject.AddIntValues("ciEnd", Position.InfoData?.CiEnd); jsonObject.AddIntValue("svLength", Position.InfoData?.SvLength); jsonObject.AddStringValue("breakendEventId", Position.InfoData?.BreakendEventId); jsonObject.AddDoubleValue("strandBias", Position.InfoData?.StrandBias, JsonCommon.FrequencyRoundingFormat); jsonObject.AddDoubleValue("fisherStrandBias", Position.InfoData?.FisherStrandBias, "0.###"); jsonObject.AddDoubleValue("mappingQuality", Position.InfoData?.MappingQuality, "0.##"); jsonObject.AddIntValue("jointSomaticNormalQuality", Position.InfoData?.JointSomaticNormalQuality); jsonObject.AddDoubleValue("recalibratedQuality", Position.InfoData?.RecalibratedQuality); jsonObject.AddStringValue("cytogeneticBand", CytogeneticBand); if (Position.Samples != null && Position.Samples.Length > 0) { jsonObject.AddStringValues("samples", Position.Samples.Select(s => s.GetJsonString()), false); } if (SupplementaryIntervals != null && SupplementaryIntervals.Any()) { AddSuppIntervalToJsonObject(jsonObject); } jsonObject.AddStringValues("variants", AnnotatedVariants.Select(v => v.GetJsonString(originalChromName)), false); sb.Append(JsonObject.CloseBrace); return(StringBuilderCache.GetStringAndRelease(sb)); }