NCBI C++ ToolKit
table2asn.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: table2asn.hpp 102515 2024-05-20 15:38:38Z foleyjp $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Jonathan Kans, Clifford Clausen,
27 * Aaron Ucko, Sergiy Gotvyanskyy
28 *
29 * File Description:
30 * Converter of various files into ASN.1 format, main application function
31 *
32 */
33 
36 #include <util/format_guess.hpp>
37 
38 #include "table2asn_context.hpp"
39 #include "async_token.hpp"
40 #include "multireader.hpp"
41 
43 
44 using namespace objects;
45 
46 class CSerialObject;
47 
48 class CTable2AsnLogger;
49 class CMultiReader;
51 class CMask;
54 class CMemorySrcFileMap;
55 
56 namespace objects::edit {
57  class CHugeFile;
58 }
59 
60 namespace objects::feature {
61  class CFeatTree;
62 }
63 
65 {
66 public:
67  CTbl2AsnApp();
68 
69  void Init() override;
70  int Run() override;
71  int DryRun() override
72  {
73  return Run();
74  }
75 
77 
78 private:
79 
81  void Setup(const CArgs& args);
82 
83  void ProcessOneFile(bool isAlignment, bool manageDiagnosticStreams = true, bool manageDataStream=true);
84  void ProcessOneFile(CNcbiOstream* output);
85  void xProcessOneFile(CFormatGuess::EFormat format,
86  CRef<CSerialObject> pInputObject,
87  TAnnotMap& annotMap,
89  void ProcessHugeFile(edit::CHugeFile& hugeFile, CNcbiOstream* output);
90  void ProcessOneFile(CFormatGuess::EFormat format, const string& contentType, unique_ptr<CNcbiIstream>& pIstr, CNcbiOstream* output);
91  void ProcessOneEntry(CFormatGuess::EFormat inputFormat, CRef<CSerialObject> obj, CRef<CSerialObject>& result);
92  void ProcessSingleEntry(CFormatGuess::EFormat inputFormat, TAsyncToken& token);
93  void MakeFlatFile(CSeq_entry_Handle seh, CRef<CSeq_submit> submit, std::ostream& ostream);
94  void ProcessTopEntry(CFormatGuess::EFormat inputFormat, bool need_update_date, CRef<CSeq_submit>& submit, CRef<CSeq_entry>& entry);
95  bool ProcessOneDirectory(const CDir& directory, const CMask& mask, bool recurse);
96  void ProcessAlignmentFile(CNcbiOstream* output);
97  void ReportUnusedSourceQuals();
98 
99  void xProcessSecretFiles1Phase(bool readModsFromTitle, CSeq_entry& result);
100  void ProcessSecretFiles1Phase(bool readModsFromTitle, TAsyncToken&);
101 
102  void ProcessSecretFiles2Phase(CSeq_entry& result) const;
103  void ProcessCMTFiles(CSeq_entry& result) const;
104  void LoadPEPFile(const string& pathname);
105  void LoadRNAFile(const string& pathname);
106  void LoadPRTFile(const string& pathname);
107  void LoadDSCFile(const string& pathname);
108  void LoadAdditionalFiles();
109  void LoadCMTFile(const string& pathname, unique_ptr<CTable2AsnStructuredCommentsReader>& comments);
110  void LoadAnnotMap(const string& pathname, TAnnotMap& annotMap);
111  void AddAnnots(CSeq_entry& entry);
112  void SetupAndOpenDiagnosticStreams();
113  void SetupAndOpenDataStreams();
114  void CloseDiagnosticStreams();
115  void CloseDataStreams();
117  size_t xGetNumThreads() const;
118 
119  void x_SetAlnArgs(CArgDescriptions& arg_desc);
120 
122  {
123  unique_ptr<CTable2AsnStructuredCommentsReader> m_struct_comments;
129  unique_ptr<CMemorySrcFileMap> mp_src_qual_map;
130  unique_ptr<CFeatureTableReader> m_feature_table_reader;
131  };
132 
134  unique_ptr<TAdditionalFiles> m_secret_files;
135 
136  unique_ptr<CMultiReader> m_reader;
140 
141  static const Int8 TBL2ASN_MAX_ALLOWED_FASTA_SIZE = INT8_C(0x7FFFFFFF);
142 };
143 
144 
145 class CTable2AsnLogger : public CMessageListenerLenient, public CDiagHandler
146 {
147 public:
148  CTable2AsnLogger() : m_enable_log(false) {}
150 
151  void PutProgress(
152  const string& sMessage,
153  const Uint8 iNumDone = 0,
154  const Uint8 iNumTotal = 0) override;
155 
156  bool PutMessage(const IObjtoolsMessage& message) override;
157 
158  void Post(const SDiagMessage& mess) override;
159 };
160 
161 
static const CDataLoadersUtil::TLoaders default_loaders
Definition: annotwriter.cpp:76
ncbi::TMaskedQueryRegions mask
CArgDescriptions –.
Definition: ncbiargs.hpp:541
CArgs –.
Definition: ncbiargs.hpp:379
CDir –.
Definition: ncbifile.hpp:1695
CFeatTree.
Definition: feature.hpp:173
EFormat
The formats are checked in the same order as declared here.
CMask –.
Definition: ncbi_mask.hpp:59
map< string, list< CRef< CSeq_annot > >> TAnnotMap
Definition: multireader.hpp:44
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
Base class for all serializable objects.
Definition: serialbase.hpp:150
CRef< CTable2AsnValidator > m_validator
Definition: table2asn.hpp:137
CTable2AsnContext m_context
Definition: table2asn.hpp:139
int DryRun() override
Test run the application.
Definition: table2asn.hpp:71
TAdditionalFiles m_global_files
Definition: table2asn.hpp:133
void xProcessHugeEntries()
unique_ptr< CMultiReader > m_reader
Definition: table2asn.hpp:136
CRef< CTable2AsnLogger > m_logger
Definition: table2asn.hpp:138
unique_ptr< TAdditionalFiles > m_secret_files
Definition: table2asn.hpp:134
Definition: map.hpp:338
#define false
Definition: bool.h:36
static void Init(void)
Definition: cursor6.c:76
static SQLCHAR output[256]
Definition: print.c:5
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
void Run(void)
Enter the main loop.
static Format format
Definition: njn_ioutil.cpp:53
#define INT8_C(val)
Definition: stdint.h:276
CRef< CSeq_entry > m_possible_proteins
Definition: table2asn.hpp:127
unique_ptr< CTable2AsnStructuredCommentsReader > m_struct_comments
Definition: table2asn.hpp:123
CRef< CSeq_entry > m_replacement_proteins
Definition: table2asn.hpp:126
CRef< CSeq_descr > m_descriptors
Definition: table2asn.hpp:128
CMultiReader::TAnnotMap m_AnnotMap
Definition: table2asn.hpp:124
unique_ptr< CMemorySrcFileMap > mp_src_qual_map
Definition: table2asn.hpp:129
unique_ptr< CFeatureTableReader > m_feature_table_reader
Definition: table2asn.hpp:130
SDiagMessage –.
Definition: ncbidiag.hpp:1599
else result
Definition: token2.c:20
Modified on Thu Jun 06 15:43:10 2024 by modify_doxy.py rev. 669887