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

Go to the SVN repository for this file.

1 /* $Id: prefix_authority.cpp 28832 2013-09-04 16:47:31Z chenj $
2  * ===========================================================================
3  *
4  *
5  * PUBLIC DOMAIN NOTICE
6  * National Center for Biotechnology Information
7  *
8  * This software/database is a "United States Government Work" under the
9  * terms of the United States Copyright Act. It was written as part of
10  * the author's official duties as a United States Government employee and
11  * thus cannot be copyrighted. This software/database is freely available
12  * to the public for use. The National Library of Medicine and the U.S.
13  * Government have not placed any restriction on its use or reproduction.
14  *
15  * Although all reasonable efforts have been taken to ensure the accuracy
16  * and reliability of the software and data, the NLM and the U.S.
17  * Government do not and cannot warrant the performance or results that
18  * may be obtained by using this software or data. The NLM and the U.S.
19  * Government disclaim all warranties, express or implied, including
20  * warranties of performance, merchantability or fitness for any particular
21  * purpose.
22  *
23  * Please cite the author in any work or product based on this material.
24  *
25  * ===========================================================================
26  *
27  * Authors: Jie Chen
28  * File: for Special:Organism->Prefix Authority with Organism
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <objmgr/bioseq_ci.hpp>
34 #include <objmgr/seqdesc_ci.hpp>
35 #include <objmgr/feat_ci.hpp>
36 #include <objects/seq/Seqdesc.hpp>
38 
40 
41 using namespace ncbi;
42 using namespace objects;
43 
45 {
46  set <const CSeqdesc*> psds;
47  for (CBioseq_CI bit(tse); bit; ++bit) {
48  for (CSeqdesc_CI it(*bit, CSeqdesc::e_Source); it; ++it) {
49  if (psds.find(&*it) != psds.end()) continue;
50  psds.insert(&*it);
51  if (it->GetSource().IsSetOrgMod()) {
52  ITERATE (list <CRef < COrgMod > >, mit, it->GetSource().GetOrgname().GetMod()) {
53  if ( (*mit)->GetSubtype() == COrgMod::eSubtype_authority) {
54  if (it->GetSource().IsSetTaxname()) {
55  const string& taxname = it->GetSource().GetTaxname();
56  const string authority = (*mit)->GetSubname();
57  if (!NStr::EqualNocase(authority, 0, taxname.size(), taxname)) {
58  CRef <COrgMod> new_mod (new COrgMod);
59  new_mod->Assign(**mit);
60  new_mod->SetSubname(taxname + " " + authority);
61  add_to_cmd <COrgMod> ( (CObject*)((*mit).GetPointer()),
62  (CObject*)(new_mod.GetPointer()), composite);
63  break;
64  }
65  }
66  }
67  }
68  }
69  }
70  }
71 };
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
virtual void apply_to(const CSeq_entry_Handle &tse, CRef< CCmdComposite > composite)
CSeq_entry_Handle –.
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5352
void SetSubname(const TSubname &value)
Assign a value to Subname data member.
Definition: OrgMod_.hpp:356
@ eSubtype_authority
Definition: OrgMod_.hpp:107
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
Magic spell ;-) needed for some weird compilers... very empiric.
Modified on Tue Dec 05 02:21:55 2023 by modify_doxy.py rev. 669887