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

Go to the SVN repository for this file.

1 /* $Id: remove_srcnotes.cpp 42188 2019-01-09 21:48:14Z 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>
33 
36 
38 {
39  return x_GetCommand(tse, "Remove SrcNotes");
40 }
41 
43 {
44  bool modified = false;
45  EDIT_EACH_ORGMOD_ON_BIOSOURCE(orgmod, biosource)
46  {
47  if ((*orgmod)->IsSetSubtype() && (*orgmod)->GetSubtype() == COrgMod::eSubtype_other)
48  {
49  ERASE_ORGMOD_ON_BIOSOURCE(orgmod, biosource);
50  modified = true;
51  }
52  }
53 
54  EDIT_EACH_SUBSOURCE_ON_BIOSOURCE(subsource, biosource)
55  {
56  if ((*subsource)->IsSetSubtype() && (*subsource)->GetSubtype() == CSubSource::eSubtype_other)
57  {
58  ERASE_SUBSOURCE_ON_BIOSOURCE(subsource, biosource);
59  modified = true;
60  }
61  }
62  return modified;
63 }
64 
65 
67 {
68  return x_GetCommand(tse, "Consolidate like modifiers");
69 }
70 
72 {
73  map<int, vector<string> > orgmods;
74  FOR_EACH_ORGMOD_ON_BIOSOURCE(orgmod, biosource)
75  {
76  if ((*orgmod)->IsSetSubtype() && (*orgmod)->IsSetSubname() &&
77  (*orgmod)->GetSubtype() != COrgMod::eSubtype_specimen_voucher &&
78  (*orgmod)->GetSubtype() != COrgMod::eSubtype_culture_collection &&
79  (*orgmod)->GetSubtype() != COrgMod::eSubtype_bio_material)
80  {
81  orgmods[(*orgmod)->GetSubtype()].push_back((*orgmod)->GetSubname());
82  }
83  }
84 
85  map<int, vector<string> > subsources;
86  FOR_EACH_SUBSOURCE_ON_BIOSOURCE(subsource, biosource)
87  {
88  if ((*subsource)->IsSetSubtype() && (*subsource)->IsSetName())
89  {
90  subsources[(*subsource)->GetSubtype()].push_back((*subsource)->GetName());
91  }
92  }
93 
94  bool modified = false;
95  EDIT_EACH_ORGMOD_ON_BIOSOURCE(orgmod, biosource)
96  {
97  if ((*orgmod)->IsSetSubtype() &&
98  (*orgmod)->IsSetSubname() &&
99  orgmods.find((*orgmod)->GetSubtype()) != orgmods.end() &&
100  orgmods[(*orgmod)->GetSubtype()].size() > 1 )
101  {
102  if ((*orgmod)->GetSubname() == orgmods[(*orgmod)->GetSubtype()].front())
103  {
104  (*orgmod)->SetSubname(NStr::Join(orgmods[(*orgmod)->GetSubtype()], m_delimiter));
105  }
106  else
107  {
108  ERASE_ORGMOD_ON_BIOSOURCE(orgmod, biosource);
109  }
110  modified = true;
111  }
112  }
113 
114  EDIT_EACH_SUBSOURCE_ON_BIOSOURCE(subsource, biosource)
115  {
116  if ((*subsource)->IsSetSubtype() &&
117  (*subsource)->IsSetName() &&
118  subsources.find((*subsource)->GetSubtype()) != subsources.end() &&
119  subsources[(*subsource)->GetSubtype()].size() > 1 )
120  {
121  if ((*subsource)->GetName() == subsources[(*subsource)->GetSubtype()].front())
122  {
123  (*subsource)->SetName(NStr::Join(subsources[(*subsource)->GetSubtype()], m_delimiter));
124  }
125  else
126  {
127  ERASE_SUBSOURCE_ON_BIOSOURCE(subsource, biosource);
128  }
129  modified = true;
130  }
131  }
132 
133  return modified;
134 }
135 
137 
virtual bool x_ApplyToBioSource(objects::CBioSource &biosource)
CRef< CCmdComposite > GetCommand(objects::CSeq_entry_Handle tse)
CRef< CCmdComposite > GetCommand(objects::CSeq_entry_Handle tse)
virtual bool x_ApplyToBioSource(objects::CBioSource &biosource)
CSeq_entry_Handle –.
CRef< CCmdComposite > x_GetCommand(objects::CSeq_entry_Handle tse, const string &title)
size_type size() const
Definition: map.hpp:148
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2699
@ eSubtype_other
ASN5: old-name (254) will be added to next spec.
Definition: OrgMod_.hpp:125
@ eSubtype_specimen_voucher
Definition: OrgMod_.hpp:106
@ eSubtype_bio_material
Definition: OrgMod_.hpp:119
@ eSubtype_culture_collection
Definition: OrgMod_.hpp:118
USING_SCOPE(objects)
#define ERASE_ORGMOD_ON_BIOSOURCE(Itr, Var)
ERASE_ORGMOD_ON_BIOSOURCE.
#define EDIT_EACH_ORGMOD_ON_BIOSOURCE(Itr, Var)
#define ERASE_SUBSOURCE_ON_BIOSOURCE(Itr, Var)
ERASE_SUBSOURCE_ON_BIOSOURCE.
#define FOR_EACH_ORGMOD_ON_BIOSOURCE(Itr, Var)
FOR_EACH_ORGMOD_ON_BIOSOURCE EDIT_EACH_ORGMOD_ON_BIOSOURCE.
#define FOR_EACH_SUBSOURCE_ON_BIOSOURCE(Itr, Var)
FOR_EACH_SUBSOURCE_ON_BIOSOURCE EDIT_EACH_SUBSOURCE_ON_BIOSOURCE.
#define EDIT_EACH_SUBSOURCE_ON_BIOSOURCE(Itr, Var)
Modified on Fri Sep 20 14:57:00 2024 by modify_doxy.py rev. 669887