Ejemplo n.º 1
0
        private static IEnumerable <AnnotationRange> GetAnnotationRanges(NirvanaConfig config, GenomeAssembly genomeAssembly)
        {
            string cachePathPrefix = LambdaUtilities.GetCachePathPrefix(genomeAssembly);

            IntervalForest <IGene>            geneIntervalForest;
            IDictionary <string, IChromosome> refNameToChromosome;
            List <long> blockOffsets;

            using (var tabixStream = PersistentStreamUtils.GetReadStream(config.tabixUrl))
                using (var tabixReader = new BinaryReader(new BlockGZipStream(tabixStream, CompressionMode.Decompress)))
                    using (var referenceStream = PersistentStreamUtils.GetReadStream(LambdaUrlHelper.GetRefUrl(genomeAssembly)))
                        using (var sequenceProvider = new ReferenceSequenceProvider(referenceStream))
                            using (var taProvider = new TranscriptAnnotationProvider(cachePathPrefix, sequenceProvider, null))
                            {
                                long vcfSize       = HttpUtilities.GetLength(config.vcfUrl);
                                int  numPartitions = Math.Max(Math.Min((int)((vcfSize - 1) / MinPartitionSize + 1), MaxNumPartitions), MinNumPartitions);

                                var tabixIndex = Reader.Read(tabixReader, sequenceProvider.RefNameToChromosome);
                                blockOffsets = PartitionUtilities.GetFileOffsets(config.vcfUrl, numPartitions, tabixIndex);

                                IntervalArray <ITranscript>[] transcriptIntervalArrays = taProvider.TranscriptIntervalArrays;
                                geneIntervalForest  = GeneForestGenerator.GetGeneForest(transcriptIntervalArrays);
                                refNameToChromosome = sequenceProvider.RefNameToChromosome;
                            }

            IEnumerable <AnnotationRange> annotationRanges = PartitionUtilities.GenerateAnnotationRanges(blockOffsets, config.vcfUrl, geneIntervalForest, refNameToChromosome);

            return(annotationRanges);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public ValidationResult Run(ValidationConfig config, ILambdaContext context)
        {
            string snsTopicArn = null;

            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);

                string nirvanaS3Ref = LambdaUrlHelper.GetRefUrl(genomeAssembly);
                var    refProvider  = ProviderUtilities.GetSequenceProvider(nirvanaS3Ref);

                using (var stream = PersistentStreamUtils.GetReadStream(config.customStrUrl))
                    TryLoadStrFile(stream, genomeAssembly, refProvider);
            }
            catch (Exception exception)
            {
                return(HandleException(config.id, exception, snsTopicArn));
            }

            return(GetSuccessOutput(config.id));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public void GetS3RefLocation_AsExpected()
 {
     Assert.Equal(LambdaUrlHelper.GetRefPrefix("whatever") + "GRCh37" + LambdaUrlHelper.RefSuffix, LambdaUrlHelper.GetRefUrl(GenomeAssembly.GRCh37, "whatever"));
 }
Ejemplo n.º 6
0
        private static VariantAnnotationsParser GetVariantAnnotationsParserFromCustomTsvStream(PersistentStream customTsvStream)
        {
            var parser = VariantAnnotationsParser.Create(new StreamReader(GZipUtilities.GetAppropriateStream(customTsvStream)));

            parser.SequenceProvider = new ReferenceSequenceProvider(PersistentStreamUtils.GetReadStream(LambdaUrlHelper.GetRefUrl(parser.Assembly)));

            return(parser);
        }