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 101501 2023-12-20 18:34:00Z 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  fGeoLocNameCountry = 1 << 21
208  };
209 
210  enum EView {
211  // determines which Bioseqs in an entry to view
212  fViewNucleotides = 0x1,
213  fViewProteins = 0x2,
214  fViewAll = (fViewNucleotides | fViewProteins),
215  fViewFirst = 0x4
216  };
217 
218  enum EPolicy {
219  // far feature fetch policy
220  ePolicy_Adaptive = 0,
221  ePolicy_Internal = 1,
222  ePolicy_External = 2,
223  ePolicy_Exhaustive = 3,
224  ePolicy_Ftp = 4,
225  ePolicy_Web = 5,
226  ePolicy_Genomes = 6
227  };
228 
229  // These flags are used to select the GenBank sections to print or skip.
231  // default is all sections
232  fGenbankBlocks_All = (~0u),
233  fGenbankBlocks_None = 0,
234 
235  // or, specify individual sections to print.
236  // or, specify individual sections to skip
237  // (via (fGenbankBlocks_All & ~fGenbankBlocks_Locus), for example)
238  // Note that these flags do NOT have a one-to-one relationship
239  // with the notify() functions in CGenbankBlockCallback.
240  // For example, fGenbankBlocks_FeatAndGap is used to turn
241  // on both the CFeatureItem and CGapItem notify functions.
242  fGenbankBlocks_Head = (1u << 0),
243  fGenbankBlocks_Locus = (1u << 1),
244  fGenbankBlocks_Defline = (1u << 2),
245  fGenbankBlocks_Accession = (1u << 3),
246  fGenbankBlocks_Version = (1u << 4),
247  fGenbankBlocks_Project = (1u << 5),
248  fGenbankBlocks_Dbsource = (1u << 6),
249  fGenbankBlocks_Keywords = (1u << 7),
250  fGenbankBlocks_Segment = (1u << 8),
251  fGenbankBlocks_Source = (1u << 9),
252  fGenbankBlocks_Reference = (1u << 10),
253  fGenbankBlocks_Comment = (1u << 11),
254  fGenbankBlocks_Primary = (1u << 12),
255  fGenbankBlocks_Featheader = (1u << 13),
256  fGenbankBlocks_Sourcefeat = (1u << 14),
257  fGenbankBlocks_FeatAndGap = (1u << 15),
258  fGenbankBlocks_Basecount = (1u << 16),
259  fGenbankBlocks_Origin = (1u << 17),
260  fGenbankBlocks_Sequence = (1u << 18),
261  fGenbankBlocks_Contig = (1u << 19),
262  fGenbankBlocks_Wgs = (1u << 20),
263  fGenbankBlocks_Tsa = (1u << 21),
264  fGenbankBlocks_Slash = (1u << 22),
265  fGenbankBlocks_Cache = (1u << 23)
266  };
267 
268  // types
269  typedef EFormat TFormat;
270  typedef EMode TMode;
271  typedef EStyle TStyle;
272  typedef EPolicy TPolicy;
273  typedef unsigned int TFlags; // binary OR of "EFlags"
274  typedef unsigned int TView;
275  typedef unsigned int TGenbankBlocks;
276  typedef unsigned int TCustom; // binary OR of "ECustom"
277 
279  public:
280  enum EAction {
281  /// the normal case
283  /// skip this block (i.e. don't print it)
285  /// If for some reason you don't want the rest of the flatfile generated,
286  /// this will trigger a CFlatException of type eHaltRequested
287  eAction_HaltFlatfileGeneration
288  };
289 
290  enum EBioseqSkip {
292  eBioseqSkip_Yes
293  };
294 
295  virtual ~CGenbankBlockCallback(void) { }
296 
297  // It is intentional that CBioseqContext is non-const here,
298  // but const in the other notify functions.
299  virtual EBioseqSkip notify_bioseq( CBioseqContext& ctx );
300 
301  // please note that these notify functions let you change the block_text
302  virtual EAction notify( string & block_text,
303  const CBioseqContext& ctx,
304  const CStartSectionItem & head_item );
305  virtual EAction notify( string & block_text,
306  const CBioseqContext& ctx,
307  const CHtmlAnchorItem & anchor_item );
308  virtual EAction notify( string & block_text,
309  const CBioseqContext& ctx,
310  const CLocusItem &locus_item );
311  virtual EAction notify( string & block_text,
312  const CBioseqContext& ctx,
313  const CDeflineItem & defline_item );
314  virtual EAction notify( string & block_text,
315  const CBioseqContext& ctx,
316  const CAccessionItem & accession_item );
317  virtual EAction notify( string & block_text,
318  const CBioseqContext& ctx,
319  const CVersionItem & version_item );
320  virtual EAction notify( string & block_text,
321  const CBioseqContext& ctx,
322  const CGenomeProjectItem & project_item );
323  virtual EAction notify( string & block_text,
324  const CBioseqContext& ctx,
325  const CDBSourceItem & dbsource_item );
326  virtual EAction notify( string & block_text,
327  const CBioseqContext& ctx,
328  const CKeywordsItem & keywords_item );
329  virtual EAction notify( string & block_text,
330  const CBioseqContext& ctx,
331  const CSegmentItem & segment_item );
332  virtual EAction notify( string & block_text,
333  const CBioseqContext& ctx,
334  const CSourceItem & source_item );
335  virtual EAction notify( string & block_text,
336  const CBioseqContext& ctx,
337  const CReferenceItem & ref_item );
338  virtual EAction notify( string & block_text,
339  const CBioseqContext& ctx,
340  const CCacheItem & cache_item );
341  virtual EAction notify( string & block_text,
342  const CBioseqContext& ctx,
343  const CCommentItem & comment_item );
344  virtual EAction notify( string & block_text,
345  const CBioseqContext& ctx,
346  const CPrimaryItem & primary_item );
347  virtual EAction notify( string & block_text,
348  const CBioseqContext& ctx,
349  const CFeatHeaderItem & featheader_item );
350  virtual EAction notify( string & block_text,
351  const CBioseqContext& ctx,
352  const CSourceFeatureItem & sourcefeat_item );
353  virtual EAction notify( string & block_text,
354  const CBioseqContext& ctx,
355  const CFeatureItem & feature_item );
356  virtual EAction notify( string & block_text,
357  const CBioseqContext& ctx,
358  const CGapItem & feature_item );
359  virtual EAction notify( string & block_text,
360  const CBioseqContext& ctx,
361  const CBaseCountItem & basecount_item );
362  virtual EAction notify( string & block_text,
363  const CBioseqContext& ctx,
364  const COriginItem & origin_item );
365  virtual EAction notify( string & block_text,
366  const CBioseqContext& ctx,
367  const CSequenceItem & sequence_chunk_item );
368  virtual EAction notify( string & block_text,
369  const CBioseqContext& ctx,
370  const CContigItem & contig_item );
371  virtual EAction notify( string & block_text,
372  const CBioseqContext& ctx,
373  const CWGSItem & wgs_item );
374  virtual EAction notify( string & block_text,
375  const CBioseqContext& ctx,
376  const CTSAItem & tsa_item );
377  virtual EAction notify( string & block_text,
378  const CBioseqContext& ctx,
379  const CEndSectionItem & slash_item );
380 
381  // add more overridable functions if more blocks are invented
382 
383 
384  // ...or override
385  // this if you want only a single entry-point for
386  // notifications.
388  string & /*block_text*/,
389  const CBioseqContext& /*ctx*/,
390  const IFlatItem & /*flat_item*/,
391  FGenbankBlocks /*which_block*/ ) { return eAction_Default; }
392  };
393 
394  // constructor
395  CFlatFileConfig(TFormat format = eFormat_GenBank,
396  TMode mode = eMode_GBench,
397  TStyle style = eStyle_Normal,
398  TFlags flags = 0,
399  TView view = fViewNucleotides,
400  TPolicy policy = ePolicy_Adaptive,
401  TCustom custom = 0);
402 
403  // destructor
404  ~CFlatFileConfig(void);
405 
407  {
408  m_html_formatter = html_fmt;
409  }
411  {
412  return *m_html_formatter;
413  }
414 
415  // -- Format
416  // getters
417  const TFormat& GetFormat(void) const { return m_Format; }
418  bool IsFormatGenbank(void) const { return m_Format == eFormat_GenBank; }
419  bool IsFormatEMBL (void) const { return m_Format == eFormat_EMBL; }
420  bool IsFormatDDBJ (void) const { return m_Format == eFormat_DDBJ; }
421  bool IsFormatGBSeq (void) const { return m_Format == eFormat_GBSeq; }
422  bool IsFormatINSDSeq(void) const { return m_Format == eFormat_INSDSeq; }
423  bool IsFormatFTable (void) const { return m_Format == eFormat_FTable; }
424  bool IsFormatAGP (void) const { return m_Format == eFormat_AGP; }
425  bool IsFormatLite (void) const { return m_Format == eFormat_Lite; }
426 
427  // setters
428  void SetFormat(const TFormat& format) { m_Format = format; }
429  void SetFormatGenbank(void) { m_Format = eFormat_GenBank; }
430  void SetFormatEMBL (void) { m_Format = eFormat_EMBL; }
431  void SetFormatDDBJ (void) { m_Format = eFormat_DDBJ; }
432  void SetFormatGBSeq (void) { m_Format = eFormat_GBSeq; }
433  void SetFormatINSDSeq(void) { m_Format = eFormat_INSDSeq; }
434  void SetFormatFTable (void) { m_Format = eFormat_FTable; }
435  void SetFormatAGP (void) { m_Format = eFormat_AGP; }
436  void SetFormatLite (void) { m_Format = eFormat_Lite; }
437 
438  // -- Mode
439  // getters
440  const TMode& GetMode(void) const { return m_Mode; }
441  bool IsModeRelease(void) const { return m_Mode == eMode_Release; }
442  bool IsModeEntrez (void) const { return m_Mode == eMode_Entrez; }
443  bool IsModeGBench (void) const { return m_Mode == eMode_GBench; }
444  bool IsModeDump (void) const { return m_Mode == eMode_Dump; }
445  // setters
446  void SetMode(const TMode& mode) { m_Mode = mode; }
447  void SetModeRelease(void) { m_Mode = eMode_Release; }
448  void SetModeEntrez (void) { m_Mode = eMode_Entrez; }
449  void SetModeGBench (void) { m_Mode = eMode_GBench; }
450  void SetModeDump (void) { m_Mode = eMode_Dump; }
451 
452  // -- Style
453  // getters
454  const TStyle& GetStyle(void) const { return m_Style; }
455  bool IsStyleNormal (void) const { return m_Style == eStyle_Normal; }
456  bool IsStyleSegment(void) const { return m_Style == eStyle_Segment; }
457  bool IsStyleMaster (void) const { return m_Style == eStyle_Master; }
458  bool IsStyleContig (void) const { return m_Style == eStyle_Contig; }
459  // setters
460  void SetStyle(const TStyle& style) { m_Style = style; }
461  void SetStyleNormal (void) { m_Style = eStyle_Normal; }
462  void SetStyleSegment(void) { m_Style = eStyle_Segment; }
463  void SetStyleMaster (void) { m_Style = eStyle_Master; }
464  void SetStyleContig (void) { m_Style = eStyle_Contig; }
465 
466  // -- View
467  // getters
468  const TView& GetView(void) const { return m_View; }
469  bool IsViewNuc (void) const { return (m_View & fViewNucleotides) != 0; }
470  bool IsViewProt(void) const { return (m_View & fViewProteins) != 0; }
471  bool IsViewAll (void) const { return IsViewNuc() && IsViewProt(); }
472  bool IsViewFirst (void) const { return (m_View & fViewFirst) != 0; }
473  // setters
474  void SetView(const TView& view) { m_View = view; }
475  inline void SetViewNuc (void)
476  {
477  m_View = (m_View & ~fViewAll) | fViewNucleotides;
478  }
479  inline void SetViewProt (void)
480  {
481  m_View = (m_View & ~fViewAll) | fViewProteins;
482  }
483  inline void SetViewAll (void)
484  {
485  m_View |= fViewAll;
486  }
487  inline void SetViewFirst (bool enabled)
488  {
489  if (enabled) {
490  m_View |= fViewFirst;
491  } else {
492  m_View &= ~fViewFirst;
493  }
494  }
495 
496  // -- Policy
497  // getters
498  const TPolicy& GetPolicy(void) const { return m_Policy; }
499  bool IsPolicyAdaptive (void) const { return m_Policy == ePolicy_Adaptive; }
500  bool IsPolicyInternal(void) const { return m_Policy == ePolicy_Internal; }
501  bool IsPolicyExternal (void) const { return m_Policy == ePolicy_External; }
502  bool IsPolicyExhaustive (void) const { return m_Policy == ePolicy_Exhaustive; }
503  bool IsPolicyFtp (void) const { return m_Policy == ePolicy_Ftp; }
504  bool IsPolicyWeb (void) const { return m_Policy == ePolicy_Web; }
505  bool IsPolicyGenomes (void) const { return m_Policy == ePolicy_Genomes; }
506  // setters
507  void SetPolicy(const TPolicy& Policy) { m_Policy = Policy; }
508  void SetPolicyAdaptive (void) { m_Policy = ePolicy_Adaptive; }
509  void SetPolicyInternal(void) { m_Policy = ePolicy_Internal; }
510  void SetPolicyExternal (void) { m_Policy = ePolicy_External; }
511  void SetPolicyExhaustive (void) { m_Policy = ePolicy_Exhaustive; }
512  void SetPolicyFtp (void) { m_Policy = ePolicy_Ftp; }
513  void SetPolicyWeb (void) { m_Policy = ePolicy_Web; }
514  void SetPolicyGenomes (void) { m_Policy = ePolicy_Genomes; }
515 
516  // -- Flags
517  // getters
518  const TFlags& GetFlags(void) const { return m_Flags; }
519  // customizable flags
520  bool DoHTML (void) const;
521  bool HideImpFeatures (void) const;
522  bool HideSNPFeatures (void) const;
523  bool HideExonFeatures (void) const;
524  bool HideIntronFeatures (void) const;
525  bool HideMiscFeatures (void) const;
526  bool HideRemoteImpFeatures (void) const;
527  bool HideGeneRIFs (void) const;
528  bool OnlyGeneRIFs (void) const;
529  bool HideCDSProdFeatures (void) const;
530  bool HideCDDFeatures (void) const;
531  bool LatestGeneRIFs (void) const;
532  bool ShowContigFeatures (void) const;
533  bool ShowContigSources (void) const;
534  bool ShowContigAndSeq (void) const;
535  bool CopyGeneToCDNA (void) const;
536  bool ShowContigInMaster (void) const;
537  bool CopyCDSFromCDNA (void) const;
538  bool HideSourceFeatures (void) const;
539  bool AlwaysTranslateCDS (void) const;
540  bool OnlyNearFeatures (void) const;
541  bool FavorFarFeatures (void) const;
542  bool ShowFarTranslations (void) const;
543  bool TranslateIfNoProduct (void) const;
544  bool ShowTranscript (void) const;
545  bool ShowPeptides (void) const;
546  bool ShowFtableRefs (void) const;
547  bool OldFeaturesOrder (void) const;
548  bool HideGapFeatures (void) const;
549  bool NeverTranslateCDS (void) const;
550  bool ShowSeqSpans (void) const;
551  // mode dependant flags
552  bool SuppressLocalId (void) const;
553  bool ValidateFeatures (void) const;
554  bool IgnorePatPubs (void) const;
555  bool DropShortAA (void) const;
556  bool AvoidLocusColl (void) const;
557  bool IupacaaOnly (void) const;
558  bool DropBadCitGens (void) const;
559  bool NoAffilOnUnpub (void) const;
560  bool DropIllegalQuals (void) const;
561  bool CheckQualSyntax (void) const;
562  bool NeedRequiredQuals (void) const;
563  bool NeedOrganismQual (void) const;
564  bool NeedAtLeastOneRef (void) const;
565  bool CitArtIsoJta (void) const;
566  bool DropBadDbxref (void) const;
567  bool UseEmblMolType (void) const;
568  bool HideBankItComment (void) const;
569  bool CheckCDSProductId (void) const;
570  bool FrequencyToNote (void) const;
571  bool SrcQualsToNote (void) const;
572  bool HideEmptySource (void) const;
573  bool GoQualsToNote (void) const;
574  bool SelenocysteineToNote(void) const;
575  bool ForGBRelease (void) const;
576  bool HideUnclassPartial (void) const;
577  bool CodonRecognizedToNote(void) const;
578  bool GoQualsEachMerge (void) const;
579  bool ShowOutOfBoundsFeats(void) const;
580  bool HideSpecificGeneMaps(void) const;
581 
582  // setters (for customization flags)
583  void SetFlags(const TFlags& flags) { m_Flags = flags; }
584  CFlatFileConfig& SetDoHTML (bool val = true);
585  CFlatFileConfig& SetHideImpFeatures (bool val = true);
586  CFlatFileConfig& SetHideSNPFeatures (bool val = true);
587  CFlatFileConfig& SetHideExonFeatures (bool val = true);
588  CFlatFileConfig& SetHideIntronFeatures (bool val = true);
589  CFlatFileConfig& SetHideMiscFeatures (bool val = true);
590  CFlatFileConfig& SetHideRemoteImpFeatures(bool val = true);
591  CFlatFileConfig& SetHideGeneRIFs (bool val = true);
592  CFlatFileConfig& SetOnlyGeneRIFs (bool val = true);
593  CFlatFileConfig& SetHideCDSProdFeatures (bool val = true);
594  CFlatFileConfig& SetHideCDDFeatures (bool val = true);
595  CFlatFileConfig& SetLatestGeneRIFs (bool val = true);
596  CFlatFileConfig& SetShowContigFeatures (bool val = true);
597  CFlatFileConfig& SetShowContigSources (bool val = true);
598  CFlatFileConfig& SetShowContigAndSeq (bool val = true);
599  CFlatFileConfig& SetCopyGeneToCDNA (bool val = true);
600  CFlatFileConfig& SetShowContigInMaster (bool val = true);
601  CFlatFileConfig& SetCopyCDSFromCDNA (bool val = true);
602  CFlatFileConfig& SetHideSourceFeatures (bool val = true);
603  CFlatFileConfig& SetAlwaysTranslateCDS (bool val = true);
604  CFlatFileConfig& SetOnlyNearFeatures (bool val = true);
605  CFlatFileConfig& SetFavorFarFeatures (bool val = true);
606  CFlatFileConfig& SetShowFarTranslations (bool val = true);
607  CFlatFileConfig& SetTranslateIfNoProduct (bool val = true);
608  CFlatFileConfig& SetShowTranscript (bool val = true);
609  CFlatFileConfig& SetShowPeptides (bool val = true);
610  CFlatFileConfig& SetShowFtableRefs (bool val = true);
611  CFlatFileConfig& SetOldFeaturesOrder (bool val = true);
612  CFlatFileConfig& SetHideGapFeatures (bool val = true);
613  CFlatFileConfig& SetNeverTranslateCDS (bool val = true);
614  CFlatFileConfig& SetShowSeqSpans (bool val = true);
615 
616  // -- Custom
617  // getters
618  const TCustom& GetCustom(void) const { return m_Custom; }
619  bool HideProteinID (void) const;
620  bool HideGI (void) const;
621  bool LongLocusNames (void) const;
622  bool ExpandGaps (void) const;
623  bool ShowSNPFeatures (void) const;
624  bool ShowCDDFeatures (void) const;
625  bool ShowDebugTiming (void) const;
626  bool FasterReleaseSets (void) const;
627  bool DisableAnnotRefs (void) const;
628  bool UseSeqEntryIndexer (void) const;
629  bool UseAutoDef (void) const;
630  bool IgnoreExistingTitle (void) const;
631  bool GeneRNACDSFeatures (void) const;
632  bool ShowFtablePeptides (void) const;
633  bool DisableReferenceCache (void) const;
634  bool ShowDeflineModifiers (void) const;
635  bool DoNotUseAutoDef (void) const;
636  bool OldTpaDisplay (void) const;
637  bool DisableDefaultIndex (void) const;
638  bool GeoLocNameCountry (void) const;
639 
640  // setters
641  void SetCustom(const TCustom& custom) { m_Custom = custom; }
642  CFlatFileConfig& SetHideProteinID (bool val = true);
643  CFlatFileConfig& SetHideGI (bool val = true);
644  CFlatFileConfig& SetLongLocusNames (bool val = true);
645  CFlatFileConfig& SetExpandGaps (bool val = true);
646  CFlatFileConfig& SetShowSNPFeatures (bool val = true);
647  CFlatFileConfig& SetShowCDDFeatures (bool val = true);
648  CFlatFileConfig& SetShowDebugTiming (bool val = true);
649  CFlatFileConfig& SetFasterReleaseSets (bool val = true);
650  CFlatFileConfig& SetDisableAnnotRefs (bool val = true);
651  CFlatFileConfig& SetUseSeqEntryIndexer (bool val = true);
652  CFlatFileConfig& SetUseAutoDef (bool val = true);
653  CFlatFileConfig& SetIgnoreExistingTitle (bool val = true);
654  CFlatFileConfig& SetGeneRNACDSFeatures (bool val = true);
655  CFlatFileConfig& SetShowFtablePeptides (bool val = true);
656  CFlatFileConfig& SetDisableReferenceCache (bool val = true);
657  CFlatFileConfig& SetShowDeflineModifiers (bool val = true);
658  CFlatFileConfig& SetDoNotUseAutoDef (bool val = true);
659  CFlatFileConfig& SetOldTpaDisplay (bool val = true);
660  CFlatFileConfig& SetDisableDefaultIndex (bool val = true);
661  CFlatFileConfig& SetGeoLocNameCountry (bool val = true);
662 
663  // adjust mode dependant flags for RefSeq
664  void SetRefSeqConventions(void);
665 
666  // -- Single Accession filter
667  void SetSingleAccession(const string& accn) { m_SingleAccession = accn; }
668  const string& GetSingleAccession(void) const { return m_SingleAccession; }
669 
670  int GetFeatDepth(void) const { return m_FeatDepth; }
671  void SetFeatDepth(const int featDepth) { m_FeatDepth = featDepth; }
672 
673  int GetGapDepth(void) const { return m_GapDepth; }
674  void SetGapDepth(const int gapDepth) { m_GapDepth = gapDepth; }
675 
676 
677  void SetGenbankBlocks(const TGenbankBlocks& genbank_blocks)
678  {
679  m_fGenbankBlocks = genbank_blocks;
680  };
681 
682  // check if the given section is shown
683  bool IsShownGenbankBlock(FGenbankBlocks fTGenbankBlocksMask) const
684  {
685  return m_fGenbankBlocks & fTGenbankBlocksMask;
686  }
687 
688  // set the given section to be shown
689  void ShowGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
690  {
691  m_fGenbankBlocks |= (fTGenbankBlocksMask);
692  }
693 
694  // set the given section to be skipped
695  // (that is, not shown or even processed)
696  void SkipGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
697  {
698  m_fGenbankBlocks &= (~fTGenbankBlocksMask);
699  }
700 
701  // throws on error
702  static FGenbankBlocks StringToGenbankBlock(const string & str);
703  // returns the set of all possible genbank strings
704  // "head, "locus", etc. Guaranteed to be sorted.
705  static const vector<string> & GetAllGenbankStrings(void);
706 
707  // return non-const callback even if the CFlatFileConfig is const
709  return m_GenbankBlockCallback; }
710  void SetGenbankBlockCallback(CGenbankBlockCallback* pGenbankBlockCallback) {
711  m_GenbankBlockCallback = pGenbankBlockCallback;
712  }
713 
714  const ICanceled * GetCanceledCallback(void) const {
715  return m_pCanceledCallback;
716  }
717  void SetCanceledCallback(ICanceled * pCallback) {
718  m_pCanceledCallback = pCallback;
719  }
720 
721  // -- BasicCleanup
722  // getters
723  bool BasicCleanup(void) const { return m_BasicCleanup; }
724  // setters
725  void BasicCleanup(bool clean) { m_BasicCleanup = clean; }
726 
727  /// This throws a CFlatException if
728  /// flatfile generation cancellation has been requested via ICanceled.
729  void ThrowIfCanceled(void) const {
730  if( m_pCanceledCallback && m_pCanceledCallback->IsCanceled() ) {
731  // halt requested, so throw the appropriate exception
732  x_ThrowHaltNow();
733  }
734  }
735 
736  // options to share between applications related to flatfile
737  static void AddArgumentDescriptions(CArgDescriptions& args);
738  void FromArguments(const CArgs& args);
739 
740 public:
741  static const size_t SMARTFEATLIMIT = 1000000;
742 
743 private:
744  // mode specific flags
745  static const bool sm_ModeFlags[4][32];
746 
747  void x_ThrowHaltNow(void) const;
748 
749  // data
753  TFlags m_Flags; // custom flags
759  const ICanceled * m_pCanceledCallback; // instance does NOT own it
766 };
767 
768 
769 /////////////////////////////////////////////////////////////////////////////
770 // inilne methods
771 
772 // custom flags
773 #define FLAG_ARG_GET(x) \
774 inline \
775 bool CFlatFileConfig::x(void) const \
776 { \
777  return (m_Flags & f##x) != 0; \
778 }
779 
780 #define FLAG_ARG_SET(x) inline \
781 CFlatFileConfig& CFlatFileConfig::Set##x(bool val) \
782 { \
783  if ( val ) { \
784  m_Flags |= f##x; \
785  } else { \
786  m_Flags &= ~f##x; \
787  } \
788  return *this; \
789 }
790 
791 #define FLAG_ARG_IMP(x) \
792 FLAG_ARG_GET(x) \
793 FLAG_ARG_SET(x)
794 
796 FLAG_ARG_IMP(HideImpFeatures)
797 FLAG_ARG_IMP(HideSNPFeatures)
798 FLAG_ARG_IMP(HideExonFeatures)
799 FLAG_ARG_IMP(HideIntronFeatures)
800 FLAG_ARG_IMP(HideMiscFeatures)
801 FLAG_ARG_IMP(HideRemoteImpFeatures)
802 FLAG_ARG_IMP(HideGeneRIFs)
803 FLAG_ARG_IMP(OnlyGeneRIFs)
804 FLAG_ARG_IMP(HideCDSProdFeatures)
805 FLAG_ARG_IMP(HideCDDFeatures)
806 FLAG_ARG_IMP(LatestGeneRIFs)
807 FLAG_ARG_IMP(ShowContigFeatures)
808 FLAG_ARG_IMP(ShowContigSources)
809 FLAG_ARG_IMP(ShowContigAndSeq)
810 FLAG_ARG_IMP(CopyGeneToCDNA)
811 FLAG_ARG_IMP(ShowContigInMaster)
812 FLAG_ARG_IMP(CopyCDSFromCDNA)
813 FLAG_ARG_IMP(HideSourceFeatures)
814 FLAG_ARG_IMP(AlwaysTranslateCDS)
815 FLAG_ARG_IMP(OnlyNearFeatures)
816 FLAG_ARG_IMP(FavorFarFeatures)
817 FLAG_ARG_IMP(ShowFarTranslations)
818 FLAG_ARG_IMP(TranslateIfNoProduct)
819 FLAG_ARG_IMP(ShowTranscript)
820 FLAG_ARG_IMP(ShowPeptides)
821 FLAG_ARG_IMP(ShowFtableRefs)
822 FLAG_ARG_IMP(OldFeaturesOrder)
823 FLAG_ARG_IMP(HideGapFeatures)
824 FLAG_ARG_IMP(NeverTranslateCDS)
825 FLAG_ARG_IMP(ShowSeqSpans)
826 
827 // custom flags
828 #define CUSTOM_ARG_GET(x) \
829 inline \
830 bool CFlatFileConfig::x(void) const \
831 { \
832  return (m_Custom & f##x) != 0; \
833 }
834 
835 #define CUSTOM_ARG_SET(x) inline \
836 CFlatFileConfig& CFlatFileConfig::Set##x(bool val) \
837 { \
838  if ( val ) { \
839  m_Custom |= f##x; \
840  } else { \
841  m_Custom &= ~f##x; \
842  } \
843  return *this; \
844 }
845 
846 #define CUSTOM_ARG_IMP(x) \
847 CUSTOM_ARG_GET(x) \
848 CUSTOM_ARG_SET(x)
849 
850 CUSTOM_ARG_IMP(HideProteinID)
852 CUSTOM_ARG_IMP(LongLocusNames)
853 CUSTOM_ARG_IMP(ExpandGaps)
854 CUSTOM_ARG_IMP(ShowSNPFeatures)
855 CUSTOM_ARG_IMP(ShowCDDFeatures)
856 CUSTOM_ARG_IMP(ShowDebugTiming)
857 CUSTOM_ARG_IMP(FasterReleaseSets)
858 CUSTOM_ARG_IMP(DisableAnnotRefs)
859 CUSTOM_ARG_IMP(UseSeqEntryIndexer)
860 CUSTOM_ARG_IMP(UseAutoDef)
861 CUSTOM_ARG_IMP(IgnoreExistingTitle)
862 CUSTOM_ARG_IMP(GeneRNACDSFeatures)
863 CUSTOM_ARG_IMP(ShowFtablePeptides)
864 CUSTOM_ARG_IMP(DisableReferenceCache)
865 CUSTOM_ARG_IMP(ShowDeflineModifiers)
866 CUSTOM_ARG_IMP(DoNotUseAutoDef)
867 CUSTOM_ARG_IMP(OldTpaDisplay)
868 CUSTOM_ARG_IMP(DisableDefaultIndex)
869 CUSTOM_ARG_IMP(GeoLocNameCountry)
870 
871 #undef FLAG_ARG_IMP
872 #undef FLAG_ARG_GET
873 #undef FLAG_ARG_SET
874 
875 #undef CUSTOM_ARG_IMP
876 #undef CUSTOM_ARG_GET
877 #undef CUSTOM_ARG_SET
878 
879 inline
881 {
882  m_RefSeqConventions = true;
883 }
884 
885 // end of inline methods
886 /////////////////////////////////////////////////////////////////////////////
887 
890 
891 #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
#define CUSTOM_ARG_IMP(x)
#define FLAG_ARG_IMP(x)
CS_CONTEXT * ctx
Definition: t0006.c:12
static const char * str(char *buf, int n)
Definition: stats.c:84
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
Modified on Fri Sep 20 14:58:12 2024 by modify_doxy.py rev. 669887