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

Go to the SVN repository for this file.

1 /* $Id: global_pubmedid_lookup.cpp 47067 2022-06-29 15:20:07Z asztalos $
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  * Authors: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
34 
37 
38 CRef<CCmdComposite> CGlobalPubmedIdLookup::apply(objects::CSeq_entry_Handle tse)
39 {
40  if (!tse)
41  return CRef<CCmdComposite>(NULL);
42 
43  CRef<CCmdComposite> cmd( new CCmdComposite("Global PubmedId Lookup") );
44  bool modified = false;
45 
46  for (CSeq_entry_CI set_ci(tse, CSeq_entry_CI::fRecursive | CSeq_entry_CI::fIncludeGivenEntry); set_ci ; ++set_ci)
47  {
48  for (CSeqdesc_CI seqdesc(*set_ci, CSeqdesc::e_Pub, 1); seqdesc; ++seqdesc)
49  {
50 
51  CRef<CSeqdesc> new_desc(new CSeqdesc());
52  new_desc->Assign(*seqdesc);
53  CRef<CPubdesc> pubdesc;
54  if (new_desc->GetPub().IsSetPub() && new_desc->GetPub().GetPub().IsSet())
55  {
56  for (CPub_equiv::Tdata::iterator pub = new_desc->SetPub().SetPub().Set().begin(); pub != new_desc->SetPub().SetPub().Set().end(); ++pub)
57  {
58  if ((*pub)->IsPmid()) {
59  TEntrezId pmid = (*pub)->GetPmid().Get();
60  pubdesc = GetPubdescFromEntrezById(pmid);
61  if (pubdesc)
62  break;
63  }
64  }
65  }
66  if (pubdesc)
67  {
68  new_desc->SetPub(*pubdesc);
69  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(seqdesc.GetSeq_entry_Handle(), *seqdesc, *new_desc));
70  cmd->AddCommand (*ecmd);
71  modified = true;
72  }
73  }
74  }
75 
76  if (!modified)
77  cmd.Reset();
78  return cmd;
79 }
80 
81 
static CRef< CCmdComposite > apply(CSeq_entry_Handle tse)
CSeq_entry_CI –.
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
USING_SCOPE(objects)
SStrictId_Entrez::TId TEntrezId
TEntrezId type for entrez ids which require the same strictness as TGi.
Definition: ncbimisc.hpp:1041
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
@ fIncludeGivenEntry
Include the top (given) entry.
@ fRecursive
Iterate recursively.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
bool IsSet(void) const
Check if a value has been assigned to data member.
Definition: Pub_equiv_.hpp:153
void SetPub(TPub &value)
Assign a value to Pub data member.
Definition: Pubdesc_.cpp:72
TPub & SetPub(void)
Select the variant.
Definition: Seqdesc_.cpp:362
const TPub & GetPub(void) const
Get the variant data.
Definition: Seqdesc_.cpp:356
bool IsSetPub(void) const
the citation(s) Check if a value has been assigned to Pub data member.
Definition: Pubdesc_.hpp:593
const TPub & GetPub(void) const
Get the Pub member data.
Definition: Pubdesc_.hpp:605
@ e_Pub
a reference to the publication
Definition: Seqdesc_.hpp:122
CRef< objects::CPubdesc > GetPubdescFromEntrezById(TEntrezId id)
Definition: utilities.cpp:78
Modified on Mon Apr 22 04:05:19 2024 by modify_doxy.py rev. 669887