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

Go to the SVN repository for this file.

1 /* $Id: pub_tests.cpp 98802 2023-01-07 18:23:10Z gotvyans $
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: Colleen Bollin, based on similar discrepancy tests
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
31 #include <sstream>
33 #include <objects/seq/Pubdesc.hpp>
34 #include <objects/pub/Pub.hpp>
44 #include <objects/biblio/Title.hpp>
47 #include <objects/biblio/Affil.hpp>
54 #include <corelib/ncbistre.hpp>
55 #include <objmgr/seqdesc_ci.hpp>
56 
57 #include "discrepancy_core.hpp"
58 
62 
63 
64 // TITLE_AUTHOR_CONFLICT
65 
66 const string kTitleAuthorConflictStart = "[n] articles have title '";
67 const string kTitleAuthorConflictEnd = "' but do not have the same author list";
68 
69 string GetAuthorString(const CName_std& name_std)
70 {
71  string author;
72 
73  if (name_std.IsSetInitials() && !NStr::IsBlank(name_std.GetInitials())) {
74  author += name_std.GetInitials();
75  }
76  if (name_std.IsSetLast() && !NStr::IsBlank(name_std.GetLast())) {
77  author += name_std.GetLast();
78  }
79  return author;
80 }
81 
82 
83 string GetAuthorString(const CAuthor& author)
84 {
85  if (!author.IsSetName()) {
86  return kEmptyStr;
87  }
88  string rval;
89  switch (author.GetName().Which()) {
90  case CPerson_id::e_Name:
91  rval = GetAuthorString(author.GetName().GetName());
92  break;
93  case CPerson_id::e_Ml:
94  rval = author.GetName().GetMl();
95  break;
96  case CPerson_id::e_Str:
97  rval = author.GetName().GetStr();
98  break;
100  rval = author.GetName().GetConsortium();
101  break;
102  default:
103  break;
104  }
105  return rval;
106 }
107 
108 
109 string GetAuthorString(const CAuth_list& auth_list)
110 {
111  string authors;
112  if (auth_list.IsSetNames()) {
113  switch (auth_list.GetNames().Which()) {
115  for (const auto& it : auth_list.GetNames().GetStd()) {
116  string a = GetAuthorString(*it);
117  if (!NStr::IsBlank(a)) {
118  if (!NStr::IsBlank(authors)) {
119  authors += ", ";
120  }
121  authors += a;
122  }
123  }
124  break;
126  for (const string& it : auth_list.GetNames().GetMl()) {
127  if (!NStr::IsBlank(it)) {
128  if (!NStr::IsBlank(authors)) {
129  authors += ", ";
130  }
131  authors += it;
132  }
133  }
134  break;
136  for (const string& it : auth_list.GetNames().GetStr()) {
137  if (!NStr::IsBlank(it)) {
138  if (!NStr::IsBlank(authors)) {
139  authors += ", ";
140  }
141  authors += it;
142  }
143  }
144  break;
145  default:
146  break;
147  }
148  }
149  return authors;
150 }
151 
152 
153 void GetPubTitleAndAuthors(const CPub& pub, string& title, string & authors)
154 {
155  switch (pub.Which()) {
156  case CPub::e_Gen:
157  if (pub.GetGen().IsSetTitle()) {
158  title = pub.GetGen().GetTitle();
159  }
160  if (pub.GetGen().IsSetAuthors()) {
161  authors = GetAuthorString(pub.GetGen().GetAuthors());
162  }
163  break;
164  case CPub::e_Article:
165  if (pub.GetArticle().IsSetTitle()) {
166  title = pub.GetArticle().GetTitle().GetTitle();
167  }
168  if (pub.GetArticle().IsSetAuthors()) {
169  authors = GetAuthorString(pub.GetArticle().GetAuthors());
170  }
171  break;
172  case CPub::e_Patent:
173  if (pub.GetPatent().IsSetTitle()) {
174  title = pub.GetPatent().GetTitle();
175  }
176  if (pub.GetPatent().IsSetAuthors()) {
177  authors = GetAuthorString(pub.GetPatent().GetAuthors());
178  }
179  break;
180  case CPub::e_Man:
181  if (pub.GetMan().IsSetCit()) {
182  if (pub.GetMan().GetCit().IsSetTitle()) {
183  title = pub.GetMan().GetCit().GetTitle().GetTitle();
184  }
185  if (pub.GetMan().GetCit().IsSetAuthors()) {
186  authors = GetAuthorString(pub.GetMan().GetCit().GetAuthors());
187  }
188  }
189  break;
190  case CPub::e_Book:
191  if (pub.GetBook().IsSetTitle()) {
192  title = pub.GetBook().GetTitle().GetTitle();
193  }
194  if (pub.GetBook().IsSetAuthors()) {
195  authors = GetAuthorString(pub.GetBook().GetAuthors());
196  }
197  break;
198  default:
199  break;
200  }
201 }
202 
203 
204 void GetPubTitleAndAuthors(const CPubdesc& pubdesc, string& title, string& authors)
205 {
206  title.clear();
207  authors.clear();
208  if (pubdesc.IsSetPub()) {
209  for (const auto& it : pubdesc.GetPub().Get()) {
210  GetPubTitleAndAuthors(*it, title, authors);
211  if (!NStr::IsBlank(title)) {
212  break;
213  }
214  }
215  }
216 }
217 
218 
219 DISCREPANCY_CASE(TITLE_AUTHOR_CONFLICT, DESC, eDisc | eOncaller | eSmart | eFatal, "Publications with the same titles should have the same authors")
220 {
221  for (const auto& desc : context.GetSeqdesc()) {
222  if (desc.IsPub()) {
223  string title;
224  string authors;
225  GetPubTitleAndAuthors(desc.GetPub(), title, authors);
226  if (!title.empty()) {
227  m_Objs[kEmptyStr][title][authors].Add(*context.SeqdescObjRef(desc));
228  }
229  }
230  }
231 }
232 
233 
234 static const char* kTitleAuthorConflict = "Publication Title/Author Inconsistencies";
235 
236 DISCREPANCY_SUMMARIZE(TITLE_AUTHOR_CONFLICT)
237 {
238  if (m_Objs.empty()) {
239  return;
240  }
241  for (auto& it : m_Objs[kEmptyStr].GetMap()) {
242  if (it.second->GetMap().size() > 1) {
243  string top = "[n] articles have title [(]'" + it.first + "'[)] but do not have the same author list";
244  for (auto& aa : it.second->GetMap()) {
245  string label = "[n] article[s] [has] title [(]'" + it.first + "'[)] and author list [(]'" + aa.first + "'";
246  for (auto& obj: aa.second->GetObjects()) {
247  m_Objs[kTitleAuthorConflict][top][label].Add(*obj).Fatal();
248  }
249  }
250  }
251  }
252  m_Objs.GetMap().erase(kEmptyStr);
253  if (m_Objs.Exist(kTitleAuthorConflict) && m_Objs[kTitleAuthorConflict].GetMap().size() == 1) {
254  m_ReportItems = m_Objs.GetMap().cbegin()->second->Export(*this)->GetSubitems();
255  }
256  else {
257  xSummarize();
258  }
259 }
260 
261 
262 // UNPUB_PUB_WITHOUT_TITLE
263 
264 bool IsPubUnpublished(const CImprint& imp)
265 {
266  bool is_unpublished = false;
267  if (!imp.IsSetPrepub() || imp.GetPrepub() == CImprint::ePrepub_other) {
268  is_unpublished = true;
269  }
270  return is_unpublished;
271 }
272 
273 
275 {
276  bool is_unpublished = false;
277  if (journal.IsSetImp()) {
278  is_unpublished = IsPubUnpublished(journal.GetImp());
279  }
280  return is_unpublished;
281 }
282 
283 
284 bool IsPubUnpublished(const CCit_book& book)
285 {
286  bool is_unpublished = false;
287  if (book.IsSetImp()) {
288  is_unpublished = IsPubUnpublished(book.GetImp());
289  }
290  return is_unpublished;
291 }
292 
293 
295 {
296  bool is_unpublished = false;
297  if (proc.IsSetBook()) {
298  is_unpublished = IsPubUnpublished(proc.GetBook());
299  }
300  return is_unpublished;
301 }
302 
303 
304 bool IsPubUnpublished(const CCit_let& let)
305 {
306  bool is_unpublished = false;
307  if (let.IsSetCit() && let.GetCit().IsSetImp()) {
308  is_unpublished = IsPubUnpublished(let.GetCit().GetImp());
309  }
310  return is_unpublished;
311 }
312 
313 
314 bool IsPubUnpublished(const CPub& pub)
315 {
316  bool is_unpublished = false;
317 
318  switch (pub.Which()) {
319  case CPub::e_Gen:
320  if (pub.GetGen().IsSetCit() && NStr::FindNoCase(pub.GetGen().GetCit(), "unpublished") != NPOS) {
321  is_unpublished = true;
322  }
323  break;
324  case CPub::e_Article:
325  if (pub.GetArticle().IsSetFrom()) {
326  if (pub.GetArticle().GetFrom().IsJournal()) {
327  is_unpublished = IsPubUnpublished(pub.GetArticle().GetFrom().GetJournal());
328  } else if (pub.GetArticle().GetFrom().IsBook()) {
329  is_unpublished = IsPubUnpublished(pub.GetArticle().GetFrom().GetBook());
330  } else if (pub.GetArticle().GetFrom().IsProc()) {
331  is_unpublished = IsPubUnpublished(pub.GetArticle().GetFrom().GetProc());
332  }
333  }
334  break;
335  case CPub::e_Book:
336  is_unpublished = IsPubUnpublished(pub.GetBook());
337  break;
338  case CPub::e_Journal:
339  is_unpublished = IsPubUnpublished(pub.GetJournal());
340  break;
341  case CPub::e_Proc:
342  is_unpublished = IsPubUnpublished(pub.GetProc());
343  break;
344  case CPub::e_Patent:
345  is_unpublished = true;
346  break;
347  case CPub::e_Man:
348  is_unpublished = IsPubUnpublished(pub.GetMan());
349  break;
350  default:
351  break;
352  }
353 
354  return is_unpublished;
355 }
356 
357 
358 bool HasUnpubWithoutTitle(const CPubdesc& pubdesc)
359 {
360  if (!pubdesc.IsSetPub()) {
361  return false;
362  }
363  for (const auto& it : pubdesc.GetPub().Get()) {
364  if (IsPubUnpublished(*it)) {
365  string title;
366  string authors;
367  GetPubTitleAndAuthors(*it, title, authors);
368  if (NStr::IsBlank(title) || NStr::EqualNocase(title, "Direct Submission")) {
369  return true;
370  }
371  }
372  }
373  return false;
374 }
375 
376 
377 DISCREPANCY_CASE(UNPUB_PUB_WITHOUT_TITLE, PUBDESC, eDisc | eOncaller | eSubmitter | eSmart | eBig | eFatal, "Unpublished pubs should have titles")
378 {
379  for (const CPubdesc* pubdesc : context.GetPubdescs()) {
380  if (HasUnpubWithoutTitle(*pubdesc)) {
381  m_Objs["[n] unpublished pub[s] [has] no title"].Add(*context.PubdescObjRef(*pubdesc)).Fatal();
382  }
383  }
384 }
385 
386 
387 // MISSING_AFFIL
388 
389 bool HasNoAffiliation(const CAffil& affil)
390 {
391  bool rval = false;
392  if (affil.IsStr()) {
393  if (NStr::IsBlank(affil.GetStr())) {
394  rval = true;
395  }
396  } else if (affil.IsStd()) {
397  if (!affil.GetStd().IsSetAffil() ||
398  NStr::IsBlank(affil.GetStd().GetAffil())) {
399  rval = true;
400  }
401  } else {
402  rval = true;
403  }
404  return rval;
405 }
406 
407 
409 {
410  if (!pubdesc.IsSetPub()) {
411  return false;
412  }
413  bool rval = false;
414  for (const auto& it : pubdesc.GetPub().Get()) {
415  if (it->IsSub()) {
416  if (!it->GetSub().IsSetAuthors() ||
417  !it->GetSub().GetAuthors().IsSetAffil() ||
418  HasNoAffiliation(it->GetSub().GetAuthors().GetAffil())) {
419  rval = true;
420  break;
421  }
422  }
423  }
424  return rval;
425 }
426 
427 
428 DISCREPANCY_CASE(MISSING_AFFIL, PUBDESC, eDisc | eOncaller | eFatal, "Missing affiliation")
429 {
430  for (auto& pubdesc : context.GetPubdescs()) {
431  if (IsCitSubMissingAffiliation(*pubdesc)) {
432  m_Objs["[n] citsub[s] [is] missing affiliation"].Add(*context.PubdescObjRef(*pubdesc)).Fatal();
433  }
434  }
435 }
436 
437 
438 // CITSUBAFFIL_CONFLICT
439 
440 #define ADD_TO_AFFIL_SUMMARY(Fieldname) \
441  if(affil.IsSet##Fieldname() && !NStr::IsBlank(affil.Get##Fieldname())) { \
442  if (!NStr::IsBlank(rval)) { \
443  rval += ", "; \
444  } \
445  rval += affil.Get##Fieldname(); \
446  }
447 
449 {
450  string rval;
452  ADD_TO_AFFIL_SUMMARY(Affil)
453  ADD_TO_AFFIL_SUMMARY(Street)
456  if (affil.IsSetPostal_code() && !NStr::IsBlank(affil.GetPostal_code())) {
457  if (!NStr::IsBlank(rval)) {
458  rval += " ";
459  }
460  rval += affil.GetPostal_code();
461  }
462  ADD_TO_AFFIL_SUMMARY(Country)
463 
464  return rval;
465 }
466 
467 
468 string SummarizeAffiliation(const CAffil& affil)
469 {
470  if (affil.IsStd()) {
471  return SummarizeAffiliation(affil.GetStd());
472  } else if (affil.IsStr()) {
473  return affil.GetStr();
474  } else {
475  return kEmptyStr;
476  }
477 }
478 
479 
480 const string kCitSubSummary = "Citsub affiliation conflicts found";
481 const string kSummaries = "summaries";
482 
483 
484 DISCREPANCY_CASE(CITSUBAFFIL_CONFLICT, AUTHORS, eDisc | eOncaller | eSmart | eFatal, "All Cit-subs should have identical affiliations")
485 {
486  for (auto& authors : context.GetAuthors()) {
487  const CPub* pub = context.AuthPub(authors);
488  if (pub && !pub->IsSub()) {
489  continue;
490  }
491  CRef<CDiscrepancyObject> repobj = context.AuthorsObjRef(*authors);
492  if (authors->IsSetAffil()) {
493  const CAffil& affil = authors->GetAffil();
494  if (affil.IsStr()) {
495  m_Objs["Affil"][affil.GetStr()].Add(*repobj);
496  m_Objs["Div"][kEmptyStr].Add(*repobj);
497  m_Objs["City"][kEmptyStr].Add(*repobj);
498  m_Objs["Sub"][kEmptyStr].Add(*repobj);
499  m_Objs["Country"][kEmptyStr].Add(*repobj);
500  m_Objs["Street"][kEmptyStr].Add(*repobj);
501  m_Objs["Postal_code"][kEmptyStr].Add(*repobj);
502  }
503  else if (affil.IsStd()) {
504  m_Objs["Affil"][affil.GetStd().IsSetAffil() && !NStr::IsBlank(affil.GetStd().GetAffil()) ? affil.GetStd().GetAffil() : kEmptyStr].Add(*repobj);
505  m_Objs["Div"][affil.GetStd().IsSetDiv() && !NStr::IsBlank(affil.GetStd().GetDiv()) ? affil.GetStd().GetDiv() : kEmptyStr].Add(*repobj);
506  m_Objs["City"][affil.GetStd().IsSetCity() && !NStr::IsBlank(affil.GetStd().GetCity()) ? affil.GetStd().GetCity() : kEmptyStr].Add(*repobj);
507  m_Objs["Sub"][affil.GetStd().IsSetSub() && !NStr::IsBlank(affil.GetStd().GetSub()) ? affil.GetStd().GetSub() : kEmptyStr].Add(*repobj);
508  m_Objs["Country"][affil.GetStd().IsSetCountry() && !NStr::IsBlank(affil.GetStd().GetCountry()) ? affil.GetStd().GetCountry() : kEmptyStr].Add(*repobj);
509  m_Objs["Street"][affil.GetStd().IsSetStreet() && !NStr::IsBlank(affil.GetStd().GetStreet()) ? affil.GetStd().GetStreet() : kEmptyStr].Add(*repobj);
510  m_Objs["Postal_code"][affil.GetStd().IsSetPostal_code() && !NStr::IsBlank(affil.GetStd().GetPostal_code()) ? affil.GetStd().GetPostal_code() : kEmptyStr].Add(*repobj);
511  }
512  else {
513  m_Objs["Affil"][kEmptyStr].Add(*repobj);
514  }
515  m_Objs[kSummaries][SummarizeAffiliation(affil)].Add(*repobj);
516  }
517  else {
518  m_Objs[kSummaries][kEmptyStr].Add(*repobj);
519  }
520  }
521 }
522 
523 
524 DISCREPANCY_SUMMARIZE(CITSUBAFFIL_CONFLICT)
525 {
527  if (m_Objs.empty()) {
528  out[kCitSubSummary]["No citsubs were found!"].Fatal();
529  }
530  if (m_Objs[kSummaries].GetMap().size() > 1) {
531  for (const auto& it : m_Objs[kSummaries].GetMap()) {
532  string two = NStr::IsBlank(it.first) ? "[*0*][n] Cit-sub[s] [has] no affiliation" : "[*1*][n] CitSub[s] [has] affiliation " + it.first;
533  for (auto& robj : m_Objs[kSummaries][it.first].GetObjects()) {
534  out[kCitSubSummary][two].Add(*robj, false);
535  }
536  }
537  }
538 #define REPORT_CITSUBAFFIL_CONFLICT(order, field, alias) \
539  if (m_Objs[#field].GetMap().size() > 1) {\
540  for (const auto& it : m_Objs[#field].GetMap()) {\
541  string two = "[n] affiliation[s] [has] "#alias" value '" + it.first + "'";\
542  for (auto& robj : m_Objs[#field][it.first].GetObjects()) {\
543  out[kCitSubSummary]["[*"#order"*]Affiliations have different values for "#alias][two].Ext().Add(*robj, false);\
544  }\
545  }\
546  }
547  REPORT_CITSUBAFFIL_CONFLICT(3, Affil, institution)
548  REPORT_CITSUBAFFIL_CONFLICT(4, Div, department)
549  REPORT_CITSUBAFFIL_CONFLICT(5, City, city)
550  REPORT_CITSUBAFFIL_CONFLICT(6, Sub, state/province)
551  REPORT_CITSUBAFFIL_CONFLICT(7, Country, country)
552  REPORT_CITSUBAFFIL_CONFLICT(8, Street, street)
553  REPORT_CITSUBAFFIL_CONFLICT(9, Postal_code, postal code)
554  m_ReportItems = out.Export(*this)->GetSubitems();
555 }
556 
557 
558 // SUBMITBLOCK_CONFLICT
559 
560 DISCREPANCY_CASE(SUBMITBLOCK_CONFLICT, SUBMIT, eDisc | eOncaller | eSmart, "Records should have identical submit-blocks")
561 {
562  const CSubmit_block* sub = context.GetSubmit_block();
563  if (sub) {
564  stringstream ss;
565  ss << MSerial_AsnBinary << *sub;
566  m_Objs[ss.str()].Add(*context.SubmitBlockObjRef());
567  }
568 }
569 
570 
571 DISCREPANCY_SUMMARIZE(SUBMITBLOCK_CONFLICT)
572 {
573  if (m_Objs.GetMap().size() > 1) {
575  CReportNode& outout = out["SubmitBlock Conflicts"];
576  size_t count = 0;
577  for (auto& it : m_Objs.GetMap()) {
578  CReportNode& node = outout["[*" + to_string(count++) + "*][n] record[s] [has] identical submit-blocks"];
579  for (auto& obj : it.second->GetObjects()) {
580  node.Add(*obj);
581  }
582  }
583  m_ReportItems = out.Export(*this)->GetSubitems();
584  }
585 }
586 
587 
588 // CONSORTIUM
589 
590 DISCREPANCY_CASE(CONSORTIUM, AUTHORS, eOncaller, "Submitter blocks and publications have consortiums")
591 {
592  static const string msg = "[n] publication[s]/submitter block[s] [has] consortium";
593  for (auto& authors : context.GetAuthors()) {
594  if (authors->IsSetNames() && authors->GetNames().IsStd()) {
595  const CAuth_list::C_Names::TStd& names = authors->GetNames().GetStd();
596  for (auto& auth : names) {
597  if (auth->IsSetName() && auth->GetName().IsConsortium()) {
598  m_Objs[msg].Add(*context.AuthorsObjRef(*authors, true));
599  }
600  }
601  }
602  }
603  const CPerson_id* pid = context.GetPerson_id();
604  if (pid && pid->IsConsortium()) {
605  m_Objs[msg].Add(*context.SubmitBlockObjRef(true));
606  }
607 }
608 
609 
610 static int RemoveConsortium(CAuth_list& authors)
611 {
612  int n = 0;
613  CAuth_list::C_Names::TStd& names = authors.SetNames().SetStd();
614  CAuth_list::C_Names::TStd::iterator it = names.begin();
615  while (it != names.end()) {
616  if ((*it)->CanGetName() && (*it)->GetName().IsConsortium()) {
617  names.erase(it++);
618  n++;
619  }
620  else {
621  ++it;
622  }
623  }
624  return n;
625 }
626 
627 
629 {
630  CSerialObject* sobj = const_cast<CSerialObject*>(context.FindObject(*obj));
631  CSeq_feat* feat = dynamic_cast<CSeq_feat*>(sobj);
632  CSeqdesc* desc = dynamic_cast<CSeqdesc*>(sobj);
633  CSubmit_block* subb = dynamic_cast<CSubmit_block*>(sobj);
634  unsigned int n = 0;
635  if (feat) {
636  cout << "CONSORTIUM AUTOFIX: on seq_feat is not implemented\n";
637  }
638  if (desc && desc->IsPub() && desc->GetPub().CanGetPub() && desc->GetPub().GetPub().CanGet()) {
639  CPub_equiv::Tdata& data = desc->SetPub().SetPub().Set();
640  for (auto pub : data) {
641  if (pub->IsSetAuthors()) {
642  n += RemoveConsortium(pub->SetAuthors());
643  }
644  }
645  }
646  if (subb && subb->CanGetCit() && subb->GetCit().CanGetAuthors() && subb->GetCit().GetAuthors().CanGetNames()) {
647  n += RemoveConsortium(subb->SetCit().SetAuthors());
648  // we don't autofix in the cit_sub->contact
649  }
650  obj->SetFixed();
651  return CRef<CAutofixReport>(n ? new CAutofixReport("CONSORTIUM: [n] Consortium[s] [is] removed", n) : nullptr);
652 }
653 
654 
655 // CHECK_AUTH_NAME
656 
657 const string kMissingAuthorsName = "[n] pub[s] missing author\'s first or last name";
658 
659 DISCREPANCY_CASE(CHECK_AUTH_NAME, AUTHORS, eDisc | eOncaller | eSubmitter | eSmart, "Missing authors or first/last author's names")
660 {
661  //if (context.IsPubMed()) { -- need to rewrite context.IsPubMed()
662  // return;
663  //}
664  for (auto& authors : context.GetAuthors()) {
665  if (authors->IsSetNames() && authors->GetNames().IsStd()) {
666  const CAuth_list::C_Names::TStd& names = authors->GetNames().GetStd();
667  if (names.empty()) {
668  m_Objs[kMissingAuthorsName].Add(*context.AuthorsObjRef(*authors));
669  }
670  else {
671  for (auto& auth : names) {
672  if (!auth->IsSetName() || (auth->GetName().IsName() &&
673  (!auth->GetName().GetName().CanGetFirst() || !auth->GetName().GetName().CanGetLast() || auth->GetName().GetName().GetFirst().empty() || auth->GetName().GetName().GetLast().empty()))) {
674  m_Objs[kMissingAuthorsName].Add(*context.AuthorsObjRef(*authors));
675  break;
676  }
677  }
678  }
679  }
680  }
681 }
682 
683 
684 // CITSUB_AFFIL_DUP_TEXT
685 
686 static const CCit_sub* GetCitSubFromPub(const CPub& pub)
687 {
688  const CCit_sub* ret = nullptr;
689  if (pub.IsEquiv() && pub.GetEquiv().IsSet()) {
690  for (auto cur_pub : pub.GetEquiv().Get()) {
691  ret = GetCitSubFromPub(*cur_pub);
692  if (ret) {
693  break;
694  }
695  }
696  }
697  else if (pub.IsSub()) {
698  ret = &pub.GetSub();
699  }
700  return ret;
701 }
702 
703 
704 static bool AffilStreetEndsWith(const string& street, const string& tail)
705 {
706  bool ret = false;
707  if (street.size() > tail.size() && NStr::EndsWith(street, tail, NStr::eNocase)) {
708  size_t delimiter_pos = street.size() - tail.size() - 1;
709  if (ispunct(street[delimiter_pos]) || isspace(street[delimiter_pos])) {
710  string university_of("University of");
711  university_of += street[delimiter_pos] + tail;
712 
713  ret = !NStr::EndsWith(street, university_of, NStr::eNocase);
714  }
715  }
716  return ret;
717 }
718 
719 
720 static bool AffilStreetContainsDup(const CAffil& affil)
721 {
722  bool ret = false;
723  if (affil.IsStd() && affil.GetStd().IsSetStreet() && !affil.GetStd().GetStreet().empty()) {
724  const CAffil::C_Std& data = affil.GetStd();
725  const string& street = data.GetStreet();
726  if (data.IsSetCountry()) {
727  ret = AffilStreetEndsWith(street, data.GetCountry());
728  }
729  if (!ret && data.IsSetPostal_code()) {
730  ret = AffilStreetEndsWith(street, data.GetPostal_code());
731  }
732  if (!ret && data.IsSetSub()) {
733  ret = AffilStreetEndsWith(street, data.GetSub());
734  }
735  if (!ret && data.IsSetCity()) {
736  ret = AffilStreetEndsWith(street, data.GetCity());
737  }
738  }
739  return ret;
740 }
741 
742 
743 DISCREPANCY_CASE(CITSUB_AFFIL_DUP_TEXT, PUBDESC, eOncaller, "Cit-sub affiliation street contains text from other affiliation fields")
744 {
745  for (auto& pubdesc : context.GetPubdescs()) {
746  if (pubdesc->IsSetPub()) {
747  const CCit_sub* cit_sub = nullptr;
748  for (auto& it : pubdesc->GetPub().Get()) {
749  cit_sub = GetCitSubFromPub(*it);
750  if (cit_sub) {
751  break;
752  }
753  }
754  if (cit_sub && cit_sub->IsSetAuthors() && cit_sub->GetAuthors().IsSetAffil()) {
755  const CAffil& affil = cit_sub->GetAuthors().GetAffil();
756  if (AffilStreetContainsDup(affil)) {
757  m_Objs["[n] Cit-sub pubs have duplicate affil text"].Add(*context.PubdescObjRef(*pubdesc, true)); // , const_cast<CCit_sub*>(cit_sub)* / ));
758  }
759  }
760  }
761  }
762 }
763 
764 
765 static bool RemoveAffilStreetEnd(string& street, const string& tail, bool country)
766 {
767  bool ret = AffilStreetEndsWith(street, tail);
768  if (ret) {
769  size_t off = street.size() - tail.size();
770  static const string kChina = "China";
771  static const string kChinaPR = "P.R. China";
772  if (country && NStr::EqualNocase(tail, kChina) && NStr::EndsWith(street, kChinaPR, NStr::eNocase)) {
773  off = street.size() - kChinaPR.size();
774  }
775  string new_street = street.substr(0, off);
777  }
778  return ret;
779 }
780 
781 
782 static bool RemoveAffilDup(CCit_sub* cit_sub)
783 {
784  bool ret = false;
785  if (cit_sub) {
786  CAffil& affil = cit_sub->SetAuthors().SetAffil();
787  CAffil::C_Std& data = affil.SetStd();
788  string& street = data.SetStreet();
789  if (data.IsSetCountry()) {
790  ret = RemoveAffilStreetEnd(street, data.GetCountry(), true);
791  }
792  if (!ret && data.IsSetPostal_code()) {
793  ret = RemoveAffilStreetEnd(street, data.GetPostal_code(), false);
794  }
795  if (!ret && data.IsSetSub()) {
796  ret = RemoveAffilStreetEnd(street, data.GetSub(), false);
797  }
798  if (!ret && data.IsSetCity()) {
799  ret = RemoveAffilStreetEnd(street, data.GetCity(), false);
800  }
801  }
802  return ret;
803 }
804 
805 
806 DISCREPANCY_AUTOFIX(CITSUB_AFFIL_DUP_TEXT)
807 {
808  CSerialObject* sobj = const_cast<CSerialObject*>(context.FindObject(*obj));
809  CSeq_feat* feat = dynamic_cast<CSeq_feat*>(sobj);
810  CSeqdesc* desc = dynamic_cast<CSeqdesc*>(sobj);
811 
812  unsigned int n = 0;
813  if (feat) {
814  cout << "CITSUB_AFFIL_DUP_TEXT AUTOFIX on seq_feat -- coming soon!\n";
815  }
816  if (desc && desc->IsPub() && desc->GetPub().CanGetPub() && desc->GetPub().GetPub().CanGet()) {
817  CPub_equiv::Tdata& data = desc->SetPub().SetPub().Set();
818  CCit_sub* cit_sub = nullptr;
819  for (auto pub : data) {
820  cit_sub = const_cast<CCit_sub*>(GetCitSubFromPub(*pub));
821  if (cit_sub) {
822  break;
823  }
824  }
825  if (cit_sub && cit_sub->IsSetAuthors() && cit_sub->GetAuthors().IsSetAffil()) {
826  const CAffil& affil = cit_sub->GetAuthors().GetAffil();
827  if (AffilStreetContainsDup(affil) && RemoveAffilDup(cit_sub)) {
828  obj->SetFixed();
829  n++;
830  }
831  }
832  }
833  return CRef<CAutofixReport>(n ? new CAutofixReport("CITSUB_AFFIL_DUP_TEXT: [n] Cit-sub affiliation street duplication[s] [is] removed", n) : nullptr);
834 }
835 
836 
837 // USA_STATE
838 
839 static pair<string, string> us_state_abbreviations[] = {
840  { "AL", "Alabama" },
841  { "AL", "Ala" },
842  { "AK", "Alaska" },
843  { "AK", "Alas" },
844  { "AZ", "Arizona" },
845  { "AZ", "Ariz" },
846  { "AR", "Arkansas" },
847  { "AR", "Ark" },
848  { "CA", "California" },
849  { "CA", "Calif" },
850  { "CA", "Cali" },
851  { "CA", "Cal" },
852  { "CO", "Colorado" },
853  { "CO", "Colo" },
854  { "CO", "Col" },
855  { "CT", "Connecticut" },
856  { "CT", "Conn" },
857  { "DE", "Delaware" },
858  { "DE", "Del" },
859  { "FL", "Florida" },
860  { "FL", "Fla" },
861  { "GA", "Georgia" },
862  { "HI", "Hawaii" },
863  { "ID", "Idaho" },
864  { "ID", "Ida" },
865  { "IL", "Illinois" },
866  { "IL", "Ill" },
867  { "IN", "Indiana" },
868  { "IN", "Ind" },
869  { "IA", "Iowa" },
870  { "KS", "Kansas" },
871  { "KS", "Kans" },
872  { "KS", "Kan" },
873  { "KY", "Kentucky" },
874  { "KY", "Kent" },
875  { "KY", "Ken" },
876  { "LA", "Louisiana" },
877  { "ME", "Maine" },
878  { "MD", "Maryland" },
879  { "MA", "Massachusetts" },
880  { "MA", "Mass" },
881  { "MI", "Michigan" },
882  { "MI", "Mich" },
883  { "MN", "Minnesota" },
884  { "MN", "Minn" },
885  { "MS", "Mississippi" },
886  { "MS", "Miss" },
887  { "MO", "Missouri" },
888  { "MT", "Montana" },
889  { "MT", "Mont" },
890  { "NE", "Nebraska" },
891  { "NE", "Nebr" },
892  { "NE", "Neb" },
893  { "NV", "Nevada" },
894  { "NV", "Nev" },
895  { "NH", "New Hampshire" },
896  { "NJ", "New Jersey" },
897  { "NM", "New Mexico" },
898  { "NY", "New York" },
899  { "NC", "North Carolina" },
900  { "NC", "N Car" },
901  { "ND", "North Dakota" },
902  { "ND", "N Dak" },
903  { "OH", "Ohio" },
904  { "OK", "Oklahoma" },
905  { "OK", "Okla" },
906  { "OR", "Oregon" },
907  { "OR", "Oreg" },
908  { "OR", "Ore" },
909  { "PA", "Pennsylvania" },
910  { "PA", "Penna" },
911  { "PA", "Penn" },
912  { "PR", "Puerto Rico" },
913  { "RI", "Rhode Island" },
914  { "SC", "South Carolina" },
915  { "SC", "S Car" },
916  { "SD", "South Dakota" },
917  { "SD", "S Dak" },
918  { "TN", "Tennessee" },
919  { "TN", "Tenn" },
920  { "TX", "Texas" },
921  { "TX", "Tex" },
922  { "UT", "Utah" },
923  { "VT", "Vermont" },
924  { "VA", "Virginia" },
925  { "VA", "Virg" },
926  { "WA", "Washington" },
927  { "WA", "Wash" },
928  { "WV", "West Virginia" },
929  { "WI", "Wisconsin" },
930  { "WI", "Wisc" },
931  { "WI", "Wis" },
932  { "WY", "Wyoming" },
933  { "WY", "Wyo" }
934 };
935 
937 
938 static bool IsValidStateAbbreviation(const string& state)
939 {
940  for (size_t i = 0; i < kNumOfAbbreviations; ++i) {
942  return true;
943  }
944  }
945  return false;
946 }
947 
948 
949 DISCREPANCY_CASE(USA_STATE, PUBDESC, eDisc | eOncaller | eSmart, "For country USA, state should be present and abbreviated")
950 {
951  for (auto& pubdesc : context.GetPubdescs()) {
952  if (pubdesc->IsSetPub()) {
953  }
954  const CCit_sub* cit_sub = nullptr;
955  for (auto& it : pubdesc->GetPub().Get()) {
956  cit_sub = GetCitSubFromPub(*it);
957  if (cit_sub) {
958  break;
959  }
960  }
961  if (cit_sub && cit_sub->IsSetAuthors() && cit_sub->GetAuthors().IsSetAffil()) {
962  const CAffil& affil = cit_sub->GetAuthors().GetAffil();
963  if (affil.IsStd() && affil.GetStd().IsSetCountry()) {
964  const string& country = affil.GetStd().GetCountry();
965  if (country == "USA") {
966  bool report = !affil.GetStd().IsSetSub();
967  if (!report) {
968  const string& state = affil.GetStd().GetSub();
969  report = !IsValidStateAbbreviation(state);
970  }
971  if (report) {
972  m_Objs["[n] cit-sub[s] [is] missing state abbreviations"].Add(*context.PubdescObjRef(*pubdesc, true)); // , const_cast<CAffil*>(&affil)* / ));
973  }
974  }
975  }
976  }
977  }
978 }
979 
980 
981 static bool ReplaceStateAbbreviation(CAffil* affil)
982 {
983  if (!affil) {
984  return false;
985  }
986  if (affil->GetStd().IsSetSub()) {
987  const string& state = affil->GetStd().GetSub();
988  for (size_t i = 0; i < kNumOfAbbreviations; ++i) {
991  return true;
992  }
993  }
994  }
995  return false;
996 }
997 
998 
1000 {
1001  CSerialObject* sobj = const_cast<CSerialObject*>(context.FindObject(*obj));
1002  CSeq_feat* feat = dynamic_cast<CSeq_feat*>(sobj);
1003  CSeqdesc* desc = dynamic_cast<CSeqdesc*>(sobj);
1004 
1005  unsigned int n = 0;
1006  if (feat) {
1007  cout << "USA_STATE AUTOFIX on seq_feat -- coming soon!\n";
1008  }
1009  if (desc && desc->IsPub() && desc->GetPub().CanGetPub() && desc->GetPub().GetPub().CanGet()) {
1010  CPub_equiv::Tdata& data = desc->SetPub().SetPub().Set();
1011  CCit_sub* cit_sub = nullptr;
1012  for (auto& pub : data) {
1013  cit_sub = const_cast<CCit_sub*>(GetCitSubFromPub(*pub));
1014  if (cit_sub) {
1015  break;
1016  }
1017  }
1018  if (cit_sub && cit_sub->IsSetAuthors() && cit_sub->GetAuthors().IsSetAffil()) {
1019  CAffil& affil = const_cast<CAffil&>(cit_sub->GetAuthors().GetAffil());
1020  if (affil.IsStd() && affil.GetStd().IsSetCountry()) {
1021  const string& country = affil.GetStd().GetCountry();
1022  if (country == "USA") {
1023  bool report = !affil.GetStd().IsSetSub();
1024  if (!report) {
1025  const string& state = affil.GetStd().GetSub();
1026  report = !IsValidStateAbbreviation(state);
1027  }
1028  if (report && ReplaceStateAbbreviation(&affil)) {
1029  obj->SetFixed();
1030  n++;
1031  }
1032  }
1033  }
1034  }
1035  }
1036  return CRef<CAutofixReport>(n ? new CAutofixReport("USA_STATE: [n] Cit-sub[s] [is] changed to contain a correct US state abbreviation", n) : nullptr);
1037 }
1038 
1039 
1040 // CHECK_AUTH_CAPS
1041 
1042 static const string kIncorrectCap = "[n] pub[s] [has] incorrect author capitalization";
1043 
1044 static bool IsCapNameCorrect(const string& name)
1045 {
1046  static const set<string> kShortNames = {
1047  "del",
1048  "de",
1049  "da",
1050  "du",
1051  "dos",
1052  "la",
1053  "le",
1054  "van",
1055  "von",
1056  "der",
1057  "den",
1058  "di", };
1059  bool ret = true;
1060 
1061  if (!name.empty()) {
1062  bool need_cap = true;
1063  bool need_lower = false;
1064  bool found_lower = true;
1065  size_t len = name.size();
1066  for (size_t i = 0; i < len; ++i) {
1067  if (isalpha(name[i])) {
1068  if (need_cap) {
1069  if (islower(name[i])) {
1070  // check if it is a short name
1071  string::const_iterator start = name.cbegin() + i;
1072  string::const_iterator end = start + 1;
1073  while (end != name.cend() && *end != ' ') {
1074  ++end;
1075  }
1076  string short_name(start, end);
1077  set<string>::const_iterator it = kShortNames.find(short_name);
1078  if (it == kShortNames.cend()) {
1079  ret = false;
1080  break;
1081  }
1082  i += it->size() - 1;
1083  }
1084  need_cap = false;
1085  }
1086  else {
1087 
1088  need_lower = true;
1089  found_lower = islower(name[i]) != 0;
1090  }
1091  }
1092  else {
1093  need_cap = true;
1094  }
1095  }
1096  if (need_lower && !found_lower) {
1097  ret = false;
1098  }
1099  }
1100  return ret;
1101 }
1102 
1103 
1104 static bool IsCapInitialsCorrect(const string& initials)
1105 {
1106  bool ret = true;
1107  if (!initials.empty()) {
1108  for (auto& cur : initials) {
1109  if (isalpha(cur) && islower(cur)) {
1110  ret = false;
1111  break;
1112  }
1113  }
1114  }
1115  return ret;
1116 }
1117 
1118 
1119 DISCREPANCY_CASE(CHECK_AUTH_CAPS, AUTHORS, eDisc | eOncaller | eSmart, "Check for correct capitalization in author names")
1120 {
1121  for (auto& authors : context.GetAuthors()) {
1122  if (authors->IsSetNames() && authors->GetNames().IsStd()) {
1123  for (auto& auth : authors->GetNames().GetStd()) {
1124  if (auth->IsSetName() && auth->GetName().IsName()) {
1125  const CName_std& name = auth->GetName().GetName();
1126  bool correct = true;
1127  if (name.IsSetLast()) {
1128  correct = IsCapNameCorrect(name.GetLast());
1129  }
1130  if (correct && name.IsSetFirst()) {
1131  correct = IsCapNameCorrect(name.GetFirst());
1132  }
1133  if (correct && name.IsSetInitials()) {
1134  correct = IsCapInitialsCorrect(name.GetInitials());
1135  }
1136  if (!correct) {
1137  m_Objs[kIncorrectCap].Add(*context.AuthorsObjRef(*authors, true));
1138  break;
1139  }
1140  }
1141  }
1142  }
1143  }
1144 }
1145 
1146 
1147 static bool FixCapitalization(string& name, bool apostroph)
1148 {
1149  bool ret = false;
1150  bool to_lower = false;
1151  for (auto& cur : name) {
1152  if (isalpha(cur)) {
1153  if (to_lower && isupper(cur)) {
1154  cur = tolower(cur);
1155  ret = true;
1156  }
1157  if (!to_lower) {
1158  if (islower(cur)) {
1159  cur = toupper(cur);
1160  ret = true;
1161  }
1162  to_lower = true;
1163  }
1164  }
1165  else if (apostroph && cur == '\'') {
1166  to_lower = false;
1167  }
1168  else if (cur == ' ' || cur == '-') {
1169  to_lower = false;
1170  }
1171  }
1172  return ret;
1173 }
1174 
1175 
1176 static bool FixCapitalization(CAuth_list* auth_list)
1177 {
1178  bool ret = false;
1179  if (! auth_list) {
1180  return false;
1181  }
1182  for (auto auth : auth_list->SetNames().SetStd()) {
1183  if (auth->GetName().IsName()) {
1184  CName_std& name = auth->SetName().SetName();
1185  if (name.IsSetFirst() && !IsCapNameCorrect(name.GetFirst()) && FixCapitalization(name.SetFirst(), false)) {
1186  ret = true;
1187  }
1188  if (name.IsSetLast() && !IsCapNameCorrect(name.GetLast()) && FixCapitalization(name.SetLast(), true)) {
1189  ret = true;
1190  }
1191  if (name.IsSetInitials() && !IsCapInitialsCorrect(name.GetInitials())) {
1192  for (auto& cur : name.SetInitials()) {
1193  if (isalpha(cur) && islower(cur)) {
1194  cur = toupper(cur);
1195  ret = true;
1196  }
1197  }
1198  }
1199  }
1200  }
1201  return ret;
1202 }
1203 
1204 
1205 DISCREPANCY_AUTOFIX(CHECK_AUTH_CAPS)
1206 {
1207  CSerialObject* sobj = const_cast<CSerialObject*>(context.FindObject(*obj));
1208  CSeq_feat* feat = dynamic_cast<CSeq_feat*>(sobj);
1209  CSeqdesc* desc = dynamic_cast<CSeqdesc*>(sobj);
1210  CSubmit_block* subb = dynamic_cast<CSubmit_block*>(sobj);
1211 
1212  unsigned int n = 0;
1213  if (feat) {
1214  cout << "CHECK_AUTH_CAPS AUTOFIX on seq_feat -- coming soon!\n";
1215  }
1216  if (desc) {
1217  for (auto& authors : desc->SetPub().SetPub().Set()) {
1218  if (authors->IsSetAuthors()) {
1219  if (FixCapitalization(&authors->SetAuthors())) {
1220  obj->SetFixed();
1221  n++;
1222  }
1223  }
1224  }
1225  }
1226  if (subb) {
1227  if (subb->SetCit().IsSetAuthors()) {
1228  if (FixCapitalization(&subb->SetCit().SetAuthors())) {
1229  obj->SetFixed();
1230  n++;
1231  }
1232  }
1233  }
1234  return CRef<CAutofixReport>(n ? new CAutofixReport("CHECK_AUTH_CAPS: capitalization of [n] author[s] is fixed", n) : nullptr);
1235 }
1236 
1237 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
std representation
Definition: Affil_.hpp:91
@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
CAuthor –.
Definition: Author.hpp:59
CImprint –.
Definition: Imprint.hpp:66
@Name_std.hpp User-defined methods of the data storage class.
Definition: Name_std.hpp:56
Definition: Pub.hpp:56
@Pubdesc.hpp User-defined methods of the data storage class.
Definition: Pubdesc.hpp:54
CRef –.
Definition: ncbiobj.hpp:618
static void Add(TReportObjectList &list, TReportObjectSet &hash, CReportObj &obj, bool unique=true)
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Base class for all serializable objects.
Definition: serialbase.hpp:150
CSubmit_block –.
const string & GetTitle(C_E::E_Choice type=C_E::e_not_set) const
If the internal list contains a title (of the specified type, if given), returns the corresponding st...
Definition: Title.cpp:56
size_type size() const
Definition: set.hpp:132
const_iterator find(const key_type &key) const
Definition: set.hpp:137
@ eFatal
@ eBig
@ eDisc
@ eOncaller
@ eSubmitter
@ eSmart
#define DISCREPANCY_AUTOFIX(name)
#define DISCREPANCY_CASE(name, type, group, descr)
#define DISCREPANCY_SUMMARIZE(name)
std::ofstream out("events_result.xml")
main entry point for tests
static const struct name_t names[]
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static const char * proc
Definition: stats.c:21
char data[12]
Definition: iconv.c:80
constexpr size_t ArraySize(const Element(&)[Size])
Definition: ncbimisc.hpp:1532
#define MSerial_AsnBinary
Definition: serialbase.hpp:697
#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 kEmptyStr
Definition: ncbistr.hpp:123
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2993
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5430
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
#define NPOS
Definition: ncbistr.hpp:133
static string Sanitize(CTempString str, TSS_Flags flags=fSS_print)
Sanitize a string, allowing only specified classes of characters.
Definition: ncbistr.hpp:2876
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:5353
@ fSS_NoTruncate_Begin
Do not truncate leading spaces.
Definition: ncbistr.hpp:2849
@ fSS_alnum
Check on isalnum()
Definition: ncbistr.hpp:2837
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
static const char label[]
bool IsProc(void) const
Check if variant Proc is selected.
Definition: Cit_art_.hpp:507
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_book_.hpp:296
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_book_.hpp:347
const TCit & GetCit(void) const
Get the Cit member data.
Definition: Cit_let_.hpp:267
bool IsSetAffil(void) const
author affiliation Check if a value has been assigned to Affil data member.
Definition: Auth_list_.hpp:498
bool IsSetAuthors(void) const
Check if a value has been assigned to Authors data member.
Definition: Cit_gen_.hpp:623
bool IsSetAuthors(void) const
authors (ANSI requires) Check if a value has been assigned to Authors data member.
Definition: Cit_art_.hpp:534
const TJournal & GetJournal(void) const
Get the variant data.
Definition: Cit_art_.cpp:111
void SetSub(const TSub &value)
Assign a value to Sub data member.
Definition: Affil_.hpp:850
bool IsSetPrepub(void) const
Check if a value has been assigned to Prepub data member.
Definition: Imprint_.hpp:1080
const TFrom & GetFrom(void) const
Get the From member data.
Definition: Cit_art_.hpp:567
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_gen_.hpp:635
const TCit & GetCit(void) const
Get the Cit member data.
Definition: Cit_gen_.hpp:588
bool IsSetTitle(void) const
Title of book Check if a value has been assigned to Title data member.
Definition: Cit_book_.hpp:284
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Auth_list_.hpp:510
bool IsSetStreet(void) const
street address, not ANSI Check if a value has been assigned to Street data member.
Definition: Affil_.hpp:923
const TStr & GetStr(void) const
Get the variant data.
Definition: Affil_.hpp:1193
bool IsSetTitle(void) const
title of paper (ANSI requires) Check if a value has been assigned to Title data member.
Definition: Cit_art_.hpp:513
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_art_.hpp:525
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_sub_.hpp:357
bool IsSetCity(void) const
Author Affiliation, City Check if a value has been assigned to City data member.
Definition: Affil_.hpp:782
bool IsSetFrom(void) const
Check if a value has been assigned to From data member.
Definition: Cit_art_.hpp:555
bool IsSetAuthors(void) const
not necessarily authors of the paper Check if a value has been assigned to Authors data member.
Definition: Cit_sub_.hpp:345
TPrepub GetPrepub(void) const
Get the Prepub member data.
Definition: Imprint_.hpp:1099
const TStreet & GetStreet(void) const
Get the Street member data.
Definition: Affil_.hpp:935
const TName & GetName(void) const
Get the Name member data.
Definition: Author_.hpp:352
void SetAuthors(TAuthors &value)
Assign a value to Authors data member.
Definition: Cit_sub_.cpp:74
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Affil_.hpp:700
bool IsSetCit(void) const
anything, not parsable Check if a value has been assigned to Cit data member.
Definition: Cit_gen_.hpp:576
const TSub & GetSub(void) const
Get the Sub member data.
Definition: Affil_.hpp:841
const TProc & GetProc(void) const
Get the variant data.
Definition: Cit_art_.cpp:155
list< CRef< CAuthor > > TStd
Definition: Auth_list_.hpp:170
bool IsStr(void) const
Check if variant Str is selected.
Definition: Affil_.hpp:1187
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_gen_.hpp:933
bool CanGetAuthors(void) const
Check if it is safe to call GetAuthors method.
Definition: Cit_sub_.hpp:351
bool IsSetNames(void) const
Check if a value has been assigned to Names data member.
Definition: Auth_list_.hpp:464
bool IsSetTitle(void) const
eg.
Definition: Cit_gen_.hpp:921
bool IsSetAuthors(void) const
author/inventor Check if a value has been assigned to Authors data member.
Definition: Cit_pat_.hpp:703
void SetNames(TNames &value)
Assign a value to Names data member.
Definition: Auth_list_.cpp:149
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_pat_.hpp:715
bool CanGetNames(void) const
Check if it is safe to call GetNames method.
Definition: Auth_list_.hpp:472
bool IsSetDiv(void) const
Author Affiliation, Division Check if a value has been assigned to Div data member.
Definition: Affil_.hpp:735
const TCountry & GetCountry(void) const
Get the Country member data.
Definition: Affil_.hpp:888
const TStd & GetStd(void) const
Get the variant data.
Definition: Affil_.cpp:214
const TPostal_code & GetPostal_code(void) const
Get the Postal_code member data.
Definition: Affil_.hpp:1123
bool IsSetName(void) const
Author, Primary or Secondary Check if a value has been assigned to Name data member.
Definition: Author_.hpp:340
const TStr & GetStr(void) const
Get the variant data.
Definition: Auth_list_.hpp:450
bool IsSetTitle(void) const
Check if a value has been assigned to Title data member.
Definition: Cit_pat_.hpp:656
bool IsBook(void) const
Check if variant Book is selected.
Definition: Cit_art_.hpp:501
bool IsSetAuthors(void) const
authors Check if a value has been assigned to Authors data member.
Definition: Cit_book_.hpp:335
bool IsJournal(void) const
Check if variant Journal is selected.
Definition: Cit_art_.hpp:495
const TNames & GetNames(void) const
Get the Names member data.
Definition: Auth_list_.hpp:478
bool IsSetCit(void) const
same fields as a book Check if a value has been assigned to Cit data member.
Definition: Cit_let_.hpp:255
const TStd & GetStd(void) const
Get the variant data.
Definition: Auth_list_.hpp:410
bool IsStd(void) const
Check if variant Std is selected.
Definition: Affil_.hpp:1207
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_art_.hpp:546
bool IsSetPostal_code(void) const
Check if a value has been assigned to Postal_code data member.
Definition: Affil_.hpp:1111
bool IsSetCountry(void) const
Author Affiliation, Country Check if a value has been assigned to Country data member.
Definition: Affil_.hpp:876
const TImp & GetImp(void) const
Get the Imp member data.
Definition: Cit_book_.hpp:377
const TMl & GetMl(void) const
Get the variant data.
Definition: Auth_list_.hpp:430
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_pat_.hpp:668
const TCity & GetCity(void) const
Get the City member data.
Definition: Affil_.hpp:794
bool IsSetAffil(void) const
Author Affiliation, Name Check if a value has been assigned to Affil data member.
Definition: Affil_.hpp:688
const TDiv & GetDiv(void) const
Get the Div member data.
Definition: Affil_.hpp:747
TStd & SetStd(void)
Select the variant.
Definition: Affil_.cpp:220
E_Choice Which(void) const
Which variant is currently selected.
Definition: Auth_list_.hpp:375
bool IsSetImp(void) const
Check if a value has been assigned to Imp data member.
Definition: Cit_book_.hpp:365
bool IsSetSub(void) const
Author Affiliation, County Sub Check if a value has been assigned to Sub data member.
Definition: Affil_.hpp:829
const TBook & GetBook(void) const
Get the variant data.
Definition: Cit_art_.cpp:133
@ e_Ml
MEDLINE, semi-structured.
Definition: Auth_list_.hpp:114
@ e_Std
full citations
Definition: Auth_list_.hpp:113
E_Choice Which(void) const
Which variant is currently selected.
Definition: Person_id_.hpp:324
const TStr & GetStr(void) const
Get the variant data.
Definition: Person_id_.hpp:391
bool IsConsortium(void) const
Check if variant Consortium is selected.
Definition: Person_id_.hpp:405
void SetInitials(const TInitials &value)
Assign a value to Initials data member.
Definition: Name_std_.hpp:619
const TInitials & GetInitials(void) const
Get the Initials member data.
Definition: Name_std_.hpp:610
void SetLast(const TLast &value)
Assign a value to Last data member.
Definition: Name_std_.hpp:431
void SetFirst(const TFirst &value)
Assign a value to First data member.
Definition: Name_std_.hpp:478
bool IsSetInitials(void) const
first + middle initials Check if a value has been assigned to Initials data member.
Definition: Name_std_.hpp:598
const TMl & GetMl(void) const
Get the variant data.
Definition: Person_id_.hpp:371
bool IsSetLast(void) const
Check if a value has been assigned to Last data member.
Definition: Name_std_.hpp:410
const TConsortium & GetConsortium(void) const
Get the variant data.
Definition: Person_id_.hpp:411
const TFirst & GetFirst(void) const
Get the First member data.
Definition: Name_std_.hpp:469
const TLast & GetLast(void) const
Get the Last member data.
Definition: Name_std_.hpp:422
const TName & GetName(void) const
Get the variant data.
Definition: Person_id_.cpp:137
bool IsSetFirst(void) const
Check if a value has been assigned to First data member.
Definition: Name_std_.hpp:457
@ e_Ml
MEDLINE name (semi-structured) eg. "Jones RM".
Definition: Person_id_.hpp:97
@ e_Consortium
consortium name
Definition: Person_id_.hpp:99
@ e_Name
structured name
Definition: Person_id_.hpp:96
@ e_Str
unstructured name
Definition: Person_id_.hpp:98
bool CanGet(void) const
Check if it is safe to call Get method.
Definition: Pub_equiv_.hpp:159
list< CRef< CPub > > Tdata
Definition: Pub_equiv_.hpp:90
const TMan & GetMan(void) const
Get the variant data.
Definition: Pub_.cpp:365
const TArticle & GetArticle(void) const
Get the variant data.
Definition: Pub_.cpp:233
const TJournal & GetJournal(void) const
Get the variant data.
Definition: Pub_.cpp:255
const TSub & GetSub(void) const
Get the variant data.
Definition: Pub_.cpp:189
bool IsSet(void) const
Check if a value has been assigned to data member.
Definition: Pub_equiv_.hpp:153
const TPatent & GetPatent(void) const
Get the variant data.
Definition: Pub_.cpp:321
const Tdata & Get(void) const
Get the member data.
Definition: Pub_equiv_.hpp:165
const TProc & GetProc(void) const
Get the variant data.
Definition: Pub_.cpp:299
const TEquiv & GetEquiv(void) const
Get the variant data.
Definition: Pub_.cpp:387
E_Choice Which(void) const
Which variant is currently selected.
Definition: Pub_.hpp:555
bool IsEquiv(void) const
Check if variant Equiv is selected.
Definition: Pub_.hpp:671
bool IsSub(void) const
Check if variant Sub is selected.
Definition: Pub_.hpp:590
const TGen & GetGen(void) const
Get the variant data.
Definition: Pub_.cpp:167
const TBook & GetBook(void) const
Get the variant data.
Definition: Pub_.cpp:277
@ e_Article
Definition: Pub_.hpp:106
@ e_Book
Definition: Pub_.hpp:108
@ e_Gen
general or generic unparsed
Definition: Pub_.hpp:102
@ e_Journal
Definition: Pub_.hpp:107
@ e_Patent
Definition: Pub_.hpp:110
@ e_Proc
proceedings of a meeting
Definition: Pub_.hpp:109
@ e_Man
manuscript, thesis, or letter
Definition: Pub_.hpp:112
void SetPub(TPub &value)
Assign a value to Pub data member.
Definition: Pubdesc_.cpp:72
bool CanGetPub(void) const
Check if it is safe to call GetPub method.
Definition: Pubdesc_.hpp:599
TPub & SetPub(void)
Select the variant.
Definition: Seqdesc_.cpp:362
const TPub & GetPub(void) const
Get the variant data.
Definition: Seqdesc_.cpp:356
bool IsPub(void) const
Check if variant Pub is selected.
Definition: Seqdesc_.hpp:1096
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
const TCit & GetCit(void) const
Get the Cit member data.
void SetCit(TCit &value)
Assign a value to Cit data member.
bool CanGetCit(void) const
Check if it is safe to call GetCit method.
int i
yy_size_t n
int len
const struct ncbi::grid::netcache::search::fields::SIZE size
unsigned int a
Definition: ncbi_localip.c:102
int isalpha(Uchar c)
Definition: ncbictype.hpp:61
int isspace(Uchar c)
Definition: ncbictype.hpp:69
int tolower(Uchar c)
Definition: ncbictype.hpp:72
int toupper(Uchar c)
Definition: ncbictype.hpp:73
int ispunct(Uchar c)
Definition: ncbictype.hpp:68
int islower(Uchar c)
Definition: ncbictype.hpp:66
int isupper(Uchar c)
Definition: ncbictype.hpp:70
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
string SummarizeAffiliation(const CAffil::C_Std &affil)
Definition: pub_tests.cpp:448
USING_SCOPE(objects)
static bool ReplaceStateAbbreviation(CAffil *affil)
Definition: pub_tests.cpp:981
static size_t kNumOfAbbreviations
Definition: pub_tests.cpp:936
static const char * kTitleAuthorConflict
Definition: pub_tests.cpp:234
#define REPORT_CITSUBAFFIL_CONFLICT(order, field, alias)
static bool FixCapitalization(string &name, bool apostroph)
Definition: pub_tests.cpp:1147
static bool RemoveAffilDup(CCit_sub *cit_sub)
Definition: pub_tests.cpp:782
void GetPubTitleAndAuthors(const CPub &pub, string &title, string &authors)
Definition: pub_tests.cpp:153
bool IsPubUnpublished(const CImprint &imp)
Definition: pub_tests.cpp:264
static bool RemoveAffilStreetEnd(string &street, const string &tail, bool country)
Definition: pub_tests.cpp:765
static bool IsCapInitialsCorrect(const string &initials)
Definition: pub_tests.cpp:1104
static const CCit_sub * GetCitSubFromPub(const CPub &pub)
Definition: pub_tests.cpp:686
const string kTitleAuthorConflictEnd
Definition: pub_tests.cpp:67
static bool AffilStreetEndsWith(const string &street, const string &tail)
Definition: pub_tests.cpp:704
static bool AffilStreetContainsDup(const CAffil &affil)
Definition: pub_tests.cpp:720
const string kTitleAuthorConflictStart
Definition: pub_tests.cpp:66
bool IsCitSubMissingAffiliation(const CPubdesc &pubdesc)
Definition: pub_tests.cpp:408
static const string kIncorrectCap
Definition: pub_tests.cpp:1042
string GetAuthorString(const CName_std &name_std)
Definition: pub_tests.cpp:69
static pair< string, string > us_state_abbreviations[]
Definition: pub_tests.cpp:839
static bool IsValidStateAbbreviation(const string &state)
Definition: pub_tests.cpp:938
bool HasUnpubWithoutTitle(const CPubdesc &pubdesc)
Definition: pub_tests.cpp:358
const string kMissingAuthorsName
Definition: pub_tests.cpp:657
bool HasNoAffiliation(const CAffil &affil)
Definition: pub_tests.cpp:389
#define ADD_TO_AFFIL_SUMMARY(Fieldname)
Definition: pub_tests.cpp:440
const string kCitSubSummary
Definition: pub_tests.cpp:480
static int RemoveConsortium(CAuth_list &authors)
Definition: pub_tests.cpp:610
static bool IsCapNameCorrect(const string &name)
Definition: pub_tests.cpp:1044
const string kSummaries
Definition: pub_tests.cpp:481
CRef< CPub > journal(ParserPtr pp, char *bptr, char *eptr, CRef< CAuth_list > &auth_list, CRef< CTitle::C_E > &title, bool has_muid, CRef< CCit_art > &cit_art, Int4 er)
Definition: ref.cpp:1457
Definition: inftrees.h:24
static CS_CONTEXT * context
Definition: will_convert.c:21
#define const
Definition: zconf.h:232
Modified on Thu May 23 12:32:06 2024 by modify_doxy.py rev. 669887