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

Go to the SVN repository for this file.

1 /* $Id: defline_item.cpp 96393 2022-03-23 16:47:41Z kans $
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, NCBI
27 *
28 * File Description:
29 * flat-file generator -- defline item implementation
30 *
31 */
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 
35 #include <objmgr/util/sequence.hpp>
37 
42 #include <objmgr/util/objutil.hpp>
43 #include <objmgr/seqdesc_ci.hpp>
44 
45 
48 
49 
51  CFlatItem(&ctx)
52 {
53  x_GatherInfo(ctx);
54 }
55 
57 {
58  return eItem_Defline;
59 }
60 
62 (IFormatter& formatter,
63  IFlatTextOStream& text_os) const
64 
65 {
66  formatter.FormatDefline(*this, text_os);
67 }
68 
69 
70 const string& CDeflineItem::GetDefline(void) const
71 {
72  return m_Defline;
73 }
74 
75 
76 /***************************************************************************/
77 /* PRIVATE */
78 /***************************************************************************/
79 
80 
82 {
83 
84  sequence::CDeflineGenerator Defliner;
85  CConstRef<CBioseq> bioseq = ctx.GetHandle().GetBioseqCore();
86  CScope& scope = ctx.GetScope();
87  sequence::CDeflineGenerator::TUserFlags flags = 0;
88  if ( ctx.Config().DoNotUseAutoDef() ) {
89  flags |= sequence::CDeflineGenerator::fDoNotUseAutoDef;
90  }
91  if ( ctx.Config().IgnoreExistingTitle() ) {
92  flags |= sequence::CDeflineGenerator::fIgnoreExisting;
93  }
94  if ( ctx.Config().ShowDeflineModifiers() ) {
95  flags |= sequence::CDeflineGenerator::fShowModifiers;
96  }
97  if ( ctx.UsingSeqEntryIndex() ) {
98  CRef<CSeqEntryIndex> idx = ctx.GetSeqEntryIndex();
99  CBioseq_Handle bsh = scope.GetBioseqHandle(*bioseq);
100  m_Defline = Defliner.GenerateDefline( bsh, *idx, flags );
101  } else {
102  m_Defline = Defliner.GenerateDefline( *bioseq, scope, flags );
103  }
104  if (! Defliner.UsePDBCompoundForDefline()) {
105  ctx.SetPDBCompoundForComment(true);
106  }
107  if ( ctx.Config().ShowDeflineModifiers() ) {
109  } else {
111  }
114  CSeqdesc_CI di(ctx.GetHandle(), CSeqdesc::e_Title);
115  if (di) {
116  x_SetObject(*di);
117  }
118 }
119 
120 
CBioseq_Handle –.
void x_GatherInfo(CBioseqContext &ctx) override
string m_Defline
EItem GetItemType() const override
const string & GetDefline(void) const
void Format(IFormatter &formatter, IFlatTextOStream &text_os) const override
void x_SetObject(const CSerialObject &obj)
Definition: item_base.hpp:160
CScope –.
Definition: scope.hpp:92
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
@ eItem_Defline
Definition: item.hpp:62
virtual void FormatDefline(const CDeflineItem &defline, IFlatTextOStream &text_os)=0
Include a standard set of the NCBI C++ Toolkit most basic headers.
API (CDeflineGenerator) for computing sequences' titles ("definitions").
static uch flags
CS_CONTEXT * ctx
Definition: t0006.c:12
#define CompressSpaces
Definition: ncbistr.hpp:343
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
#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
@ e_Title
a title for this sequence
Definition: Seqdesc_.hpp:115
void AddPeriod(string &str)
Definition: objutil.cpp:377
void CleanAndCompress(string &dest, const CTempString &instr)
Definition: objutil.cpp:823
void ConvertQuotes(string &str)
Definition: objutil.cpp:240
Modified on Sat Dec 02 09:21:57 2023 by modify_doxy.py rev. 669887