public override string ToString() { var sb = new StringBuilder(); var jsonObject = new JsonObject(sb); // data section sb.Append(JsonObject.OpenBrace); jsonObject.AddStringValue("variantFreq", VariantFrequency, false); jsonObject.AddStringValue("totalDepth", TotalDepth, false); jsonObject.AddStringValue("genotypeQuality", GenotypeQuality, false); jsonObject.AddStringValue("copyNumber", CopyNumber, false); jsonObject.AddStringValues("alleleDepths", AlleleDepths, false); jsonObject.AddStringValue("genotype", Genotype); jsonObject.AddBoolValue("failedFilter", FailedFilter, true, "true"); jsonObject.AddStringValues("splitReadCounts", SplitReadCounts, false); jsonObject.AddStringValues("pairedEndReadCounts", PairEndReadCounts, false); jsonObject.AddBoolValue("isEmpty", IsEmpty, true, "true"); jsonObject.AddBoolValue("lossOfHeterozygosity", IsLossOfHeterozygosity, true, "true"); jsonObject.AddStringValue("deNovoQuality", DenovoQuality, false); sb.Append(JsonObject.CloseBrace); return(sb.ToString()); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); if (string.IsNullOrEmpty(RefAllele)) { RefAllele = "-"; } if (string.IsNullOrEmpty(AltAllele)) { AltAllele = "-"; } jsonObject.AddStringValue("refAllele", RefAllele); jsonObject.AddStringValue("altAllele", AltAllele); jsonObject.AddStringValues("diseases", _diseases?.Distinct()); if (_homoplasmy.HasValue) { jsonObject.AddBoolValue("hasHomoplasmy", _homoplasmy.Value, true); } if (_heteroplasmy.HasValue) { jsonObject.AddBoolValue("hasHeteroplasmy", _heteroplasmy.Value, true); } jsonObject.AddStringValue("status", _status); jsonObject.AddStringValue("clinicalSignificance", _clinicalSignificance); jsonObject.AddStringValue("scorePercentile", _scorePercentile, false); jsonObject.AddIntValue("numGenBankFullLengthSeqs", _numGenBankFullLengthSeqs); jsonObject.AddStringValues("pubMedIds", _pubMedIds); return(StringBuilderCache.GetStringAndRelease(sb)); }
public void SerializeJson(StringBuilder sb) { var jsonObject = new JsonObject(sb); sb.Append(JsonObject.OpenBrace); jsonObject.AddStringValue("transcript", Id.WithVersion); jsonObject.AddStringValue("hgnc", GeneName); jsonObject.AddBoolValue("isCanonical", IsCanonical); jsonObject.AddBoolValue("partialOverlap", IsPartionalOverlap); sb.Append(JsonObject.CloseBrace); }
public void AddBoolValue_True_TwoTimes() { var sb = StringBuilderCache.Acquire(); var json = new JsonObject(sb); json.AddBoolValue("test1", true); json.AddBoolValue("test2", true); const string expectedResult = "\"test1\":true,\"test2\":true"; var observedResult = StringBuilderCache.GetStringAndRelease(sb); Assert.Equal(expectedResult, observedResult); }
public void SerializeJson(StringBuilder sb) { var jsonObject = new JsonObject(sb); sb.Append(JsonObject.OpenBrace); jsonObject.AddStringValue("id", Id); jsonObject.AddStringValue("altAllele", "N" == AltAllele ? null : AltAllele); jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false); if (StringFields != null) { foreach (var stringField in StringFields) { jsonObject.AddStringValue(stringField.Key, stringField.Value); } } if (BooleanFields != null) { foreach (var booleanField in BooleanFields) { jsonObject.AddBoolValue(booleanField, true, true, "true"); } } sb.Append(JsonObject.CloseBrace); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); jsonObject.AddStringValue("id", Id); jsonObject.AddStringValue("altAllele", "N" == AlternateAllele ? null : AlternateAllele); jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false); if (StringFields != null) { foreach (var stringField in StringFields) { jsonObject.AddStringValue(stringField.Key, stringField.Value); } } if (NumberFields != null) { foreach (var numFields in NumberFields) { jsonObject.AddStringValue(numFields.Key, numFields.Value.ToString(CultureInfo.InvariantCulture), false); } } if (BooleanFields != null) { foreach (var booleanField in BooleanFields) { jsonObject.AddBoolValue(booleanField, true); } } return(StringBuilderCache.GetStringAndRelease(sb)); }
public void SerializeJson(StringBuilder sb) { var jsonObject = new JsonObject(sb); sb.Append(JsonObject.OpenBrace); jsonObject.AddStringValue("id", Id); jsonObject.AddStringValue("altAllele", "N" == AlternateAllele ? null : AlternateAllele); jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false); if (StringFields != null) { foreach (var stringField in StringFields) { jsonObject.AddStringValue(stringField.Key, stringField.Value); } } if (NumberFields != null) { foreach (var numFields in NumberFields) { jsonObject.AddStringValue(numFields.Key, numFields.Value.ToString(CultureInfo.InvariantCulture), false); } } if (BooleanFields != null) { foreach (var booleanField in BooleanFields) { jsonObject.AddBoolValue(booleanField, true); } } sb.Append(JsonObject.CloseBrace); }
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.AddStringValue("clinicalInterpretation", GetClinicalDescription(ClinicalInterpretation)); jsonObject.AddStringValues("phenotypes", Phenotypes); jsonObject.AddStringValues("phenotypeIds", PhenotypeIds); if (ObservedGains > 0) { jsonObject.AddIntValue("observedGains", ObservedGains); } if (ObservedLosses > 0) { jsonObject.AddIntValue("observedLosses", ObservedLosses); } jsonObject.AddBoolValue("validated", Validated); 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); var originalChromName = Position.VcfFields[0]; jsonObject.AddStringValue("chromosome", originalChromName); jsonObject.AddIntValue("position", Position.Start); if (IsShortTandemRepeat()) { jsonObject.AddStringValue("repeatUnit", Position.InfoData.RepeatUnit); jsonObject.AddIntValue("refRepeatCount", Position.InfoData.RefRepeatCount); } 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.AddDoubleValue("strandBias", Position.InfoData.StrandBias, JsonCommon.FrequencyRoundingFormat); jsonObject.AddIntValue("jointSomaticNormalQuality", Position.InfoData.JointSomaticNormalQuality); jsonObject.AddDoubleValue("recalibratedQuality", Position.InfoData.RecalibratedQuality); jsonObject.AddIntValue("copyNumber", Position.InfoData.CopyNumber); jsonObject.AddBoolValue("colocalizedWithCnv", Position.InfoData.ColocalizedWithCnv); 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)); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); jsonObject.AddIntValue("coverage", Coverage); if (HasFailedFilters) { jsonObject.AddBoolValue("failedFilter", true); } jsonObject.AddStringValue("allAf", ComputingUtilities.ComputeFrequency(AllAlleleNumber, AllAlleleCount), false); jsonObject.AddIntValue("allAn", AllAlleleNumber); jsonObject.AddIntValue("allAc", AllAlleleCount); jsonObject.AddIntValue("allHc", AllHomCount); jsonObject.AddStringValue("afrAf", ComputingUtilities.ComputeFrequency(AfrAlleleNumber, AfrAlleleCount), false); jsonObject.AddIntValue("afrAn", AfrAlleleNumber); jsonObject.AddIntValue("afrAc", AfrAlleleCount); jsonObject.AddIntValue("afrHc", AfrHomCount); jsonObject.AddStringValue("amrAf", ComputingUtilities.ComputeFrequency(AmrAlleleNumber, AmrAlleleCount), false); jsonObject.AddIntValue("amrAn", AmrAlleleNumber); jsonObject.AddIntValue("amrAc", AmrAlleleCount); jsonObject.AddIntValue("amrHc", AmrHomCount); jsonObject.AddStringValue("easAf", ComputingUtilities.ComputeFrequency(EasAlleleNumber, EasAlleleCount), false); jsonObject.AddIntValue("easAn", EasAlleleNumber); jsonObject.AddIntValue("easAc", EasAlleleCount); jsonObject.AddIntValue("easHc", EasHomCount); jsonObject.AddStringValue("finAf", ComputingUtilities.ComputeFrequency(FinAlleleNumber, FinAlleleCount), false); jsonObject.AddIntValue("finAn", FinAlleleNumber); jsonObject.AddIntValue("finAc", FinAlleleCount); jsonObject.AddIntValue("finHc", FinHomCount); jsonObject.AddStringValue("nfeAf", ComputingUtilities.ComputeFrequency(NfeAlleleNumber, NfeAlleleCount), false); jsonObject.AddIntValue("nfeAn", NfeAlleleNumber); jsonObject.AddIntValue("nfeAc", NfeAlleleCount); jsonObject.AddIntValue("nfeHc", NfeHomCount); jsonObject.AddStringValue("asjAf", ComputingUtilities.ComputeFrequency(AsjAlleleNumber, AsjAlleleCount), false); jsonObject.AddIntValue("asjAn", AsjAlleleNumber); jsonObject.AddIntValue("asjAc", AsjAlleleCount); jsonObject.AddIntValue("asjHc", AsjHomCount); jsonObject.AddStringValue("sasAf", ComputingUtilities.ComputeFrequency(SasAlleleNumber, SasAlleleCount), false); jsonObject.AddIntValue("sasAn", SasAlleleNumber); jsonObject.AddIntValue("sasAc", SasAlleleCount); jsonObject.AddIntValue("sasHc", SasHomCount); jsonObject.AddStringValue("othAf", ComputingUtilities.ComputeFrequency(OthAlleleNumber, OthAlleleCount), false); jsonObject.AddIntValue("othAn", OthAlleleNumber); jsonObject.AddIntValue("othAc", OthAlleleCount); jsonObject.AddIntValue("othHc", OthHomCount); return(StringBuilderCache.GetStringAndRelease(sb)); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); jsonObject.AddBoolValue("isReferenceMinor", true); return(StringBuilderCache.GetStringAndRelease(sb)); }
public string GetVariantJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); if (string.IsNullOrEmpty(ReferenceAllele)) { ReferenceAllele = "-"; } if (string.IsNullOrEmpty(AlternateAllele)) { AlternateAllele = "-"; } jsonObject.AddStringValue("refAllele", ReferenceAllele); jsonObject.AddStringValue("altAllele", AlternateAllele); if (_diseases != null && _diseases.Count > 0) { jsonObject.AddStringValues("diseases", _diseases.Distinct().ToList()); } if (_homoplasmy.HasValue) { jsonObject.AddBoolValue("hasHomoplasmy", _homoplasmy.Value, true); } if (_heteroplasmy.HasValue) { jsonObject.AddBoolValue("hasHeteroplasmy", _heteroplasmy.Value, true); } if (!string.IsNullOrEmpty(_status)) { jsonObject.AddStringValue("status", _status); } if (!string.IsNullOrEmpty(_clinicalSignificance)) { jsonObject.AddStringValue("clinicalSignificance", _clinicalSignificance); } if (!string.IsNullOrEmpty(_scorePercentile)) { jsonObject.AddStringValue("scorePercentile", _scorePercentile, false); } 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("bioType", GetBioType(Transcript.BioType)); jsonObject.AddStringValue("codons", GetAlleleString(ReferenceCodons, AlternateCodons)); jsonObject.AddStringValue("aminoAcids", GetAlleleString(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(); 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 (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); } } sb.Append(JsonObject.CloseBrace); }
public string GetJsonContent() { var sb = new StringBuilder(); var jsonObject = new JsonObject(sb); // data section jsonObject.AddStringValue("chromosome", ReferenceName); jsonObject.AddIntValue("begin", Start); jsonObject.AddIntValue("end", End); jsonObject.AddStringValue("source", Source); jsonObject.AddStringValue("variantType", VariantType.ToString()); foreach (var kvp in PopulationFrequencies) { if (kvp.Value > 0) { jsonObject.AddStringValue(kvp.Key, kvp.Value.ToString("0.#####"), false); } } foreach (var kvp in StringValues) { jsonObject.AddStringValue(kvp.Key, kvp.Value); } foreach (var kvp in IntValues) { jsonObject.AddIntValue(kvp.Key, kvp.Value); } foreach (var kvp in DoubleValues) { if (kvp.Value > 0) { jsonObject.AddStringValue(kvp.Key, kvp.Value.ToString("0.#####"), false); } } foreach (var kvp in BoolValues) { jsonObject.AddBoolValue(kvp, true, true, "true"); } foreach (var kvp in StringLists) { jsonObject.AddStringValues(kvp.Key, kvp.Value); } return(sb.ToString()); }
public string GetJsonString() { var sb = StringBuilderCache.Acquire(); var jsonObject = new JsonObject(sb); // data section jsonObject.AddStringValue("chromosome", Chromosome.EnsemblName); jsonObject.AddIntValue("begin", Start); jsonObject.AddIntValue("end", End); jsonObject.AddStringValue("variantType", VariantType.ToString()); foreach (var kvp in PopulationFrequencies) { if (kvp.Value > 0) { jsonObject.AddStringValue(kvp.Key, kvp.Value.ToString("0.#####"), false); } } foreach (var kvp in StringValues) { jsonObject.AddStringValue(kvp.Key, kvp.Value); } foreach (var kvp in IntValues) { jsonObject.AddIntValue(kvp.Key, kvp.Value); } foreach (var kvp in DoubleValues) { if (kvp.Value > 0) { jsonObject.AddStringValue(kvp.Key, kvp.Value.ToString("0.#####"), false); } } foreach (var kvp in BoolValues) { jsonObject.AddBoolValue(kvp, true); } foreach (var kvp in StringLists) { jsonObject.AddStringValues(kvp.Key, kvp.Value.ToArray()); } return(StringBuilderCache.GetStringAndRelease(sb)); }
public string GetJsonString() { var sb = new StringBuilder(); var jsonObject = new JsonObject(sb); jsonObject.AddStringValue("allAf", ComputingUtilities.ComputeFrequency(_alleleNum, _alleleCount), false); jsonObject.AddIntValue("allAn", _alleleNum); jsonObject.AddIntValue("allAc", _alleleCount); jsonObject.AddIntValue("allHc", _homCount); if (_failedFilter) { jsonObject.AddBoolValue("failedFilter", true); } return(sb.ToString()); }
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 override string ToString() { // return if this is a reference site // ReSharper disable once AssignNullToNotNullAttribute if (!AnnotatedAlternateAlleles.Any()) { return(null); } var sb = new StringBuilder(); var jsonObject = new JsonObject(sb); if (NeedsVariantComma) { sb.Append(JsonObject.Comma); sb.Append('\n'); } else { NeedsVariantComma = true; } // data section sb.Append(JsonObject.OpenBrace); // ========== // positional // ========== jsonObject.AddStringValue(ChromosomeTag, ReferenceName); jsonObject.AddStringValue(RefAlleleTag, ReferenceAllele); jsonObject.AddIntValue(PositionTag, ReferenceBegin); jsonObject.AddStringValues("ciPos", CiPos, false); jsonObject.AddStringValues("ciEnd", CiEnd, false); jsonObject.AddIntValue("svLength", SvLength); jsonObject.AddStringValue("quality", Quality, false); jsonObject.AddStringValues("filters", Filters); jsonObject.AddStringValues("altAlleles", AlternateAlleles); jsonObject.AddStringValue("strandBias", StrandBias, false); jsonObject.AddStringValue("jointSomaticNormalQuality", JointSomaticNormalQuality, false); jsonObject.AddStringValue("recalibratedQuality", RecalibratedQuality, false); jsonObject.AddStringValue("copyNumber", CopyNumber, false); jsonObject.AddStringValue("cytogeneticBand", CytogeneticBand); jsonObject.AddBoolValue("colocalizedWithCnv", ColocalizedWithCnv, true, TrueTag); if (AnnotatedSamples != null) { jsonObject.AddStringValues(SamplesTag, AnnotatedSamples.Select(s => s.ToString()).ToArray(), false); } if (SupplementaryIntervals != null && SupplementaryIntervals.Any()) { jsonObject.AddStringValues(StructuralVariantsTag, SupplementaryIntervals.Select(s => s.ToString()).ToArray(), false); } jsonObject.AddStringValues(VariantsTag, AnnotatedAlternateAlleles.Select(v => v.ToString()).ToArray(), false); sb.Append(JsonObject.CloseBrace.ToString()); return(sb.ToString()); }
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); }
/// <summary> /// returns a string representation of our variant /// </summary> public override string ToString() { var sb = new StringBuilder(); var jsonObject = new JsonObject(sb); // data section sb.Append(JsonObject.OpenBrace); // ========== // positional // ========== jsonObject.AddStringValue(AncestralAlleleTag, AncestralAllele); if (!IsReferenceMinor) { jsonObject.AddStringValue(AltAlleleTag, string.IsNullOrEmpty(AltAllele) ? "-" : AltAllele); jsonObject.AddStringValue(RefAlleleTag, string.IsNullOrEmpty(RefAllele) ? "-" : RefAllele); } else { jsonObject.AddStringValue(RefAlleleTag, string.IsNullOrEmpty(RefAllele) ? "-" : RefAllele); } jsonObject.AddIntValue(BeginTag, ReferenceBegin); jsonObject.AddStringValue(ChromosomeTag, ReferenceName); jsonObject.AddStringValue(PhylopScoreTag, PhylopScore, false); jsonObject.AddStringValues(DbsnpTag, DbSnpIds); jsonObject.AddIntValue(EndTag, ReferenceEnd); jsonObject.AddStringValue(GlobalMinorAlleleTag, GlobalMinorAllele); jsonObject.AddStringValue(GmafTag, GlobalMinorAlleleFrequency, false); jsonObject.AddBoolValue(IsReferenceMinorAlleleTag, true, IsReferenceMinor, "true"); jsonObject.AddStringValue(VariantTypeTag, VariantType); jsonObject.AddStringValue(VidTag, VariantId); // regulatory regions if (RegulatoryRegions.Count > 0) { jsonObject.AddObjectValues(RegulatoryRegionsTag, RegulatoryRegions); } // ClinVar & COSMIC if (ClinVarEntries.Count > 0) { jsonObject.AddObjectValues(ClinVarTag, ClinVarEntries); } if (CosmicEntries.Count > 0) { jsonObject.AddObjectValues(CosmicTag, CosmicEntries); } // Custom annotations if (CustomItems.Count > 0) { AddCustomeItems(jsonObject); } // Custom Intervals // if (CustomIntervals.Count > 0) jsonObject.AddObjectValues(CustomIntervals[0].Type, CustomIntervals); if (CustomIntervals.Count > 0) { AddCustomeIntervals(jsonObject); } // ================= // Overlapping Genes // ================= if (OverlappingGenes.Count > 0) { jsonObject.AddStringValues(OverlappingGenesTag, OverlappingGenes.ToArray()); } // ================= // Overlapping Transcripts // ================= if (SvOverlappingTranscripts.Any()) { jsonObject.AddObjectValues(OverlappingTranscriptsTag, SvOverlappingTranscripts); } // ========== // transcript // ========== var hasRefSeq = RefSeqTranscripts.Any(); var hasEnsembl = EnsemblTranscripts.Any(); if (hasRefSeq || hasEnsembl) { jsonObject.OpenObject(TranscriptsTag); jsonObject.Reset(); if (hasRefSeq) { jsonObject.AddStringValues(RefseqTag, RefSeqTranscripts.Select(t => t.ToString()), false); } if (hasEnsembl) { jsonObject.AddStringValues(EnsemblTag, EnsemblTranscripts.Select(t => t.ToString()), false); } jsonObject.CloseObject(); } // ======= // allelic // ======= jsonObject.Reset(true); jsonObject.AddStringValue(OneKgAllTag, AlleleFrequencyAll, false); jsonObject.AddStringValue(OneKgAfrTag, AlleleFrequencyAfrican, false); jsonObject.AddStringValue(OneKgAmrTag, AlleleFrequencyAdMixedAmerican, false); jsonObject.AddStringValue(OneKgEasTag, AlleleFrequencyEastAsian, false); jsonObject.AddStringValue(OneKgEurTag, AlleleFrequencyEuropean, false); jsonObject.AddStringValue(OneKgSasTag, AlleleFrequencySouthAsian, false); jsonObject.AddStringValue(OneKgAllAnTag, OneKgAlleleNumberAll, false); jsonObject.AddStringValue(OneKgAfrAnTag, OneKgAlleleNumberAfrican, false); jsonObject.AddStringValue(OneKgAmrAnTag, OneKgAlleleNumberAmerican, false); jsonObject.AddStringValue(OneKgEasAnTag, OneKgAlleleNumberEastAsian, false); jsonObject.AddStringValue(OneKgEurAnTag, OneKgAlleleNumberEuropean, false); jsonObject.AddStringValue(OneKgSasAnTag, OneKgAlleleNumberSouthAsian, false); jsonObject.AddStringValue(OneKgAllAcTag, OneKgAlleleCountAll, false); jsonObject.AddStringValue(OneKgAfrAcTag, OneKgAlleleCountAfrican, false); jsonObject.AddStringValue(OneKgAmrAcTag, OneKgAlleleCountAmerican, false); jsonObject.AddStringValue(OneKgEasAcTag, OneKgAlleleCountEastAsian, false); jsonObject.AddStringValue(OneKgEurAcTag, OneKgAlleleCountEuropean, false); jsonObject.AddStringValue(OneKgSasAcTag, OneKgAlleleCountSouthAsian, false); jsonObject.AddStringValue(EvsCoverageTag, EvsCoverage, false); jsonObject.AddStringValue(EvsSamplesTag, EvsSamples, false); jsonObject.AddStringValue(EvsAllTag, EvsAlleleFrequencyAll, false); jsonObject.AddStringValue(EvsAfrTag, EvsAlleleFrequencyAfricanAmerican, false); jsonObject.AddStringValue(EvsEurTag, EvsAlleleFrequencyEuropeanAmerican, false); jsonObject.AddStringValue(ExacCoverageTag, ExacCoverage, false); jsonObject.AddStringValue(ExacAllTag, ExacAlleleFrequencyAll, false); jsonObject.AddStringValue(ExacAfrTag, ExacAlleleFrequencyAfrican, false); jsonObject.AddStringValue(ExacAmrTag, ExacAlleleFrequencyAmerican, false); jsonObject.AddStringValue(ExacEasTag, ExacAlleleFrequencyEastAsian, false); jsonObject.AddStringValue(ExacFinTag, ExacAlleleFrequencyFinish, false); jsonObject.AddStringValue(ExacNfeTag, ExacAlleleFrequencyNonFinish, false); jsonObject.AddStringValue(ExacOthTag, ExacAlleleFrequencyOther, false); jsonObject.AddStringValue(ExacSasTag, ExacAlleleFrequencySouthAsian, false); jsonObject.AddStringValue(ExacAllAnTag, ExacAlleleNumberAll, false); jsonObject.AddStringValue(ExacAfrAnTag, ExacAlleleNumberAfrican, false); jsonObject.AddStringValue(ExacAmrAnTag, ExacAlleleNumberAmerican, false); jsonObject.AddStringValue(ExacEasAnTag, ExacAlleleNumberEastAsian, false); jsonObject.AddStringValue(ExacFinAnTag, ExacAlleleNumberFinish, false); jsonObject.AddStringValue(ExacNfeAnTag, ExacAlleleNumberNonFinish, false); jsonObject.AddStringValue(ExacOthAnTag, ExacAlleleNumberOther, false); jsonObject.AddStringValue(ExacSasAnTag, ExacAlleleNumberSouthAsian, false); jsonObject.AddStringValue(ExacAllAcTag, ExacAlleleCountAll, false); jsonObject.AddStringValue(ExacAfrAcTag, ExacAlleleCountAfrican, false); jsonObject.AddStringValue(ExacAmrAcTag, ExacAlleleCountAmerican, false); jsonObject.AddStringValue(ExacEasAcTag, ExacAlleleCountEastAsian, false); jsonObject.AddStringValue(ExacFinAcTag, ExacAlleleCountFinish, false); jsonObject.AddStringValue(ExacNfeAcTag, ExacAlleleCountNonFinish, false); jsonObject.AddStringValue(ExacOthAcTag, ExacAlleleCountOther, false); jsonObject.AddStringValue(ExacSasAcTag, ExacAlleleCountSouthAsian, false); sb.Append(JsonObject.CloseBrace); return(sb.ToString()); }