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

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_FORMAT___FLAT_FILE_CONFIG__HPP
2 #define OBJTOOLS_FORMAT___FLAT_FILE_CONFIG__HPP
3 
4 /* $Id: flat_file_config.hpp 99504 2023-04-10 15:10:28Z kans $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Mati Shomrat, NCBI
30  *
31  * File Description:
32  * Configuration class for flat-file generator
33  */
34 #include <corelib/ncbistd.hpp>
35 #include <corelib/ncbiobj.hpp>
36 
37 #include <util/icanceled.hpp>
38 
40 
41 class CArgDescriptions;
42 class CArgs;
43 
45 
46 class CBioseqContext;
47 class CStartSectionItem;
48 class CHtmlAnchorItem;
49 class CLocusItem;
50 class CDeflineItem;
51 class CAccessionItem;
52 class CVersionItem;
53 class CGenomeProjectItem;
54 class CDBSourceItem;
55 class CKeywordsItem;
56 class CSegmentItem;
57 class CSourceItem;
58 class CReferenceItem;
59 class CCacheItem;
60 class CCommentItem;
61 class CPrimaryItem;
62 class CFeatHeaderItem;
63 class CSourceFeatureItem;
64 class CFeatureItem;
65 class CGapItem;
66 class CBaseCountItem;
67 class COriginItem;
68 class CSequenceItem;
69 class CContigItem;
70 class CWGSItem;
71 class CTSAItem;
72 class CEndSectionItem;
73 class IFlatItem;
74 class CSeq_id;
75 class CSeq_loc;
76 struct SModelEvidance;
77 
78 // --- Flat File configuration class
79 
81 {
82 public:
83  virtual ~IHTMLFormatter() {}
84 
85  virtual void FormatProteinId(string& str, const CSeq_id& seq_id, const string& prot_id) const = 0;
86  virtual void FormatTranscriptId(string& str, const CSeq_id& seq_id, const string& nuc_id) const = 0;
87  virtual void FormatNucSearch(CNcbiOstream& os, const string& id) const = 0;
88  virtual void FormatNucId(string& str, const CSeq_id& seq_id, TIntId gi, const string& acc_id) const = 0;
89  virtual void FormatTaxid(string& str, const TTaxId taxid, const string& taxname) const = 0;
90  virtual void FormatLocation(string& str, const CSeq_loc& loc, TIntId gi, const string& visible_text) const = 0;
91  virtual void FormatModelEvidence(string& str, const SModelEvidance& me) const = 0;
92  virtual void FormatTranscript(string& str, const string& name) const = 0;
93  virtual void FormatGeneralId(CNcbiOstream& os, const string& id) const = 0;
94  virtual void FormatGapLink(CNcbiOstream& os, TSeqPos gap_size, const string& id, bool is_prot) const = 0;
95  virtual void FormatUniProtId(string& str, const string& prot_id) const = 0;
96 };
97 
99 {
100 public:
101  ~CHTMLEmptyFormatter() override {}
102 
103  void FormatProteinId(string& str, const CSeq_id& seq_id, const string& prot_id) const override;
104  void FormatTranscriptId(string& str, const CSeq_id& seq_id, const string& nuc_id) const override;
105  void FormatNucSearch(CNcbiOstream& os, const string& id) const override;
106  void FormatNucId(string& str, const CSeq_id& seq_id, TIntId gi, const string& acc_id) const override;
107  void FormatTaxid(string& str, const TTaxId taxid, const string& taxname) const override;
108  void FormatLocation(string& str, const CSeq_loc& loc, TIntId gi, const string& visible_text) const override;
109  void FormatModelEvidence(string& str, const SModelEvidance& me) const override;
110  void FormatTranscript(string& str, const string& name) const override;
111  void FormatGeneralId(CNcbiOstream& os, const string& id) const override;
112  void FormatGapLink(CNcbiOstream& os, TSeqPos gap_size, const string& id, bool is_prot) const override;
113  void FormatUniProtId(string& str, const string& prot_id) const override;
114 };
115 
117 {
118 public:
119 
120  enum EFormat {
121  // formatting styles
131  eFormat_Lite
132  };
133 
134  enum EMode {
135  // determines the tradeoff between strictness and completeness
136  eMode_Release = 0, // strict -- for official public releases
137  eMode_Entrez, // somewhat laxer -- for CGIs
138  eMode_GBench, // even laxer -- for editing submissions
139  eMode_Dump // shows everything, regardless of validity
140  };
141 
142 
143  enum EStyle {
144  // determines handling of segmented records
145  eStyle_Normal, // default -- show segments iff they're near
146  eStyle_Segment, // always show segments
147  eStyle_Master, // merge segments into a single virtual record
148  eStyle_Contig // just an index of segments -- no actual sequence
149  };
150 
151  enum EFlags {
152  // customization flags
153  fDoHTML = 1,
154  fShowContigFeatures = 1 << 1, // not just source features
155  fShowContigSources = 1 << 2, // not just focus
156  fShowFarTranslations = 1 << 3,
157  fTranslateIfNoProduct = 1 << 4,
158  fAlwaysTranslateCDS = 1 << 5,
159  fOnlyNearFeatures = 1 << 6,
160  fFavorFarFeatures = 1 << 7, // ignore near feats on segs w/far feats
161  fCopyCDSFromCDNA = 1 << 8, // for gen-prod sets
162  fCopyGeneToCDNA = 1 << 9, // for gen-prod sets
163  fShowContigInMaster = 1 << 10,
164  fHideImpFeatures = 1 << 11,
165  fHideRemoteImpFeatures = 1 << 12,
166  fHideSNPFeatures = 1 << 13,
167  fHideExonFeatures = 1 << 14,
168  fHideIntronFeatures = 1 << 15,
169  fHideMiscFeatures = 1 << 16,
170  fHideCDSProdFeatures = 1 << 17,
171  fHideCDDFeatures = 1 << 18,
172  fShowTranscript = 1 << 19,
173  fShowPeptides = 1 << 20,
174  fHideGeneRIFs = 1 << 21,
175  fOnlyGeneRIFs = 1 << 22,
176  fLatestGeneRIFs = 1 << 23,
177  fShowContigAndSeq = 1 << 24,
178  fHideSourceFeatures = 1 << 25,
179  fShowFtableRefs = 1 << 26,
180  fOldFeaturesOrder = 1 << 27,
181  fHideGapFeatures = 1 << 28,
182  fNeverTranslateCDS = 1 << 29,
183  fShowSeqSpans = 1 << 30
184  };
185 
186  enum ECustom {
187  // additional customization flags
188  fHideProteinID = 1,
189  fHideGI = 1 << 1,
190  fLongLocusNames = 1 << 2,
191  fExpandGaps = 1 << 3,
192  fShowSNPFeatures = 1 << 6,
193  fShowCDDFeatures = 1 << 7,
194  fShowDebugTiming = 1 << 8,
195  fFasterReleaseSets = 1 << 9,
196  fDisableAnnotRefs = 1 << 10,
197  fUseSeqEntryIndexer = 1 << 11,
198  fUseAutoDef = 1 << 12,
199  fIgnoreExistingTitle = 1 << 13,
200  fGeneRNACDSFeatures = 1 << 14,
201  fShowFtablePeptides = 1 << 15,
202  fDisableReferenceCache = 1 << 16,
203  fShowDeflineModifiers = 1 << 17,
204  fDoNotUseAutoDef = 1 << 18,
205  fOldTpaDisplay = 1 << 19,
206  fDisableDefaultIndex = 1 << 20
207  };
208 
209  enum EView {
210  // determines which Bioseqs in an entry to view
211  fViewNucleotides = 0x1,
212  fViewProteins = 0x2,
213  fViewAll = (fViewNucleotides | fViewProteins),
214  fViewFirst = 0x4
215  };
216 
217  enum EPolicy {
218  // far feature fetch policy
219  ePolicy_Adaptive = 0,
220  ePolicy_Internal = 1,
221  ePolicy_External = 2,
222  ePolicy_Exhaustive = 3,
223  ePolicy_Ftp = 4,
224  ePolicy_Web = 5,
225  ePolicy_Genomes = 6
226  };
227 
228  // These flags are used to select the GenBank sections to print or skip.
230  // default is all sections
231  fGenbankBlocks_All = (~0u),
232  fGenbankBlocks_None = 0,
233 
234  // or, specify individual sections to print.
235  // or, specify individual sections to skip
236  // (via (fGenbankBlocks_All & ~fGenbankBlocks_Locus), for example)
237  // Note that these flags do NOT have a one-to-one relationship
238  // with the notify() functions in CGenbankBlockCallback.
239  // For example, fGenbankBlocks_FeatAndGap is used to turn
240  // on both the CFeatureItem and CGapItem notify functions.
241  fGenbankBlocks_Head = (1u << 0),
242  fGenbankBlocks_Locus = (1u << 1),
243  fGenbankBlocks_Defline = (1u << 2),
244  fGenbankBlocks_Accession = (1u << 3),
245  fGenbankBlocks_Version = (1u << 4),
246  fGenbankBlocks_Project = (1u << 5),
247  fGenbankBlocks_Dbsource = (1u << 6),
248  fGenbankBlocks_Keywords = (1u << 7),
249  fGenbankBlocks_Segment = (1u << 8),
250  fGenbankBlocks_Source = (1u << 9),
251  fGenbankBlocks_Reference = (1u << 10),
252  fGenbankBlocks_Comment = (1u << 11),
253  fGenbankBlocks_Primary = (1u << 12),
254  fGenbankBlocks_Featheader = (1u << 13),
255  fGenbankBlocks_Sourcefeat = (1u << 14),
256  fGenbankBlocks_FeatAndGap = (1u << 15),
257  fGenbankBlocks_Basecount = (1u << 16),
258  fGenbankBlocks_Origin = (1u << 17),
259  fGenbankBlocks_Sequence = (1u << 18),
260  fGenbankBlocks_Contig = (1u << 19),
261  fGenbankBlocks_Wgs = (1u << 20),
262  fGenbankBlocks_Tsa = (1u << 21),
263  fGenbankBlocks_Slash = (1u << 22),
264  fGenbankBlocks_Cache = (1u << 23)
265  };
266 
267  // types
268  typedef EFormat TFormat;
269  typedef EMode TMode;
270  typedef EStyle TStyle;
271  typedef EPolicy TPolicy;
272  typedef unsigned int TFlags; // binary OR of "EFlags"
273  typedef unsigned int TView;
274  typedef unsigned int TGenbankBlocks;
275  typedef unsigned int TCustom; // binary OR of "ECustom"
276 
278  public:
279  enum EAction {
280  /// the normal case
282  /// skip this block (i.e. don't print it)
284  /// If for some reason you don't want the rest of the flatfile generated,
285  /// this will trigger a CFlatException of type eHaltRequested
286  eAction_HaltFlatfileGeneration
287  };
288 
289  enum EBioseqSkip {
291  eBioseqSkip_Yes
292  };
293 
294  virtual ~CGenbankBlockCallback(void) { }
295 
296  // It is intentional that CBioseqContext is non-const here,
297  // but const in the other notify functions.
298  virtual EBioseqSkip notify_bioseq( CBioseqContext& ctx );
299 
300  // please note that these notify functions let you change the block_text
301  virtual EAction notify( string & block_text,
302  const CBioseqContext& ctx,
303  const CStartSectionItem & head_item );
304  virtual EAction notify( string & block_text,
305  const CBioseqContext& ctx,
306  const CHtmlAnchorItem & anchor_item );
307  virtual EAction notify( string & block_text,
308  const CBioseqContext& ctx,
309  const CLocusItem &locus_item );
310  virtual EAction notify( string & block_text,
311  const CBioseqContext& ctx,
312  const CDeflineItem & defline_item );
313  virtual EAction notify( string & block_text,
314  const CBioseqContext& ctx,
315  const CAccessionItem & accession_item );
316  virtual EAction notify( string & block_text,
317  const CBioseqContext& ctx,
318  const CVersionItem & version_item );
319  virtual EAction notify( string & block_text,
320  const CBioseqContext& ctx,
321  const CGenomeProjectItem & project_item );
322  virtual EAction notify( string & block_text,
323  const CBioseqContext& ctx,
324  const CDBSourceItem & dbsource_item );
325  virtual EAction notify( string & block_text,
326  const CBioseqContext& ctx,
327  const CKeywordsItem & keywords_item );
328  virtual EAction notify( string & block_text,
329  const CBioseqContext& ctx,
330  const CSegmentItem & segment_item );
331  virtual EAction notify( string & block_text,
332  const CBioseqContext& ctx,
333  const CSourceItem & source_item );
334  virtual EAction notify( string & block_text,
335  const CBioseqContext& ctx,
336  const CReferenceItem & ref_item );
337  virtual EAction notify( string & block_text,
338  const CBioseqContext& ctx,
339  const CCacheItem & cache_item );
340  virtual EAction notify( string & block_text,
341  const CBioseqContext& ctx,
342  const CCommentItem & comment_item );
343  virtual EAction notify( string & block_text,
344  const CBioseqContext& ctx,
345  const CPrimaryItem & primary_item );
346  virtual EAction notify( string & block_text,
347  const CBioseqContext& ctx,
348  const CFeatHeaderItem & featheader_item );
349  virtual EAction notify( string & block_text,
350  const CBioseqContext& ctx,
351  const CSourceFeatureItem & sourcefeat_item );
352  virtual EAction notify( string & block_text,
353  const CBioseqContext& ctx,
354  const CFeatureItem & feature_item );
355  virtual EAction notify( string & block_text,
356  const CBioseqContext& ctx,
357  const CGapItem & feature_item );
358  virtual EAction notify( string & block_text,
359  const CBioseqContext& ctx,
360  const CBaseCountItem & basecount_item );
361  virtual EAction notify( string & block_text,
362  const CBioseqContext& ctx,
363  const COriginItem & origin_item );
364  virtual EAction notify( string & block_text,
365  const CBioseqContext& ctx,
366  const CSequenceItem & sequence_chunk_item );
367  virtual EAction notify( string & block_text,
368  const CBioseqContext& ctx,
369  const CContigItem & contig_item );
370  virtual EAction notify( string & block_text,
371  const CBioseqContext& ctx,
372  const CWGSItem & wgs_item );
373  virtual EAction notify( string & block_text,
374  const CBioseqContext& ctx,
375  const CTSAItem & tsa_item );
376  virtual EAction notify( string & block_text,
377  const CBioseqContext& ctx,
378  const CEndSectionItem & slash_item );
379 
380  // add more overridable functions if more blocks are invented
381 
382 
383  // ...or override
384  // this if you want only a single entry-point for
385  // notifications.
387  string & /*block_text*/,
388  const CBioseqContext& /*ctx*/,
389  const IFlatItem & /*flat_item*/,
390  FGenbankBlocks /*which_block*/ ) { return eAction_Default; }
391  };
392 
393  // constructor
394  CFlatFileConfig(TFormat format = eFormat_GenBank,
395  TMode mode = eMode_GBench,
396  TStyle style = eStyle_Normal,
397  TFlags flags = 0,
398  TView view = fViewNucleotides,
399  TPolicy policy = ePolicy_Adaptive,
400  TCustom custom = 0);
401 
402  // destructor
403  ~CFlatFileConfig(void);
404 
406  {
407  m_html_formatter = html_fmt;
408  }
410  {
411  return *m_html_formatter;
412  }
413 
414  // -- Format
415  // getters
416  const TFormat& GetFormat(void) const { return m_Format; }
417  bool IsFormatGenbank(void) const { return m_Format == eFormat_GenBank; }
418  bool IsFormatEMBL (void) const { return m_Format == eFormat_EMBL; }
419  bool IsFormatDDBJ (void) const { return m_Format == eFormat_DDBJ; }
420  bool IsFormatGBSeq (void) const { return m_Format == eFormat_GBSeq; }
421  bool IsFormatINSDSeq(void) const { return m_Format == eFormat_INSDSeq; }
422  bool IsFormatFTable (void) const { return m_Format == eFormat_FTable; }
423  bool IsFormatAGP (void) const { return m_Format == eFormat_AGP; }
424  bool IsFormatLite (void) const { return m_Format == eFormat_Lite; }
425 
426  // setters
427  void SetFormat(const TFormat& format) { m_Format = format; }
428  void SetFormatGenbank(void) { m_Format = eFormat_GenBank; }
429  void SetFormatEMBL (void) { m_Format = eFormat_EMBL; }
430  void SetFormatDDBJ (void) { m_Format = eFormat_DDBJ; }
431  void SetFormatGBSeq (void) { m_Format = eFormat_GBSeq; }
432  void SetFormatINSDSeq(void) { m_Format = eFormat_INSDSeq; }
433  void SetFormatFTable (void) { m_Format = eFormat_FTable; }
434  void SetFormatAGP (void) { m_Format = eFormat_AGP; }
435  void SetFormatLite (void) { m_Format = eFormat_Lite; }
436 
437  // -- Mode
438  // getters
439  const TMode& GetMode(void) const { return m_Mode; }
440  bool IsModeRelease(void) const { return m_Mode == eMode_Release; }
441  bool IsModeEntrez (void) const { return m_Mode == eMode_Entrez; }
442  bool IsModeGBench (void) const { return m_Mode == eMode_GBench; }
443  bool IsModeDump (void) const { return m_Mode == eMode_Dump; }
444  // setters
445  void SetMode(const TMode& mode) { m_Mode = mode; }
446  void SetModeRelease(void) { m_Mode = eMode_Release; }
447  void SetModeEntrez (void) { m_Mode = eMode_Entrez; }
448  void SetModeGBench (void) { m_Mode = eMode_GBench; }
449  void SetModeDump (void) { m_Mode = eMode_Dump; }
450 
451  // -- Style
452  // getters
453  const TStyle& GetStyle(void) const { return m_Style; }
454  bool IsStyleNormal (void) const { return m_Style == eStyle_Normal; }
455  bool IsStyleSegment(void) const { return m_Style == eStyle_Segment; }
456  bool IsStyleMaster (void) const { return m_Style == eStyle_Master; }
457  bool IsStyleContig (void) const { return m_Style == eStyle_Contig; }
458  // setters
459  void SetStyle(const TStyle& style) { m_Style = style; }
460  void SetStyleNormal (void) { m_Style = eStyle_Normal; }
461  void SetStyleSegment(void) { m_Style = eStyle_Segment; }
462  void SetStyleMaster (void) { m_Style = eStyle_Master; }
463  void SetStyleContig (void) { m_Style = eStyle_Contig; }
464 
465  // -- View
466  // getters
467  const TView& GetView(void) const { return m_View; }
468  bool IsViewNuc (void) const { return (m_View & fViewNucleotides) != 0; }
469  bool IsViewProt(void) const { return (m_View & fViewProteins) != 0; }
470  bool IsViewAll (void) const { return IsViewNuc() && IsViewProt(); }
471  bool IsViewFirst (void) const { return (m_View & fViewFirst) != 0; }
472  // setters
473  void SetView(const TView& view) { m_View = view; }
474  inline void SetViewNuc (void)
475  {
476  m_View = (m_View & ~fViewAll) | fViewNucleotides;
477  }
478  inline void SetViewProt (void)
479  {
480  m_View = (m_View & ~fViewAll) | fViewProteins;
481  }
482  inline void SetViewAll (void)
483  {
484  m_View |= fViewAll;
485  }
486  inline void SetViewFirst (bool enabled)
487  {
488  if (enabled) {
489  m_View |= fViewFirst;
490  } else {
491  m_View &= ~fViewFirst;
492  }
493  }
494 
495  // -- Policy
496  // getters
497  const TPolicy& GetPolicy(void) const { return m_Policy; }
498  bool IsPolicyAdaptive (void) const { return m_Policy == ePolicy_Adaptive; }
499  bool IsPolicyInternal(void) const { return m_Policy == ePolicy_Internal; }
500  bool IsPolicyExternal (void) const { return m_Policy == ePolicy_External; }
501  bool IsPolicyExhaustive (void) const { return m_Policy == ePolicy_Exhaustive; }
502  bool IsPolicyFtp (void) const { return m_Policy == ePolicy_Ftp; }
503  bool IsPolicyWeb (void) const { return m_Policy == ePolicy_Web; }
504  bool IsPolicyGenomes (void) const { return m_Policy == ePolicy_Genomes; }
505  // setters
506  void SetPolicy(const TPolicy& Policy) { m_Policy = Policy; }
507  void SetPolicyAdaptive (void) { m_Policy = ePolicy_Adaptive; }
508  void SetPolicyInternal(void) { m_Policy = ePolicy_Internal; }
509  void SetPolicyExternal (void) { m_Policy = ePolicy_External; }
510  void SetPolicyExhaustive (void) { m_Policy = ePolicy_Exhaustive; }
511  void SetPolicyFtp (void) { m_Policy = ePolicy_Ftp; }
512  void SetPolicyWeb (void) { m_Policy = ePolicy_Web; }
513  void SetPolicyGenomes (void) { m_Policy = ePolicy_Genomes; }
514 
515  // -- Flags
516  // getters
517  const TFlags& GetFlags(void) const { return m_Flags; }
518  // customizable flags
519  bool DoHTML (void) const;
520  bool HideImpFeatures (void) const;
521  bool HideSNPFeatures (void) const;
522  bool HideExonFeatures (void) const;
523  bool HideIntronFeatures (void) const;
524  bool HideMiscFeatures (void) const;
525  bool HideRemoteImpFeatures (void) const;
526  bool HideGeneRIFs (void) const;
527  bool OnlyGeneRIFs (void) const;
528  bool HideCDSProdFeatures (void) const;
529  bool HideCDDFeatures (void) const;
530  bool LatestGeneRIFs (void) const;
531  bool ShowContigFeatures (void) const;
532  bool ShowContigSources (void) const;
533  bool ShowContigAndSeq (void) const;
534  bool CopyGeneToCDNA (void) const;
535  bool ShowContigInMaster (void) const;
536  bool CopyCDSFromCDNA (void) const;
537  bool HideSourceFeatures (void) const;
538  bool AlwaysTranslateCDS (void) const;
539  bool OnlyNearFeatures (void) const;
540  bool FavorFarFeatures (void) const;
541  bool ShowFarTranslations (void) const;
542  bool TranslateIfNoProduct (void) const;
543  bool ShowTranscript (void) const;
544  bool ShowPeptides (void) const;
545  bool ShowFtableRefs (void) const;
546  bool OldFeaturesOrder (void) const;
547  bool HideGapFeatures (void) const;
548  bool NeverTranslateCDS (void) const;
549  bool ShowSeqSpans (void) const;
550  // mode dependant flags
551  bool SuppressLocalId (void) const;
552  bool ValidateFeatures (void) const;
553  bool IgnorePatPubs (void) const;
554  bool DropShortAA (void) const;
555  bool AvoidLocusColl (void) const;
556  bool IupacaaOnly (void) const;
557  bool DropBadCitGens (void) const;
558  bool NoAffilOnUnpub (void) const;
559  bool DropIllegalQuals (void) const;
560  bool CheckQualSyntax (void) const;
561  bool NeedRequiredQuals (void) const;
562  bool NeedOrganismQual (void) const;
563  bool NeedAtLeastOneRef (void) const;
564  bool CitArtIsoJta (void) const;
565  bool DropBadDbxref (void) const;
566  bool UseEmblMolType (void) const;
567  bool HideBankItComment (void) const;
568  bool CheckCDSProductId (void) const;
569  bool FrequencyToNote (void) const;
570  bool SrcQualsToNote (void) const;
571  bool HideEmptySource (void) const;
572  bool GoQualsToNote (void) const;
573  bool SelenocysteineToNote(void) const;
574  bool ForGBRelease (void) const;
575  bool HideUnclassPartial (void) const;
576  bool CodonRecognizedToNote(void) const;
577  bool GoQualsEachMerge (void) const;
578  bool ShowOutOfBoundsFeats(void) const;
579  bool HideSpecificGeneMaps(void) const;
580 
581  // setters (for customization flags)
582  void SetFlags(const TFlags& flags) { m_Flags = flags; }
583  CFlatFileConfig& SetDoHTML (bool val = true);
584  CFlatFileConfig& SetHideImpFeatures (bool val = true);
585  CFlatFileConfig& SetHideSNPFeatures (bool val = true);
586  CFlatFileConfig& SetHideExonFeatures (bool val = true);
587  CFlatFileConfig& SetHideIntronFeatures (bool val = true);
588  CFlatFileConfig& SetHideMiscFeatures (bool val = true);
589  CFlatFileConfig& SetHideRemoteImpFeatures(bool val = true);
590  CFlatFileConfig& SetHideGeneRIFs (bool val = true);
591  CFlatFileConfig& SetOnlyGeneRIFs (bool val = true);
592  CFlatFileConfig& SetHideCDSProdFeatures (bool val = true);
593  CFlatFileConfig& SetHideCDDFeatures (bool val = true);
594  CFlatFileConfig& SetLatestGeneRIFs (bool val = true);
595  CFlatFileConfig& SetShowContigFeatures (bool val = true);
596  CFlatFileConfig& SetShowContigSources (bool val = true);
597  CFlatFileConfig& SetShowContigAndSeq (bool val = true);
598  CFlatFileConfig& SetCopyGeneToCDNA (bool val = true);
599  CFlatFileConfig& SetShowContigInMaster (bool val = true);
600  CFlatFileConfig& SetCopyCDSFromCDNA (bool val = true);
601  CFlatFileConfig& SetHideSourceFeatures (bool val = true);
602  CFlatFileConfig& SetAlwaysTranslateCDS (bool val = true);
603  CFlatFileConfig& SetOnlyNearFeatures (bool val = true);
604  CFlatFileConfig& SetFavorFarFeatures (bool val = true);
605  CFlatFileConfig& SetShowFarTranslations (bool val = true);
606  CFlatFileConfig& SetTranslateIfNoProduct (bool val = true);
607  CFlatFileConfig& SetShowTranscript (bool val = true);
608  CFlatFileConfig& SetShowPeptides (bool val = true);
609  CFlatFileConfig& SetShowFtableRefs (bool val = true);
610  CFlatFileConfig& SetOldFeaturesOrder (bool val = true);
611  CFlatFileConfig& SetHideGapFeatures (bool val = true);
612  CFlatFileConfig& SetNeverTranslateCDS (bool val = true);
613  CFlatFileConfig& SetShowSeqSpans (bool val = true);
614 
615  // -- Custom
616  // getters
617  const TCustom& GetCustom(void) const { return m_Custom; }
618  bool HideProteinID (void) const;
619  bool HideGI (void) const;
620  bool LongLocusNames (void) const;
621  bool ExpandGaps (void) const;
622  bool ShowSNPFeatures (void) const;
623  bool ShowCDDFeatures (void) const;
624  bool ShowDebugTiming (void) const;
625  bool FasterReleaseSets (void) const;
626  bool DisableAnnotRefs (void) const;
627  bool UseSeqEntryIndexer (void) const;
628  bool UseAutoDef (void) const;
629  bool IgnoreExistingTitle (void) const;
630  bool GeneRNACDSFeatures (void) const;
631  bool ShowFtablePeptides (void) const;
632  bool DisableReferenceCache (void) const;
633  bool ShowDeflineModifiers (void) const;
634  bool DoNotUseAutoDef (void) const;
635  bool OldTpaDisplay (void) const;
636  bool DisableDefaultIndex (void) const;
637 
638  // setters
639  void SetCustom(const TCustom& custom) { m_Custom = custom; }
640  CFlatFileConfig& SetHideProteinID (bool val = true);
641  CFlatFileConfig& SetHideGI (bool val = true);
642  CFlatFileConfig& SetLongLocusNames (bool val = true);
643  CFlatFileConfig& SetExpandGaps (bool val = true);
644  CFlatFileConfig& SetShowSNPFeatures (bool val = true);
645  CFlatFileConfig& SetShowCDDFeatures (bool val = true);
646  CFlatFileConfig& SetShowDebugTiming (bool val = true);
647  CFlatFileConfig& SetFasterReleaseSets (bool val = true);
648  CFlatFileConfig& SetDisableAnnotRefs (bool val = true);
649  CFlatFileConfig& SetUseSeqEntryIndexer (bool val = true);
650  CFlatFileConfig& SetUseAutoDef (bool val = true);
651  CFlatFileConfig& SetIgnoreExistingTitle (bool val = true);
652  CFlatFileConfig& SetGeneRNACDSFeatures (bool val = true);
653  CFlatFileConfig& SetShowFtablePeptides (bool val = true);
654  CFlatFileConfig& SetDisableReferenceCache (bool val = true);
655  CFlatFileConfig& SetShowDeflineModifiers (bool val = true);
656  CFlatFileConfig& SetDoNotUseAutoDef (bool val = true);
657  CFlatFileConfig& SetOldTpaDisplay (bool val = true);
658  CFlatFileConfig& SetDisableDefaultIndex (bool val = true);
659 
660  // adjust mode dependant flags for RefSeq
661  void SetRefSeqConventions(void);
662 
663  // -- Single Accession filter
664  void SetSingleAccession(const string& accn) { m_SingleAccession = accn; }
665  const string& GetSingleAccession(void) const { return m_SingleAccession; }
666 
667  int GetFeatDepth(void) const { return m_FeatDepth; }
668  void SetFeatDepth(const int featDepth) { m_FeatDepth = featDepth; }
669 
670  int GetGapDepth(void) const { return m_GapDepth; }
671  void SetGapDepth(const int gapDepth) { m_GapDepth = gapDepth; }
672 
673 
674  void SetGenbankBlocks(const TGenbankBlocks& genbank_blocks)
675  {
676  m_fGenbankBlocks = genbank_blocks;
677  };
678 
679  // check if the given section is shown
680  bool IsShownGenbankBlock(FGenbankBlocks fTGenbankBlocksMask) const
681  {
682  return m_fGenbankBlocks & fTGenbankBlocksMask;
683  }
684 
685  // set the given section to be shown
686  void ShowGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
687  {
688  m_fGenbankBlocks |= (fTGenbankBlocksMask);
689  }
690 
691  // set the given section to be skipped
692  // (that is, not shown or even processed)
693  void SkipGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
694  {
695  m_fGenbankBlocks &= (~fTGenbankBlocksMask);
696  }
697 
698  // throws on error
699  static FGenbankBlocks StringToGenbankBlock(const string & str);
700  // returns the set of all possible genbank strings
701  // "head, "locus", etc. Guaranteed to be sorted.
702  static const vector<string> & GetAllGenbankStrings(void);
703 
704  // return non-const callback even if the CFlatFileConfig is const
706  return m_GenbankBlockCallback; }
707  void SetGenbankBlockCallback(CGenbankBlockCallback* pGenbankBlockCallback) {
708  m_GenbankBlockCallback = pGenbankBlockCallback;
709  }
710 
711  const ICanceled * GetCanceledCallback(void) const {
712  return m_pCanceledCallback;
713  }
714  void SetCanceledCallback(ICanceled * pCallback) {
715  m_pCanceledCallback = pCallback;
716  }
717 
718  // -- BasicCleanup
719  // getters
720  bool BasicCleanup(void) const { return m_BasicCleanup; }
721  // setters
722  void BasicCleanup(bool clean) { m_BasicCleanup = clean; }
723 
724  /// This throws a CFlatException if
725  /// flatfile generation cancellation has been requested via ICanceled.
726  void ThrowIfCanceled(void) const {
727  if( m_pCanceledCallback && m_pCanceledCallback->IsCanceled() ) {
728  // halt requested, so throw the appropriate exception
729  x_ThrowHaltNow();
730  }
731  }
732 
733  // options to share between applications related to flatfile
734  static void AddArgumentDescriptions(CArgDescriptions& args);
735  void FromArguments(const CArgs& args);
736 
737 public:
738  static const size_t SMARTFEATLIMIT = 1000000;
739 
740 private:
741  // mode specific flags
742  static const bool sm_ModeFlags[4][32];
743 
744  void x_ThrowHaltNow(void) const;
745 
746  // data
750  TFlags m_Flags; // custom flags
756  const ICanceled * m_pCanceledCallback; // instance does NOT own it
763 };
764 
765 
766 /////////////////////////////////////////////////////////////////////////////
767 // inilne methods
768 
769 // custom flags
770 #define FLAG_ARG_GET(x) \
771 inline \
772 bool CFlatFileConfig::x(void) const \
773 { \
774  return (m_Flags & f##x) != 0; \
775 }
776 
777 #define FLAG_ARG_SET(x) inline \
778 CFlatFileConfig& CFlatFileConfig::Set##x(bool val) \
779 { \
780  if ( val ) { \
781  m_Flags |= f##x; \
782  } else { \
783  m_Flags &= ~f##x; \
784  } \
785  return *this; \
786 }
787 
788 #define FLAG_ARG_IMP(x) \
789 FLAG_ARG_GET(x) \
790 FLAG_ARG_SET(x)
791 
793 FLAG_ARG_IMP(HideImpFeatures)
794 FLAG_ARG_IMP(HideSNPFeatures)
795 FLAG_ARG_IMP(HideExonFeatures)
796 FLAG_ARG_IMP(HideIntronFeatures)
797 FLAG_ARG_IMP(HideMiscFeatures)
798 FLAG_ARG_IMP(HideRemoteImpFeatures)
799 FLAG_ARG_IMP(HideGeneRIFs)
800 FLAG_ARG_IMP(OnlyGeneRIFs)
801 FLAG_ARG_IMP(HideCDSProdFeatures)
802 FLAG_ARG_IMP(HideCDDFeatures)
803 FLAG_ARG_IMP(LatestGeneRIFs)
804 FLAG_ARG_IMP(ShowContigFeatures)
805 FLAG_ARG_IMP(ShowContigSources)
806 FLAG_ARG_IMP(ShowContigAndSeq)
807 FLAG_ARG_IMP(CopyGeneToCDNA)
808 FLAG_ARG_IMP(ShowContigInMaster)
809 FLAG_ARG_IMP(CopyCDSFromCDNA)
810 FLAG_ARG_IMP(HideSourceFeatures)
811 FLAG_ARG_IMP(AlwaysTranslateCDS)
812 FLAG_ARG_IMP(OnlyNearFeatures)
813 FLAG_ARG_IMP(FavorFarFeatures)
814 FLAG_ARG_IMP(ShowFarTranslations)
815 FLAG_ARG_IMP(TranslateIfNoProduct)
816 FLAG_ARG_IMP(ShowTranscript)
817 FLAG_ARG_IMP(ShowPeptides)
818 FLAG_ARG_IMP(ShowFtableRefs)
819 FLAG_ARG_IMP(OldFeaturesOrder)
820 FLAG_ARG_IMP(HideGapFeatures)
821 FLAG_ARG_IMP(NeverTranslateCDS)
822 FLAG_ARG_IMP(ShowSeqSpans)
823 
824 // custom flags
825 #define CUSTOM_ARG_GET(x) \
826 inline \
827 bool CFlatFileConfig::x(void) const \
828 { \
829  return (m_Custom & f##x) != 0; \
830 }
831 
832 #define CUSTOM_ARG_SET(x) inline \
833 CFlatFileConfig& CFlatFileConfig::Set##x(bool val) \
834 { \
835  if ( val ) { \
836  m_Custom |= f##x; \
837  } else { \
838  m_Custom &= ~f##x; \
839  } \
840  return *this; \
841 }
842 
843 #define CUSTOM_ARG_IMP(x) \
844 CUSTOM_ARG_GET(x) \
845 CUSTOM_ARG_SET(x)
846 
847 CUSTOM_ARG_IMP(HideProteinID)
849 CUSTOM_ARG_IMP(LongLocusNames)
850 CUSTOM_ARG_IMP(ExpandGaps)
851 CUSTOM_ARG_IMP(ShowSNPFeatures)
852 CUSTOM_ARG_IMP(ShowCDDFeatures)
853 CUSTOM_ARG_IMP(ShowDebugTiming)
854 CUSTOM_ARG_IMP(FasterReleaseSets)
855 CUSTOM_ARG_IMP(DisableAnnotRefs)
856 CUSTOM_ARG_IMP(UseSeqEntryIndexer)
857 CUSTOM_ARG_IMP(UseAutoDef)
858 CUSTOM_ARG_IMP(IgnoreExistingTitle)
859 CUSTOM_ARG_IMP(GeneRNACDSFeatures)
860 CUSTOM_ARG_IMP(ShowFtablePeptides)
861 CUSTOM_ARG_IMP(DisableReferenceCache)
862 CUSTOM_ARG_IMP(ShowDeflineModifiers)
863 CUSTOM_ARG_IMP(DoNotUseAutoDef)
864 CUSTOM_ARG_IMP(OldTpaDisplay)
865 CUSTOM_ARG_IMP(DisableDefaultIndex)
866 
867 #undef FLAG_ARG_IMP
868 #undef FLAG_ARG_GET
869 #undef FLAG_ARG_SET
870 
871 #undef CUSTOM_ARG_IMP
872 #undef CUSTOM_ARG_GET
873 #undef CUSTOM_ARG_SET
874 
875 inline
877 {
878  m_RefSeqConventions = true;
879 }
880 
881 // end of inline methods
882 /////////////////////////////////////////////////////////////////////////////
883 
886 
887 #endif /* OBJTOOLS_FORMAT___FLAT_FILE_CONFIG__HPP */
CArgDescriptions –.
Definition: ncbiargs.hpp:541
CArgs –.
Definition: ncbiargs.hpp:379
@ eAction_Skip
skip this block (i.e. don't print it)
virtual EAction unified_notify(string &, const CBioseqContext &, const IFlatItem &, FGenbankBlocks)
bool IsFormatDDBJ(void) const
void SetFormatGenbank(void)
void SetFlags(const TFlags &flags)
const TCustom & GetCustom(void) const
void SetSingleAccession(const string &accn)
void SetStyleMaster(void)
void SkipGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
bool IsModeGBench(void) const
const TFormat & GetFormat(void) const
const TStyle & GetStyle(void) const
const IHTMLFormatter & GetHTMLFormatter() const
bool IsPolicyInternal(void) const
bool IsFormatGBSeq(void) const
const ICanceled * GetCanceledCallback(void) const
void SetFormatLite(void)
bool IsStyleSegment(void) const
bool IsPolicyExhaustive(void) const
bool IsPolicyExternal(void) const
void SetViewFirst(bool enabled)
void SetRefSeqConventions(void)
void SetPolicyGenomes(void)
void SetFeatDepth(const int featDepth)
const TMode & GetMode(void) const
void SetFormat(const TFormat &format)
void SetHTMLFormatter(CRef< IHTMLFormatter > html_fmt)
void BasicCleanup(bool clean)
bool IsPolicyAdaptive(void) const
void SetStyleNormal(void)
void SetCustom(const TCustom &custom)
void SetGapDepth(const int gapDepth)
void ShowGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
void SetGenbankBlocks(const TGenbankBlocks &genbank_blocks)
bool IsPolicyFtp(void) const
bool IsPolicyWeb(void) const
void SetPolicyInternal(void)
int GetGapDepth(void) const
void SetPolicyExternal(void)
bool IsViewNuc(void) const
bool IsViewFirst(void) const
bool IsStyleMaster(void) const
const ICanceled * m_pCanceledCallback
void SetPolicy(const TPolicy &Policy)
bool IsFormatINSDSeq(void) const
bool IsPolicyGenomes(void) const
bool IsFormatGenbank(void) const
void SetMode(const TMode &mode)
bool IsFormatFTable(void) const
const TPolicy & GetPolicy(void) const
void SetStyle(const TStyle &style)
int GetFeatDepth(void) const
void SetFormatINSDSeq(void)
void SetCanceledCallback(ICanceled *pCallback)
void SetModeGBench(void)
void SetGenbankBlockCallback(CGenbankBlockCallback *pGenbankBlockCallback)
TGenbankBlocks m_fGenbankBlocks
CRef< CGenbankBlockCallback > GetGenbankBlockCallback(void) const
void SetView(const TView &view)
bool IsViewAll(void) const
const string & GetSingleAccession(void) const
bool IsViewProt(void) const
void SetPolicyExhaustive(void)
void SetFormatEMBL(void)
CRef< CGenbankBlockCallback > m_GenbankBlockCallback
void SetStyleContig(void)
unsigned int TCustom
CRef< IHTMLFormatter > m_html_formatter
void ThrowIfCanceled(void) const
This throws a CFlatException if flatfile generation cancellation has been requested via ICanceled.
unsigned int TGenbankBlocks
const TFlags & GetFlags(void) const
bool IsModeRelease(void) const
bool BasicCleanup(void) const
bool IsFormatEMBL(void) const
bool IsModeDump(void) const
void SetModeEntrez(void)
bool IsModeEntrez(void) const
bool IsFormatLite(void) const
bool IsShownGenbankBlock(FGenbankBlocks fTGenbankBlocksMask) const
void SetPolicyAdaptive(void)
const TView & GetView(void) const
bool IsStyleNormal(void) const
bool IsStyleContig(void) const
void SetFormatDDBJ(void)
bool IsFormatAGP(void) const
void SetModeRelease(void)
void SetStyleSegment(void)
void SetFormatFTable(void)
void SetFormatGBSeq(void)
CObject –.
Definition: ncbiobj.hpp:180
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
virtual void FormatProteinId(string &str, const CSeq_id &seq_id, const string &prot_id) const =0
virtual void FormatModelEvidence(string &str, const SModelEvidance &me) const =0
virtual void FormatNucSearch(CNcbiOstream &os, const string &id) const =0
virtual void FormatNucId(string &str, const CSeq_id &seq_id, TIntId gi, const string &acc_id) const =0
virtual void FormatGeneralId(CNcbiOstream &os, const string &id) const =0
virtual void FormatTranscriptId(string &str, const CSeq_id &seq_id, const string &nuc_id) const =0
virtual void FormatLocation(string &str, const CSeq_loc &loc, TIntId gi, const string &visible_text) const =0
virtual void FormatUniProtId(string &str, const string &prot_id) const =0
virtual void FormatTranscript(string &str, const string &name) const =0
virtual void FormatGapLink(CNcbiOstream &os, TSeqPos gap_size, const string &id, bool is_prot) const =0
virtual void FormatTaxid(string &str, const TTaxId taxid, const string &taxname) const =0
virtual ~IHTMLFormatter()
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
CS_CONTEXT * ctx
Definition: t0006.c:12
#define CUSTOM_ARG_IMP(x)
#define FLAG_ARG_IMP(x)
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
Int8 TIntId
Definition: ncbimisc.hpp:999
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
#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
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define NCBI_FORMAT_EXPORT
Definition: ncbi_export.h:496
mdb_mode_t mode
Definition: lmdb++.h:38
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static Format format
Definition: njn_ioutil.cpp:53
static const char * str(char *buf, int n)
Definition: stats.c:84
Modified on Thu Dec 07 10:10:32 2023 by modify_doxy.py rev. 669887