Beispiel #1
0
        public static NgaWriter GetNgaWriter(Stream ngaStream, GeneAnnotationsParser parser, string dataVersion)
        {
            dataVersion = string.IsNullOrEmpty(parser.Version) ? dataVersion : parser.Version;
            var version = new DataSourceVersion(parser.JsonTag, dataVersion, DateTime.Now.Ticks, parser.DataSourceDescription);

            return(new NgaWriter(ngaStream, version, parser.JsonTag, SaCommon.SchemaVersion, false));
        }
        public static GeneAnnotationsParser Create(StreamReader reader, Dictionary <string, string> entrezGeneIdToSymbol, Dictionary <string, string> ensemblIdToSymbol)
        {
            var parser = new GeneAnnotationsParser(reader, entrezGeneIdToSymbol, ensemblIdToSymbol);

            parser.ParseHeaderLines();
            parser.InitiateSchema();
            parser.AddHeaderAnnotation();

            return(parser);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #5
0
        public static NgaWriter GetNgaWriter(Stream ngaStream, GeneAnnotationsParser parser, string dataVersion)
        {
            var version = new DataSourceVersion(parser.JsonTag, dataVersion, DateTime.Now.Ticks);

            return(new NgaWriter(ngaStream, version, parser.JsonTag, SaCommon.SchemaVersion, false));
        }