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

Go to the SVN repository for this file.

1 /* $Id: flat_file_generator.cpp 100570 2023-08-11 13:06:22Z 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: Mati Shomrat
27 *
28 * File Description:
29 * User interface for generating flat file reports from ASN.1
30 *
31 */
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 #include <corelib/ncbiobj.hpp>
35 #include <corelib/ncbitime.hpp>
37 
42 #include <objmgr/scope.hpp>
43 #include <objmgr/bioseq_handle.hpp>
45 #include <objmgr/util/sequence.hpp>
46 #include <objmgr/mapped_feat.hpp>
47 #include <objmgr/util/feature.hpp>
48 #include <objmgr/annot_ci.hpp>
49 
59 
61 
64 USING_SCOPE(sequence);
65 
66 
67 //////////////////////////////////////////////////////////////////////////////
68 //
69 // PUBLIC
70 
71 // constructor
73  m_Ctx(new CFlatFileContext(cfg))
74 {
75  m_Failed = false;
76  if ( !m_Ctx ) {
77  NCBI_THROW(CFlatException, eInternal, "Unable to initialize context");
78  }
79 }
80 
81 
89  CFlatFileConfig::TPolicy policy) :
90  m_Ctx(new CFlatFileContext(CFlatFileConfig(format, mode, style, flags, view, policy, custom)))
91 {
92  m_Failed = false;
93  if ( !m_Ctx ) {
94  NCBI_THROW(CFlatException, eInternal, "Unable to initialize context");
95  }
96 }
97 
98 
99 // destructor
100 
102 {
103 }
104 
105 
106 // Set annotation selector for feature gathering
107 
109 {
110  return m_Ctx->SetAnnotSelector();
111 }
112 
113 void CFlatFileGenerator::SetFeatTree(feature::CFeatTree* tree)
114 {
116 }
117 
119 {
120  m_Ctx->SetSeqEntryIndex(idx);
121 }
122 
124 {
126 }
127 
128 
129 
130  /*
131  template<typename _Pred>
132  void VisitAllBioseqs(objects::CSeq_entry& entry, _Pred m)
133  {
134  if (entry.IsSeq())
135  {
136  m(entry.SetSeq());
137  }
138  else
139  if (entry.IsSet())
140  {
141  NON_CONST_ITERATE(CSeq_entry::TSet::TSeq_set, it_se, entry.SetSet().SetSeq_set())
142  {
143  VisitAllBioseqs(**it_se, m);
144  }
145  }
146  }
147  // also const visitor
148  template<typename _Pred>
149  void VisitAllBioseqs(const objects::CSeq_entry& entry, _Pred m)
150  {
151  if (entry.IsSeq())
152  {
153  m(entry.GetSeq());
154  }
155  else
156  if (entry.IsSet())
157  {
158  ITERATE(CSeq_entry::TSet::TSeq_set, it_se, entry.GetSet().GetSeq_set())
159  {
160  VisitAllBioseqs(**it_se, m);
161  }
162  }
163  }
164 
165  template<typename _Pred>
166  void VisitAllSeqSets(objects::CSeq_entry& entry, _Pred m)
167  {
168  if (entry.IsSet())
169  {
170  m(entry.SetSet());
171  NON_CONST_ITERATE(CSeq_entry::TSet::TSeq_set, it_se, entry.SetSet().SetSeq_set())
172  {
173  VisitAllSeqSets(**it_se, m);
174  }
175  }
176  }
177  */
178  // also const visitor
179  template<typename _Pred>
180  void VisitAllSeqSets(const objects::CSeq_entry& entry, _Pred m)
181  {
182  if (entry.IsSet())
183  {
184  m(entry.GetSet());
185  ITERATE(CSeq_entry::TSet::TSeq_set, it_se, entry.GetSet().GetSeq_set())
186  {
187  VisitAllSeqSets(**it_se, m);
188  }
189  }
190  }
191 
192 
193 
194 // Generate a flat-file report for a Seq-entry
195 // (the other CFlatFileGenerator::Generate functions ultimately
196 // call this)
197 #if 0
199 (const CSeq_entry_Handle& entry,
200  CFlatItemOStream& item_os)
201 {
202  _ASSERT(entry && entry.Which() != CSeq_entry::e_not_set);
203 
204  if ( m_Ctx->GetConfig().BasicCleanup() )
205  {
206 
210  CBioseq_EditHandle bseqh;
211  CRef<CSeq_entry> tmp_se(new CSeq_entry);
212 
213  if ( tseh.IsSet() ) {
214  bseth = tseh.SetSet();
216  bseth.Remove(bseth.eKeepSeq_entry);
217  tmp_se->SetSet(const_cast<CBioseq_set&>(*bset));
218  }
219  else {
220  bseqh = tseh.SetSeq();
221  CConstRef<CBioseq> bseq = bseqh.GetCompleteObject();
222  bseqh.Remove(bseqh.eKeepSeq_entry);
223  tmp_se->SetSeq(const_cast<CBioseq&>(*bseq));
224  }
225 
227  cleanup.BasicCleanup( *tmp_se );
228 
229  if ( tmp_se->IsSet() ) {
230  tseh.SelectSet(bseth);
231  }
232  else {
233  tseh.SelectSeq(bseqh);
234  }
235  }
236 
237  m_Ctx->SetSGS(false);
239  if (topent && topent->IsSet()) {
240  /*
241  const CBioseq_set& topset = topent->GetSet();
242  VISIT_ALL_SEQSETS_WITHIN_SEQSET (itr, topset) {
243  const CBioseq_set& bss = *itr;
244  if (bss.GetClass() == CBioseq_set::eClass_small_genome_set) {
245  m_Ctx->SetSGS(true);
246  }
247  }
248  */
249  VisitAllSeqSets(*topent, [this](const CBioseq_set& bss){
251  m_Ctx->SetSGS(true);
252  }});
253  }
254 
255  CRef<CFlatItemOStream> pItemOS( & item_os );
256  // If there is a ICancel callback, wrap the item_os so
257  // that every call checks it.
258  const ICanceled * pCanceled =
260  if( pCanceled ) {
261  pItemOS.Reset(
262  new CCancelableFlatItemOStreamWrapper(
263  item_os, pCanceled) );
264  }
265 
266  /// archive a copy of the annot selector before we generate!
268  m_Ctx->SetEntry(entry);
269 
270  if ( m_Ctx->GetConfig().UseSeqEntryIndexer() ) {
271  // CSeq_entry& top = const_cast<CSeq_entry&> (*topent);
272  CSeq_entry_Handle topseh = entry.GetTopLevelEntry();
273  if (m_Ctx->UsingSeqEntryIndex()) {
275  if (idx) {
276  const CRef<CSeqMasterIndex>& midx = idx->GetMasterIndex();
277  if (midx) {
278  if (midx->GetTopSEH() != topseh) {
280  }
281  }
282  }
283  }
284  if (! m_Ctx->UsingSeqEntryIndex()) {
285  try {
288  const CFlatFileConfig& cfg = m_Ctx->GetConfig();
289  if ( cfg.OnlyNearFeatures() && ! ( cfg.IsPolicyFtp() || cfg.IsPolicyGenomes() ) ) {
290  policy = CSeqEntryIndex::eInternal;
291  }
292  if ( cfg.HideSNPFeatures() ) {
294  }
295  if ( cfg.HideCDDFeatures() ) {
297  }
298  if ( cfg.ShowSNPFeatures() ) {
300  }
301  if ( cfg.ShowCDDFeatures() ) {
303  }
304  if ( cfg.HideExonFeatures() ) {
306  }
307  if ( cfg.HideIntronFeatures() ) {
309  }
310  if ( cfg.HideMiscFeatures() ) {
312  }
313  if ( cfg.GeneRNACDSFeatures() ) {
315  }
316  if ( cfg.IsPolicyInternal() ) {
317  policy = CSeqEntryIndex::eInternal;
318  }
319  if ( cfg.IsPolicyExternal() ) {
320  policy = CSeqEntryIndex::eExternal;
321  }
322  if ( cfg.IsPolicyExhaustive() ) {
324  }
325  if ( cfg.IsPolicyFtp() ) {
326  policy = CSeqEntryIndex::eFtp;
327  }
328  if ( cfg.IsPolicyGenomes() ) {
329  policy = CSeqEntryIndex::eGenomes;
330  }
331  if ( cfg.IsPolicyWeb() ) {
332  policy = CSeqEntryIndex::eWeb;
333  }
334  CRef<CSeqEntryIndex> idx(new CSeqEntryIndex( topseh, policy, flags ));
335  m_Ctx->SetSeqEntryIndex(idx);
336  if (idx->IsIndexFailure()) {
337  m_Failed = true;
338  return;
339  }
340  } catch(CException &) {
341  m_Failed = true;
342  return;
343  }
344  }
345  }
346 
347 
348  bool onlyNearFeats = false;
349  // bool nearFeatsSuppress = false;
350 
351  bool isNc = false;
352  /*
353  bool isNgNtNwNz = false;
354  bool isGED = false;
355  bool isTPA = false;
356  */
357 
358  bool hasLocalFeat = false;
359  bool forceOnlyNear = false;
360 
361  for (CBioseq_CI bi(entry); bi; ++bi) {
362  const CBioseq_Handle& bh = *bi;
363 
364  const CBioseq& bsp = *(bi->GetCompleteBioseq());
365 
366  FOR_EACH_SEQID_ON_BIOSEQ (it, bsp) {
367  const CSeq_id& sid = **it;
368  switch (sid.Which()) {
369  case CSeq_id::e_Genbank:
370  case CSeq_id::e_Embl:
371  case CSeq_id::e_Ddbj:
372  // isGED = true;
373  break;
374  case CSeq_id::e_Tpg:
375  case CSeq_id::e_Tpe:
376  case CSeq_id::e_Tpd:
377  // isTPA = true;
378  break;
379  case CSeq_id::e_Other:
380  {
381  const CTextseq_id* tsid = sid.GetTextseq_Id();
382  if (tsid && tsid->IsSetAccession()) {
383  const string& acc = tsid->GetAccession().substr(0, 3);
384  if (acc == "NC_") {
385  isNc = true;
386  } else if (acc == "NG_" || acc == "NT_" || acc == "NW_" || acc == "NZ_") {
387  // isNgNtNwNz = true;
388  }
389  }
390  }
391  break;
392  default:
393  break;
394  }
395  }
396 
397  FOR_EACH_SEQDESC_ON_BIOSEQ (desc_it, bsp) {
398  const CSeqdesc& desc = **desc_it;
399  if (! desc.IsUser()) continue;
400  if (! desc.GetUser().IsSetType()) continue;
401  const CUser_object& usr = desc.GetUser();
402  const CObject_id& oi = usr.GetType();
403  if (! oi.IsStr()) continue;
404  const string& type = oi.GetStr();
405  if (! NStr::EqualNocase(type, "FeatureFetchPolicy")) continue;
407  const CUser_field& fld = **uitr;
408  if (FIELD_IS_SET_AND_IS(fld, Label, Str)) {
409  const string &label_str = GET_FIELD(fld.GetLabel(), Str);
410  if (! NStr::EqualNocase(label_str, "Policy")) continue;
411  if (fld.IsSetData() && fld.GetData().IsStr()) {
412  const string& str = fld.GetData().GetStr();
413  if (NStr::EqualNocase(str, "OnlyNearFeatures")) {
414  forceOnlyNear = true;
415  }
416  }
417  }
418  }
419  }
420 
421  CSeq_annot_CI annot_ci(bh);
422  for (; annot_ci; ++annot_ci) {
423  const CSeq_annot_Handle& annt = *annot_ci;
425  const CSeq_annot& antx = *pAnnot;
426  FOR_EACH_SEQFEAT_ON_SEQANNOT (feat_it, antx) {
427  const CSeq_feat& sft = **feat_it;
428  const CSeqFeatData& data = sft.GetData();
429  CSeqFeatData::ESubtype subtype = data.GetSubtype();
430  if (isNc) {
431  switch (subtype) {
436  break;
437  default:
438  hasLocalFeat = true;
439  break;
440  }
441  } else {
442  hasLocalFeat = true;
443  }
444  }
445  if (hasLocalFeat) {
446  break;
447  }
448  }
449  }
450 
451  if (forceOnlyNear) {
452  onlyNearFeats = true;
453  /*
454  } else if (isNc) {
455  nearFeatsSuppress = true;
456  } else if (isNgNtNwNz) {
457  onlyNearFeats = true;
458  } else if (isTPA) {
459  onlyNearFeats = true;
460  } else if (isGED) {
461  nearFeatsSuppress = true;
462  */
463  }
464 
465  if (onlyNearFeats) {
467  /*
468  } else if (nearFeatsSuppress) {
469  if (hasLocalFeat) {
470  m_Ctx->SetAnnotSelector().SetResolveDepth(0);
471  } else {
472  m_Ctx->SetAnnotSelector().SetResolveDepth(1);
473  }
474  */
475  } else {
476  // m_Ctx->SetAnnotSelector().SetResolveDepth(1);
478  }
479 
480 
483  if ( !formatter ) {
484  NCBI_THROW(CFlatException, eInternal, "Unable to initialize formatter");
485  }
486  formatter->SetContext(*m_Ctx);
487  pItemOS->SetFormatter(formatter);
488 
490  if ( !gatherer ) {
491  NCBI_THROW(CFlatException, eInternal, "Unable to initialize gatherer");
492  }
493  gatherer->Gather(*m_Ctx, *pItemOS);
494 
495  /// reset the context, but preserve our selector
496  /// we do this a bit oddly since resetting the context erases the selector;
497  /// since the caller is reusing this object (most likely), we automatically
498  /// restore the selector to its former glory
499  m_Ctx->Reset();
500  m_Ctx->SetAnnotSelector() = sel;
501 
502  /*
503  if ( m_Ctx->GetConfig().UseSeqEntryIndexer() ) {
504  m_Ctx->ResetSeqEntryIndex();
505  }
506  */
507 }
508 
509 
511 (const CSeq_submit& submit,
512  CScope& scope,
513  CFlatItemOStream& item_os)
514 {
515  _ASSERT(submit.CanGetData());
516  _ASSERT(submit.CanGetSub());
517  _ASSERT(submit.GetData().IsEntrys());
518  _ASSERT(!submit.GetData().GetEntrys().empty());
519 
520  // NB: though the spec specifies a submission may contain multiple entries
521  // this is not the case. A submission should only have a single Top-level
522  // Seq-entry
523  CConstRef<CSeq_entry> e(submit.GetData().GetEntrys().front());
524  if (e.NotEmpty()) {
525  // get Seq_entry_Handle from scope
526  CSeq_entry_Handle entry;
527  try {
528  entry = scope.GetSeq_entryHandle(*e);
529  } catch (CException&) {}
530 
531  if (!entry) { // add to scope if not already in it
532  entry = scope.AddTopLevelSeqEntry(*e);
533  }
534  // "remember" the submission block
535  m_Ctx->SetSubmit(submit.GetSub());
536 
537  Generate(entry, item_os);
538  }
539 }
540 
541 
543 (const CBioseq& bioseq,
544 CScope& scope,
545  CFlatItemOStream& item_os)
546 {
547  const CBioseq_Handle bsh = scope.GetBioseqHandle(bioseq);
548  const CSeq_entry_Handle entry = bsh.GetSeq_entry_Handle();
549  Generate(entry, item_os);
550 }
551 
552 
554 (const CSeq_loc& loc,
555  CScope& scope,
556  CFlatItemOStream& item_os)
557 {
558  CBioseq_Handle bsh = GetBioseqFromSeqLoc(loc, scope);
559  if (!bsh) {
560  NCBI_THROW(CFlatException, eInvalidParam, "location not in scope");
561  }
562  CSeq_entry_Handle entry = bsh.GetParentEntry();
563  if (!entry) {
564  NCBI_THROW(CFlatException, eInvalidParam, "Id not in scope");
565  }
567  location->Assign(loc);
569 
570  CFlatFileConfig& cfg = m_Ctx->SetConfig();
571  if (cfg.IsStyleNormal()) {
572  cfg.SetStyleMaster();
573  }
574 
575  Generate(entry, item_os);
576 }
577 
578 
580 (const CBioseq_Handle& bsh,
581  CFlatItemOStream& item_os)
582 {
583  const CSeq_entry_Handle entry = bsh.GetSeq_entry_Handle();
584  Generate(entry, item_os);
585 }
586 
587 
589 (const CSeq_id& id,
590  const TRange& range,
591  ENa_strand strand,
592  CScope& scope,
593  CFlatItemOStream& item_os)
594 {
595  CRef<CSeq_id> id2(new CSeq_id);
596  id2->Assign(id);
597  CRef<CSeq_loc> loc;
598  if ( range.IsWhole() ) {
599  loc.Reset(new CSeq_loc);
600  loc->SetWhole(*id2);
601  } else {
602  loc.Reset(new CSeq_loc(*id2, range.GetFrom(), range.GetTo(), strand));
603  }
604  if ( loc ) {
605  Generate(*loc, scope, item_os);
606  }
607 }
609 (const CSeq_submit& submit,
610  CScope& scope,
611  CNcbiOstream& os)
612 {
614  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
615 
616  Generate(submit, scope, *item_os);
617 }
618 
619 
621 (const CBioseq& bioseq,
622  CScope& scope,
623  CNcbiOstream& os)
624 {
626  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
627 
628  const CBioseq_Handle bsh = scope.GetBioseqHandle(bioseq);
629  const CSeq_entry_Handle entry = bsh.GetSeq_entry_Handle();
630  Generate(entry, *item_os);
631 }
632 
633 
635 (const CSeq_entry_Handle& entry,
636  CNcbiOstream& os)
637 {
639  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
640 
641  Generate(entry, *item_os);
642 }
643 
644 
646 (const CBioseq_Handle& bsh,
647  CNcbiOstream& os)
648 {
650  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
651 
652  const CSeq_entry_Handle entry = bsh.GetSeq_entry_Handle();
653  Generate(entry, *item_os);
654 }
655 
656 
658 (const CSeq_loc& loc,
659  CScope& scope,
660  CNcbiOstream& os)
661 {
663  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
664 
665  Generate(loc, scope, *item_os);
666 }
667 
668 
670 (const CSeq_id& id,
671  const TRange& range,
672  ENa_strand strand,
673  CScope& scope,
674  CNcbiOstream& os)
675 {
677  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
678 
679  Generate(id, range, strand, scope, *item_os);
680 }
681 
682 
683 #endif
684 
685 
686 // This version iterates Bioseqs within the Bioseq_set
688  const CSeq_entry_Handle& entry,
689  CFlatItemOStream& item_os,
690  const multiout& mo)
691 {
692  // useSeqEntryIndexing now turned ON by default
693  bool useSeqEntryIndexing = true;
694 
695  /*
696  // useSeqEntryIndexing argument also set by relevant flags in CFlatFileConfig
697  if ( m_Ctx->GetConfig().UseSeqEntryIndexer() ) {
698  useSeqEntryIndexing = true;
699  }
700  */
701 
702  // Setting the -custom 1048576 bit flag turns OFF default indexing
703  if ( m_Ctx->GetConfig().DisableDefaultIndex() ) {
704  useSeqEntryIndexing = false;
706  }
707 
708  if (useSeqEntryIndexing) {
710  } else {
711  SetFeatTree(new feature::CFeatTree(entry));
712  }
713 
714  _ASSERT(entry && entry.Which() != CSeq_entry::e_not_set);
715 
716  const CFlatFileConfig& cfg = m_Ctx->GetConfig();
717 
718  bool showDebugTiming = cfg.ShowDebugTiming();
719 
720  CStopWatch sw;
721 
722  bool doNuc = false;
723  bool doProt = false;
724  bool doFastSets = false;
725 
726  // doNuc and doProt arguments also set by relevant flags in CFlatFileConfig
727  if ( cfg.IsViewNuc() ) {
728  doNuc = true;
729  }
730  if ( cfg.IsViewProt() ) {
731  doProt = true;
732  }
733  if ( cfg.IsViewAll() ) {
734  doNuc = true;
735  doProt = true;
736  }
737  if ( cfg.FasterReleaseSets() ) {
738  doFastSets = true;
739  }
740 
741  if ( cfg.BasicCleanup() )
742  {
743  if (showDebugTiming) {
744  sw.Start();
745  }
746 
750  CBioseq_EditHandle bseqh;
751  CRef<CSeq_entry> tmp_se(new CSeq_entry);
752 
753  if ( tseh.IsSet() ) {
754  bseth = tseh.SetSet();
756  bseth.Remove(bseth.eKeepSeq_entry);
757  tmp_se->SetSet(const_cast<CBioseq_set&>(*bset));
758  }
759  else {
760  bseqh = tseh.SetSeq();
761  CConstRef<CBioseq> bseq = bseqh.GetCompleteObject();
762  bseqh.Remove(bseqh.eKeepSeq_entry);
763  tmp_se->SetSeq(const_cast<CBioseq&>(*bseq));
764  }
765 
767  cleanup.BasicCleanup( *tmp_se );
768 
769  if ( tmp_se->IsSet() ) {
770  tseh.SelectSet(bseth);
771  }
772  else {
773  tseh.SelectSeq(bseqh);
774  }
775 
776  if (showDebugTiming) {
777  NcbiCerr << "Cleanup: " << sw.Elapsed() << ", ";
778  sw.Reset();
779  }
780  }
781 
782  if (showDebugTiming) {
783  sw.Start();
784  }
785 
786  m_Ctx->SetSGS(false);
788  if (topent && topent->IsSet()) {
789  /*
790  const CBioseq_set& topset = topent->GetSet();
791  VISIT_ALL_SEQSETS_WITHIN_SEQSET (itr, topset) {
792  const CBioseq_set& bss = *itr;
793  if (bss.GetClass() == CBioseq_set::eClass_small_genome_set) {
794  m_Ctx->SetSGS(true);
795  }
796  }
797  */
798  VisitAllSeqSets(*topent, [this](const CBioseq_set& bss){
800  m_Ctx->SetSGS(true);
801  }});
802  }
803 
804  // If there is a ICancel callback, wrap the item_os so
805  // that every call checks it.
806  const ICanceled * pCanceled = cfg.GetCanceledCallback();
807 
808  /// archive a copy of the annot selector before we generate!
810  m_Ctx->SetEntry(entry);
811 
812  if ( cfg.UseSeqEntryIndexer() ) {
813  // CSeq_entry& top = const_cast<CSeq_entry&> (*topent);
814  CSeq_entry_Handle topseh = entry.GetTopLevelEntry();
815  if (m_Ctx->UsingSeqEntryIndex()) {
817  if (idx) {
818  const CRef<CSeqMasterIndex>& midx = idx->GetMasterIndex();
819  if (midx) {
820  if (midx->GetTopSEH() != topseh) {
822  }
823  }
824  }
825  }
826  if (! m_Ctx->UsingSeqEntryIndex()) {
827  try {
830  if ( cfg.OnlyNearFeatures() && ! ( cfg.IsPolicyFtp() || cfg.IsPolicyGenomes() ) ) {
831  policy = CSeqEntryIndex::eInternal;
832  }
833  if ( cfg.HideSNPFeatures() ) {
835  } else if ( cfg.ShowSNPFeatures() ) {
837  }
838  if ( cfg.HideCDDFeatures() ) {
840  } else if ( cfg.ShowCDDFeatures() ) {
842  }
843  if ( cfg.IsPolicyInternal() ) {
844  policy = CSeqEntryIndex::eInternal;
845  }
846  if ( cfg.IsPolicyExternal() ) {
847  policy = CSeqEntryIndex::eExternal;
848  }
849  if ( cfg.IsPolicyExhaustive() ) {
851  }
852  if ( cfg.IsPolicyFtp() ) {
853  policy = CSeqEntryIndex::eFtp;
854  }
855  if ( cfg.IsPolicyGenomes() ) {
856  policy = CSeqEntryIndex::eGenomes;
857  }
858  if ( cfg.IsPolicyWeb() ) {
859  policy = CSeqEntryIndex::eWeb;
860  }
861  CRef<CSeqEntryIndex> idx(new CSeqEntryIndex( topseh, policy, flags));
862  m_Ctx->SetSeqEntryIndex(idx);
863  if (idx->IsIndexFailure()) {
864  m_Failed = true;
865  return;
866  }
867  int featDepth = cfg.GetFeatDepth();
868  idx->SetFeatDepth(featDepth);
869  int gapDepth = cfg.GetGapDepth();
870  idx->SetGapDepth(gapDepth);
871  } catch(CException &) {
872  m_Failed = true;
873  return;
874  }
875  }
876  }
877 
880  if ( !formatter ) {
881  NCBI_THROW(CFlatException, eInternal, "Unable to initialize formatter");
882  }
883  formatter->SetContext(*m_Ctx);
884 
885  if (showDebugTiming) {
886  // NcbiCerr << "Prepare: " << sw.Elapsed() << ", ";
887  sw.Reset();
888  }
889 
890  const string accn_filt = cfg.GetSingleAccession();
891 
892  // internal Bioseq iterator loop moved up from x_GatherSeqEntry
893  for (CBioseq_CI bioseq_it(entry); bioseq_it; ++bioseq_it) {
894 
895  if (showDebugTiming) {
896  sw.Start();
897  }
898 
899  CBioseq_Handle bsh = *bioseq_it;
900  if (! bsh) continue;
901 
902  if ( ! accn_filt.empty()) {
903  bool okay = false;
904  const CBioseq& bsp = *bsh.GetBioseqCore();
905  for (auto& sid : bsp.GetId()) {
906  switch (sid->Which()) {
907  case NCBI_SEQID(Genbank):
908  case NCBI_SEQID(Embl):
909  case NCBI_SEQID(Ddbj):
910  case NCBI_SEQID(Tpg):
911  case NCBI_SEQID(Tpe):
912  case NCBI_SEQID(Tpd):
913  case NCBI_SEQID(Local):
914  case NCBI_SEQID(General):
915  case NCBI_SEQID(Other):
916  case NCBI_SEQID(Gpipe):
917  {
918  const string accn_string = sid->GetSeqIdString();
919  if ( accn_filt == accn_string ) {
920  okay = true;
921  }
922  const string fasta_str = sid->AsFastaString();
923  if ( accn_filt == fasta_str ) {
924  okay = true;
925  }
926  break;
927  }
928  default:
929  break;
930  }
931  }
932  if ( ! okay) {
933  continue;
934  }
935  }
936 
938  if (showDebugTiming) {
939  NcbiCerr << "Accession: " << sidh << ", ";
940  }
941  const CSeq_entry_Handle ent = bsh.GetSeq_entry_Handle();
943 
944  CNcbiOstream* flatfile_os = nullptr;
945 
946  bool is_genomic = false;
947  bool is_RNA = false;
948 
950  if (closest_molinfo) {
951  const CMolInfo& molinf = closest_molinfo->GetMolinfo();
952  CMolInfo::TBiomol biomol = molinf.GetBiomol();
953  switch (biomol) {
954  case NCBI_BIOMOL(genomic):
955  case NCBI_BIOMOL(other_genetic):
956  case NCBI_BIOMOL(genomic_mRNA):
957  case NCBI_BIOMOL(cRNA):
958  is_genomic = true;
959  break;
960  case NCBI_BIOMOL(pre_RNA):
961  case NCBI_BIOMOL(mRNA):
962  case NCBI_BIOMOL(rRNA):
963  case NCBI_BIOMOL(tRNA):
964  case NCBI_BIOMOL(snRNA):
965  case NCBI_BIOMOL(scRNA):
966  case NCBI_BIOMOL(snoRNA):
967  case NCBI_BIOMOL(transcribed_RNA):
968  case NCBI_BIOMOL(ncRNA):
969  case NCBI_BIOMOL(tmRNA):
970  is_RNA = true;
971  break;
972  case NCBI_BIOMOL(other):
973  {
975  switch (mol) {
976  case CSeq_inst::eMol_dna:
977  is_genomic = true;
978  break;
979  case CSeq_inst::eMol_rna:
980  is_RNA = true;
981  break;
982  case CSeq_inst::eMol_na:
983  is_genomic = true;
984  break;
985  default:
986  break;
987  }
988  }
989  break;
990  default:
991  break;
992  }
993  }
994 
995  if (mo.m_Os) {
996  flatfile_os = mo.m_Os;
997  if ( bsh.IsNa() && ! doNuc ) continue;
998  if ( bsh.IsAa() && ! doProt ) continue;
999  } else if ( bsh.IsNa() ) {
1000  if (mo.m_On) {
1001  flatfile_os = mo.m_On;
1002  } else if ((is_genomic || ! closest_molinfo) && mo.m_Og) {
1003  flatfile_os = mo.m_Og;
1004  } else if (is_RNA && mo.m_Or) {
1005  flatfile_os = mo.m_Or;
1006  }
1007  } else if ( bsh.IsAa() ) {
1008  if (mo.m_Op) {
1009  flatfile_os = mo.m_Op;
1010  }
1011  } else {
1012  if (mo.m_Ou) {
1013  flatfile_os = mo.m_Ou;
1014  } else if (mo.m_On) {
1015  flatfile_os = mo.m_On;
1016  }
1017  }
1018 
1019  CRef<CFlatItemOStream> newitem_os;
1020  if (! flatfile_os) {
1021  if (! mo) {
1022  if ( bsh.IsNa() && ! doNuc ) continue;
1023  if ( bsh.IsAa() && ! doProt ) continue;
1024  newitem_os.Reset(&item_os);
1025  } else {
1026  continue;
1027  }
1028  } else {
1029  newitem_os.Reset(
1030  new CFormatItemOStream(new COStreamTextOStream(*flatfile_os)));
1031  }
1032  if (newitem_os.Empty()) continue;
1033 
1034  CRef<CFlatItemOStream> pItemOS( newitem_os );
1035  if( pCanceled ) {
1036  pItemOS.Reset(
1038  *newitem_os, pCanceled) );
1039  }
1040 
1041  pItemOS->SetFormatter(formatter);
1042 
1044  if ( !gatherer ) {
1045  NCBI_THROW(CFlatException, eInternal, "Unable to initialize gatherer");
1046  }
1047 
1048  gatherer->Gather(*m_Ctx, *pItemOS, ent, bsh, useSeqEntryIndexing, doNuc, doProt, doFastSets);
1049 
1050  if (showDebugTiming) {
1051  NcbiCerr << "Elapsed: " << sw.Elapsed() << NcbiEndl;
1052  sw.Reset();
1053  }
1054  }
1055 
1056  /*
1057  if ( m_Ctx->GetConfig().UseSeqEntryIndexer() ) {
1058  m_Ctx->ResetSeqEntryIndex();
1059  }
1060  */
1061 
1062  /// reset the context, but preserve our selector
1063  /// we do this a bit oddly since resetting the context erases the selector;
1064  /// since the caller is reusing this object (most likely), we automatically
1065  /// restore the selector to its former glory
1066  m_Ctx->Reset();
1067  m_Ctx->SetAnnotSelector() = sel;
1068 }
1069 
1070 
1072  const CSeq_entry_Handle& entry,
1073  CNcbiOstream& os,
1074  const multiout& mo)
1075 {
1077  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
1078 
1079  Generate(entry, *item_os, mo);
1080 }
1081 
1082 
1084  const CBioseq_Handle& bsh,
1085  CNcbiOstream& os,
1086  const multiout& mo)
1087 {
1089  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
1090 
1091  const CSeq_entry_Handle entry = bsh.GetSeq_entry_Handle();
1092  Generate(entry, *item_os, mo);
1093 }
1094 
1095 
1097  const CSeq_submit& submit,
1098  CScope& scope,
1099  CNcbiOstream& os,
1100  const multiout& mo)
1101 {
1102  _ASSERT(submit.CanGetData());
1103  _ASSERT(submit.CanGetSub());
1104  _ASSERT(submit.GetData().IsEntrys());
1105  _ASSERT(!submit.GetData().GetEntrys().empty());
1106 
1107  // NB: though the spec specifies a submission may contain multiple entries
1108  // this is not the case. A submission should only have a single Top-level
1109  // Seq-entry
1110  CConstRef<CSeq_entry> e(submit.GetData().GetEntrys().front());
1111  if (e.NotEmpty()) {
1112  // get Seq_entry_Handle from scope
1113  CSeq_entry_Handle entry;
1114  try {
1115  entry = scope.GetSeq_entryHandle(*e);
1116  } catch (CException&) {}
1117 
1118  if (!entry) { // add to scope if not already in it
1119  entry = scope.AddTopLevelSeqEntry(*e);
1120  }
1121  // "remember" the submission block
1122  m_Ctx->SetSubmit(submit.GetSub());
1123 
1125  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
1126 
1127  Generate(entry, *item_os, mo);
1128  }
1129 }
1130 
1131 
1133  const CBioseq& bioseq,
1134  CScope& scope,
1135  CNcbiOstream& os,
1136  const multiout& mo)
1137 {
1139  item_os(new CFormatItemOStream(new COStreamTextOStream(os)));
1140 
1141  const CBioseq_Handle bsh = scope.GetBioseqHandle(bioseq);
1142  const CSeq_entry_Handle entry = bsh.GetSeq_entry_Handle();
1143  Generate(entry, *item_os, mo);
1144 }
1145 
1146 
1148  const CSeq_loc& loc,
1149  CScope& scope,
1150  CNcbiOstream& os,
1151  const multiout& mo)
1152 {
1153  CBioseq_Handle bsh = GetBioseqFromSeqLoc(loc, scope);
1154  if (!bsh) {
1155  NCBI_THROW(CFlatException, eInvalidParam, "location not in scope");
1156  }
1157  CSeq_entry_Handle entry = bsh.GetParentEntry();
1158  if (!entry) {
1159  NCBI_THROW(CFlatException, eInvalidParam, "Id not in scope");
1160  }
1162  location->Assign(loc);
1164 
1165  CFlatFileConfig& cfg = m_Ctx->SetConfig();
1166  if (cfg.IsStyleNormal()) {
1167  cfg.SetStyleMaster();
1168  }
1169 
1170  Generate(entry, os, mo);
1171 }
1172 
1173 
1175  const CSeq_id& id,
1176  const TRange& range,
1177  ENa_strand strand,
1178  CScope& scope,
1179  CNcbiOstream& os,
1180  const multiout& mo)
1181 {
1182  CRef<CSeq_id> id2(new CSeq_id);
1183  id2->Assign(id);
1184  CRef<CSeq_loc> loc;
1185  if ( range.IsWhole() ) {
1186  loc.Reset(new CSeq_loc);
1187  loc->SetWhole(*id2);
1188  } else {
1189  loc.Reset(new CSeq_loc(*id2, range.GetFrom(), range.GetTo(), strand));
1190  }
1191  if ( loc ) {
1192  Generate(*loc, scope, os, mo);
1193  }
1194 }
1195 
1196 
1197 
1198 //void CFlatFileGenerator::Reset(void)
1199 //{
1200 // m_Ctx->Reset();
1201 //}
1202 
1203 
1205 (const CMappedFeat& feat,
1206  CScope& scope,
1207  const CFlatFileConfig& cfg,
1209 {
1211  if (!seq) {
1212  NCBI_THROW(CFlatException, eUnknown, "Bioseq not found for feature");
1213  }
1216 
1217  ctx->SetEntry(seq.GetParentEntry());
1218  formatter->SetContext(*ctx);
1219 
1220  CConn_MemoryStream os;
1221  CFormatItemOStream item_os(new COStreamTextOStream(os));
1222  item_os.SetFormatter(formatter);
1223 
1224  CBioseqContext bctx(seq, *ctx);
1225 
1226  if (ftree.Empty()) {
1227  CSeq_entry_Handle tseh = seq.GetTopLevelEntry();
1228  CFeat_CI iter (tseh);
1229  ftree.Reset (new feature::CFeatTree (iter));
1230  }
1231 
1232  CConstRef<IFlatItem> item;
1233  if (feat.GetData().IsBiosrc()) {
1234  item.Reset( new CSourceFeatureItem(feat, bctx, ftree, &feat.GetLocation()) );
1235  item_os << item;
1236  } else {
1237  item.Reset( new CFeatureItem(feat, bctx, ftree, &feat.GetLocation()) );
1238  item_os << item;
1239  }
1240 
1241  string text;
1242  os.ToString(&text);
1243  return text;
1244 }
1245 
1246 
1248 (const CSeq_entry_Handle& entry,
1249  TSeqPos from,
1250  TSeqPos to,
1251  ENa_strand strand,
1252  CSeq_loc& loc)
1253 {
1254  _ASSERT(entry);
1255 
1256  CBioseq_Handle h = x_DeduceTarget(entry);
1257  if ( !h ) {
1258  NCBI_THROW(CFlatException, eInvalidParam,
1259  "Cannot deduce target bioseq.");
1260  }
1261  TSeqPos length = h.GetInst_Length();
1262 
1263  if ( from == CRange<TSeqPos>::GetWholeFrom() && to == length ) {
1264  // whole
1265  loc.SetWhole().Assign(*h.GetSeqId());
1266  } else {
1267  // interval
1268  loc.SetInt().SetId().Assign(*h.GetSeqId());
1269  loc.SetInt().SetFrom(from);
1270  loc.SetInt().SetTo(to);
1271  if ( strand > 0 ) {
1272  loc.SetInt().SetStrand(strand);
1273  }
1274  }
1275 }
1276 
1277 // if the 'from' or 'to' flags are specified try to guess the bioseq.
1279 {
1280  if ( entry.IsSeq() ) {
1281  return entry.GetSeq();
1282  }
1283 
1284  _ASSERT(entry.IsSet());
1285  CBioseq_set_Handle bsst = entry.GetSet();
1286  if ( !bsst.IsSetClass() ) {
1287  NCBI_THROW(CFlatException, eInvalidParam,
1288  "Cannot deduce target bioseq.");
1289  }
1290  _ASSERT(bsst.IsSetClass());
1291  switch ( bsst.GetClass() ) {
1293  // return the nucleotide
1294  for ( CSeq_entry_CI it(entry); it; ++it ) {
1295  if ( it->IsSeq() ) {
1296  CBioseq_Handle h = it->GetSeq();
1297  if ( h && CSeq_inst::IsNa(h.GetInst_Mol()) ) {
1298  return h;
1299  }
1300  }
1301  }
1302  break;
1304  // return the genomic
1305  for ( CSeq_entry_CI it(bsst); it; ++it ) {
1306  if ( it->IsSeq() &&
1307  it->GetSeq().GetInst_Mol() == CSeq_inst::eMol_dna ) {
1308  return it->GetSeq();
1309  }
1310  }
1311  break;
1313  // return the segmented bioseq
1314  for ( CSeq_entry_CI it(bsst); it; ++it ) {
1315  if ( it->IsSeq() ) {
1316  return it->GetSeq();
1317  }
1318  }
1319  break;
1321  {
1322  CBioseq_CI bi(bsst, CSeq_inst::eMol_na);
1323  if (bi) {
1324  return *bi;
1325  }
1326  }
1327  break;
1328  default:
1329  break;
1330  }
1331  NCBI_THROW(CFlatException, eInvalidParam,
1332  "Cannot deduce target bioseq.");
1333 }
1334 
1335 void
1337  IFormatter* formatter)
1338 {
1339  CFlatItemOStream::SetFormatter(formatter);
1340  m_pUnderlying->SetFormatter(formatter);
1341 }
1342 
1343 void
1345  CConstRef<IFlatItem> item)
1346 {
1347  if( m_pCanceledCallback && m_pCanceledCallback->IsCanceled() ) {
1348  NCBI_THROW(CFlatException, eHaltRequested,
1349  "FlatFileGeneration canceled by ICancel callback");
1350  }
1351  m_pUnderlying->AddItem(item);
1352 }
1353 
1355 {
1356  m_Ctx->SetConfig(cfg);
1357 }
1358 
User-defined methods of the data storage class.
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_EditHandle –.
CBioseq_Handle –.
CBioseq_set_EditHandle –.
CBioseq_set_Handle –.
CConstRef< CSeqdesc > GetClosestDescriptor(CSeqdesc::E_Choice choice, int *level=NULL) const
Definition: Seq_entry.cpp:212
In-memory stream (a la strstream or stringstream)
CFeat_CI –.
Definition: feat_ci.hpp:64
void SetStyleMaster(void)
const TFormat & GetFormat(void) const
bool IsPolicyInternal(void) const
const ICanceled * GetCanceledCallback(void) const
bool GeneRNACDSFeatures(void) const
bool IsPolicyExhaustive(void) const
bool IsPolicyExternal(void) const
CFlatFileConfig & SetUseSeqEntryIndexer(bool val=true)
bool DisableDefaultIndex(void) const
bool OnlyNearFeatures(void) const
bool ShowCDDFeatures(void) const
bool IsPolicyFtp(void) const
bool UseSeqEntryIndexer(void) const
bool ShowSNPFeatures(void) const
bool IsPolicyWeb(void) const
int GetGapDepth(void) const
bool IsViewNuc(void) const
bool IsPolicyGenomes(void) const
bool ShowDebugTiming(void) const
int GetFeatDepth(void) const
bool IsViewAll(void) const
const string & GetSingleAccession(void) const
bool IsViewProt(void) const
unsigned int TCustom
bool HideSNPFeatures(void) const
bool HideMiscFeatures(void) const
bool HideCDDFeatures(void) const
bool BasicCleanup(void) const
bool FasterReleaseSets(void) const
bool HideExonFeatures(void) const
bool IsStyleNormal(void) const
bool HideIntronFeatures(void) const
CFlatFileConfig & SetConfig(void)
Definition: context.hpp:456
void SetLocation(const CSeq_loc *loc)
Definition: context.hpp:464
SAnnotSelector & SetAnnotSelector(void)
Definition: context.hpp:769
const CRef< CSeqEntryIndex > GetSeqEntryIndex(void) const
Definition: context.hpp:471
void SetSubmit(const CSubmit_block &sub)
Definition: context.hpp:453
void SetSeqEntryIndex(CRef< CSeqEntryIndex > idx)
Definition: context.hpp:472
void ResetSeqEntryIndex(void)
Definition: context.hpp:473
bool UsingSeqEntryIndex(void) const
Definition: context.hpp:470
void SetSGS(const bool sgs)
Definition: context.hpp:476
const CFlatFileConfig & GetConfig(void) const
Definition: context.hpp:455
void SetEntry(const CSeq_entry_Handle &entry)
Definition: context.hpp:450
void Reset(void)
Definition: context.hpp:787
void SetFeatTree(feature::CFeatTree *tree)
Definition: context.hpp:468
Use this class to wrap CFlatItemOStream instances so that they check if canceled for every item added...
virtual void SetFormatter(IFormatter *formatter)
If a subclass overrides this, it must call the parent class's version as its first action.
virtual void AddItem(CConstRef< IFlatItem > item)
void Generate(const CSeq_entry_Handle &entry, CFlatItemOStream &item_os, const multiout &={})
SAnnotSelector & SetAnnotSelector(void)
void SetFeatTree(feature::CFeatTree *tree)
CFlatFileGenerator(const CFlatFileConfig &cfg)
CBioseq_Handle x_DeduceTarget(const CSeq_entry_Handle &entry)
void SetSeqEntryIndex(CRef< CSeqEntryIndex > idx)
CRef< CFlatFileContext > m_Ctx
void SetConfig(const CFlatFileConfig &cfg)
static string GetSeqFeatText(const CMappedFeat &feat, CScope &scope, const CFlatFileConfig &cfg, CRef< feature::CFeatTree > ftree=null)
void x_GetLocation(const CSeq_entry_Handle &entry, TSeqPos from, TSeqPos to, ENa_strand strand, CSeq_loc &loc)
static CFlatGatherer * New(CFlatFileConfig::TFormat format)
static CFlatItemFormatter * New(CFlatFileConfig::TFormat format)
virtual void SetFormatter(IFormatter *formatter)
If a subclass overrides this, it must call the parent class's version as its first action.
CMappedFeat –.
Definition: mapped_feat.hpp:59
CScope –.
Definition: scope.hpp:92
CRef< CSeqMasterIndex > GetMasterIndex(void) const
Definition: indexer.hpp:189
void SetFeatDepth(int featDepth)
Definition: indexer.cpp:185
bool IsIndexFailure(void)
Definition: indexer.cpp:215
void SetGapDepth(int gapDepth)
Definition: indexer.cpp:197
ESubtype GetSubtype(void) const
CSeq_entry_Handle GetTopSEH(void) const
Definition: indexer.hpp:250
CSeq_annot_CI –.
CSeq_annot_Handle –.
CSeq_entry_CI –.
CSeq_entry_Handle –.
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
bool IsNa(void) const
Definition: Seq_inst.hpp:106
CStopWatch –.
Definition: ncbitime.hpp:1938
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
static const char location[]
Definition: config.c:97
Include a standard set of the NCBI C++ Toolkit most basic headers.
static void cleanup(void)
Definition: ct_dynamic.c:30
static uch flags
CS_CONTEXT * ctx
Definition: t0006.c:12
USING_SCOPE(sequence)
void VisitAllSeqSets(const objects::CSeq_entry &entry, _Pred m)
#define FOR_EACH_USERFIELD_ON_USEROBJECT(Itr, Var)
FOR_EACH_USERFIELD_ON_USEROBJECT EDIT_EACH_USERFIELD_ON_USEROBJECT.
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
void ToString(string *)
The CConnMemoryStream::To* methods allow to obtain unread portion of the stream into a single contain...
#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:704
const string AsFastaString(void) const
Definition: Seq_id.cpp:2265
string GetSeqIdString(bool with_version=false) const
Return seqid string with optional version for text seqid type.
Definition: Seq_id.cpp:2144
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
Definition: Seq_id.cpp:318
const CTextseq_id * GetTextseq_Id(void) const
Return embedded CTextseq_id, if any.
Definition: Seq_id.cpp:169
void SetWhole(TWhole &v)
Definition: Seq_loc.hpp:982
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
CBioseq_Handle GetBioseqFromSeqLoc(const CSeq_loc &loc, CScope &scope, CScope::EGetBioseqFlag flag=CScope::eGetBioseq_Loaded)
Retrieve the Bioseq Handle from a location.
Definition: sequence.cpp:308
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
Definition: scope.cpp:522
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
Definition: scope.cpp:113
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
TClass GetClass(void) const
TSet SelectSet(TClass set_class=CBioseq_set::eClass_not_set) const
Convert the empty Seq-entry to Bioseq-set.
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
CConstRef< TObject > GetCompleteObject(void) const
E_Choice Which(void) const
CSeq_id_Handle GetAccessSeq_id_Handle(void) const
Get any CSeq_id_Handle handle that can be used to access this bioseq Use GetSeq_id_Handle() if it's n...
const CSeqFeatData & GetData(void) const
TSet GetSet(void) const
bool IsAa(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CConstRef< CSeq_annot > GetCompleteSeq_annot(void) const
Complete and return const reference to the current seq-annot.
TInst_Mol GetInst_Mol(void) const
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
void Remove(ERemoveMode mode=eRemoveSeq_entry) const
void Remove(ERemoveMode mode=eRemoveSeq_entry) const
Remove current seqset-entry from its location.
TSeq GetSeq(void) const
CConstRef< TObject > GetCompleteObject(void) const
TSeq SelectSeq(CBioseq &seq) const
Make the empty Seq-entry be in seq state with specified Bioseq object.
CSeq_entry_EditHandle GetEditHandle(void) const
Get 'edit' version of handle.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
TInst_Length GetInst_Length(void) const
bool IsSetClass(void) const
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
TMol GetSequenceType(void) const
bool IsSet(void) const
CConstRef< TObject > GetCompleteObject(void) const
bool IsNa(void) const
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
bool IsSeq(void) const
const CSeq_loc & GetLocation(void) const
SAnnotSelector & SetAdaptiveDepth(bool value=true)
SetAdaptiveDepth() requests to restrict subsegment resolution depending on annotations found on lower...
SAnnotSelector & SetResolveDepth(int depth)
SetResolveDepth sets the limit of subsegment resolution in searching annotations.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool NotEmpty(void) const THROWS_NONE
Check if CConstRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:1392
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
#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
#define NcbiEndl
Definition: ncbistre.hpp:548
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define NcbiCerr
Definition: ncbistre.hpp:544
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5352
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
Definition: ncbitime.hpp:2776
void Start(void)
Start the timer.
Definition: ncbitime.hpp:2765
void Reset(void)
Stop (if running) and reset the timer.
Definition: ncbitime.hpp:2808
const TStr & GetStr(void) const
Get the variant data.
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
bool IsSetType(void) const
type of object within class Check if a value has been assigned to Type data member.
const TData & GetData(void) const
Get the Data member data.
bool IsStr(void) const
Check if variant Str is selected.
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
const TLabel & GetLabel(void) const
Get the Label member data.
const TType & GetType(void) const
Get the Type member data.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
bool IsBiosrc(void) const
Check if variant Biosrc is selected.
bool IsSetAccession(void) const
Check if a value has been assigned to Accession data member.
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_id_.hpp:746
const TAccession & GetAccession(void) const
Get the Accession member data.
@ e_Other
for historical reasons, 'other' = 'refseq'
Definition: Seq_id_.hpp:104
@ e_Tpe
Third Party Annot/Seq EMBL.
Definition: Seq_id_.hpp:111
@ e_Tpd
Third Party Annot/Seq DDBJ.
Definition: Seq_id_.hpp:112
@ e_Ddbj
DDBJ.
Definition: Seq_id_.hpp:107
@ e_Tpg
Third Party Annot/Seq Genbank.
Definition: Seq_id_.hpp:110
TSet & SetSet(void)
Select the variant.
Definition: Seq_entry_.cpp:130
TClass GetClass(void) const
Get the Class member data.
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
list< CRef< CSeq_entry > > TSeq_set
TSeq & SetSeq(void)
Select the variant.
Definition: Seq_entry_.cpp:108
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
@ eClass_gen_prod_set
genomic products, chrom+mRNA+protein
@ eClass_genbank
converted genbank
@ eClass_segset
segmented sequence + parts
@ eClass_small_genome_set
viral segments or mitochondrial minicircles
@ e_not_set
No variant selected.
Definition: Seq_entry_.hpp:88
const TUser & GetUser(void) const
Get the variant data.
Definition: Seqdesc_.cpp:384
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
TBiomol GetBiomol(void) const
Get the Biomol member data.
Definition: MolInfo_.hpp:447
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
const TMolinfo & GetMolinfo(void) const
Get the variant data.
Definition: Seqdesc_.cpp:588
bool IsUser(void) const
Check if variant User is selected.
Definition: Seqdesc_.hpp:1122
@ e_Molinfo
info on the molecule and techniques
Definition: Seqdesc_.hpp:134
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
const TEntrys & GetEntrys(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TSub & GetSub(void) const
Get the Sub member data.
bool IsEntrys(void) const
Check if variant Entrys is selected.
bool CanGetSub(void) const
Check if it is safe to call GetSub method.
bool CanGetData(void) const
Check if it is safe to call GetData method.
static CStopWatch sw
static void text(MDB_val *v)
Definition: mdb_dump.c:62
range(_Ty, _Ty) -> range< _Ty >
mdb_mode_t mode
Definition: lmdb++.h:38
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Defines: CTimeFormat - storage class for time format.
static Format format
Definition: njn_ioutil.cpp:53
#define NCBI_BIOMOL(Type)
CMolInfo definitions.
Definition: seq_macros.hpp:110
#define FOR_EACH_SEQDESC_ON_BIOSEQ(Itr, Var)
FOR_EACH_SEQDESC_ON_BIOSEQ EDIT_EACH_SEQDESC_ON_BIOSEQ.
Definition: seq_macros.hpp:218
#define FOR_EACH_SEQID_ON_BIOSEQ(Itr, Var)
FOR_EACH_SEQID_ON_BIOSEQ EDIT_EACH_SEQID_ON_BIOSEQ.
Definition: seq_macros.hpp:308
#define FOR_EACH_SEQFEAT_ON_SEQANNOT(Itr, Var)
FOR_EACH_SEQFEAT_ON_SEQANNOT EDIT_EACH_SEQFEAT_ON_SEQANNOT.
Definition: seq_macros.hpp:410
#define NCBI_SEQID(Type)
@NAME Convenience macros for NCBI objects
#define FIELD_IS_SET_AND_IS(Var, Fld, Chs)
FIELD_IS_SET_AND_IS base macro.
#define GET_FIELD(Var, Fld)
GET_FIELD base macro.
static const char * str(char *buf, int n)
Definition: stats.c:84
SAnnotSelector –.
CNcbiOstream * m_Or
CNcbiOstream * m_On
CNcbiOstream * m_Os
CNcbiOstream * m_Op
CNcbiOstream * m_Ou
CNcbiOstream * m_Og
Definition: type.c:6
#define _ASSERT
#define const
Definition: zconf.h:230
Modified on Thu Sep 28 03:39:18 2023 by modify_doxy.py rev. 669887