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

Go to the SVN repository for this file.

1 /* $Id: fix_orgmod_institution.cpp 42189 2019-01-09 22:13:08Z 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 #include <ncbi_pch.hpp>
32 
35 
36 
38 {
39  return x_GetCommand(tse, "Fix OrgMod Institution");
40 }
41 
43 {
44  bool modified = false;
45 
46  EDIT_EACH_ORGMOD_ON_BIOSOURCE(orgmod, biosource) {
47  if ((*orgmod)->IsSetSubtype() && (*orgmod)->IsSetSubname() &&
48  ((*orgmod)->GetSubtype() == COrgMod::eSubtype_specimen_voucher ||
49  (*orgmod)->GetSubtype() == COrgMod::eSubtype_culture_collection ||
50  (*orgmod)->GetSubtype() == COrgMod::eSubtype_bio_material))
51  {
52  string inst_code, coll_code, id, inst_coll; // See CValidError_imp::ValidateOrgModVoucher
53  if (!COrgMod::ParseStructuredVoucher((*orgmod)->GetSubname(), inst_code, coll_code, id)) continue;
54  if (NStr::IsBlank(coll_code)) inst_coll = inst_code;
55  else inst_coll = inst_code + ":" + coll_code;
56  string voucher_type;
57  bool is_miscapitalized;
58  bool needs_country;
59  bool erroneous_country;
60  string correct_cap;
61  if (COrgMod::IsInstitutionCodeValid(inst_coll, voucher_type, is_miscapitalized, correct_cap, needs_country, erroneous_country)) continue; // Returns true if invalid, actually
62  if (NStr::StartsWith(inst_coll, "personal", NStr::eNocase)) continue;
63  if (COrgMod::IsInstitutionCodeValid(inst_code, voucher_type, is_miscapitalized, correct_cap, needs_country, erroneous_country) && NStr::Equal(coll_code, "DNA")) continue;
64  string abbr = COrgMod::GetInstitutionShortName(inst_code);
65  if (!NStr::IsBlank(abbr))
66  {
67  if (NStr::IsBlank(id))
68  (*orgmod)->SetSubname(abbr);
69  else
70  (*orgmod)->SetSubname(abbr + ":" + id);
71  modified = true;
72  }
73  }
74  }
75  return modified;
76 }
77 
CRef< CCmdComposite > GetCommand(objects::CSeq_entry_Handle tse)
virtual bool x_ApplyToBioSource(objects::CBioSource &biosource)
static const string & GetInstitutionShortName(const string &full_name)
Definition: OrgMod.cpp:724
static bool IsInstitutionCodeValid(const string &inst_coll, string &voucher_type, bool &is_miscapitalized, string &correct_cap, bool &needs_country, bool &erroneous_country)
Definition: OrgMod.cpp:357
static bool ParseStructuredVoucher(const string &str, string &inst, string &coll, string &id)
Definition: OrgMod.cpp:189
CSeq_entry_Handle –.
CRef< CCmdComposite > x_GetCommand(objects::CSeq_entry_Handle tse, const string &title)
USING_SCOPE(objects)
#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 bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5406
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5378
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
@ eSubtype_specimen_voucher
Definition: OrgMod_.hpp:106
@ eSubtype_bio_material
Definition: OrgMod_.hpp:119
@ eSubtype_culture_collection
Definition: OrgMod_.hpp:118
#define EDIT_EACH_ORGMOD_ON_BIOSOURCE(Itr, Var)
Modified on Fri Sep 20 14:58:04 2024 by modify_doxy.py rev. 669887