コード例 #1
0
        public void Gene_in_gene_annotation_database_get_annotated()
        {
            var annotatedGene = new AnnotatedGene("A2M",
                                                  new IGeneAnnotationSource[] { new GeneAnnotationSource("omim", new[] { "{\"mimNumber\":103950,\"description\":\"Alpha-2-macroglobulin\",\"phenotypes\":[{\"mimNumber\":614036,\"phenotype\":\"Alpha-2-macroglobulin deficiency\",\"mapping\":\"mapping of the wildtype gene\",\"inheritances\":[\"Autosomal dominant\"]}", "{\"mimNumber\":104300,\"phenotype\":\"Alzheimer disease, susceptibility to\",\"mapping\":\"molecular basis of the disorder is known\",\"inheritances\":[\"Autosomal dominant\"],\"comments\":\"contribute to susceptibility to multifactorial disorders or to susceptibility to infection\"}]}" }, true) });

            var ms     = new MemoryStream();
            var header = new SupplementaryAnnotationHeader("", DateTime.Now.Ticks, 1, new IDataSourceVersion[] { }, GenomeAssembly.Unknown);

            using (var writer = new GeneDatabaseWriter(ms, header, true))
            {
                writer.Write(annotatedGene);
            }

            ms.Position = 0;
            var reader = new GeneDatabaseReader(ms);

            var geneAnnotationProvider = new GeneAnnotationProvider(reader);

            var observedAnnotation  = geneAnnotationProvider.Annotate("A2M");
            var observedAnnotation2 = geneAnnotationProvider.Annotate("A2M2L");

            Assert.NotNull(observedAnnotation);
            Assert.Null(observedAnnotation2);
            Assert.Single(observedAnnotation.Annotations);
            Assert.Equal("omim", observedAnnotation.Annotations[0].DataSource);
        }
コード例 #2
0
        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());
        }