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

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_FORMAT_ITEMS___REFERENCE_ITEM__HPP
2 #define OBJTOOLS_FORMAT_ITEMS___REFERENCE_ITEM__HPP
3 
4 /* $Id: reference_item.hpp 99549 2023-04-17 14:20:00Z gotvyans $
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 * Author: Aaron Ucko, NCBI
30 * Mati Shomrat
31 *
32 * File Description:
33 * Reference item for flat-file generator
34 *
35 */
36 #include <corelib/ncbistd.hpp>
38 #include <objects/seq/Pubdesc.hpp>
39 
41 
42 
45 
46 class CSubmit_block;
47 class CSeq_loc;
48 class CSeq_feat;
49 class CAuth_list;
50 class CCit_art;
51 class CCit_gen;
52 class CCit_jour;
53 class CCit_let;
54 class CCit_pat;
55 class CCit_proc;
56 class CCit_sub;
57 class CMedline_entry;
58 class CPub;
59 class CPub_set;
60 class CDate;
61 class CAffil;
62 class CBioseqContext;
63 class IFormatter;
64 
65 
67 {
68 public:
69  // types
70  typedef vector<string>* TCache;
71 
72  CCacheItem(CBioseqContext& ctx, TCache csh, int length, bool is_prot);
73  void Format(IFormatter& formatter, IFlatTextOStream& text_os) const override;
74 
75  const TCache& GetCache(void) const { return m_Cache; }
76  int GetLength(void) const { return m_Length; }
77  bool IsProt(void) const { return m_IsProt; }
78 
79  EItem GetItemType() const override;
80 private:
81 
82  // data
84  int m_Length;
85  bool m_IsProt;
86 };
87 
88 
90 {
91 public:
92  enum ECategory {
93  eUnknown, // none of the below
94  ePublished, // published paper
95  eUnpublished, // unpublished paper
96  eSubmission // direct submission
97  };
98 
99  enum EPubType
100  {
108  ePub_pat
109  };
110 
113  typedef vector< CRef<CReferenceItem> > TReferences;
114  typedef list<string> TStrList;
115  typedef int TSeqid;
117 
118  /// constructors
119  CReferenceItem(const CSeqdesc& desc, CBioseqContext& ctx);
121  const CSeq_loc* loc = nullptr);
123 
124  /// destructor
125  ~CReferenceItem();
126 
127  /// format
128  void Format(IFormatter& formatter, IFlatTextOStream& text_os) const override;
129 
130  TPubType GetPubType (void) const { return m_PubType; }
131  TCategory GetCategory (void) const { return m_Category; }
132  const CPubdesc& GetPubdesc (void) const { return *m_Pubdesc; }
133  TReftype GetReftype (void) const;
134  const CSeq_loc& GetLoc (void) const { return *m_Loc; }
135  int GetSerial (void) const { return m_Serial; }
136 
137  // Date
138  bool IsSetDate (void) const { return m_Date.NotEmpty(); }
139  const CDate& GetDate (void) const { return *m_Date; }
140  //Authors
141  bool IsSetAuthors (void) const { return m_Authors.NotEmpty(); }
142  const CAuth_list& GetAuthors (void) const { return *m_Authors; }
143 
144  bool IsSetBook (void) const { return m_Book.NotEmpty(); }
145  const CCit_book& GetBook (void) const { return *m_Book; }
146 
147  bool IsSetPatent (void) const { return m_Patent.NotEmpty(); }
148  const CCit_pat& GetPatent (void) const { return *m_Patent; }
149  TSeqid GetPatSeqid (void) const { return m_PatentId; }
150 
151  bool IsSetGen (void) const { return m_Gen.NotEmpty(); }
152  const CCit_gen& GetGen (void) const { return *m_Gen; }
153 
154  bool IsSetSub (void) const { return m_Sub.NotEmpty(); }
155  const CCit_sub& GetSub (void) const { return *m_Sub; }
156 
157  bool IsSetJournal (void) const { return m_Journal.NotEmpty(); }
158  const CCit_jour& GetJournal (void) const { return *m_Journal; }
159 
160  TEntrezId GetPMID (void) const { return m_PMID; }
161  TEntrezId GetMUID (void) const { return m_MUID; }
162  const string& GetDOI (void) const { return m_DOI; }
163  const string& GetPII (void) const { return m_ELocationPII; }
164  const string& GetOldPII (void) const { return m_OldPII; }
165 
166  const string& GetTitle (void) const { return m_Title; }
167 
168  const string& GetUniqueStr (void) const;
169 
170  bool IsJustUids (void) const { return m_JustUids; }
171  bool IsElectronic (void) const { return m_Elect; }
172  const string& GetConsortium(void) const { return m_Consortium; }
173  const string& GetRemark (void) const { return m_Remark; }
174 
175  void SetLoc(const CConstRef<CSeq_loc>& loc);
176  void SetRemark( const CPubdesc::TFig* new_fig,
177  const CPubdesc::TMaploc *new_maploc,
178  const CPubdesc::TPoly_a *new_poly_a );
179 
180  // test if matches publication(s)
181  bool Matches(const CPub_set& ps) const;
182  bool Matches(const CPub& pub) const;
183 
184  // sort, merge duplicates and cleans up remaining items
185  static void Rearrange(TReferences& refs, CBioseqContext& ctx);
186  // get names from authors list
187  static void GetAuthNames(const CAuth_list& alp, TStrList& authors);
188  // format author list
189  static void FormatAuthors(const CAuth_list& alp, string& auth);
190  // format affiliation
191  static void FormatAffil(const CAffil& affil, string& result, bool gen_sub = false);
192 
193  static void ChangeMedlineAuthorsToISO(CRef<CPub> pub);
194 
195  EItem GetItemType() const override;
196 private:
197 
200 
201  void x_GatherInfo(CBioseqContext& ctx) override;
202  void x_Init(const CPub& pub, CBioseqContext& ctx);
203  void x_Init(const CCit_gen& gen, CBioseqContext& ctx);
204  void x_Init(const CCit_sub& sub, CBioseqContext& ctx);
205  void x_Init(const CMedline_entry& mle, CBioseqContext& ctx);
206  void x_Init(const CCit_art& art, CBioseqContext& ctx);
207  void x_Init(const CCit_jour& jour, CBioseqContext& ctx);
208  void x_Init(const CCit_book& book, CBioseqContext& ctx);
209  void x_Init(const CCit_pat& pat, CBioseqContext& ctx);
210  void x_Init(const CCit_let& man, CBioseqContext& ctx);
211  void x_Init(const CCit_proc& proc, CBioseqContext& ctx);
212  void x_InitProc(const CCit_book& book, CBioseqContext& ctx);
213 
214  void x_AddAuthors(const CAuth_list& auth);
215  void x_AddImprint(const CImprint& imp, CBioseqContext& ctx);
216 
217  // Genbank format specific
218  void x_GatherRemark(CBioseqContext& ctx);
219 
220  void x_CreateUniqueStr(void) const;
221  void x_CleanData(void);
222  void x_CapitalizeTitleIfNecessary(void);
223 
224  // data
239  string m_DOI;
241  string m_OldPII;
242  int m_Serial;
243  mutable string m_UniqueStr;
245  string m_Title;
246  bool m_Elect;
247  string m_Consortium;
248  string m_Remark; // genbank specific
249 };
250 
251 
252 ///////////////////////////////////////////////////////////////////////////
253 //
254 // INLINE METHODS
255 
256 inline
257 const string& CReferenceItem::GetUniqueStr(void) const
258 {
259  // supress creation if other identifiers exist.
262  }
263  return m_UniqueStr;
264 }
265 
266 
267 inline
269 {
271 }
272 
273 /*
274 inline string CReferenceItem::x_GetURL(int id)
275 {
276  return "http://www.ncbi.nlm.nih.gov/entrez/utils/qmap.cgi?uid="
277  + NStr::IntToString(id) + "&form=6&db=m&Dopt=r";
278 }
279 */
282 
283 #endif /* OBJTOOLS_FORMAT_ITEMS___REFERENCE_ITEM__HPP */
@Affil.hpp User-defined methods of the data storage class.
Definition: Affil.hpp:56
@Auth_list.hpp User-defined methods of the data storage class.
Definition: Auth_list.hpp:57
vector< string > * TCache
const TCache & GetCache(void) const
bool IsProt(void) const
int GetLength(void) const
Definition: Date.hpp:53
virtual void Format(IFormatter &formatter, IFlatTextOStream &text_os) const =0
virtual void x_GatherInfo(CBioseqContext &)
Definition: item_base.hpp:71
CImprint –.
Definition: Imprint.hpp:66
Definition: Pub.hpp:56
@Pubdesc.hpp User-defined methods of the data storage class.
Definition: Pubdesc.hpp:54
bool IsSetSub(void) const
CConstRef< CSeq_loc > m_Loc
TPubType GetPubType(void) const
TSeqid GetPatSeqid(void) const
CConstRef< CPubdesc > m_Pubdesc
TEntrezId GetMUID(void) const
CConstRef< CDate > m_Date
CReferenceItem(const CReferenceItem &value)
const string & GetTitle(void) const
bool IsSetJournal(void) const
void x_CreateUniqueStr(void) const
bool IsSetBook(void) const
const CCit_gen & GetGen(void) const
const CCit_pat & GetPatent(void) const
list< string > TStrList
CConstRef< CCit_gen > m_Gen
CConstRef< CCit_sub > m_Sub
const string & GetPII(void) const
const string & GetRemark(void) const
const CCit_sub & GetSub(void) const
const string & GetUniqueStr(void) const
const string & GetOldPII(void) const
CConstRef< CCit_book > m_Book
int GetSerial(void) const
TEntrezId GetPMID(void) const
const CCit_book & GetBook(void) const
vector< CRef< CReferenceItem > > TReferences
TCategory GetCategory(void) const
CReferenceItem & operator=(const CReferenceItem &value)
TReftype GetReftype(void) const
const CAuth_list & GetAuthors(void) const
bool IsSetGen(void) const
const CCit_jour & GetJournal(void) const
const CPubdesc & GetPubdesc(void) const
CConstRef< CCit_pat > m_Patent
CConstRef< CCit_jour > m_Journal
CConstRef< CAuth_list > m_Authors
bool IsSetPatent(void) const
bool IsJustUids(void) const
bool IsSetDate(void) const
const CSeq_loc & GetLoc(void) const
CPubdesc::TReftype TReftype
const CDate & GetDate(void) const
TCategory m_Category
const string & GetDOI(void) const
const string & GetConsortium(void) const
bool IsElectronic(void) const
bool IsSetAuthors(void) const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSubmit_block –.
virtual EItem GetItemType(void) const =0
Definition: sls_alp.hpp:92
Include a standard set of the NCBI C++ Toolkit most basic headers.
CS_CONTEXT * ctx
Definition: t0006.c:12
static const char * proc
Definition: stats.c:21
SStrictId_Entrez::TId TEntrezId
TEntrezId type for entrez ids which require the same strictness as TGi.
Definition: ncbimisc.hpp:1041
#define ZERO_ENTREZ_ID
Definition: ncbimisc.hpp:1102
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
#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 NCBI_FORMAT_EXPORT
Definition: ncbi_export.h:496
TReftype GetReftype(void) const
Get the Reftype member data.
Definition: Pubdesc_.hpp:1045
string TMaploc
Definition: Pubdesc_.hpp:108
@ eReftype_seq
refers to sequence
Definition: Pubdesc_.hpp:92
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
else result
Definition: token2.c:20
Modified on Wed Sep 04 14:59:45 2024 by modify_doxy.py rev. 669887