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()); }
// ReSharper disable once UnusedMember.Global public Stream Run(GeneConfig config, ILambdaContext context) { string snsTopicArn = null; var runLog = new StringBuilder(); try { LogUtilities.UpdateLogger(context.Logger, runLog); LogUtilities.LogLambdaInfo(context, CommandLineUtilities.InformationalVersion); LogUtilities.LogObject("Config", config); LogUtilities.Log(new[] { LambdaUrlHelper.UrlBaseEnvironmentVariableName, LambdaUtilities.SnsTopicKey }); LambdaUtilities.GarbageCollect(); snsTopicArn = LambdaUtilities.GetEnvironmentVariable(LambdaUtilities.SnsTopicKey); config.Validate(); string result = GetGeneAnnotation(config, _saManifestUrl, _saPathPrefix); return(LambdaResponse.Create(config.id, LambdaUrlHelper.SuccessMessage, result)); } catch (Exception e) { return(HandleException(config.id, snsTopicArn, e)); } }
public void Validate_NoId_ThrowException() { var input = new GeneConfig { geneSymbols = new[] { "TP53" } }; Assert.Throws <UserErrorException>(() => input.Validate()); }
public void Validate_EmptyGeneSymbols_ThrowException() { var input = new GeneConfig { id = "test", geneSymbols = new string[] {} }; Assert.Throws <UserErrorException>(() => input.Validate()); }
public void Validate_NoGeneSymbols_ThrowException() { var input = new GeneConfig { id = "test" }; Assert.Throws <UserErrorException>(() => input.Validate()); }
public void GetGeneAnnotation_AsExpected() { var input = new GeneConfig { id = "test", geneSymbols = new[] { "TP53", "ZIC2", "LOC645752" }, ngaUrls = new[] { _customNgaPath } }; string responseString = global::GeneAnnotationLambda.GeneAnnotationLambda.GetGeneAnnotation(input, _manifestPath, _prefix); Assert.Contains("header", responseString); Assert.Contains("TP53", responseString); Assert.Contains("ZIC2", responseString); Assert.Contains("clingenDosageSensitivityMap", responseString); Assert.Contains("gnomAD", responseString); Assert.Contains("omim", responseString); Assert.Contains("InternalGeneAnnotation", responseString); Assert.DoesNotContain("LOC645752", responseString); }