Example #1
0
        private static AnnotationResources GetAnnotationResources(AnnotationConfig annotationConfig)
        {
            var    genomeAssembly  = GenomeAssemblyHelper.Convert(annotationConfig.genomeAssembly);
            string cachePathPrefix = LambdaUrlHelper.GetCacheFolder().UrlCombine(genomeAssembly.ToString()).UrlCombine(LambdaUrlHelper.DefaultCacheSource);
            string nirvanaS3Ref    = LambdaUrlHelper.GetRefUrl(genomeAssembly);
            string saManifestUrl   = LambdaUtilities.GetManifestUrl(annotationConfig.supplementaryAnnotations ?? "latest", genomeAssembly);
            var    metrics         = new PerformanceMetrics();

            var annotationResources = new AnnotationResources(nirvanaS3Ref, cachePathPrefix,
                                                              saManifestUrl == null? null: new List <string> {
                saManifestUrl
            },
                                                              annotationConfig.customAnnotations,
                                                              annotationConfig.customStrUrl,
                                                              false,
                                                              false,
                                                              false,
                                                              metrics);

            using (var tabixStream = PersistentStreamUtils.GetReadStream(annotationConfig.tabixUrl))
            {
                annotationResources.InputStartVirtualPosition = GetTabixVirtualPosition(annotationConfig.annotationRange, tabixStream, annotationResources.SequenceProvider.RefNameToChromosome);
            }

            Logger.WriteLine($"Tabix position :{annotationResources.InputStartVirtualPosition}");

            return(annotationResources);
        }
Example #2
0
        // ReSharper disable once UnusedMember.Global
        public Stream Run(SingleConfig config, ILambdaContext context)
        {
            string snsTopicArn = null;
            Stream response;

            try
            {
                LogUtilities.UpdateLogger(context.Logger, null);
                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();

                GenomeAssembly genomeAssembly = GenomeAssemblyHelper.Convert(config.genomeAssembly);

                var  cacheConfiguration = new CacheConfiguration(genomeAssembly, config.supplementaryAnnotations, config.vepVersion);
                bool preloadRequired    = !string.IsNullOrEmpty(config.supplementaryAnnotations);
                AnnotationResources annotationResources = GetAndCacheAnnotationResources(config, cacheConfiguration);

                if (genomeAssembly != GenomeAssembly.hg19)
                {
                    annotationResources.Annotator.EnableMitochondrialAnnotation();
                }

                (IPosition position, string[] sampleNames) = config.GetPositionAndSampleNames(annotationResources.SequenceProvider, annotationResources.RefMinorProvider);
                if (position.Chromosome.IsEmpty())
                {
                    throw new UserErrorException($"An unknown chromosome was specified ({config.variant.chromosome})");
                }

                string annotationResult = GetPositionAnnotation(position, annotationResources, sampleNames, preloadRequired);
                response = SingleResult.Create(config.id, LambdaUrlHelper.SuccessMessage, annotationResult);
            }
            catch (Exception exception)
            {
                response = ExceptionHandler.GetStream(config.id, snsTopicArn, exception);
            }

            return(response);
        }
        private static AnnotationResources GetAnnotationResources(SingleConfig lambdaConfig)
        {
            GenomeAssembly genomeAssembly  = GenomeAssemblyHelper.Convert(lambdaConfig.genomeAssembly);
            string         cachePathPrefix = CacheUtilities.GetCachePathPrefix(lambdaConfig.vepVersion, genomeAssembly);
            string         nirvanaS3Ref    = LambdaUrlHelper.GetRefUrl(genomeAssembly);

            string annotatorVersion = "Nirvana " + CommandLineUtilities.GetVersion(Assembly.GetAssembly(typeof(SingleAnnotationLambda)));
            var    metrics          = new PerformanceMetrics();

            Logger.WriteLine($"Cache prefix: {cachePathPrefix}");
            //todo: get customStrTsv from lambdaConfig
            var annotationResources = new AnnotationResources(nirvanaS3Ref, cachePathPrefix,
                                                              null, lambdaConfig.customAnnotations, null, false, false, false, metrics)
            {
                AnnotatorVersionTag = annotatorVersion
            };

            return(annotationResources);
        }