Example #1
0
        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);
        }
Example #2
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            jsonObject.AddStringValue("start", Start.ToString(), false);
            jsonObject.AddStringValue("end", End.ToString(), false);

            if (StringValues != null)
            {
                foreach (var kvp in StringValues)
                {
                    jsonObject.AddStringValue(kvp.Key, kvp.Value);
                }
            }

            if (NonStringValues != null)
            {
                foreach (var kvp in NonStringValues)
                {
                    jsonObject.AddStringValue(kvp.Key, kvp.Value, false);
                }
            }

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Example #3
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));
        }
Example #4
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);
            }
Example #5
0
        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);
        }
Example #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);
            }
Example #7
0
        public void SerializeJson(StringBuilder sb)
        {
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("Start", Start.ToString(), false);
            jsonObject.AddStringValue("End", End.ToString(), false);
            // jsonObject.AddStringValue("ReferenceName", ReferenceName);//should be a quoted string
            // jsonObject.AddStringValue("Type",Type);//should be a quoted string

            if (StringValues != null)
            {
                foreach (var kvp in StringValues)
                {
                    jsonObject.AddStringValue(kvp.Key, kvp.Value);
                }
            }

            if (NonStringValues != null)
            {
                foreach (var kvp in NonStringValues)
                {
                    jsonObject.AddStringValue(kvp.Key, kvp.Value, false);
                }
            }

            sb.Append(JsonObject.CloseBrace);
        }
Example #8
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());
        }
Example #9
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));
        }
        public string Annotate(string geneName)
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("name", geneName);

            bool hasAnnotation = false;

            foreach (NgaReader ngaReader in _ngaReaders)
            {
                var jsonString = ngaReader.GetAnnotation(geneName);
                jsonObject.AddStringValue(ngaReader.JsonKey, jsonString, false);
                if (!string.IsNullOrEmpty(jsonString))
                {
                    hasAnnotation = true;
                }
            }

            if (!hasAnnotation)
            {
                return(null);
            }

            sb.Append(JsonObject.CloseBrace);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Example #11
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));
        }
Example #12
0
        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));
        }
Example #13
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);
            }
        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);
        }
Example #15
0
            public void SerializeJson(StringBuilder sb)
            {
                var jsonObject = new JsonObject(sb);

                sb.Append(JsonObject.OpenBrace);
                jsonObject.AddStringValue("transcript", TranscriptID);
                jsonObject.AddStringValue("hgnc", Hgnc);
                jsonObject.AddStringValue("isCanonical", IsCanonical, false);
                jsonObject.AddStringValue("partialOverlap", IsPartialOverlap, false);
                sb.Append(JsonObject.CloseBrace);
            }
Example #16
0
        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);
        }
Example #17
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));
        }
Example #18
0
        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));
        }
Example #19
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("haploinsufficiency", Data.ScoreToDescription[_hiScore]);
            jsonObject.AddStringValue("triplosensitivity", Data.ScoreToDescription[_tsScore]);
            sb.Append(JsonObject.CloseBrace);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Example #20
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("haploinsufficiency", Data.ScoreToDescription[_hiScore]);
            jsonObject.AddStringValue("triplosensitivity", Data.ScoreToDescription[_tsScore]);

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

                sb.Append(JsonObject.OpenBrace);
                if (!string.IsNullOrEmpty(ID))
                {
                    jsonObject.AddStringValue("id", ID, false);
                }
                jsonObject.AddStringValue("histology", Histology?.Replace('_', ' '));
                jsonObject.AddStringValue("primarySite", PrimarySite?.Replace('_', ' '));
                sb.Append(JsonObject.CloseBrace);
            }
Example #22
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            jsonObject.AddStringValue("sampleCount", NumSamples, false);
            jsonObject.AddStringValue("coverage", Coverage, false);
            jsonObject.AddStringValue("allAf", AllFreq, false);
            jsonObject.AddStringValue("afrAf", AfrFreq, false);
            jsonObject.AddStringValue("eurAf", EurFreq, false);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Example #23
0
        public void AddStringValue_TwoTimes()
        {
            var sb   = StringBuilderCache.Acquire();
            var json = new JsonObject(sb);

            json.AddStringValue("test1", "bob");
            json.AddStringValue("test2", "jane", false);

            const string expectedResult = "\"test1\":\"bob\",\"test2\":jane";
            var          observedResult = StringBuilderCache.GetStringAndRelease(sb);

            Assert.Equal(expectedResult, observedResult);
        }
Example #24
0
        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());

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

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("diseaseId", DiseaseId);
            jsonObject.AddStringValue("disease", _disease);
            jsonObject.AddStringValue("classification", _classification);
            jsonObject.AddStringValue("classificationDate", _classificationDate);
            sb.Append(JsonObject.CloseBrace);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Example #26
0
        public void SerializeJson(StringBuilder sb)
        {
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("id", ID);
            jsonObject.AddStringValue("isAlleleSpecific", IsAlleleSpecific, false);
            jsonObject.AddStringValue("refAllele", RefAllele);
            jsonObject.AddStringValue("altAllele", AltAllele);
            jsonObject.AddStringValue("gene", Gene);
            jsonObject.AddIntValue("sampleCount", SampleCount);
            jsonObject.AddObjectValues("studies", Studies);
            sb.Append(JsonObject.CloseBrace);
        }
        private static string GetHeader(IProvider geneAnnotationProvider)
        {
            var sb         = new StringBuilder();
            var jsonObject = new JsonObject(sb);

            sb.Append(JsonObject.OpenBrace);
            jsonObject.AddStringValue("annotator", "Nirvana " + CommandLineUtilities.Version);
            jsonObject.AddStringValue("creationTime", Date.CurrentTimeStamp);
            jsonObject.AddIntValue("schemaVersion", SaCommon.SchemaVersion);
            jsonObject.AddObjectValues("dataSources", geneAnnotationProvider.DataSourceVersions);
            sb.Append(JsonObject.CloseBrace);

            return(sb.ToString());
        }
Example #28
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));
        }
Example #30
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);
                }
            }
        }
Example #31
0
        static void Main(string[] args)
        {
            SyndicationClient client = new SyndicationClient();
            JsonArray jsonArray = new JsonArray();

            foreach (string key in keys)
            {
                string uriString = "http://social.msdn.microsoft.com/Forums/en-US/" + key + "/threads?outputAs=rss";
                Uri uri = new Uri(uriString);
                Task<SyndicationFeed> task = client.RetrieveFeedAsync(uri).AsTask();
                task.Wait();
                SyndicationFeed feed = task.Result;
                Console.WriteLine(key);
                Console.WriteLine(feed.Title.Text);
                Console.WriteLine(feed.Subtitle.Text);
                Console.WriteLine();

                JsonObject jsonObject = new JsonObject();
                jsonObject.AddStringValue("favicon_url", "http://social.microsoft.com/Forums/GlobalResources/images/Msdn/favicon.ico");
                jsonObject.AddStringValue("icon_url", "http://kiewic.com/questions/icon/" + key);
                jsonObject.AddStringValue("audience", feed.Subtitle.Text);
                jsonObject.AddStringValue("site_url", uriString);
                jsonObject.AddStringValue("api_site_parameter", key);
                jsonObject.AddStringValue("name", feed.Title.Text);

                jsonArray.Add(jsonObject);
            }

            File.WriteAllText("msdn.json", jsonArray.Stringify());
            Console.WriteLine(jsonArray.Stringify());
        }