예제 #1
0
        private static string GetOutputPrefix(string inputFilePath)
        {
            string fileName = CaUtilities.GetInputFileName(inputFilePath);

            if (fileName.EndsWith(".tsv"))
            {
                return(fileName.Substring(0, fileName.Length - 4));
            }
            return(fileName.EndsWith(".tsv.gz") ? fileName.Substring(0, fileName.Length - 7) : fileName);
        }
예제 #2
0
        private static ExitCodes ProgramExecution()
        {
            var referenceProvider = new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReference));

            List <CustomInterval> intervals;
            SaJsonSchema          intervalJsonSchema;
            string            jsonTag;
            DataSourceVersion version;
            string            outputPrefix      = GetOutputPrefix(_inputFile);
            string            nsaFileName       = Path.Combine(_outputDirectory, outputPrefix + SaCommon.SaFileSuffix);
            string            nsaIndexFileName  = nsaFileName + SaCommon.IndexSufix;
            string            nsaSchemaFileName = nsaFileName + SaCommon.JsonSchemaSuffix;
            ReportFor         reportFor;

            var nsaItemCount = 0;

            using (var parser = VariantAnnotationsParser.Create(GZipUtilities.GetAppropriateStreamReader(_inputFile), referenceProvider))
                using (var nsaStream = FileUtilities.GetCreateStream(nsaFileName))
                    using (var indexStream = FileUtilities.GetCreateStream(nsaIndexFileName))
                        using (var nsaWriter = CaUtilities.GetNsaWriter(nsaStream, indexStream, parser, CaUtilities.GetInputFileName(_inputFile), referenceProvider, out version))
                            using (var saJsonSchemaStream = FileUtilities.GetCreateStream(nsaSchemaFileName))
                                using (var schemaWriter = new StreamWriter(saJsonSchemaStream))
                                {
                                    (jsonTag, nsaItemCount, intervalJsonSchema, intervals) = CaUtilities.WriteSmallVariants(parser, nsaWriter, schemaWriter);
                                    reportFor = parser.ReportFor;
                                    if (intervals == null)
                                    {
                                        return(ExitCodes.Success);
                                    }
                                }

            if (nsaItemCount == 0)
            {
                File.Delete(nsaFileName);
                File.Delete(nsaIndexFileName);
                File.Delete(nsaSchemaFileName);
            }

            using (var nsiStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outputPrefix + SaCommon.IntervalFileSuffix)))
                using (var nsiWriter = CaUtilities.GetNsiWriter(nsiStream, version, referenceProvider.Assembly, jsonTag, reportFor))
                    using (var siJsonSchemaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outputPrefix + SaCommon.IntervalFileSuffix + SaCommon.JsonSchemaSuffix)))
                        using (var schemaWriter = new StreamWriter(siJsonSchemaStream))
                        {
                            nsiWriter.Write(intervals);
                            schemaWriter.Write(intervalJsonSchema);
                        }

            return(ExitCodes.Success);
        }
예제 #3
0
        private static ExitCodes ProgramExecution()
        {
            var(entrezGeneIdToSymbol, ensemblGeneIdToSymbol) = GeneUtilities.ParseUniversalGeneArchive(null, _universalGeneArchivePath);

            string outputPrefix      = GetOutputPrefix(_inputFile);
            string ngaFilePath       = Path.Combine(_outputDirectory, outputPrefix + SaCommon.NgaFileSuffix);
            string ngaSchemaFilePath = ngaFilePath + SaCommon.JsonSchemaSuffix;

            using (var parser = GeneAnnotationsParser.Create(GZipUtilities.GetAppropriateStreamReader(_inputFile), entrezGeneIdToSymbol, ensemblGeneIdToSymbol))
                using (var ngaStream = FileUtilities.GetCreateStream(ngaFilePath))
                    using (var ngaWriter = CaUtilities.GetNgaWriter(ngaStream, parser, CaUtilities.GetInputFileName(_inputFile)))
                        using (var saJsonSchemaStream = FileUtilities.GetCreateStream(ngaSchemaFilePath))
                            using (var schemaWriter = new StreamWriter(saJsonSchemaStream))
                            {
                                ngaWriter.Write(parser.GetItems());
                                schemaWriter.Write(parser.JsonSchema);
                            }

            return(ExitCodes.Success);
        }
예제 #4
0
        private static ExitCodes ProgramExecution()
        {
            var(entrezGeneIdToSymbol, ensemblGeneIdToSymbol) = GeneUtilities.ParseUniversalGeneArchive(null, _universalGeneArchivePath);

            string outputPrefix      = GetOutputPrefix(_inputFile);
            string ngaFilePath       = Path.Combine(_outputDirectory, outputPrefix + SaCommon.GeneFileSuffix);
            string ngaSchemaFilePath = ngaFilePath + SaCommon.JsonSchemaSuffix;

            using (var parser = GeneAnnotationsParser.Create(GZipUtilities.GetAppropriateStreamReader(_inputFile), entrezGeneIdToSymbol, ensemblGeneIdToSymbol))
                using (var ngaStream = FileUtilities.GetCreateStream(ngaFilePath))
                    using (var ngaWriter = CaUtilities.GetNgaWriter(ngaStream, parser, CaUtilities.GetInputFileName(_inputFile)))
                        using (var saJsonSchemaStream = FileUtilities.GetCreateStream(ngaSchemaFilePath))
                            using (var schemaWriter = new StreamWriter(saJsonSchemaStream))
                            {
                                ngaWriter.Write(parser.GetItems());
                                if (parser.GetUnknownGenes().Count > 0)
                                {
                                    throw new UserErrorException($"The following gene IDs were not recognized in Nirvana: {string.Join(',',parser.GetUnknownGenes())}.");
                                }
                                schemaWriter.Write(parser.JsonSchema);
                            }

            return(ExitCodes.Success);
        }