NCBI C++ ToolKit
seqannot_splicer.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: seqannot_splicer.cpp 67311 2015-05-07 14:25:39Z mcelhany $
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 * Author: David McElhany, with thanks to Eugene Vasilchenko and Andrei
27 * Gourianov for patiently answering my many questions.
28 *
29 * File Description:
30 * A demo program to answer the question:
31 * - I've got 1,000,000 separate Seq-annots. How do I splice them into
32 * Seq-entries I have without reading the seq-entries in?
33 *
34 * NOTE: This question was given in CXX-1382 in the context of demonstrating
35 * serial hooks, and the program is therefore designed primarily to demo
36 * serial hooks, not to demo an optimal splicing algorithm.
37 *
38 * Implementation Approach:
39 *
40 * 1. Scan the Seq-annot file and create two cross-reference maps. One maps
41 * from Seq-id to stream positions of Seq-Annot's that reference the Seq-id.
42 * The other maps from Seq-annot stream positions to all the Seq-id's that
43 * the Seq-annot at that stream position references.
44 *
45 * The scanning is done by setting skip hooks on the Seq-annot and Seq-id
46 * object types and skipping through the file. Inside the Seq-annot hook,
47 * the stream position is noted. Inside the Seq-id hook, the Seq-id is read
48 * and cross references between the Seq-annot and the Seq-id are mapped.
49 *
50 * The first map is necessary because Seq-annot's will be spliced based on
51 * the Seq-id's they reference. However, there is no way to know ahead of
52 * time which Seq-id from the Seq-entry files will be used to trigger the
53 * splicing of a given Seq-annot. So this map eliminates a linear search
54 * through all Seq-annot's looking for Seq-annot's that reference each
55 * Seq-id by providing random access to the Seq-annot's keyed on Seq-id.
56 *
57 * The second map was added to eliminate a linear search through all
58 * Seq-id's looking for those that a given Seq-annot references. This
59 * will eliminate the search through all Seq-id's every time a Seq-annot is
60 * spliced - nominally a million times. However, optimizing this may or
61 * may not be required, and is probably highly dependent on the splicing
62 * algorithm. It is expected that a real splicing application would use
63 * a different algorithm and would need to revamp the data structures.
64 * Some things to consider:
65 * (a) There are initially a million Seq-annot's, but each Seq-annot will
66 * only be spliced once so it makes sense to remove it from searches
67 * once it has been spliced. This is most easily accomplished by
68 * having a map keyed on Seq-annot stream position.
69 * (b) Seq-annot's might reference many Seq-id's, so once a Seq-annot is
70 * spliced, it makes sense to not look for it again for any of the
71 * Seq-id's that it references.
72 * (c) The Seq-entry files may contain a large number of references to the
73 * same Seq-id. So this map provides random access to all the Seq-id's
74 * that a given Seq-annot references.
75 *
76 * 2. For each Seq-entry file, scan the file and build a tree of contexts
77 * within which Seq-annot's can be spliced. Seq-annot's can only occur in
78 * Bioseq or Bioseq-set objects, so for this purpose a context basically
79 * just means the nested location of these objects in the Seq-entry file.
80 *
81 * The scanning is done by setting skip hooks for Bioseq and Bioseq-set
82 * objects, which build the context tree, and by setting skip hooks on
83 * Seq-annot and Seq-id objects, which update the current context node.
84 * The Seq-annot hook simply notes that the context contains annotations,
85 * while the Seq-id hook just reads in a Seq-id and adds it to the set of
86 * Seq-id's referenced in that context.
87 *
88 * 3. With the Seq-entry file just scanned, now copy it to the output file,
89 * splicing Seq-annot's as appropriate. The question of where to splice
90 * is not the focus of this program, so it uses the simple approach of
91 * (a) setting copy hooks on Bioseq and Bioseq-set objects to traverse
92 * the context tree, and (b) setting a copy hook on Seq-annot objects to
93 * splice any Seq-annot's that contain Seq-id's also referenced in the
94 * current context. Basically, the first time a Seq-id is encountered in
95 * the Seq-entry, all Seq-annot's referencing that Seq-id are spliced
96 * into the 'annot' member of the enclosing Bioseq or Bioseq-set.
97 *
98 * Some Assumptions:
99 *
100 * 1. There should be linear complexity in time and memory with respect to
101 * the number of Seq-annot's.
102 * 2. There should be linear complexity in time and memory with respect to
103 * the number of Seq-entry's.
104 * 3. It's OK to use a test file having less than 1,000,000 Seq-annots,
105 * provided the program scales well without changing the complexity.
106 *
107 * 4. All Seq-annot's are concatenated in one file with no top-level type.
108 * Note that due to an apparent bug in CObjectIStream::{G|S}etStreamPos(),
109 * this file should be in ASN.1 binary format.
110 * 5. All Seq-entry's are stored one per file in a dedicated directory and
111 * have the same format.
112 * 6. There are not so many Seq-entry's that storing them all in a single
113 * directory will be hard for the file system to manage.
114 * 7. There's sufficient storage to write the Seq-entry files (with spliced
115 * Seq-annot's) to a new directory.
116 * 8. It's OK to delete all contents of the Seq-entry output directory prior
117 * to writing the new spliced Seq-entry files.
118 *
119 * 9. All Seq-annot's will reference at least one Seq-id.
120 * 10. Individual Seq-annot's will typically reference relatively few Seq-id's -
121 * that is, optimizing performance won't be necessary for accessing the
122 * Seq-id's referenced by a Seq-annot.
123 * 11. Seq-id's are not unique across all the Seq-annot's.
124 * 12. Seq-id's are not unique across all the Seq-entry files.
125 *
126 * 13. Every Seq-annot should be spliced into exactly one Seq-entry.
127 * 14. It's OK to splice a Seq-annot into the first Seq-entry containing any
128 * Seq-id also in the Seq-annot, regardless of the other Seq-id's contained
129 * in either the Seq-annot or Seq-entry.
130 * 15. If none of the Seq-id's in a Seq-annot are contained in any of the
131 * Seq-entry's, the Seq-annot could be spliced into a new "catch-all"
132 * Seq-entry (but this is not implemented).
133 * 16. Any Seq-id's contained in the Seq-entry's but not in any Seq-annot's
134 * do not require any processing.
135 *
136 * 17. Reporting should go to STDOUT and should include:
137 * a. The number of Seq-annot's processed.
138 * b. The number of Seq-annot's spliced into existing Seq-entry's.
139 * c. The number of Seq-annot's not spliced (or spliced into a new
140 * catch-all Seq-entry).
141 * d. The number of Seq-entry's processed.
142 * e. The number of Seq-entry's copied with spliced Seq-annot's.
143 * f. The number of Seq-entry's copied unchanged.
144 *
145 * Program Organization:
146 * seqannot_splicer.cpp
147 * Main application and serial hooks logic.
148 * seqannot_splicer_stats.[ch]pp
149 * For tracking and reporting program statistics.
150 * seqannot_splicer_util.[ch]pp
151 * Supporting code not specifically related to serial
152 * hooks - notably, a simplistic method of splicing.
153 *
154 * ===========================================================================
155 */
156 
157 #include <ncbi_pch.hpp>
158 #include <corelib/ncbiapp.hpp>
159 #include <corelib/ncbiargs.hpp>
160 #include <corelib/ncbiexpt.hpp>
161 #include <corelib/ncbifile.hpp>
162 #include <corelib/ncbistre.hpp>
163 
164 #include <objects/seq/Bioseq.hpp>
165 #include <objects/seq/Seq_annot.hpp>
168 #include <objects/seqloc/Seq_id.hpp>
169 
170 #include <serial/iterator.hpp>
171 #include <serial/objcopy.hpp>
172 #include <serial/objectio.hpp>
173 #include <serial/objhook.hpp>
174 #include <serial/objistr.hpp>
175 #include <serial/objostr.hpp>
176 #include <serial/serial.hpp>
177 
179 #include "seqannot_splicer_util.hpp"
180 
183 
184 
185 ///////////////////////////////////////////////////////////////////////////
186 // Static Function Prototypes
187 
189 
191 
192 
193 ///////////////////////////////////////////////////////////////////////////
194 // Hook Classes
195 
196 // This class is used when skipping Seq-annot's. The entire Seq-annot is
197 // hooked so that any necessary wrapper functionality can be implemented.
199 {
200 public:
201  virtual void SkipObject(CObjectIStream& in,
202  const CObjectTypeInfo& passed_info)
203  {
204  // Do any needed processing before skipping object.
205  SeqAnnotSet_Pre(in);
206 
207  // Skip the Seq-annot (triggering other hooks).
208  DefaultSkip(in, passed_info);
209  }
210 };
211 
212 
213 // This class is used when skipping Seq-annot's. The Seq-id is
214 // hooked so that Seq-id's can be associated with the Seq-annot's.
216 {
217 public:
218  virtual void SkipObject(CObjectIStream& in,
219  const CObjectTypeInfo& passed_info)
220  {
221  // Read Seq-id locally (not saved outside this scope).
222  CRef<CSeq_id> seqid(new CSeq_id);
223  in.Read(&*seqid, CType<CSeq_id>().GetTypeInfo(),
225 
226  // Associate this Seq-id with the containing Seq-annot.
227  SeqAnnotMapSeqId(seqid);
228  }
229 };
230 
231 
232 // This class is used when copying Seq-entry's. Bioseq and Bioseq-set's are
233 // hooked so that the context can be tracked, and so that splicing can be
234 // done within the proper context.
236 {
237 public:
238  virtual void CopyObject(CObjectStreamCopier& copier,
239  const CObjectTypeInfo& passed_info)
240  {
241  // This hook simply follows the context (Bioseq and Bioseq-set),
242  // and the copy hook for the Seq-annot then checks the current
243  // context to see if it should splice any Seq-annot's.
244  ContextEnter();
245  DefaultCopy(copier, passed_info);
246  ContextLeave();
247  }
248 };
249 
250 
251 // This class is used when copying Seq-entry's. Seq-annot's are hooked so
252 // that splicing new Seq-annot's can be done in conjunction with copying the
253 // existing Seq-annot's.
255 {
256 public:
258  : m_sai(sai)
259  {
260  }
261  virtual void CopyClassMember(CObjectStreamCopier& copier,
262  const CObjectTypeInfoMI& member)
263  {
264  // The relevant ASN.1 is:
265  // Bioseq ::= {
266  // ...
267  // annot SET OF Seq-annot
268  // or:
269  // Bioseq-set ::= {
270  // ...
271  // annot SET OF Seq-annot
272  //
273  // Hooks are on the 'annot' class member of the both objects.
274  //
275  // However, we want to process individual Seq-annot's, so we will
276  // iterate through the set and: (1) read into a local Seq-annot object,
277  // (2) write that object, and (3) check if any new Seq-annot's need
278  // to be spliced in with that Seq-annot - if so they then get added.
279  //
280  // The set is initiated in the output stream (e.g. writing '{' for
281  // ASN.1 text format) when the CIStreamContainerIterator is created,
282  // and terminated when the CIStreamContainerIterator goes out of scope.
283 
284  // Create a temporary Seq-annot object.
285  CSeq_annot annot;
286 
287  // Create an object output iterator.
288  COStreamContainer osc(copier.Out(), member.GetMemberType());
289 
290  // Iterate through the existing set of Seq-annot's.
291  CIStreamContainerIterator isc(copier.In(), member.GetMemberType());
292  for ( ; isc; ++isc ) {
293  isc >> annot; // Read existing Seq-annot.
294  osc << annot; // Write existing Seq-annot.
295  }
296 
297  // Splice in any applicable annotations.
299  }
300 private:
302 };
303 
304 
305 // This class is used when skipping Seq-entry's. Bioseq and Bioseq-set's are
306 // hooked so that a context tree can be created for reference when the
307 // Seq-entry is copied.
309 {
310 public:
312  : m_context(context)
313  {
314  }
315 
316  virtual void SkipObject(CObjectIStream& in,
317  const CObjectTypeInfo& passed_info)
318  {
319  // This hook just helps establish context for other hooks by
320  // recording the context (nesting of Bioseq and Bioseq-set).
321  // So just update the context and Skip the object.
322  ContextStart(in, m_context);
323  DefaultSkip(in, passed_info);
324  ContextEnd();
325  }
326 private:
328 };
329 
330 
331 // This class is used when skipping Seq-entry's. Seq-annot's are
332 // hooked because the splicing code needs to know whether the context
333 // being copied contains a Seq-annot.
335 {
336 public:
337  virtual void SkipObject(CObjectIStream& in,
338  const CObjectTypeInfo& passed_info)
339  {
340  // This hook just records that the current context contains
341  // Seq-annot's and then skips over the annotation.
343  DefaultSkip(in, passed_info);
344  }
345 };
346 
347 
348 // This class is used when skipping Seq-entry's. Seq-id's are
349 // hooked so that all the Seq-id's referenced in a given context will be
350 // known when it's time to splice.
352 {
353 public:
354  virtual void SkipObject(CObjectIStream& in,
355  const CObjectTypeInfo& passed_info)
356  {
357  // Read Seq-id locally (not saved outside this scope).
358  CRef<CSeq_id> id(new CSeq_id);
359  in.Read(&*id, CType<CSeq_id>().GetTypeInfo(),
361 
362  // Add this Seq-id to the current context.
364  }
365 };
366 
367 
368 ///////////////////////////////////////////////////////////////////////////
369 // Static Function Definitions
370 
371 // This function pre-processes the Seq-annot stream to record the stream
372 // positions of the Seq-annot's and to associate Seq-annot's with the Seq-id's
373 // they reference.
375 {
376  // Set a hook to handle any processing necessary for the full Seq-annot.
379 
380  // Set a hook to process each Seq-id within the Seq-annot's to get info
381  // on how to maps Seq-Id's to Seq-annot's and vice versa.
384 
385  // Skip through all Seq-annot's (triggering the hooks).
386  // This will throw when all are skipped and no data is left in the file.
387  try {
388  while (true) {
392  }
393  } catch(CEofException&) {
394  // This is expected - no more data to skip.
395  } catch(...) {
396  // This is not.
398  "Unexpected exception while preprocessing Seq-annot file.");
399  }
400 
401  // Remove the hook.
402  sai->ResetLocalHooks();
403 }
404 
405 
406 // This function figures out the context for each Seq-id so the best place to
407 // splice Seq-annot's can be determined.
409 {
410  // Set hooks to find the context for each Seq-id.
413 
416 
419 
422 
423  // Ignore header line.
424  sei->ReadFileHeader();
425 
426  // Skip through the Seq-entry (triggering hooks).
428 
429  // Remove the skip hooks - they won't be used anymore.
430  sei->ResetLocalHooks();
431 
432  // Rewind the file.
433  sei->SetStreamPos(0);
434 
435  // Initialize the current context.
436  ContextInit();
437 }
438 
439 
440 ///////////////////////////////////////////////////////////////////////////
441 // Main Application Functionality
442 
444 {
445  virtual void Init(void);
446  virtual int Run(void);
447 };
448 
449 
451 {
452  // Create command-line argument descriptions class
454 
455  // Specify USAGE context
456  arg_desc->SetUsageContext
457  (GetArguments().GetProgramBasename(),
458  "Seq-annot splicer");
459 
460  // Describe the expected command-line arguments
461 
462  arg_desc->AddDefaultKey
463  ("sa", "SeqAnnotFile",
464  "name of file containing Seq-annot's",
466  arg_desc->AddDefaultKey("safmt", "SeqAnnotFormat", "format of Seq-annot file",
467  CArgDescriptions::eString, "asnb");
468  arg_desc->SetConstraint
469  ("safmt", &(*new CArgAllow_Strings, "asn", "asnb", "xml", "json"));
470 
471  arg_desc->AddDefaultKey
472  ("sei", "SeqEntryInputDir",
473  "the directory containing the input Seq-Entry files",
475  arg_desc->AddDefaultKey("seifmt", "SeqEntryInputFormat", "format of input Seq-entry files",
476  CArgDescriptions::eString, "asnb");
477  arg_desc->SetConstraint
478  ("seifmt", &(*new CArgAllow_Strings, "asn", "asnb", "xml", "json"));
479 
480  arg_desc->AddDefaultKey
481  ("seo", "SeqEntryOutputDir",
482  "the directory containing the output Seq-Entry files",
484  arg_desc->AddDefaultKey("seofmt", "SeqEntryOutputFormat", "format of output Seq-entry files",
485  CArgDescriptions::eString, "asnb");
486  arg_desc->SetConstraint
487  ("seofmt", &(*new CArgAllow_Strings, "asn", "asnb", "xml", "json"));
488 
489  arg_desc->AddOptionalKey
490  ("sasm", "SeqAnnotChoiceMask",
491  "Seq-annot choice mask",
493 
494  arg_desc->AddOptionalKey
495  ("sism", "SeqIdChoiceMask",
496  "Seq-id choice mask",
498 
499  // Setup arg.descriptions for this application
500  SetupArgDescriptions(arg_desc.release());
501 }
502 
504 {
505  // Get arguments
506  const CArgs& args = GetArgs();
507 
508  // Set up Seq-annot selection mask.
509  if (args["sasm"].HasValue()) {
510  SetSeqAnnotChoiceMask(args["sasm"].AsString());
511  }
512  //
513  // NOTE: There appears to be a bug in CObjectIStream::{G|S}etStreamPos()
514  // for ASN.1 text format, so don't allow that format.
516  NcbiCout << "I'm sorry, the Seq_table CHOICE mask for Seq-annot's "
517  "is not currently supported \n"
518  "due to an apparent bug in parsing seq-table CHOICE values.\n"
519  "Please try an alternate CHOICE." << NcbiEndl;
520  return 0;
521  }
522 
523  // Set up Seq-id selection mask.
524  if (args["sism"].HasValue()) {
525  SetSeqIdChoiceMask(args["sism"].AsString());
526  }
527 
528  // Set up Seq-annot stream.
530  (GetFormat(args["safmt"].AsString()),
531  args["sa"].AsInputFile()));
532  //
533  // NOTE: There appears to be a bug in CObjectIStream::{G|S}etStreamPos()
534  // for ASN.1 text format, so don't allow that format.
535  if (eSerial_AsnText == GetFormat(args["safmt"].AsString())) {
536  NcbiCout << "I'm sorry, ASN.1 text is not currently "
537  "supported for the concatenated \n"
538  "Seq-Annot file due to an apparent bug in "
539  "CObjectIStream::{G|S}etStreamPos().\n"
540  "Please try an alternate format." << NcbiEndl;
541  return 0;
542  }
543 
544  // Pre-process the Seq-annot stream to create map from Seq-id to Seq-annot.
546 
547  // For handling Seq-entry input and output file formats and directories:
548  ESerialDataFormat seifmt = GetFormat(args["seifmt"].AsString());
549  ESerialDataFormat seofmt = GetFormat(args["seofmt"].AsString());
550  string seidir = args["sei"].AsString();
551  string seodir = args["seo"].AsString();
552 
553  // Clear the Seq-entry output directory.
554  CDir(seodir).Remove();
555  CDir(seodir).Create();
556 
557  // Loop through all the Seq-entry files.
558  CDir::TEntries dir_entries(CDir(seidir).GetEntries());
559  ITERATE (CDir::TEntries, file, dir_entries) {
560  // Get the current (non-trivial) directory entry.
561  string name = (*file)->GetName();
562  if (name.compare(".") && name.compare("..")) {
563  string seiname = (*file)->GetPath();
564  string seoname = seodir + CDir::GetPathSeparator() + name;
565 
566  // Start the statistics for this Seq-entry.
568 
569  // Set up input and output streams for copying Seq-entry's.
570  auto_ptr<CObjectIStream> sei(CObjectIStream::Open(seifmt, seiname));
571  auto_ptr<CObjectOStream> seo(CObjectOStream::Open(seofmt, seoname));
572  CObjectStreamCopier copier(*sei, *seo);
573 
574  // Do any preprocessing necessary.
575  NcbiCout << "Processing Seq-entry: " << name << NcbiEndl;
577 
578  // Set up hooks to follow the Bioseq / Bioseq-set context.
580  .SetLocalCopyHook(copier, new CHookSeq_entry__Copy());
582  .SetLocalCopyHook(copier, new CHookSeq_entry__Copy());
583 
584  // Set up hooks to copy existing and possibly splice new
585  // Seq-annot's. Note that the hooks must be set on the 'annot'
586  // member, because it's a SET OF, and we want to iterate through
587  // the set in the hook. Therefore, must set a hook for both
588  // Bioseq and Bioseq-set (both hooks call the same code).
590  .FindMember("annot")
593  .FindMember("annot")
595 
596  // Copy input Seq-entry to output Seq-entry. This will trigger the
597  // hooks, which will copy the existing Seq-entry's Seq-annot's, then
598  // splice any applicable new Seq-annot's.
599  copier.Copy(CType<CSeq_entry>());
600 
601  // Reset Seq-entry data structures.
603 
604  // Stop the statistics for this Seq-entry.
606  }
607  }
608 
609  // Report on program statistics.
610  g_Stats->Report();
611 
612  return 0;
613 }
614 
615 
616 int main(int argc, const char* argv[])
617 {
618  // Execute main application function
619  return CSeqAnnotSplicerApp().AppMain(argc, argv);
620 }
list< AutoPtr< CDirEntry > > TEntries
Define a list of pointers to directory entries.
Definition: ncbifile.hpp:1630
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
Definition: objostr.cpp:126
static void s_PreprocessSeqAnnots(auto_ptr< CObjectIStream > &sai)
CObjectIStream –.
Definition: objistr.hpp:92
void SetLocalCopyHook(CObjectStreamCopier &stream, CCopyClassMemberHook *hook) const
Definition: objectiter.cpp:168
void SeqAnnotMapSeqId(TSeqRef seqid_in_annot)
CObjectTypeInfoMI –.
Definition: objectiter.hpp:240
virtual void SkipObject(CObjectIStream &in, const CObjectTypeInfo &passed_info)
void ResetSeqEntryProcessing(void)
void AddDefaultKey(const string &name, const string &synopsis, const string &comment, EType type, const string &default_value, TFlags flags=0, const string &env_var=kEmptyStr, const char *display_value=nullptr)
Add description for optional key with default value.
Definition: ncbiargs.cpp:2239
Copy hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:254
CHookSeq_entry__Skip(const EContextType context)
void SkipObject(const CObjectTypeInfo &objectType)
Skip child object.
Definition: objistr.cpp:1073
Defines command line argument related classes.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
Definition: ncbiapp.cpp:779
virtual int Run(void)
Run the application.
Name of file (must exist and be readable)
Definition: ncbiargs.hpp:558
ASN.1 text.
Definition: serialdef.hpp:73
#define NcbiCout
Definition: ncbistre.hpp:406
void ContextStart(CObjectIStream &in, EContextType type)
virtual void SkipObject(CObjectIStream &in, const CObjectTypeInfo &passed_info)
CObjectIStream & In(void) const
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
CObjectTypeInfo –.
Definition: objectinfo.hpp:93
#define NcbiEndl
Definition: ncbistre.hpp:411
void SeqAnnotSet_Pre(CObjectIStream &in)
CObjectStreamCopier –.
Definition: objcopy.hpp:70
bool IsSeqAnnotChoiceSelected(TSeqAnnotChoiceMaskFlags flags)
bool Create(void) const
Create the directory using "dirname" passed in the constructor.
Definition: ncbifile.cpp:3927
static char GetPathSeparator(void)
Get path separator symbol specific for the current platform.
Definition: ncbifile.cpp:419
Defines NCBI C++ exception handling.
void ContextEnter(void)
void ContextEnd(void)
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
Definition: ncbiapp.cpp:492
X * release(void)
Release pointer.
Definition: ncbimisc.hpp:400
void SetStreamPos(CNcbiStreampos pos)
Set the current read position in underlying input stream This is the same as istream::seekg() ...
Definition: objistr.cpp:781
void DefaultSkip(CObjectIStream &in, const CObjectTypeInfo &type)
Default skip.
Definition: objhook.cpp:111
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:872
FILE * file
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
Definition: objistr.cpp:185
CObjectOStream & Out(void) const
void SetLocalSkipHook(CObjectIStream &stream, CSkipObjectHook *hook) const
Set local (for the specified stream) skip hook.
Definition: objectinfo.cpp:419
USING_SCOPE(ncbi)
CDir –.
Definition: ncbifile.hpp:1594
CMemberIterator FindMember(const string &memberName) const
Find class member by its name.
void ResetLocalHooks(void)
Definition: objistr.cpp:504
virtual string ReadFileHeader(void)
Read file header.
Definition: objistr.cpp:1093
Writing containers (SET OF, SEQUENCE OF).
Definition: objectio.hpp:232
void ProcessSeqEntryAnnot(auto_ptr< CObjectIStream > &sai, COStreamContainer &osc)
CHookSeq_entry__Copy__Seq_annot(auto_ptr< CObjectIStream > &sai)
void Copy(const CObjectTypeInfo &type)
Copy data.
Definition: objcopy.cpp:74
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
Definition: ncbiapp.cpp:185
void ContextLeave(void)
CArgDescriptions –.
Definition: ncbiargs.hpp:504
void SetLocalCopyHook(CObjectStreamCopier &stream, CCopyObjectHook *hook) const
Set local (for the specified stream) copy hook.
Definition: objectinfo.cpp:436
Magic spell ;-) needed for some weird compilers... very empiric.
void ContextInit(void)
An arbitrary string.
Definition: ncbiargs.hpp:553
Open file right away; for eInputFile, eOutputFile, eIOFile.
Definition: ncbiargs.hpp:579
virtual void Init(void)
Initialize the application.
CException –.
Definition: ncbiexpt.hpp:709
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
Definition: ncbiapp.hpp:649
void DefaultCopy(CObjectStreamCopier &copier, const CObjectTypeInfo &type)
Definition: objhook.cpp:210
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock, CFileIO, CFileReader, CFileWriter, CFileReaderWriter, CFileException.
CArgs –.
Definition: ncbiargs.hpp:355
virtual void SkipObject(CObjectIStream &in, const CObjectTypeInfo &passed_info)
auto_ptr< CObjectIStream > & m_sai
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
CObjectTypeInfo GetMemberType(void) const
Get data type information.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
int main(int argc, const char *argv[])
Reading (iterating through) elements of containers (SET OF, SEQUENCE OF).
Definition: objectio.hpp:163
static void s_PreprocessSeqEntry(auto_ptr< CObjectIStream > &sei)
CNcbiApplication –.
Definition: ncbiapp.hpp:120
void SetUsageContext(const string &usage_name, const string &usage_description, bool usage_sort_args=false, SIZE_TYPE usage_width=78)
Set extra info to be used by PrintUsage().
Definition: ncbiargs.cpp:3081
EContextType m_context
ESerialDataFormat GetFormat(const string &name)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string...
Definition: ncbiexpt.hpp:546
void AddOptionalKey(const string &name, const string &synopsis, const string &comment, EType type, TFlags flags=0)
Add description for optional key without default value.
Definition: ncbiargs.cpp:2224
void CurrentContextContainsSeqAnnots(void)
void SetSeqAnnotChoiceMask(const string &mask)
CSeqAnnotSplicerStats * g_Stats
std::istream & in(std::istream &in_, double &x_)
void Read(const CObjectInfo &object)
Read object of know type.
Definition: objistr.cpp:923
Copy hook for a standalone object.
Definition: objhook.hpp:242
void SetSeqIdChoiceMask(const string &mask)
void AddSeqIdToCurrentContext(TSeqRef id)
CArgAllow_Strings –.
Definition: ncbiargs.hpp:1543
virtual void SkipObject(CObjectIStream &in, const CObjectTypeInfo &passed_info)
Skip hook for a standalone object.
Definition: objhook.hpp:197
virtual void CopyObject(CObjectStreamCopier &copier, const CObjectTypeInfo &passed_info)
virtual void CopyClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
void SetConstraint(const string &name, CArgAllow *constraint, EConstraintNegate negate=eConstraint)
Set additional user defined constraint on argument value.
Definition: ncbiargs.cpp:2383
virtual bool Remove(TRemoveFlags flags=eRecursive) const
Delete existing directory.
Definition: ncbifile.cpp:4115
virtual void SkipObject(CObjectIStream &in, const CObjectTypeInfo &passed_info)
Modified on Thu Aug 27 15:30:03 2015 by modify_doxy.py rev. 426318