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

Go to the SVN repository for this file.

1 /* $Id: asn2asn.cpp 98273 2022-10-20 14:05:57Z gotvyans $
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: Eugene Vasilchenko
27 *
28 * File Description:
29 * asn2asn test program
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <common/ncbi_source_ver.h>
34 #include <corelib/ncbistd.hpp>
35 #include <corelib/ncbienv.hpp>
36 #include <corelib/ncbithr.hpp>
37 #include <corelib/ncbimempool.hpp>
41 #include <objects/seq/Seqdesc.hpp>
42 #include <objects/seq/MolInfo.hpp>
50 #include <objects/seq/Seq_inst.hpp>
52 #include <memory>
53 
55 
56 // CSEQ_ENTRY_REF_CHOICE macro to switch implementation of CSeq_entry choice
57 // as choice class or virtual base class.
58 // 0 -> generated choice class
59 // 1 -> virtual base class
60 #define CSEQ_ENTRY_REF_CHOICE 0
61 
62 #if CSEQ_ENTRY_REF_CHOICE
63 
64 template<typename T> const CTypeInfo* (*GetTypeRef(const T* object))(void);
65 template<typename T> pair<void*, const CTypeInfo*> ObjectInfo(T& object);
66 template<typename T> pair<const void*, const CTypeInfo*> ConstObjectInfo(const T& object);
67 
69 inline
70 const CTypeInfo* (*GetTypeRef< CRef<NCBI_NS_NCBI::objects::CSeq_entry> >(const CRef<NCBI_NS_NCBI::objects::CSeq_entry>* object))(void)
71 {
72  return &NCBI_NS_NCBI::objects::CSeq_entry::GetRefChoiceTypeInfo;
73 }
75 inline
76 pair<void*, const CTypeInfo*> ObjectInfo< CRef<NCBI_NS_NCBI::objects::CSeq_entry> >(CRef<NCBI_NS_NCBI::objects::CSeq_entry>& object)
77 {
78  return make_pair((void*)&object, GetTypeRef(&object)());
79 }
81 inline
82 pair<const void*, const CTypeInfo*> ConstObjectInfo< CRef<NCBI_NS_NCBI::objects::CSeq_entry> >(const CRef<NCBI_NS_NCBI::objects::CSeq_entry>& object)
83 {
84  return make_pair((const void*)&object, GetTypeRef(&object)());
85 }
86 
87 #endif
88 
90 
91 #include "asn2asn.hpp"
92 #include <corelib/ncbiutil.hpp>
93 #include <corelib/ncbiargs.hpp>
94 #include <objects/seq/Bioseq.hpp>
95 #include <serial/objectio.hpp>
96 #include <serial/objistr.hpp>
97 #include <serial/objostr.hpp>
98 #include <serial/objistrasnb.hpp>
99 #include <serial/objostrasnb.hpp>
100 #include <serial/objcopy.hpp>
101 #include <serial/serial.hpp>
102 #include <serial/objhook.hpp>
103 #include <serial/iterator.hpp>
104 
105 // The headers for PubSeqOS access.
108 #include <dbapi/driver/drivers.hpp>
109 #include <corelib/rwstream.hpp>
110 #include <util/compress/zlib.hpp>
111 
113 
114 using namespace NCBI_NS_NCBI::objects;
115 
116 #if CSEQ_ENTRY_REF_CHOICE
118 #else
120 #endif
121 
122 int main(int argc, char** argv)
123 {
124  return CAsn2Asn().AppMain(argc, argv, 0, eDS_Default, 0, "asn2asn");
125 }
126 
127 static
128 void SeqEntryProcess(CSeq_entry& entry); /* dummy function */
129 
130 #if CSEQ_ENTRY_REF_CHOICE
131 static
133 {
134  SeqEntryProcess(*entry);
135 }
136 #endif
137 
138 class CCounter
139 {
140 public:
141  CCounter(void)
142  : m_Counter(0)
143  {
144  }
145  ~CCounter(void)
146  {
147  _ASSERT(m_Counter == 0);
148  }
149 
150  operator int(void) const
151  {
152  return m_Counter;
153  }
154 private:
155  friend class CInc;
157 };
158 
159 class CInc
160 {
161 public:
162  CInc(CCounter& counter)
163  : m_Counter(counter)
164  {
165  ++counter.m_Counter;
166  }
167  ~CInc(void)
168  {
169  --m_Counter.m_Counter;
170  }
171 private:
173 };
174 
176 {
177 public:
178  void ReadClassMember(CObjectIStream& in,
179  const CObjectInfo::CMemberIterator& member);
180 
182 };
183 
185 {
186 public:
188  const CConstObjectInfo::CMemberIterator& member);
189 
191 };
192 
194 {
195 public:
196  void WriteObject(CObjectOStream& out, const CConstObjectInfo& object);
197 
199 };
200 
201 
203 {
204 public:
206  : m_Count(0)
207  {
208  }
209 
210  size_t GetCount() const { return m_Count; }
211 
212  virtual void ReadObject(CObjectIStream& in,
213  const CObjectInfo& info)
214  {
215  ++m_Count;
216  if ( m_Count % 1000 == 0 )
217  NcbiCout << "Bioseq "<<m_Count<<NcbiEndl;
218 
219  try {
220  ///
221  /// bioseq is in here
222  ///
223  CRef<CBioseq> bioseq(new CBioseq);
224  info.GetTypeInfo()->DefaultReadData(in, bioseq);
225  //in.ReadExternalObject(&*bioseq, CType<CBioseq>().GetTypeInfo());
226  in.SetDiscardCurrObject();
227 
228  ///
229  /// do some nifty formatting
230  ///
231  //Process(*bioseq);
232  }
233  catch (CException& e) {
234  ERR_POST(Error << "error processing bioseq: " << e.what());
235  }
236  }
237 
238 private:
239  size_t m_Count;
240 };
241 
242 
244 {
245 public:
247  const CObjectInfo::CMemberIterator& member)
248  {
249  in.SkipObject(member.GetMemberType().GetTypeInfo());
250  }
251 };
252 
253 
254 template<typename Member>
256 {
257 public:
258  typedef Member TObject;
260 
262  {
263  _ASSERT((*member).GetTypeInfo()->GetSize() == sizeof(object));
264  CObjectInfo info(&object, (*member).GetTypeInfo());
265  in.ReadObject(info);
266  NcbiCout << "Skipped class member: " <<
267  member.GetClassType().GetTypeInfo()->GetName() << '.' <<
268  member.GetMemberInfo()->GetId().GetName() << ": " <<
270  }
271 
272 private:
274 };
275 
276 template<typename Object>
278 {
279 public:
280  typedef Object TObject;
281 
282  CReadInSkipObjectHook() : object() {}
283 
284  int m_Dummy;
285 
287  {
288  _ASSERT(type.GetTypeInfo()->GetSize() == sizeof(object));
289  CObjectInfo info(&object, type.GetTypeInfo());
290  in.ReadObject(info);
291 
292  const CSeq_descr& descr = object;
293  string title;
294  string genome;
295  int subtype = 0;
296  string taxname;
297  string taxid;
298  int biomol = 0;
299  int complete = 0;
300  int tech = 0;
301 
302  NcbiCout << "Skipped object: " <<
303  type.GetTypeInfo()->GetName() << ": " <<
305  ITERATE(list< CRef< CSeqdesc > >,it,descr.Get()) {
306  CConstRef<CSeqdesc> desc = *it;
307  if (desc->IsTitle()) {
308  title = desc->GetTitle();
309  string lt = NStr::ToLower(title);
310  }
311  else if (desc->IsSource()) {
312  const CBioSource & source = desc->GetSource();
313  if (source.IsSetGenome())
314  genome = source.GetGenome();
315  if (source.IsSetSubtype()) {
316  ITERATE(list< CRef< CSubSource > >,it,source.GetSubtype()) {
317  string name = (*it)->GetName();
318  int st = (*it)->GetSubtype();
319  if (st == 19) subtype = st;
320  }
321  }
322  if (source.IsSetOrg()) {
323  const COrg_ref & orgref= source.GetOrg();
324  taxname = orgref.GetTaxname();
325  ITERATE(vector< CRef< CDbtag > > ,it,orgref.GetDb()) {
326  if (CDbtag::eDbtagType_taxon == (*it)->GetType()) {
327  taxid = (*it)->GetTag().GetId();
328  break;
329  }
330  }
331  }
332  }
333  else if (desc->IsMolinfo()) {
334  const CMolInfo & molinfo = desc->GetMolinfo();
335  if (molinfo.IsSetBiomol())
336  biomol = molinfo.GetBiomol();
337  if (molinfo.IsSetCompleteness())
338  complete = molinfo.GetCompleteness();
339  if (molinfo.IsSetTech())
340  tech = molinfo.GetTech();
341  }
342  }
343  m_Dummy += subtype+biomol+complete+tech;
344  }
345 
346 private:
348 };
349 
350 
352 {
354 }
355 
356 /*****************************************************************************
357 *
358 * Main program loop to read, process, write SeqEntrys
359 *
360 *****************************************************************************/
361 void CAsn2Asn::Init(void)
362 {
363  unique_ptr<CArgDescriptions> d(new CArgDescriptions);
364 
365  d->SetUsageContext("asn2asn", "convert Seq-entry or Bioseq-set data");
366 
367  d->AddKey("i", "inputFile",
368  "input data file",
370  d->AddOptionalKey("o", "outputFile",
371  "output data file",
373  d->AddFlag("e",
374  "treat data as Seq-entry");
375  d->AddFlag("sub",
376  "treat data as Seq-submit");
377  d->SetDependency("e", CArgDescriptions::eExcludes, "sub");
378  d->AddFlag("b",
379  "binary ASN.1 input format");
380  d->AddFlag("X",
381  "XML input format");
382  d->AddFlag("s",
383  "binary ASN.1 output format");
384  d->AddFlag("x",
385  "XML output format");
386  d->AddFlag("C",
387  "Convert data without reading in memory");
388  d->AddFlag("S",
389  "Skip data without reading in memory");
390  d->AddOptionalKey("Mgi", "MergeAnnotGi",
391  "Merge Seq-annot to GI",
393  d->AddOptionalKey("Min", "MergeAnnotInput",
394  "Binary ASN.1 Seq-entry file with Seq-annot for merging",
396  d->AddOptionalKey("Mext", "MergeAnnotExternal",
397  "Merge external annotation from PubSeqOS",
399  d->AddFlag("P",
400  "Use memory pool for deserialization");
401  d->AddOptionalKey("l", "logFile",
402  "log errors to <logFile>",
404  d->AddDefaultKey("c", "count",
405  "perform command <count> times",
407  d->AddDefaultKey("tc", "threadCount",
408  "perform command in <threadCount> thread",
410  d->AddFlag("m",
411  "Input file contains multiple objects");
412 
413  d->AddFlag("ih",
414  "Use read hooks");
415  d->AddFlag("oh",
416  "Use write hooks");
417 
418  d->AddFlag("q",
419  "Quiet execution");
420 
421  SetupArgDescriptions(d.release());
422 }
423 
424 class CAsn2AsnThread : public CThread
425 {
426 public:
427  CAsn2AsnThread(int index, CAsn2Asn* asn2asn)
428  : m_Index(index), m_Asn2Asn(asn2asn), m_DoneOk(false)
429  {
430  }
431 
432  void* Main()
433  {
434  string suffix = '.'+NStr::IntToString(m_Index);
435  try {
436  m_Asn2Asn->RunAsn2Asn(suffix);
437  }
438  catch (exception& e) {
439  CNcbiDiag() << Error << "[asn2asn thread " << m_Index << "]" <<
440  "Exception: " << e.what();
441  return 0;
442  }
443  m_DoneOk = true;
444  return 0;
445  }
446 
447  bool DoneOk() const
448  {
449  return m_DoneOk;
450  }
451 
452 private:
453  int m_Index;
455  bool m_DoneOk;
456 };
457 
458 int CAsn2Asn::Run(void)
459 {
461 
462  const CArgs& args = GetArgs();
463 
464  if ( const CArgValue& l = args["l"] )
465  SetDiagStream(&l.AsOutputFile());
466 
467 
468  int threadCount = args["tc"].AsInteger();
469  vector< CRef<CAsn2AsnThread> > threads(threadCount);
470  for ( int i = 1; i < threadCount; ++i ) {
471  threads[i] = new CAsn2AsnThread(i, this);
472  threads[i]->Run();
473  }
474 
475  try {
476  RunAsn2Asn("");
477  }
478  catch (exception& e) {
479  CNcbiDiag() << Error << "[asn2asn]" << "Exception: " << e.what();
480  return 1;
481  }
482 
483  for ( int i = 1; i < threadCount; ++i ) {
484  threads[i]->Join();
485  if ( !threads[i]->DoneOk() ) {
486  NcbiCerr << "Error in thread: " << i << NcbiEndl;
487  return 1;
488  }
489  }
490 
491  return 0;
492 }
493 
494 /////////////////////////////////////////////////////////////////////////////
495 // Seq-annot merging code
496 /////////////////////////////////////////////////////////////////////////////
497 
498 // All the code is enclosed into namespace merge_annot to avoid conflicts.
499 BEGIN_SCOPE(merge_annot)
500 
501 // This class contains all necessary information for various hooks.
503 {
504 public:
506  : target_gi(target_gi), do_insert(false), annot(annot), annot_in(0) {
507  }
508  CInsertAnnotManager(TGi target_gi, CObjectIStream& annot_in)
509  : target_gi(target_gi), do_insert(false), annot_in(&annot_in) {
510  }
511 
512  // Returns true if there is any annot to insert.
513  bool HasAnnot(void) const {
514  return annot || annot_in;
515  }
516 
517  // Returns true if current sequence is to be copied without modification.
518  bool SkipInsert(void) const {
519  return !do_insert;
520  }
521 
522  // Marks current annot as inserted.
523  void InsertDone(void) {
524  annot = null;
525  annot_in = 0;
526  }
527 
528  // Notifies manager about Seq-id of the current sequence.
529  void AddId(const CSeq_id& id) {
530  if ( id.IsGi() && id.GetGi() == target_gi && HasAnnot() ) {
531  do_insert = true;
532  }
533  }
534 
535  TGi target_gi; // GI of the sequence to insert annots in.
536  bool do_insert; // Flag is true if currently sequence is the target.
537  CConstRef<CSeq_annot> annot; // Explicit annot object to insert.
538  CObjectIStream* annot_in; // Input object stream source of annot to insert.
539 };
540 
541 // This hook is used to determine if current sequence is the target.
542 // It should be set on Bioseq.id field which is SEQUENCE OF Seq-id.
544 {
545 public:
548  : manager(manager) {
549  }
551  const CObjectTypeInfoMI& member) {
552  // When the Bioseq.id field is found we copy Seq-ids one by one
553  // and notify the manager about them.
554 
555  // Temporary Seq-id object.
556  CSeq_id id;
557 
558  // Open object output iterator.
559  COStreamContainer out(copier.Out(), member);
560 
561  // Scan by object input iterator.
562  for ( CIStreamContainerIterator in(copier.In(), member); in; ++in ) {
563  in >> id; // read next Seq-id
564  manager.AddId(id); // register it
565  out << id; // write it into output
566  }
567  }
568 };
569 
570 // This hook is used to extract Seq-annot from the external annot input stream
571 // and copy it into main output.
572 // It should be set on Seq-annot object.
573 // The external annot input stream is 'skipped', and when a Seq-annot type
574 // is detected we copy it into main output instead of skipping.
576 {
577 public:
578  CObjectStreamCopier& copier; // Object copier to use.
579  COStreamContainer& out; // Output stream object iterator to use.
582  : copier(copier), out(out) {
583  }
584 
586  const CObjectTypeInfo& type) {
587  // Just copy the Seq-annot.
588  out.WriteElement(copier, in);
589  }
590 };
591 
592 // This hook is used for main merging operation.
593 // It should be set on Bioseq.annot field which is SEQUENCE OF Seq-annot.
594 // It will first copy all existing Seq-annots if any,
595 // and then insert Seq-annots from external source.
597 {
598 public:
601  : manager(manager) {
602  }
603  // Inserts Seq-annot from external source.
606  if ( manager.annot ) {
607  // If there is an explicit Seq-annot object, just write it.
608  out << *manager.annot;
609  }
610  else {
611  // Otherwise, prepare the copier, setup necessary hook
612  // for insertion, and the invoke 'skip' operation on
613  // external object source.
614  // The hook will itercept Seq-annot object in the skipped data
615  // and copy it into the main output instead of skipping.
616  CObjectIStream& in = *manager.annot_in;
617  CObjectStreamCopier copier2(in, copier.Out());
619  (*new CInsertAnnotHookCopy(copier2, out), &in);
620  in.Skip(CType<CSeq_entry>());
621  }
622  // Notify the manager that the Seq-annot was inserted
623  // to avoid duplication.
624  manager.InsertDone();
625  }
626 
627  // This hook method is called by the serialization library when the field
628  // is copied.
629  // We'll copy all existing annots, and append extra from external source.
631  const CObjectTypeInfoMI& member) {
632  if ( manager.SkipInsert() ) {
633  // If no work to be done, just invoke default method.
634  DefaultCopy(copier, member);
635  return;
636  }
637 
638  // Open output object iterator.
639  COStreamContainer out(copier.Out(), member);
640  // Scan input object iterator with copying.
641  for ( CIStreamContainerIterator in(copier.In(), member); in; ++in ) {
642  out.WriteElement(copier, in);
643  }
644  // Insert external annots.
645  InsertAnnot(copier, out);
646  }
647 
648  // This hook method is called by the serialization library when the field
649  // is missing in input stream.
650  // We'll create the field in the output stream and copy external annots.
652  const CObjectTypeInfoMI& member) {
653  if ( manager.SkipInsert() ) {
654  // If no work to be done, just do nothing.
655  return;
656  }
657 
658  // Open output object iterator.
659  COStreamContainer out(copier.Out(), member);
660  // Insert external annots.
661  InsertAnnot(copier, out);
662  }
663 };
664 
665 // Main API function for merging.
666 // CObjectIStream& in - object stream of main input with Seq-entry.
667 // CObjectOStream& out - object stream of main output for modified Seq-entry.
668 // int gi - GI of target sequence.
669 // CObjectIStream& annot_in - external object stream input with Seq-entry
671  CObjectIStream& annot_in)
672 {
673  // Merge manager.
674  CInsertAnnotManager manager(gi, annot_in);
675  // Main object copier.
676  CObjectStreamCopier copier(in, out);
677  // Setup hook on Bioseq.id to detect target sequence.
678  CObjectHookGuard<CBioseq> guard1("id",
679  *new CInsertAnnotHookId(manager),
680  &copier);
681  // Setup hook on Bioseq.annot for Seq-annot insertion.
682  CObjectHookGuard<CBioseq> guard2("annot",
683  *new CInsertAnnotHookAnnot(manager),
684  &copier);
685  // These options will speed up strings processing a bit.
686  // The methods aren't declared in CObjectIStream, so we have to cast.
687  if ( CObjectIStreamAsnBinary* bin_in =
688  dynamic_cast<CObjectIStreamAsnBinary*>(&annot_in) ) {
689  bin_in->FixNonPrint(eFNP_Allow);
690  }
691  if ( CObjectIStreamAsnBinary* bin_in =
692  dynamic_cast<CObjectIStreamAsnBinary*>(&copier.In()) ) {
693  bin_in->FixNonPrint(eFNP_Allow);
694  }
695  if ( CObjectOStreamAsnBinary* bin_out =
696  dynamic_cast<CObjectOStreamAsnBinary*>(&copier.Out()) ) {
697  bin_out->FixNonPrint(eFNP_Allow);
698  }
699 
700  // Do the copy.
701  copier.Copy(CType<CSeq_entry>());
702 }
703 
704 // Merging function with external annot source from file.
705 // CObjectIStream& in - object stream of main input with Seq-entry.
706 // CObjectOStream& out - object stream of main output for modified Seq-entry.
707 // int gi - GI of target sequence.
708 // const string& in_file - the name of file with ANS.1 binary Seq-entry.
710  const string& in_file)
711 {
712  unique_ptr<CObjectIStream> annot_in(CObjectIStream::Open(eSerial_AsnBinary,
713  in_file));
714  MergeAnnot(in, out, gi, *annot_in);
715 }
716 
717 BEGIN_SCOPE(PubSeqOS)
718 
719 // Utility class for reading data from CDB_Result with blob data from PubSeqOS.
720 class CDB_Result_Reader : public IReader
721 {
722 public:
724  : m_DB_Result(db_result) {
725  }
726 
728  size_t count,
729  size_t* bytes_read) {
730  if ( !count ) {
731  if ( bytes_read ) {
732  *bytes_read = 0;
733  }
734  return eRW_Success;
735  }
736  size_t ret;
737  while ( (ret = m_DB_Result->ReadItem(buf, count)) == 0 ) {
738  if ( !m_DB_Result->Fetch() )
739  break;
740  }
741  if ( bytes_read ) {
742  *bytes_read = ret;
743  }
744  return ret? eRW_Success: eRW_Eof;
745  }
746  ERW_Result PendingCount(size_t* /*count*/) {
747  return eRW_NotImplemented;
748  }
749 
750 private:
752 };
753 
754 END_SCOPE(PubSeqOS)
755 
756 // Merging function with external annot to be read from PubSeqOS.
757 // CObjectIStream& in - object stream of main input with Seq-entry.
758 // CObjectOStream& out - object stream of main output for modified Seq-entry.
759 // int gi - GI of target sequence.
760 // int add_ext_feat - bit mask of external annots to be read from PubSeqOS.
762  int add_ext_feat)
763 {
765 
766  // Prepare PubSeqOS connection.
767  C_DriverMgr drvMgr;
768  map<string,string> args;
769  args["packet"]="3584"; // 7*512
770  args["version"]="125"; // for correct connection to OpenServer
771  string err;
772  unique_ptr<I_DriverContext> context(drvMgr.GetDriverContext("ftds", &err, &args));
773 
775  (context->Connect("PUBSEQ_OS_PUBLIC_GI64", "anyone", "allowed", 0));
776  if ( 1 ) {
777  // I'm not sure what this option does...
778  AutoPtr<CDB_LangCmd> cmd(conn->LangCmd("set blob_stream on"));
779  cmd->Send();
780  }
781  if ( 1 ) {
782  // Allow the PubSeqOS server to send gzipped data.
783  AutoPtr<CDB_LangCmd> cmd(conn->LangCmd("set accept gzip"));
784  cmd->Send();
785  }
786 
787  // Request the external annotations blob.
788  AutoPtr<CDB_RPCCmd> cmd(conn->RPC("id_get_asn"));
789  // external annotations sat is 26 (all except CDD).
790  int sat = add_ext_feat == 8? 10: 26;
791  CDB_SmallInt satIn(sat);
792  CDB_BigInt satKeyIn(GI_TO(TIntId, gi)); // sat_key is equal to GI.
793  CDB_Int ext_feat(add_ext_feat); // ext_feat mask.
794 
795  cmd->SetParam("@gi", &satKeyIn);
796  cmd->SetParam("@sat", &satIn);
797  cmd->SetParam("@ext_feat", &ext_feat);
798  cmd->Send();
799 
800  AutoPtr<CDB_Result> result; // The result with external annotations blob.
801  int zip_type = 0; // Compression of the blob.
802 
803  // Wait for result with external annotations blob.
804  while( !result && cmd->HasMoreResults() ) {
805  if ( cmd->HasFailed() ) {
806  break;
807  }
808 
809  AutoPtr<CDB_Result> dbr(cmd->Result());
810  if ( !dbr.get() || dbr->ResultType() != eDB_RowResult ) {
811  continue;
812  }
813 
814  while ( !result && dbr->Fetch() ) {
815  for ( unsigned pos = 0; pos < dbr->NofItems(); ++pos ) {
816  const string& name = dbr->ItemName(pos);
817  if ( name == "zip_type" ) {
818  // zip_type column contains compression type.
819  CDB_Int v;
820  dbr->GetItem(&v);
821  zip_type = v.Value();
822  }
823  else if ( name == "asn1" ) {
824  // asn1 column contains the blob data.
825  result = dbr;
826  break;
827  }
828  else {
829  // We are not interested in all other columns.
830  dbr->SkipItem();
831  }
832  }
833  }
834  }
835 
836  // Here the error check should be done if there is no result...
837  if ( !result.get() ) {
838  ERR_POST("No external annot found.");
839  // Main object copier.
840  CObjectStreamCopier copier(in, out);
841  // Do the copy.
842  copier.Copy(CType<CSeq_entry>());
843  return;
844  }
845 
846  // Setup CByteSourceReader for reading data from CDB_Result.
847  PubSeqOS::CDB_Result_Reader reader(result.get());
848  // Setup input stream.
849  CRStream stream(&reader);
850 
851  if ( zip_type & 2 ) { // gzip
852  // If there is a compression we add an extra piped stream
853  // for uncompressed data.
854  CZipStreamDecompressor decompressor;
855  CCompressionIStream unzip(stream, &decompressor);
856  // Open object stream for external annotations.
857  unique_ptr<CObjectIStream> annot_in
859  // Do the merging.
860  MergeAnnot(in, out, gi, *annot_in);
861  }
862  else {
863  // Open object stream for external annotations.
864  unique_ptr<CObjectIStream> annot_in
866  // Do the merging.
867  MergeAnnot(in, out, gi, *annot_in);
868  }
869 }
870 
871 END_SCOPE(merge_annot)
872 
873 /////////////////////////////////////////////////////////////////////////////
874 // End of Seq-annot merging code
875 /////////////////////////////////////////////////////////////////////////////
876 
877 
879 
880 void CAsn2Asn::RunAsn2Asn(const string& outFileSuffix)
881 {
882  CFastMutexGuard GUARD(s_ArgsMutex);
883 
884  const CArgs& args = GetArgs();
885 
886  string inFile = args["i"].AsString();
888  if ( args["b"] )
889  inFormat = eSerial_AsnBinary;
890  else if ( args["X"] )
891  inFormat = eSerial_Xml;
892 
893  const CArgValue& o = args["o"];
894  bool haveOutput = o;
895  string outFile;
897  if ( haveOutput ) {
898  outFile = o.AsString();
899  if ( args["s"] )
900  outFormat = eSerial_AsnBinary;
901  else if ( args["x"] )
902  outFormat = eSerial_Xml;
903  }
904  outFile += outFileSuffix;
905 
906  enum EDataType {
907  eDataType_BioseqSet, // the default
908  eDataType_SeqEntry,
909  eDataType_SeqSubmit
910  };
911  EDataType eDataType = eDataType_BioseqSet;
912  if( args["e"] ) {
913  eDataType = eDataType_SeqEntry;
914  } else if( args["sub"] ) {
915  eDataType = eDataType_SeqSubmit;
916  }
917  bool skip = args["S"];
918  bool convert = args["C"];
919  bool merge = args["Mgi"] && (args["Min"] || args["Mext"]);
920  if ( args["Mext"] ) {
921  int ext = args["Mext"].AsInteger();
922  if ( ext == 0 || (ext & (ext-1)) != 0 ) {
923  ERR_FATAL("Only single external annotation bit is allowed.");
924  }
925  }
926  bool readHook = args["ih"];
927  bool writeHook = args["oh"];
928  bool usePool = args["P"];
929 
930  bool quiet = args["q"];
931  bool multi = args["m"];
932 
933  size_t count = args["c"].AsInteger();
934 
935  GUARD.Release();
936 
937  for ( size_t i = 1; i <= count; ++i ) {
938  bool displayMessages = count != 1 && !quiet;
939  if ( displayMessages )
940  NcbiCerr << "Step " << i << ':' << NcbiEndl;
941  unique_ptr<CObjectIStream> in(CObjectIStream::Open(inFormat, inFile,
943  if ( usePool ) {
944  in->UseMemoryPool();
945  }
946  unique_ptr<CObjectOStream> out(!haveOutput? 0:
947  CObjectOStream::Open(outFormat, outFile,
949 
950  for ( ;; ) {
951  /* read one Seq-entry or Seq-submit */
952  if ( eDataType == eDataType_SeqEntry ||
953  eDataType == eDataType_SeqSubmit )
954  {
955  const CObjectTypeInfo objectTypeInfo = (
956  eDataType == eDataType_SeqEntry ?
957  CType<CSeq_entry>().operator ncbi::CObjectTypeInfo() :
958  CType<CSeq_submit>().operator ncbi::CObjectTypeInfo() );
959  if ( skip ) {
960  if ( displayMessages )
961  NcbiCerr << "Skipping " << objectTypeInfo.GetName() << "..." << NcbiEndl;
962  if ( readHook ) {
963  {{
965  type.SetLocalSkipHook
967  }}
968  {{
970  type.FindMember("class").SetLocalSkipHook
972  }}
973  {{
975  type.FindMember("topology").SetLocalSkipHook
977  }}
978  in->Skip(objectTypeInfo);
979  }
980  else {
981  in->Skip(objectTypeInfo);
982  }
983  }
984  else if ( convert && haveOutput ) {
985  if ( displayMessages )
986  NcbiCerr << "Copying " << objectTypeInfo.GetName() << "..." << NcbiEndl;
987 
988  CObjectStreamCopier copier(*in, *out);
989  copier.Copy(CType<CSeq_entry>());
990  }
991  else if ( eDataType == eDataType_SeqEntry &&
992  merge && haveOutput )
993  {
994  if ( displayMessages )
995  NcbiCerr << "Merging Seq-annot..." << NcbiEndl;
996 
997  if ( args["Min"] ) {
998  merge_annot::MergeFromFile(*in, *out, GI_FROM(TIntId, args["Mgi"].AsIntId()),
999  args["Min"].AsString());
1000  }
1001  else {
1002  merge_annot::MergeExternal(*in, *out, GI_FROM(TIntId, args["Mgi"].AsIntId()),
1003  args["Mext"].AsInteger());
1004  }
1005  }
1006  else {
1007  CRef<CSerialObject> pObjectFromIn;
1008  //entry.DoNotDeleteThisObject();
1009  if ( displayMessages )
1010  NcbiCerr << "Reading " << objectTypeInfo.GetName() << "..." << NcbiEndl;
1011 
1012  // read in the CSerialObject, then
1013  // extract the Seq-entry inside there for processing
1014  CRef<CSeq_entry> pInnerSeqEntry;
1015  if( eDataType == eDataType_SeqEntry ) {
1016  CRef<CSeq_entry> pEntry( new CSeq_entry );
1017  *in >> *pEntry;
1018  pObjectFromIn = pEntry;
1019  // input *is* a seq-entry, so no digging necessary
1020  pInnerSeqEntry = static_cast<CSeq_entry*>(pObjectFromIn.GetPointer());
1021  } else {
1022  CRef<CSeq_submit> pSeqSubmit( new CSeq_submit );
1023  *in >> *pSeqSubmit;
1024  pObjectFromIn = pSeqSubmit;
1025  // get the one Seq-entry from the Seq-submit
1026  if( pSeqSubmit->GetData().GetEntrys().size() == 1 ) {
1027  pInnerSeqEntry = pSeqSubmit->GetData().GetEntrys().front();
1028  }
1029  }
1030 
1031  /* do any processing */
1032  if( pInnerSeqEntry ) {
1033  SeqEntryProcess(*pInnerSeqEntry);
1034  }
1035 
1036  if ( haveOutput ) {
1037  if ( displayMessages )
1038  NcbiCerr << "Writing " << objectTypeInfo.GetName() << "..." << NcbiEndl;
1039  *out << *pObjectFromIn;
1040  }
1041  }
1042  }
1043  else { /* read Seq-entry's from a Bioseq-set */
1044  if ( skip ) {
1045  if ( displayMessages )
1046  NcbiCerr << "Skipping Bioseq-set..." << NcbiEndl;
1047  in->Skip(CType<CBioseq_set>());
1048  }
1049  else if ( convert && haveOutput ) {
1050  if ( displayMessages )
1051  NcbiCerr << "Copying Bioseq-set..." << NcbiEndl;
1052  CObjectStreamCopier copier(*in, *out);
1053  copier.Copy(CType<CBioseq_set>());
1054  }
1055  else {
1057  //entries.DoNotDeleteThisObject();
1058  if ( displayMessages )
1059  NcbiCerr << "Reading Bioseq-set..." << NcbiEndl;
1060 
1061  if ( readHook ) {
1062  CObjectTypeInfo bioseqSetType = CType<CBioseq_set>();
1063  bioseqSetType.FindMember("seq-set")
1065  *in >> *entries;
1066  }
1067  else {
1068  *in >> *entries;
1069 
1071  entries->SetSeq_set() ) {
1072  SeqEntryProcess(**seqi); /* do any processing */
1073  }
1074  }
1075  if ( haveOutput ) {
1076  if ( displayMessages )
1077  NcbiCerr << "Writing Bioseq-set..." << NcbiEndl;
1078  if ( writeHook ) {
1079 #if 0
1080  CObjectTypeInfo bioseqSetType = CType<CBioseq_set>();
1081  bioseqSetType.FindMember("seq-set")
1083 #else
1084  CObjectTypeInfo seqEntryType = CType<CSeq_entry>();
1085  seqEntryType
1087 #endif
1088  *out << *entries;
1089  }
1090  else {
1091  *out << *entries;
1092  }
1093  }
1094  }
1095  }
1096  if ( !multi || in->EndOfData() )
1097  break;
1098  }
1099  }
1100 }
1101 
1102 
1103 /*****************************************************************************
1104 *
1105 * void SeqEntryProcess (sep)
1106 * just a dummy routine that does nothing
1107 *
1108 *****************************************************************************/
1109 static
1110 void SeqEntryProcess(CSeq_entry& /* seqEntry */)
1111 {
1112 }
1113 
1115  const CObjectInfo::CMemberIterator& member)
1116 {
1117  CInc inc(m_Level);
1118  if ( m_Level == 1 ) {
1119  // (do not have to read member open/close tag, it's done by this time)
1120 
1121  // Read each element separately to a local TSeqEntry,
1122  // process it somehow, and... not store it in the container.
1123  for ( CIStreamContainerIterator i(in, member); i; ++i ) {
1124  TSeqEntry entry;
1125  //entry.DoNotDeleteThisObject();
1126  i >> entry;
1127  SeqEntryProcess(entry);
1128  }
1129 
1130  // MemberIterators are DANGEROUS! -- do not use the following
1131  // unless...
1132 
1133  // The same trick can be done with CIStreamClassMember -- to traverse
1134  // through the class members rather than container elements.
1135  // CObjectInfo object = member;
1136  // for ( CIStreamClassMemberIterator i(in, object); i; ++i ) {
1137  // // CObjectTypeInfo::CMemberIterator nextMember = *i;
1138  // in.ReadObject(object.GetMember(*i));
1139  // }
1140  }
1141  else {
1142  // standard read
1143  in.ReadClassMember(member);
1144  }
1145 }
1146 
1148  const CConstObjectInfo& object)
1149 {
1150  CInc inc(m_Level);
1151  if ( m_Level == 1 ) {
1152  NcbiCerr << "entry" << NcbiEndl;
1153  // const CSeq_entry& entry = *CType<CSeq_entry>::Get(object);
1154  object.GetTypeInfo()->DefaultWriteData(out, object.GetObjectPtr());
1155  }
1156  else {
1157  // const CSeq_entry& entry = *CType<CSeq_entry>::Get(object);
1158  object.GetTypeInfo()->DefaultWriteData(out, object.GetObjectPtr());
1159  }
1160 }
1161 
1163  const CConstObjectInfo::CMemberIterator& member)
1164 {
1165  // keep track of the level of write recursion
1166  CInc inc(m_Level);
1167 
1168  // just for fun -- do the hook only on the first level of write recursion,
1169  if ( m_Level == 1 ) {
1170  // provide opening and closing(automagic, in destr) tags for the member
1171  COStreamClassMember m(out, member);
1172 
1173  // out.WriteObject(*member); or, with just the same effect:
1174 
1175  // provide opening and closing(automagic) tags for the container
1176  COStreamContainer o(out, member);
1177 
1178  typedef CBioseq_set::TSeq_set TSeq_set;
1179  // const TSeq_set& cnt = *CType<TSeq_set>::Get(*member);
1180  // but as soon as we know for sure that it *is* TSeq_set, so:
1181  const TSeq_set& cnt = *CType<TSeq_set>::GetUnchecked(*member);
1182 
1183  // write elem-by-elem
1184  for ( TSeq_set::const_iterator i = cnt.begin(); i != cnt.end(); ++i ) {
1185  const TSeqEntry& entry = **i;
1186  // COStreamContainer is smart enough to automagically put
1187  // open/close tags for each element written
1188  o << entry;
1189 
1190  // here, we could e.g. write each elem twice:
1191  // o << entry; o << entry;
1192  // we cannot change the element content as everything is const in
1193  // the write hooks.
1194  }
1195  }
1196  else {
1197  // on all other levels -- use standard write func for this member
1198  out.WriteClassMember(member);
1199  }
1200 }
User-defined methods of the data storage class.
void MergeExternal(CObjectIStream &in, CObjectOStream &out, TGi gi, int add_ext_feat)
Definition: asn2asn.cpp:761
static void SeqEntryProcess(CSeq_entry &entry)
Definition: asn2asn.cpp:1110
void MergeFromFile(CObjectIStream &in, CObjectOStream &out, TGi gi, const string &in_file)
Definition: asn2asn.cpp:709
DEFINE_STATIC_FAST_MUTEX(s_ArgsMutex)
CSeq_entry TSeqEntry
Definition: asn2asn.cpp:119
int main(int argc, char **argv)
Definition: asn2asn.cpp:122
USING_NCBI_SCOPE
Definition: asn2asn.cpp:112
void MergeAnnot(CObjectIStream &in, CObjectOStream &out, TGi gi, CObjectIStream &annot_in)
Definition: asn2asn.cpp:670
CArgDescriptions –.
Definition: ncbiargs.hpp:541
CArgValue –.
Definition: ncbiargs.hpp:184
CArgs –.
Definition: ncbiargs.hpp:379
bool DoneOk() const
Definition: asn2asn.cpp:447
CAsn2Asn * m_Asn2Asn
Definition: asn2asn.cpp:454
void * Main()
Derived (user-created) class must provide a real thread function.
Definition: asn2asn.cpp:432
CAsn2AsnThread(int index, CAsn2Asn *asn2asn)
Definition: asn2asn.cpp:427
int Run(void)
Run the application.
Definition: asn2asn.cpp:458
void Init(void)
Initialize the application.
Definition: asn2asn.cpp:361
CAsn2Asn()
Definition: asn2asn.cpp:351
CConstObjectInfoMI –.
Definition: objectiter.hpp:397
CConstObjectInfo –.
Definition: objectinfo.hpp:421
Copy hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:266
~CCounter(void)
Definition: asn2asn.cpp:145
CCounter(void)
Definition: asn2asn.cpp:141
int m_Counter
Definition: asn2asn.cpp:156
ERW_Result PendingCount(size_t *)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
Definition: asn2asn.cpp:746
ERW_Result Read(void *buf, size_t count, size_t *bytes_read)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
Definition: asn2asn.cpp:727
CDB_Result * m_DB_Result
Definition: asn2asn.cpp:751
CDB_Result_Reader(CDB_Result *db_result)
Definition: asn2asn.cpp:723
@ eDbtagType_taxon
Definition: Dbtag.hpp:190
size_t GetCount() const
Definition: asn2asn.cpp:210
virtual void ReadObject(CObjectIStream &in, const CObjectInfo &info)
This method will be called at approriate time when the object of requested type is to be read.
Definition: asn2asn.cpp:212
size_t m_Count
Definition: asn2asn.cpp:239
void Release()
Manually force the resource to be released.
Definition: guard.hpp:166
Reading (iterating through) elements of containers (SET OF, SEQUENCE OF).
Definition: objectio.hpp:164
CInc(CCounter &counter)
Definition: asn2asn.cpp:162
~CInc(void)
Definition: asn2asn.cpp:167
CCounter & m_Counter
Definition: asn2asn.cpp:172
CInsertAnnotHookAnnot(CInsertAnnotManager &manager)
Definition: asn2asn.cpp:600
CInsertAnnotManager & manager
Definition: asn2asn.cpp:599
void CopyClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
Definition: asn2asn.cpp:630
void CopyMissingClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
Definition: asn2asn.cpp:651
void InsertAnnot(CObjectStreamCopier &copier, COStreamContainer &out)
Definition: asn2asn.cpp:604
CInsertAnnotHookCopy(CObjectStreamCopier &copier, COStreamContainer &out)
Definition: asn2asn.cpp:580
CObjectStreamCopier & copier
Definition: asn2asn.cpp:578
COStreamContainer & out
Definition: asn2asn.cpp:579
void SkipObject(CObjectIStream &in, const CObjectTypeInfo &type)
Definition: asn2asn.cpp:585
CInsertAnnotHookId(CInsertAnnotManager &manager)
Definition: asn2asn.cpp:547
void CopyClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
Definition: asn2asn.cpp:550
CInsertAnnotManager & manager
Definition: asn2asn.cpp:546
bool HasAnnot(void) const
Definition: asn2asn.cpp:513
CConstRef< CSeq_annot > annot
Definition: asn2asn.cpp:537
void AddId(const CSeq_id &id)
Definition: asn2asn.cpp:529
CInsertAnnotManager(TGi target_gi, CConstRef< CSeq_annot > annot)
Definition: asn2asn.cpp:505
CInsertAnnotManager(TGi target_gi, CObjectIStream &annot_in)
Definition: asn2asn.cpp:508
bool SkipInsert(void) const
Definition: asn2asn.cpp:518
CObjectIStream * annot_in
Definition: asn2asn.cpp:538
void InsertDone(void)
Definition: asn2asn.cpp:523
CNcbiDiag –.
Definition: ncbidiag.hpp:924
Writing class members.
Definition: objectio.hpp:101
Writing containers (SET OF, SEQUENCE OF).
Definition: objectio.hpp:237
Helper class: installs hooks in constructor, and uninstalls in destructor.
Definition: objhook.hpp:397
CObjectIStreamAsnBinary –.
Definition: objistrasnb.hpp:59
CObjectIStream –.
Definition: objistr.hpp:93
CObjectInfoMI –.
Definition: objectiter.hpp:432
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectOStreamAsnBinary –.
Definition: objostrasnb.hpp:58
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
CObjectTypeInfoMI –.
Definition: objectiter.hpp:246
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
Note about the "buf_size" parameter for streams in this API.
Definition: rwstream.hpp:122
Read hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:78
void SkipClassMember(CObjectIStream &in, const CObjectTypeInfoMI &member)
Definition: asn2asn.cpp:261
void SkipObject(CObjectIStream &in, const CObjectTypeInfo &type)
Definition: asn2asn.cpp:286
Read hook for a standalone object.
Definition: objhook.hpp:59
CCounter m_Level
Definition: asn2asn.cpp:181
void ReadClassMember(CObjectIStream &in, const CObjectInfo::CMemberIterator &member)
This method will be called at approriate time when the object of requested type is to be read.
Definition: asn2asn.cpp:1114
CRef –.
Definition: ncbiobj.hpp:618
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
Definition: Seq_entry.hpp:56
Skip hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:223
Skip hook for a standalone object.
Definition: objhook.hpp:205
virtual void ReadClassMember(CObjectIStream &in, const CObjectInfo::CMemberIterator &member)
This method will be called at approriate time when the object of requested type is to be read.
Definition: asn2asn.cpp:246
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
CVersionInfo –.
Write hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:175
Write hook for a standalone object.
Definition: objhook.hpp:161
CCounter m_Level
Definition: asn2asn.cpp:198
void WriteObject(CObjectOStream &out, const CConstObjectInfo &object)
This method will be called at approriate time when the object of requested type is to be written.
Definition: asn2asn.cpp:1147
CCounter m_Level
Definition: asn2asn.cpp:190
void WriteClassMember(CObjectOStream &out, const CConstObjectInfo::CMemberIterator &member)
Definition: asn2asn.cpp:1162
CZipStreamDecompressor – zlib based decompression stream processor.
Definition: zlib.hpp:817
A very basic data-read interface.
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define T(s)
Definition: common.h:230
std::ofstream out("events_result.xml")
main entry point for tests
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
#define false
Definition: bool.h:36
static TDSRET convert(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION direction, const char *from, size_t from_len, char *dest, size_t *dest_len)
Definition: charconv.c:57
#define GI_FROM(T, value)
Definition: ncbimisc.hpp:1086
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:819
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
element_type * get(void) const
Get pointer.
Definition: ncbimisc.hpp:469
Int8 TIntId
Definition: ncbimisc.hpp:999
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define GI_TO(T, gi)
Definition: ncbimisc.hpp:1085
virtual const string & AsString(void) const =0
Get the argument's string value.
@ eExcludes
One argument excludes another.
Definition: ncbiargs.hpp:957
@ eInputFile
Name of file (must exist and be readable)
Definition: ncbiargs.hpp:595
@ eIntId
Convertible to TIntId (int or Int8 depending on NCBI_INT8_GI)
Definition: ncbiargs.hpp:593
@ eOutputFile
Name of file (must be writable)
Definition: ncbiargs.hpp:596
@ eInteger
Convertible into an integer number (int or Int8)
Definition: ncbiargs.hpp:592
void DBAPI_RegisterDriver_FTDS(void)
I_DriverContext * GetDriverContext(const string &driver_name, string *err_msg=0, const map< string, string > *attr=0)
Definition: driver_mgr.cpp:308
@ eDB_RowResult
Definition: interfaces.hpp:387
virtual EDB_ResType ResultType() const
Get type of the result.
Definition: public.cpp:603
virtual bool SkipItem()
Skip result item.
Definition: public.cpp:690
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, EGetItem policy=eAppendLOB)
Get a result item (you can use either GetItem or ReadItem).
Definition: public.cpp:672
virtual const char * ItemName(unsigned int item_num) const
Get name of a result item.
Definition: public.cpp:624
virtual unsigned int NofItems() const
Get # of items (columns) in the result.
Definition: public.cpp:617
virtual bool Fetch()
Fetch next row.
Definition: public.cpp:649
Int4 Value() const
Definition: types.hpp:373
#define ERR_FATAL(message)
Posting fatal error and abort.
Definition: ncbidiag.hpp:240
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
Definition: ncbidiag.cpp:6129
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
void SetDiagStream(CNcbiOstream *os, bool quick_flush=true, FDiagCleanup cleanup=0, void *cleanup_data=0, const string &stream_name="")
Set diagnostic stream.
Definition: ncbidiag.cpp:8083
@ eDS_Default
Try standard log file (app.name + ".log") in /log/, use stderr on failure.
Definition: ncbidiag.hpp:1790
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
const CMemberId & GetId(void) const
const string & GetName(void) const
TTypeInfoGetter GetTypeRef(const T *object)
Definition: serial.hpp:76
CNcbiOstream & WriteObject(CNcbiOstream &str, TConstObjectPtr ptr, TTypeInfo info)
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
@ eSerial_StdWhenAny
Definition: serialdef.hpp:132
@ eFNP_Allow
pass through unchanged, post no error message
Definition: serialdef.hpp:175
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
@ eSerial_Xml
XML.
Definition: serialdef.hpp:75
@ eSerial_AsnBinary
ASN.1 binary.
Definition: serialdef.hpp:74
static C * GetUnchecked(const CObjectInfo &object)
Definition: objecttype.hpp:129
pair< TObjectPtr, TTypeInfo > ObjectInfo(C &obj)
Definition: objectinfo.hpp:762
const CMemberInfo * GetMemberInfo(void) const
CObjectTypeInfo GetMemberType(void) const
Get data type information.
CMemberIterator FindMember(const string &memberName) const
Find class member by its name.
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
Definition: objostr.cpp:126
CObjectTypeInfo GetClassType(void) const
Get containing class type.
TTypeInfo GetTypeInfo(void) const
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
Definition: objistr.cpp:195
CObjectIStream & In(void) const
pair< TConstObjectPtr, TTypeInfo > ConstObjectInfo(const C &obj)
Definition: objectinfo.hpp:770
CObjectOStream & Out(void) const
void SetLocalReadHook(CObjectIStream &stream, CReadClassMemberHook *hook) const
Definition: objectiter.cpp:96
void SetLocalWriteHook(CObjectOStream &stream, CWriteObjectHook *hook) const
Set local (for the specified stream) write hook.
Definition: objectinfo.cpp:393
const string & GetName(void) const
Get type name.
Definition: objectinfo.hpp:106
void Copy(const CObjectTypeInfo &type)
Copy data.
Definition: objcopy.cpp:74
void SetLocalWriteHook(CObjectOStream &stream, CWriteClassMemberHook *hook) const
Definition: objectiter.cpp:123
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
#define EMPTY_TEMPLATE
Definition: ncbistl.hpp:159
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
ERW_Result
Result codes for I/O operations.
#define NcbiEndl
Definition: ncbistre.hpp:548
#define NcbiCout
Definition: ncbistre.hpp:543
#define NcbiCerr
Definition: ncbistre.hpp:544
@ eRW_NotImplemented
Action / information is not available.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Success
Everything is okay, I/O completed.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
const string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
const TTaxname & GetTaxname(void) const
Get the Taxname member data.
Definition: Org_ref_.hpp:372
const TDb & GetDb(void) const
Get the Db member data.
Definition: Org_ref_.hpp:491
list< CRef< CSeq_entry > > TSeq_set
bool IsSetCompleteness(void) const
Check if a value has been assigned to Completeness data member.
Definition: MolInfo_.hpp:569
bool IsMolinfo(void) const
Check if variant Molinfo is selected.
Definition: Seqdesc_.hpp:1196
const TTitle & GetTitle(void) const
Get the variant data.
Definition: Seqdesc_.hpp:1032
const TSource & GetSource(void) const
Get the variant data.
Definition: Seqdesc_.cpp:566
bool IsSource(void) const
Check if variant Source is selected.
Definition: Seqdesc_.hpp:1190
bool IsSetBiomol(void) const
Check if a value has been assigned to Biomol data member.
Definition: MolInfo_.hpp:422
TTech GetTech(void) const
Get the Tech member data.
Definition: MolInfo_.hpp:497
const Tdata & Get(void) const
Get the member data.
Definition: Seq_descr_.hpp:166
TBiomol GetBiomol(void) const
Get the Biomol member data.
Definition: MolInfo_.hpp:447
bool IsSetTech(void) const
Check if a value has been assigned to Tech data member.
Definition: MolInfo_.hpp:472
TCompleteness GetCompleteness(void) const
Get the Completeness member data.
Definition: MolInfo_.hpp:594
bool IsTitle(void) const
Check if variant Title is selected.
Definition: Seqdesc_.hpp:1026
const TMolinfo & GetMolinfo(void) const
Get the variant data.
Definition: Seqdesc_.cpp:588
const TEntrys & GetEntrys(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
char * buf
int i
static MDB_envinfo info
Definition: mdb_load.c:37
const CharType(& source)[N]
Definition: pointer.h:1149
#define NCBI_SC_VERSION_PROXY
#define NCBI_TEAMCITY_BUILD_NUMBER_PROXY
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Definition: ncbiapp_api.hpp:54
Defines command line argument related classes.
Defines unified interface to application:
Memory pool for fast allocation of memory for localized set of CObjects, e.g.
Multi-threading – classes, functions, and features.
Useful/utility classes and methods.
std::istream & in(std::istream &in_, double &x_)
static unsigned cnt[256]
static const char * suffix[]
Definition: pcregrep.c:408
static BOOL quiet
Definition: pcregrep.c:196
static void WriteClassMember(CObjectOStream &out, const CObjectInfoMI &member)
Definition: read_hooks.cpp:47
Reader-writer based streams.
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
static CS_CONTEXT * context
Definition: will_convert.c:21
static wxAcceleratorEntry entries[3]
#define const
Definition: zconf.h:232
ZLib Compression API.
Modified on Fri May 24 14:57:24 2024 by modify_doxy.py rev. 669887