Esempio n. 1
0
        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));
        }
Esempio n. 2
0
            public void SerializeJson(StringBuilder sb)
            {
                var jsonObject = new JsonObject(sb);

                sb.Append(JsonObject.OpenBrace);
                _jsonSchema.TotalItems++;

                if (_mimNumber >= 100000)
                {
                    _jsonSchema.CountKeyIfAdded(jsonObject.AddIntValue("mimNumber", _mimNumber), "mimNumber");
                }
                _jsonSchema.CountKeyIfAdded(jsonObject.AddStringValue("phenotype", _phenotype), "phenotype");
                if (_mapping != Mapping.unknown)
                {
                    _jsonSchema.CountKeyIfAdded(jsonObject.AddStringValue("mapping", _mapping.ToString().Replace("_", " ")), "mapping");
                }
                if (_inheritance != null && _inheritance.Count > 0)
                {
                    _jsonSchema.CountKeyIfAdded(jsonObject.AddStringValues("inheritances", _inheritance), "inheritances");
                }
                if (_comments.Length > 0)
                {
                    _jsonSchema.CountKeyIfAdded(jsonObject.AddStringValues("comments", _comments.Select(x => x.ToString().Replace("_", " "))), "comments");
                }

                sb.Append(JsonObject.CloseBrace);
            }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        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.AddDoubleValue("strandBias", Position.InfoData?.StrandBias, JsonCommon.FrequencyRoundingFormat);
            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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
            public void SerializeJson(StringBuilder sb)
            {
                var jsonObject = new JsonObject(sb);

                sb.Append(JsonObject.OpenBrace);

                if (_mimNumber >= 100000)
                {
                    jsonObject.AddStringValue("mimNumber", _mimNumber.ToString());
                }
                jsonObject.AddStringValue("phenotype", _phenotype);
                if (_mapping != Mapping.unknown)
                {
                    jsonObject.AddStringValue("mapping", _mapping.ToString().Replace("_", " "));
                }
                if (_inheritance != null && _inheritance.Count > 0)
                {
                    jsonObject.AddStringValues("inheritances", _inheritance);
                }
                if (_comments != Comments.unknown)
                {
                    jsonObject.AddStringValue("comments", _comments.ToString().Replace("_", " "));
                }

                sb.Append(JsonObject.CloseBrace);
            }
Esempio n. 7
0
        public void AddStringValues_TwoTimes()
        {
            var sb   = StringBuilderCache.Acquire();
            var json = new JsonObject(sb);

            var strings  = new[] { "A", "B", "C" };
            var strings2 = new[] { "D", "E", "F" };

            json.AddStringValues("test1", strings);
            json.AddStringValues("test2", strings2, false);

            const string expectedResult = "\"test1\":[\"A\",\"B\",\"C\"],\"test2\":[D,E,F]";
            var          observedResult = StringBuilderCache.GetStringAndRelease(sb);

            Assert.Equal(expectedResult, observedResult);
        }
        public static string GetGeneAnnotation(GeneConfig input, string saManifestFilePath, string saPathPrefix)
        {
            var geneAnnotationProvider = new GeneAnnotationProvider(PersistentStreamUtils.GetStreams(
                                                                        GetNgaFileList(saManifestFilePath, saPathPrefix, input.ngaUrls).ToList()));

            var sb         = new StringBuilder(1024 * 1024);
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue(JasixCommons.HeaderSectionTag, GetHeader(geneAnnotationProvider), false);

            //not all gene symbols have annotations. So, we need to check and only output the ones that are not null
            var geneAnnotations = input.geneSymbols.Select(geneSymbol => geneAnnotationProvider.Annotate(geneSymbol))
                                  .Where(annotation => !string.IsNullOrEmpty(annotation))
                                  .ToList();

            jsonObject.AddStringValues("genes", geneAnnotations, false);
            sb.Append(JsonObject.CloseBrace);

            // AWS lambda response message can not be larger than 6MB
            if (sb.Length > 6_000_000)
            {
                throw new UserErrorException("Too many genes provided in the request. Please decrease the number of genes and try again later.");
            }

            return(sb.ToString());
        }
Esempio n. 9
0
        public static string GetHeader(string annotator, string creationTime, string genomeAssembly, int jsonSchemaVersion, string vepDataVersion, List <DataSourceVersion> dataSourceVersions, string[] sampleNames = null)
        {
            var sb         = new StringBuilder();
            var jsonObject = new JsonObject(sb);

            sb.Append("{\"header\":{");
            jsonObject.AddStringValue("annotator", annotator);
            jsonObject.AddStringValue("creationTime", creationTime);
            jsonObject.AddStringValue("genomeAssembly", genomeAssembly);
            jsonObject.AddIntValue("schemaVersion", jsonSchemaVersion);
            jsonObject.AddStringValue("dataVersion", vepDataVersion);

            // print our data source versions
            if (dataSourceVersions != null)
            {
                jsonObject.AddObjectValues("dataSources", dataSourceVersions);
            }

            if (sampleNames != null)
            {
                jsonObject.AddStringValues(SamplesTag, sampleNames);
            }

            sb.Append("},\"positions\":[\n");

            return(sb.ToString());
        }
Esempio n. 10
0
        private void AddSAstoJsonObject(JsonObject jsonObject)
        {
            var saDict = new Dictionary <string, (bool, List <string>)>();

            foreach (var annotatedSa in SupplementaryAnnotations)
            {
                var sa = annotatedSa.SaDataSource;

                if (!saDict.ContainsKey(sa.KeyName))
                {
                    saDict[sa.KeyName] = (sa.IsArray, new List <string>());
                }

                var jsonStrings = annotatedSa.GetJsonStrings();
                if (jsonStrings != null)
                {
                    saDict[sa.KeyName].Item2.AddRange(jsonStrings);
                }
            }

            foreach (var kvp in saDict)
            {
                if (kvp.Value.Item1)
                {
                    jsonObject.AddStringValues(kvp.Key, kvp.Value.Item2.ToArray(), false);
                }
                else
                {
                    jsonObject.AddStringValue(kvp.Key, kvp.Value.Item2[0], false);
                }
            }
        }
Esempio n. 11
0
 private void OutputRequiredKeys(IReadOnlyCollection <string> requiredKeys)
 {
     if (requiredKeys.Count > 0)
     {
         _jsonObject.AddStringValues("required", requiredKeys);
     }
 }
Esempio n. 12
0
 private void AddConsequences(JsonObject jsonObject)
 {
     if (Consequences.Count == 0)
     {
         Consequences.Add(ConsequenceTag.transcript_variant);
     }
     jsonObject.AddStringValues("consequence", Consequences?.Select(ConsequenceUtil.GetConsequence));
 }
Esempio n. 13
0
        public string GetJsonString()
        {
            var sb = StringBuilderCache.Acquire();

            var jsonObject = new JsonObject(sb);

            jsonObject.AddIntValue("id", CNVId);
            jsonObject.AddStringValue("variantType", _cnvType.ToString());
            if (_copyNumber != -1)
            {
                jsonObject.AddIntValue("copyNumber", _copyNumber);
            }

            jsonObject.AddStringValues("cancerTypes", GetJsonStrings(_cancerTypes), false);
            jsonObject.AddStringValues("tissueTypes", GetJsonStrings(_tissueTypes), false);

            return(sb.ToString());
        }
Esempio n. 14
0
        public void AddStringValues_EmptyArray()
        {
            var sb   = StringBuilderCache.Acquire();
            var json = new JsonObject(sb);

            json.AddStringValues("test1", new string[0]);
            var observedResult = StringBuilderCache.GetStringAndRelease(sb);

            Assert.Equal(string.Empty, observedResult);
        }
        public void SerializeJson(StringBuilder sb)
        {
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("id", RegulatoryRegion.Id.WithoutVersion);
            jsonObject.AddStringValue("type", RegulatoryRegion.Type.ToString());
            jsonObject.AddStringValues("consequence", Consequences?.Select(ConsequenceUtil.GetConsequence));
            sb.Append(JsonObject.CloseBrace);
        }
Esempio n. 16
0
            /// <summary>
            /// JSON string representation of our regulatory region
            /// </summary>
            public void SerializeJson(StringBuilder sb)
            {
                var jsonObject = new JsonObject(sb);

                sb.Append(JsonObject.OpenBrace);
                jsonObject.AddStringValue("id", ID);
                jsonObject.AddStringValue("type", Type);
                jsonObject.AddStringValues("consequence", Consequence.ToArray());
                sb.Append(JsonObject.CloseBrace);
            }
Esempio n. 17
0
        public string GetJsonString()
        {
            var sb = StringBuilderCache.Acquire();

            var jsonObject = new JsonObject(sb);

            jsonObject.AddStringValue("id", Id);
            jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false);
            jsonObject.AddStringValue("refAllele", string.IsNullOrEmpty(ReferenceAllele) ? "-" : ReferenceAllele);
            jsonObject.AddStringValue("altAllele",
                                      SupplementaryAnnotationUtilities.ReverseSaReducedAllele(AlternateAllele));
            jsonObject.AddStringValue("gene", Gene);
            jsonObject.AddIntValue("sampleCount", SampleCount);

            jsonObject.AddStringValues("cancerTypes", GetJsonStrings(GetCancerTypeCounts()), false);
            jsonObject.AddStringValues("tissues", GetJsonStrings(GetTissueCounts()), false);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            jsonObject.AddStringValue("id", $"{Accession}.{Version}");
            jsonObject.AddStringValue("reviewStatus", ClinVarCommon.ReviewStatusStrings[ReviewStatus]);
            jsonObject.AddStringValue("lastUpdatedDate", LastUpdatedDate.ToString("yyyy-MM-dd"));
            jsonObject.AddStringValues("significance", Significances);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Esempio n. 20
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            //converting empty alleles to '-'
            var refAllele = string.IsNullOrEmpty(ReferenceAllele) ? "-" : ReferenceAllele;
            var altAllele = string.IsNullOrEmpty(AlternateAllele) ? "-" : AlternateAllele;

            //the reduced alt allele should never be output
            altAllele = SupplementaryAnnotationUtilities.ReverseSaReducedAllele(altAllele);

            jsonObject.AddStringValue("id", Id);
            jsonObject.AddStringValue("reviewStatus", ReviewStatusStrings[ReviewStatus]);
            jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false);
            jsonObject.AddStringValues("alleleOrigins", AlleleOrigins);
            jsonObject.AddStringValue("refAllele", "N" == refAllele ? null : refAllele);
            jsonObject.AddStringValue("altAllele", "N" == altAllele ? null : altAllele);
            jsonObject.AddStringValues("phenotypes", Phenotypes);
            jsonObject.AddStringValues("medGenIds", MedGenIDs);
            jsonObject.AddStringValues("omimIds", OmimIDs);
            jsonObject.AddStringValues("orphanetIds", OrphanetIDs);
            jsonObject.AddStringValue("significance", Significance);

            if (LastUpdatedDate != long.MinValue)
            {
                jsonObject.AddStringValue("lastUpdatedDate", new DateTime(LastUpdatedDate).ToString("yyyy-MM-dd"));
            }

            jsonObject.AddStringValues("pubMedIds", PubmedIds?.Select(id => id.ToString()));

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Esempio n. 21
0
        public void SerializeJson(StringBuilder sb)
        {
            var jsonObject = new JsonObject(sb);

            //converting empty alleles to '-'
            var refAllele = string.IsNullOrEmpty(ReferenceAllele)? "-":ReferenceAllele;
            var altAllele = string.IsNullOrEmpty(AltAllele) ? "-" : AltAllele;


            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("id", ID);
            jsonObject.AddStringValue("reviewStatus", ReviewStatusStrings[ReviewStatus]);
            jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false);
            jsonObject.AddStringValues("alleleOrigins", _alleleOrigins);
            jsonObject.AddStringValue("refAllele", "N" == refAllele ? null : refAllele);
            jsonObject.AddStringValue("altAllele", "N" == altAllele ? null : altAllele);
            jsonObject.AddStringValues("phenotypes", Phenotypes);
            jsonObject.AddStringValues("medGenIDs", _medgenIds);
            jsonObject.AddStringValues("omimIDs", OmimIDs);
            jsonObject.AddStringValues("orphanetIDs", OrphanetIDs);
            jsonObject.AddStringValue("significance", Significance);

            if (LastUpdatedDate != long.MinValue)
            {
                jsonObject.AddStringValue("lastUpdatedDate", Date.GetDate(LastUpdatedDate));
            }

            jsonObject.AddStringValues("pubMedIds", PubmedIds?.Select(id => id.ToString()));
            sb.Append(JsonObject.CloseBrace);
        }
Esempio n. 22
0
        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());
        }
Esempio n. 23
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            jsonObject.AddStringValue("id", $"{_accession}.{_version}");
            jsonObject.AddStringValue("reviewStatus", ClinVarCommon.ReviewStatusStrings[_reviewStatus]);
            jsonObject.AddStringValues("significance", _significances);
            jsonObject.AddStringValue("refAllele", ClinVarCommon.NormalizeAllele(RefAllele));
            jsonObject.AddStringValue("altAllele", ClinVarCommon.NormalizeAllele(AltAllele));
            jsonObject.AddStringValue("lastUpdatedDate", _lastUpdatedDate.ToString("yyyy-MM-dd"));

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
        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));
        }
Esempio n. 25
0
        private void AddSuppIntervalToJsonObject(JsonObject jsonObject)
        {
            var saDict = new Dictionary <string, List <string> >();

            foreach (var si in SupplementaryIntervals)
            {
                if (!saDict.ContainsKey(si.SupplementaryInterval.KeyName))
                {
                    saDict[si.SupplementaryInterval.KeyName] = new List <string>();
                }
                saDict[si.SupplementaryInterval.KeyName].Add(si.ToString());
            }

            foreach (var kvp in saDict)
            {
                jsonObject.AddStringValues(kvp.Key, kvp.Value.ToArray(), false);
            }
        }
Esempio n. 26
0
        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));
        }
Esempio n. 27
0
        public void SerializeJson(StringBuilder sb)
        {
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("name", GeneName);
            foreach (var geneAnnotation in Annotations)
            {
                if (geneAnnotation.IsArray)
                {
                    jsonObject.AddStringValues(geneAnnotation.DataSource, geneAnnotation.JsonStrings, false);
                }
                else
                {
                    jsonObject.AddStringValue(geneAnnotation.DataSource, geneAnnotation.JsonStrings[0], false);
                }
            }

            sb.Append(JsonObject.CloseBrace);
        }
Esempio n. 28
0
            public void SerializeJson(StringBuilder sb)
            {
                var jsonObject = new JsonObject(sb);

                // data section
                sb.Append(JsonObject.OpenBrace);

                jsonObject.AddStringValue("hgvsc", HgvsCodingName);

                var consequence = new Consequences(Consequences, null);

                if (Consequences.Count > 0)
                {
                    jsonObject.AddStringValues("consequence", consequence.GetConsequenceStrings());
                }

                jsonObject.AddIntValue("intron", Intron);
                jsonObject.AddIntValue("exon", Exon);

                sb.Append(JsonObject.CloseBrace);
            }
Esempio n. 29
0
            public override string ToString()
            {
                var sb         = new StringBuilder();
                var jsonObject = new JsonObject(sb);

                sb.Append(JsonObject.OpenBrace);
                jsonObject.AddStringValue(TranscriptTag, TranscriptID);
                jsonObject.AddStringValue(BioTypeTag, BioType);
                jsonObject.AddStringValue(AminoAcidsTag, AminoAcids);
                jsonObject.AddStringValue(CdnaPosTag, ComplementaryDnaPosition);
                jsonObject.AddStringValue(CodonsTag, Codons);
                jsonObject.AddStringValue(CdsPosTag, CdsPosition);
                jsonObject.AddStringValue(ExonsTag, Exons);
                jsonObject.AddStringValue(IntronsTag, Introns);
                jsonObject.AddStringValue(GeneIdTag, Gene);
                jsonObject.AddStringValue(HgncTag, Hgnc);
                jsonObject.AddStringValues(ConsequenceTag, Consequence?.ToArray());
                jsonObject.AddStringValue(HgvscTag, HgvsCodingSequenceName);
                jsonObject.AddStringValue(HgvspTag, HgvsProteinSequenceName);
                jsonObject.AddStringValue(GeneFusionTag, GeneFusion, false);
                jsonObject.AddStringValue(IsCanonicalTag, IsCanonical, false);
                jsonObject.AddStringValue(PolyPhenScoreTag, PolyPhenScore, false);
                jsonObject.AddStringValue(PolyPhenPredictionTag, PolyPhenPrediction);
                jsonObject.AddStringValue(ProteinIdTag, ProteinID);
                jsonObject.AddStringValue(ProteinPosTag, ProteinPosition);
                jsonObject.AddStringValue(SiftScoreTag, SiftScore, false);
                jsonObject.AddStringValue(SiftPredictionTag, SiftPrediction);

                if (AdditionalInfo != null && AdditionalInfo.Count > 0)
                {
                    foreach (var kvp in AdditionalInfo)
                    {
                        jsonObject.AddStringValue(kvp.Key, kvp.Value, false);
                    }
                }

                sb.Append(JsonObject.CloseBrace);
                return(sb.ToString());
            }
Esempio n. 30
0
        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());
        }