Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
 public static IGeneAnnotationProvider GetGeneAnnotationProvider(AnnotationFiles files) => files?.NsiFiles == null ? null : new GeneAnnotationProvider(PersistentStreamUtils.GetStreams(files.NgaFiles));