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

Go to the SVN repository for this file.

1 /* $Id: src_writer.cpp 101739 2024-02-05 19:02:40Z kans $
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: Frank Ludwig, Justin Foley
27  *
28  * File Description: Write source qualifiers
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
43 
44 #include <objmgr/seqdesc_ci.hpp>
46 
51 
52 #include <objects/pub/Pub.hpp>
54 #include <objects/pub/Pub_set.hpp>
55 
59 #include <objects/biblio/Affil.hpp>
61 
63 
67 #include <objmgr/util/sequence.hpp>
68 
69 #include <sstream>
70 
73 
76 // ----------------------------------------------------------------------------
77 // Default Fields:
78 // ----------------------------------------------------------------------------
79 static const string arrDefaultSrcCheckFields[] = {
80  "id",
81  "gi",
82  "organism",
83  "taxid",
84  "specimen-voucher",
85  "culture-collection",
86  "bio-material",
87  "strain",
88  "sub-strain",
89  "isolate",
90  "sub-species",
91  "variety",
92  "forma",
93  "cultivar",
94  "ecotype",
95  "serotype",
96  "serovar",
97  "type-material",
98  "old-name",
99  "author",
100  "affil"
101 };
102 
103 static const string arrDefaultSeqEntryFields[] = {
104  "id",
105  "gi",
106  "organism",
107  "taxid",
108  "localid",
109  "specimen-voucher",
110  "culture-collection",
111  "bio-material",
112  "strain",
113  "sub-strain",
114  "isolate",
115  "sub-species",
116  "variety",
117  "forma",
118  "cultivar",
119  "ecotype",
120  "serotype",
121  "serovar",
122  "type-material",
123  "old-name",
124  "author",
125  "affil"
126 };
127 
128 
129 const size_t countDefaultSrcCheckFields = sizeof(arrDefaultSrcCheckFields)/sizeof(string);
130 
133 
135  xGetOrderedFieldNames(CSrcWriter::sDefaultSrcCheckFields));
136 
137 const size_t countDefaultSeqEntryFields = sizeof(arrDefaultSeqEntryFields)/sizeof(string);
138 
141 
143  xGetOrderedFieldNames(CSrcWriter::sDefaultSeqEntryFields));
144 
145 // ----------------------------------------------------------------------------
147  CBioseq_Handle bsh,
148  const FIELDS& desiredFields,
149  CNcbiOstream& out)
150 // ----------------------------------------------------------------------------
151 {
152  FIELDS colNames = xProcessFieldNames(desiredFields);
153 
154  if (!xGather(bsh, "", colNames)) {
155  return false;
156  }
157  if (!xFormatTabDelimited(colNames, out)) {
158  return false;
159  }
160  return true;
161 };
162 
163 
164 // ----------------------------------------------------------------------------
166  const vector<pair<string,CBioseq_Handle> >& vecIdBsh,
167  const FIELDS& desiredFields,
168  CNcbiOstream& out,
169  ILineErrorListener* pEC)
170 // ----------------------------------------------------------------------------
171 {
172  typedef vector<pair<string,CBioseq_Handle> > HANDLES;
173  FIELDS colNames = xProcessFieldNames(desiredFields);
174 
175  for (HANDLES::const_iterator it = vecIdBsh.begin(); it != vecIdBsh.end(); ++it) {
176  if (!xGather(it->second, it->first, colNames)) {
177  return false;
178  }
179  }
180 
181  if (!xFormatTabDelimited(colNames,out)) {
182  return false;
183  }
184  return true;
185 };
186 
187 
188 // ----------------------------------------------------------------------------
190  const CSeq_entry& seqEntry,
191  CScope& scope,
192  CNcbiOstream& out,
193  const bool nucsOnly)
194 // ----------------------------------------------------------------------------
195 {
196  CSeq_entry_Handle handle = scope.AddTopLevelSeqEntry(seqEntry);
197  vector<pair<string,CBioseq_Handle> > vecIdBsh;
198  for (CBioseq_CI bci(handle); bci; ++bci) {
199  if(!nucsOnly || bci->IsNa()) {
200  vecIdBsh.push_back(make_pair("",*bci));
201  }
202  }
204 
205  return true;
206 }
207 
208 
209 // ----------------------------------------------------------------------------
211  const FIELDS& desiredFields)
212 // ----------------------------------------------------------------------------
213 {
214  FIELDS colNames;
215  if (desiredFields[0] != "id") {
216  colNames.push_back("id");
217  }
218  for (FIELDS::const_iterator cit = desiredFields.begin();
219  cit != desiredFields.end(); ++cit) {
221  if (mapIterator != sFieldnameToColname.end()) {
222  colNames.push_back(mapIterator->second);
223  } else {
224  colNames.push_back(*cit);
225  }
226  }
227  return colNames;
228 }
229 
230 
231 // ---------------------------------------------------------------------------
233  const string& colName,
234  const string& colTitle,
235  const string& colDefault)
236 // ---------------------------------------------------------------------------
237 {
239  if (it == mColnameToIndex.end()) {
241  pColumn->SetHeader().SetField_name(colName);
242  pColumn->SetHeader().SetTitle(colTitle);
243  pColumn->SetDefault().SetString(colDefault);
244  mColnameToIndex[colName] = mSrcTable->GetColumns().size();
245  mSrcTable->SetColumns().push_back(pColumn);
246  }
247  size_t index = mColnameToIndex[colName];
248  CSeqTable_column& column = *mSrcTable->SetColumns().at(index);
249  column.SetData().SetString();
250  while (column.GetData().GetString().size() < mSrcTable->GetNum_rows()) {
251  column.SetData().SetString().push_back(colDefault);
252  }
253 }
254 
255 
256 // ----------------------------------------------------------------------------
258  // ----------------------------------------------------------------------------
259 {
260  if (sHandlerMap.empty()) {
268  sHandlerMap["pcr-primers"] = &CSrcWriter::xGatherPcrPrimers;
270 
272  sHandlerMap["subsource-note"] = &CSrcWriter::xGatherSubtypeFeat;
273 
274  NAMELIST nameList = xGetOrgModSubtypeNames();
275  for (NAMELIST::const_iterator cit=nameList.begin();
276  cit != nameList.end(); ++cit) {
277  if (*cit != "other" && *cit != "common") {
279  }
280  }
281 
282  nameList = xGetSubSourceSubtypeNames();
283  for (NAMELIST::const_iterator cit=nameList.begin();
284  cit != nameList.end(); ++cit) {
285  if (*cit != "other") {
287  }
288  }
289  }
290 
291 
292  if (sFieldnameToColname.empty()) {
293  sFieldnameToColname["id"] = "id";
294  sFieldnameToColname["gi"] = "gi";
295  sFieldnameToColname["localid"] = "localid";
296  sFieldnameToColname["bankitid"] = "bankitid";
297  sFieldnameToColname["definition"] = "definition";
298  sFieldnameToColname["def"] = "definition";
299  sFieldnameToColname["defline"] = "definition";
300 
301  sFieldnameToColname["author"] = "author";
302  sFieldnameToColname["affil"] = "affil";
303 
304  sFieldnameToColname["db"] = "db";
305  sFieldnameToColname["org.db"] = "db";
306 
307  sFieldnameToColname["taxid"] = "taxid";
308  sFieldnameToColname["div"] = "division";
309  sFieldnameToColname["division"] = "division";
310  sFieldnameToColname["genome"] = "genome";
311  sFieldnameToColname["lineage"] = "lineage";
312  sFieldnameToColname["common"] = "common";
313  sFieldnameToColname["org.common"] = "common";
314 
315  sFieldnameToColname["origin"] = "origin";
316  sFieldnameToColname["pcrprimers"] = "pcr-primers";
317  sFieldnameToColname["organism"] = "organism";
318  sFieldnameToColname["taxname"] = "organism";
319  sFieldnameToColname["org.taxname"] = "organism";
320  sFieldnameToColname["org"] = "organism";
321 
322  // OrgMod
323  sFieldnameToColname["note"] = "note";
324  sFieldnameToColname["orgmod.note"] = "note";
325 
326  // Subsource
327  sFieldnameToColname["insertionseq"] = "insertion-seq";
328  sFieldnameToColname["plasmid"] = "plasmid";
329  sFieldnameToColname["transposon"] = "transposon";
330 
331  sFieldnameToColname["subsourcenote"] = "subsource-note";
332  sFieldnameToColname["subsrcnote"] = "subsource-note";
333 
334  NAMELIST nameList = xGetOrgModSubtypeNames();
335  for (NAMELIST::const_iterator cit=nameList.begin();
336  cit != nameList.end(); ++cit) {
337 
338  if (*cit != "other") {
340  }
341  }
342 
343  nameList = xGetSubSourceSubtypeNames();
344  for (NAMELIST::const_iterator cit=nameList.begin();
345  cit != nameList.end(); ++cit) {
346  if(*cit != "other") {
348  }
349  }
350 
351  }
352 
353 
354  mSrcTable.Reset(new CSeq_table());
356 }
357 
358 
359 // ----------------------------------------------------------------------------
361  // ----------------------------------------------------------------------------
362 {
363  FIELDS orderedFields;
364  set<string> processedFields;
365 
366  for (FIELDS::const_iterator cit=defaultFields.begin();
367  cit != defaultFields.end();
368  ++cit) {
369  string colName = *cit;
370  orderedFields.push_back(colName);
371  processedFields.insert(xCompressFieldName(colName));
372  }
373 
374  FIELDS lexicalFields;
375  lexicalFields.push_back("organism");
376  lexicalFields.push_back("genome");
377  lexicalFields.push_back("pcr-primers");
378  lexicalFields.push_back("db");
379  lexicalFields.push_back("common");
380  lexicalFields.push_back("lineage");
381  lexicalFields.push_back("origin");
382  lexicalFields.push_back("note");
383  lexicalFields.push_back("subsource-note");
384  lexicalFields.push_back("division");
385  lexicalFields.push_back("definition");
386  lexicalFields.push_back("bankitid");
387 
388  lexicalFields.push_back("author");
389  lexicalFields.push_back("affil");
390 
391  NAMELIST nameList = xGetOrgModSubtypeNames();
392  for(NAMELIST::const_iterator cit=nameList.begin();
393  cit != nameList.end(); ++cit) {
394  if (*cit != "other" && *cit != "common") {
395  lexicalFields.push_back(*cit);
396  }
397  }
398 
399  nameList = xGetSubSourceSubtypeNames();
400  for(NAMELIST::const_iterator cit=nameList.begin();
401  cit != nameList.end(); ++cit) {
402  if(*cit != "other") {
403  lexicalFields.push_back(*cit);
404  }
405  }
406 
407  sort(lexicalFields.begin(), lexicalFields.end());
408 
409  for (FIELDS::const_iterator cit = lexicalFields.begin();
410  cit != lexicalFields.end(); ++cit)
411  {
412  string compressed_name = xCompressFieldName(*cit);
413  if (processedFields.find(compressed_name) == processedFields.end()) {
414  orderedFields.push_back(*cit);
415  processedFields.insert(compressed_name);
416  }
417  }
418 
419  return orderedFields;
420 }
421 
422 
423 // ----------------------------------------------------------------------------
425  // ----------------------------------------------------------------------------
426 {
427  NAMELIST subtypeNames;
428 
429  typedef const CEnumeratedTypeValues::TValues TVALUES;
430  TVALUES nameValPairs = COrgMod::ENUM_METHOD_NAME(ESubtype)()->GetValues();
431 
432  for (TVALUES::const_iterator cit = nameValPairs.begin();
433  cit != nameValPairs.end(); ++cit) {
434  subtypeNames.push_back(cit->first);
435  }
436  return subtypeNames;
437 }
438 
439 
440 // ----------------------------------------------------------------------------
442  // ----------------------------------------------------------------------------
443 {
444  NAMELIST subtypeNames;
445 
446  typedef const CEnumeratedTypeValues::TValues TVALUES;
447  TVALUES nameValPairs = CSubSource::ENUM_METHOD_NAME(ESubtype)()->GetValues();
448 
449  for (TVALUES::const_iterator cit = nameValPairs.begin();
450  cit != nameValPairs.end(); ++cit) {
451  subtypeNames.push_back(cit->first);
452  }
453  return subtypeNames;
454 }
455 
456 
457 // ----------------------------------------------------------------------------
459  const string& fieldName)
460 // ----------------------------------------------------------------------------
461 {
462  string name = NStr::TruncateSpaces(fieldName);
463  NStr::ToLower(name);
464  NStr::ReplaceInPlace(name,"\"","");
465  NStr::ReplaceInPlace(name,"-","");
466  NStr::ReplaceInPlace(name, "_", "");
467  NStr::ReplaceInPlace(name, " ", "");
468 
469  return name;
470 }
471 
472 
473 // ----------------------------------------------------------------------------
475  CSubSource::TSubtype subtype)
476 // ----------------------------------------------------------------------------
477 {
478  if (CSubSource::IsDiscouraged(subtype)) {
479  return true;
480  }
481  return false;
482 }
483 
484 
485 // ----------------------------------------------------------------------------
487  COrgMod::TSubtype subtype)
488 // ----------------------------------------------------------------------------
489 {
490  if (COrgMod::eSubtype_old_name == subtype) {
491  return false;
492  }
493  if (COrgMod::IsDiscouraged(subtype)) {
494  return true;
495  }
496  return false;
497 }
498 
499 
500 // ----------------------------------------------------------------------------
502  const string& fieldName)
503 // ----------------------------------------------------------------------------
504 {
505  return sHandlerMap[fieldName];
506 }
507 
508 
509 // ----------------------------------------------------------------------------
511  const CBioSource& src,
512  const string& fieldName,
513  ILineErrorListener* pEC)
514 // ----------------------------------------------------------------------------
515 {
516  HANDLER pHandler = xGetHandler(fieldName);
517 
518  if (!pHandler) {
521  "Unable to find handler for field \"" + fieldName + "\".");
522  pEC->PutError(*pE);
523  delete pE;
524  return false;
525  }
526 
527  return (this->*pHandler)(src, fieldName, pEC);
528 }
529 
530 
531 // ----------------------------------------------------------------------------
533  const string& id,
535 // ----------------------------------------------------------------------------
536 {
537  if (id.empty()) {
538  return false;
539  }
540 
541  string displayName;
542  string colName;
543  if ( NStr::StringToNumeric<TIntId>(id, NStr::fConvErr_NoThrow)) {
544  colName = displayName = "gi";
545  } else {
546  colName = "id";
547  displayName = "accession";
548  }
549 
550  const string defaultValue;
551  xPrepareTableColumn(colName, displayName, defaultValue);
552  xAppendColumnValue(colName, id);
553 
555  return true;
556 }
557 
558 
559 // ----------------------------------------------------------------------------
561  CBioseq_Handle bsh,
562  const string default_id,
563  const FIELDS& desiredFields,
565 // ----------------------------------------------------------------------------
566 {
567  // for each of biosources we may create individual record
568  // with the same ID
569  bool wantGi = ( find(desiredFields.begin(), desiredFields.end(), "gi") != desiredFields.end() );
570  bool wantLocalId = ( find(desiredFields.begin(), desiredFields.end(), "localid") != desiredFields.end() );
571  bool wantBankitId = ( find(desiredFields.begin(), desiredFields.end(), "bankitid") != desiredFields.end() );
572  bool wantDef = ( find(desiredFields.begin(), desiredFields.end(), "definition") != desiredFields.end() );
573  bool wantAuthor = ( find(desiredFields.begin(), desiredFields.end(), "author") != desiredFields.end() );
574  bool wantAffil = ( find(desiredFields.begin(), desiredFields.end(), "affil") != desiredFields.end() );
575 
576 
577  if (!bsh) {
578  return xTryDefaultId(default_id);
579  }
580 
581  if (!xGatherId(bsh) ||
582  (wantGi && !xGatherGi(bsh)) ||
583  (wantLocalId && !xGatherLocalId(bsh)) ||
584  (wantBankitId && !xGatherBankitId(bsh)) ||
585  (wantDef && !xGatherDefline(bsh))) {
586  return false; // Not sure if this is the correct logic.
587  // If any of the accession, GI, Local ID or definition are invalid/not found,
588  // the row is not counted.
589  }
590 
591  if (wantAuthor || wantAffil) {
592  string auths;
593  string comma;
594  string affls;
595  const CCit_sub* latest_sub = nullptr;
596  const CDate* latest_date = nullptr;
597  for (CSeqdesc_CI pdit(bsh, CSeqdesc::e_Pub); pdit; ++pdit) {
598  const CPubdesc& pubdesc = pdit->GetPub();
599  if (pubdesc.IsSetPub()) {
600  const CPub_equiv& pep = pubdesc.GetPub();
601  if (pep.IsSet()) {
602  ITERATE ( CPub_equiv::Tdata, it, pep.Get()) {
603  if ((*it)->Which() == CPub::e_Sub) {
604  const CCit_sub& sub = (*it)->GetSub();
605  if (sub.IsSetDate()) {
606  const CDate& curr_date = sub.GetDate();
607  if (latest_date) {
608  if (latest_date->Compare(curr_date) == CDate::eCompare_before) {
609  latest_sub = &sub;
610  latest_date = &curr_date;
611  }
612  } else {
613  latest_sub = &sub;
614  latest_date = &curr_date;
615  }
616  }
617  }
618  }
619  }
620  }
621  }
622  if (latest_sub) {
623  if (latest_sub->IsSetAuthors()) {
624  const CAuth_list& authors = latest_sub->GetAuthors();
625  if (authors.IsSetNames()) {
626  const CAuth_list::TNames& names = authors.GetNames();
627  if (names.IsStd()) {
628  ITERATE (CAuth_list::TNames::TStd, it, names.GetStd()) {
629  const CAuthor& auth = **it;
630  if (auth.IsSetName()) {
631  const CPerson_id& pid = auth.GetName();
632  if (pid.IsName()) {
633  const CName_std& name = pid.GetName();
634  if (name.IsSetLast()) {
635  string nm;
636  if (name.IsSetInitials()) {
637  nm = name.GetInitials() + " ";
638  }
639  nm += name.GetLast();
640  auths += comma + nm;
641  }
642  comma = ", ";
643  } else if (pid.IsConsortium()) {
644  string cnsrt = pid.GetConsortium();
645  auths += comma + cnsrt;
646  comma = ", ";
647  }
648  }
649  }
650  }
651  }
652  if (authors.IsSetAffil()) {
653  const CAffil& affil = authors.GetAffil();
654  if (affil.IsStr()) {
655  affls = affil.GetStr();
656  } else if (affil.IsStd()) {
657  const CAffil::C_Std& std = affil.GetStd();
658  if (std.IsSetAffil()) {
659  affls = std.GetAffil();
660  }
661  }
662  }
663  }
664  }
665  if (wantAuthor) {
666  if (auths.length() > 0) {
667  static const string colName = "author";
668  static const string displayName = colName;
669  static const string defaultValue;
670 
671  xPrepareTableColumn(colName, displayName, defaultValue);
672  xAppendColumnValue(colName, auths);
673  }
674  }
675  if (wantAffil) {
676  if (affls.length() > 0) {
677  static const string colName = "affil";
678  static const string displayName = colName;
679  static const string defaultValue;
680 
681  xPrepareTableColumn(colName, displayName, defaultValue);
682  xAppendColumnValue(colName, affls);
683  }
684  }
685  }
686 
687  int num_sources = 0;
688  for (CSeqdesc_CI sdit(bsh, CSeqdesc::e_Source); sdit; ++sdit) {
689  const CBioSource& src = sdit->GetSource();
690  for (FIELDS::const_iterator cit = desiredFields.begin();
691  cit != desiredFields.end(); ++cit) {
692  if (*cit == "id" || *cit == "gi" || *cit == "definition" || *cit == "localid" ||
693  *cit == "bankitid" || *cit == "author" || *cit == "affil") {
694  continue;
695  }
696  if (!xHandleSourceField(src, *cit)) {
697  return false;
698  }
699  }
700  ++num_sources;
701  mSrcTable->SetNum_rows(mSrcTable->GetNum_rows()+1); // Each source has its own row
702  }
703 
704 
705  if (num_sources == 0) {
707  }
708 
709 
710  return true;
711 }
712 
713 
714 // ----------------------------------------------------------------------------
716  CBioseq_Handle bsh,
718 // ----------------------------------------------------------------------------
719 {
720  if (!bsh) {
721  return false;
722  }
723 
724  string label;
725  CConstRef<CSeq_id> sid = bsh.GetSeqId();
727 
728  if (!label.empty()) {
729  const string colName = "id";
730  const string defaultValue;
731  xPrepareTableColumn(colName, "accession", defaultValue);
732  xAppendColumnValue(colName, label);
733  }
734  return true;
735 }
736 
737 
738 // ----------------------------------------------------------------------------
740  CBioseq_Handle bsh,
742 // ----------------------------------------------------------------------------
743 {
744 
745  if (!bsh) {
746  return false;
747  }
748 
749  const string colName = "gi";
750  string label;
751 
752  ITERATE( CBioseq_Handle::TId, it, bsh.GetId() ) {
753  if( it->IsGi() ){
754  it->GetSeqId()->GetLabel(&label, CSeq_id::eContent);
755  break;
756  }
757  }
758 
759  if (!label.empty()) {
760  const string displayName = "gi";
761  const string defaultValue;
762  xPrepareTableColumn(colName, displayName, defaultValue);
763  xAppendColumnValue(colName, label);
764  }
765  return true;
766 }
767 
768 
769 // ----------------------------------------------------------------------------
771 // ----------------------------------------------------------------------------
772 {
773  const CBioseq_Handle::TDescr& descr= bsh.GetDescr();
774 
775  FOR_EACH_SEQDESC_ON_SEQDESCR (it, descr) {
776  const CSeqdesc& desc = **it;
777  if ( !desc.IsUser() || !desc.GetUser().IsSetType() ) continue;
778  const CUser_object& usr = desc.GetUser();
779  const CObject_id& oi = usr.GetType();
780  if ( !oi.IsStr() ) continue;
781  const string& type = oi.GetStr();
782  if ( !NStr::EqualNocase(type, "OrginalID") && !NStr::EqualNocase(type, "OriginalID") ) continue;
784  const CUser_field& fld = **uitr;
785  if ( FIELD_IS_SET_AND_IS(fld, Label, Str) ) {
786  const string &label_str = GET_FIELD(fld.GetLabel(), Str);
787  if ( !NStr::EqualNocase(label_str, "LocalId") ) continue;
788  if ( fld.IsSetData() && fld.GetData().IsStr() ) {
789  return fld.GetData().GetStr();
790  }
791  }
792  }
793  }
794 
795  return "";
796 }
797 
798 
799 // ----------------------------------------------------------------------------
801  CBioseq_Handle bsh,
803 // ----------------------------------------------------------------------------
804 {
805  if (!bsh) {
806  return true;
807  }
808 
809  static const string colName = "localid";
810  static const string displayName = colName;
811  static const string defaultValue;
812 
813  string local_id = xGetOriginalId(bsh);
814  if ( NStr::IsBlank(local_id) ) {
815  CConstRef<CSeq_id> seq_id = bsh.GetLocalIdOrNull();
816  if ( !seq_id ) {
817  return true;
818  }
819  seq_id->GetLabel(&local_id, CSeq_id::eContent);
820  if ( NStr::IsBlank(local_id) ) {
821  return true;
822  }
823  }
824 
825  xPrepareTableColumn(colName, displayName, defaultValue);
826  xAppendColumnValue(colName, local_id);
827  return true;
828 }
829 
830 
831 // ----------------------------------------------------------------------------
833  CBioseq_Handle bsh,
835 // ----------------------------------------------------------------------------
836 {
837  if (!bsh) {
838  return true;
839  }
840 
841  static const string colName = "bankitid";
842  static const string displayName = colName;
843  static const string defaultValue;
844 
845  stringstream bankitIdOstr;
846  ITERATE( CBioseq_Handle::TId, it, bsh.GetId() ) {
847  const auto& pId = it->GetSeqId();
848  if (!pId || !pId->IsGeneral()) {
849  continue;
850  }
851  const auto& general = pId->GetGeneral();
852  if (!general.IsSetDb() || general.GetDb() != "BankIt") {
853  continue;
854  }
855  if (!general.IsSetTag()) {
856  continue; // not enough to work with
857  }
858  bankitIdOstr << "BankIt";
859  general.GetTag().AsString(bankitIdOstr);
860  break;
861  }
862  string bankitId = bankitIdOstr.str();
863  if (!bankitId.empty()) {
864  xPrepareTableColumn(colName, displayName, defaultValue);
865  xAppendColumnValue(colName, bankitId);
866  }
867  return true;
868 }
869 
870 
872  CBioseq_Handle bsh,
874 // ----------------------------------------------------------------------------
875 {
876  if (!bsh) {
877  return true;
878  }
879 
880  static const string colName = "definition";
881  static const string displayName = colName;
882  static const string defaultValue;
883 
884 
885  string label =
886  sequence::CDeflineGenerator().GenerateDefline(bsh);
887  if (label.empty()) {
888  return true;
889  }
890  xPrepareTableColumn(colName, displayName, defaultValue);
891  xAppendColumnValue(colName, label);
892  return true;
893 }
894 
895 
896 // ----------------------------------------------------------------------------
898  const CBioSource& src,
899  const string& colName,
901 // ----------------------------------------------------------------------------
902 {
903  const string displayName = "organism";
904  const string defaultValue;
905 
906  if (!src.IsSetTaxname()) {
907  return true;
908  }
909  string value = src.GetTaxname();
910  xPrepareTableColumn(colName, displayName, defaultValue);
911  xAppendColumnValue(colName, value);
912  return true;
913 }
914 
915 
916 // ----------------------------------------------------------------------------
918  const CBioSource& src,
919  const string& colName,
921 // ----------------------------------------------------------------------------
922 {
923  const string displayName = "common";
924  const string defaultValue;
925 
926  if (!src.IsSetOrg() || !src.GetOrg().IsSetCommon()) {
927  return true;
928  }
929  string value = src.GetOrg().GetCommon();
930  xPrepareTableColumn(colName, displayName, defaultValue);
931  xAppendColumnValue(colName, value);
932  return true;
933 }
934 
935 
936 // ----------------------------------------------------------------------------
938  const CBioSource& src,
939  const string& colName,
941 // ----------------------------------------------------------------------------
942 {
943  const string displayName = "lineage";
944  const string defaultValue;
945 
946  if (!src.IsSetOrg() || !src.GetOrg().IsSetOrgname()
947  || !src.GetOrg().GetOrgname().IsSetLineage()) {
948  return true;
949  }
950  string value = src.GetOrg().GetOrgname().GetLineage();
951  xPrepareTableColumn(colName, displayName, defaultValue);
952  xAppendColumnValue(colName, value);
953  return true;
954 }
955 
956 
957 // ----------------------------------------------------------------------------
959  const CBioSource& src,
960  const string& colName,
962 // ----------------------------------------------------------------------------
963 {
964  const string displayName = "division";
965  const string defaultValue;
966 
967  if (!src.IsSetOrg() || !src.GetOrg().IsSetDivision()) {
968  return true;
969  }
970  string value = src.GetOrg().GetDivision();
971  xPrepareTableColumn(colName, displayName, defaultValue);
972  xAppendColumnValue(colName, value);
973  return true;
974 }
975 
976 
977 // ----------------------------------------------------------------------------
979  const CBioSource& src,
980  const string& colName,
982 // ----------------------------------------------------------------------------
983 {
984  const string displayName = "genome";
985  const string defaultValue;
986 
987  if (!src.IsSetGenome()) {
988  return true;
989  }
991  xPrepareTableColumn(colName, displayName, defaultValue);
992  xAppendColumnValue(colName, value);
993  return true;
994 }
995 
996 
997 // ----------------------------------------------------------------------------
999  const CBioSource& src,
1000  const string& colName,
1002 // ----------------------------------------------------------------------------
1003 {
1004  const string displayName = "origin";
1005  const string defaultValue;
1006 
1007  if (!src.IsSetOrigin()) {
1008  return true;
1009  }
1011  xPrepareTableColumn(colName, displayName, defaultValue);
1012  xAppendColumnValue(colName, value);
1013  return true;
1014 }
1015 
1016 
1017 // ----------------------------------------------------------------------------
1019  const CBioSource& src,
1020  const string& colName,
1022 // ----------------------------------------------------------------------------
1023 {
1024 
1025 
1026  if ( !src.IsSetSubtype() ) {
1027  return true;
1028  }
1029 
1031 
1032  if ( xIsSubsourceTypeSuppressed(subtype) ) {
1033  return true;
1034  }
1035 
1036 
1037  typedef list<CRef<CSubSource> > SUBSOURCES;
1038  const SUBSOURCES& subsources = src.GetSubtype();
1039 
1040  string key = colName;
1041  int count = 0;
1042  for (SUBSOURCES::const_iterator cit = subsources.begin();
1043  cit != subsources.end(); ++cit) {
1044 
1045  const CSubSource& subsrc = **cit;
1046  if (subsrc.GetSubtype() != subtype) {
1047  continue;
1048  }
1049 
1050  if (count) {
1051  key = colName + "#" + NStr::IntToString(count+1);
1052  }
1053  ++count;
1054 
1055  string value;
1056  if (subsrc.IsSetName()) {
1057  value = subsrc.GetName();
1058  }
1059  if (value.empty() && CSubSource::NeedsNoText(subsrc.GetSubtype())) {
1060  value = "true";
1061  }
1062  xPrepareTableColumn(key, key, "");
1064  }
1065  return true;
1066 }
1067 
1068 
1069 // ----------------------------------------------------------------------------
1071  const CBioSource& src,
1072  const string& colName,
1074 // ----------------------------------------------------------------------------
1075 {
1076  if ( !src.IsSetOrgMod() ) {
1077  return true;
1078  }
1079 
1081 
1082  if ( xIsOrgmodTypeSuppressed(subtype) ) {
1083  return true;
1084  }
1085 
1086  typedef list<CRef<COrgMod> > ORGMODS;
1087  const ORGMODS& orgmods = src.GetOrgname().GetMod();
1088 
1089  string key = colName;
1090  int count = 0;
1091  for (ORGMODS::const_iterator cit = orgmods.begin();
1092  cit != orgmods.end(); ++cit) {
1093  const COrgMod& orgmod = **cit;
1094 
1095  if (orgmod.GetSubtype() != subtype) {
1096  continue;
1097  }
1098 
1099  if (count) {
1100  key = colName + "#" + NStr::IntToString(count+1);
1101  }
1102  ++count;
1103 
1104  string value = orgmod.GetSubname();
1105  xPrepareTableColumn(key, key, "");
1107  }
1108  return true;
1109 }
1110 
1111 
1112 // ----------------------------------------------------------------------------
1114  const CBioSource& src,
1115  const string& colName,
1117 // ----------------------------------------------------------------------------
1118 {
1119  static const string displayName = "db";
1120  static const string defaultValue;
1121 
1122  if (!src.IsSetOrg() || !src.GetOrg().IsSetDb()) {
1123  return true;
1124  }
1125 
1126  typedef vector< CRef< CDbtag > > DBTAGS;
1127  const DBTAGS& tags = src.GetOrg().GetDb();
1128  for (DBTAGS::const_iterator cit = tags.begin(); cit != tags.end(); ++cit) {
1129  const CDbtag& tag = **cit;
1130  if (!tag.IsSetDb() || tag.GetDb().empty() || !tag.IsSetTag()) {
1131  continue;
1132  }
1133  const CObject_id& objid = tag.GetTag();
1134  string dbtagStr;
1135  switch (objid.Which()) {
1136  default:
1137  break;
1138  case CObject_id::e_Str:
1139  if (objid.GetStr().empty()) {
1140  continue;
1141  }
1142  dbtagStr = objid.GetStr();
1143  break;
1144  case CObject_id::e_Id:
1145  dbtagStr = NStr::IntToString(objid.GetId());
1146  break;
1147  }
1148  string curColName = colName;
1149  string curDisplayName = displayName;
1150  curColName += tag.GetDb();
1151  curDisplayName += tag.GetDb();
1152  xPrepareTableColumn(curColName, curDisplayName, "");
1153  xAppendColumnValue(curColName, dbtagStr);
1154  }
1155  return true;
1156 }
1157 
1158 
1159 // ----------------------------------------------------------------------------
1161  const CBioSource& src,
1162  const string& colName,
1164 // ----------------------------------------------------------------------------
1165 {
1166  static const string displayName = "taxid";
1167  static const string defaultValue;
1168 
1169  if (!src.IsSetOrg() || !src.GetOrg().IsSetDb()) {
1170  return true;
1171  }
1172 
1173  typedef vector< CRef< CDbtag > > DBTAGS;
1174  const DBTAGS& tags = src.GetOrg().GetDb();
1175  string taxonIdStr;
1176  for (DBTAGS::const_iterator cit = tags.begin(); cit != tags.end(); ++cit) {
1177  const CDbtag& tag = **cit;
1178  if (!tag.IsSetDb() || tag.GetDb() != "taxon") {
1179  continue;
1180  }
1181  const CObject_id& objid = tag.GetTag();
1182  switch (objid.Which()) {
1183  default:
1184  return false;
1185  case CObject_id::e_Str:
1186  if (objid.GetStr().empty()) {
1187  continue;
1188  }
1189  taxonIdStr = objid.GetStr();
1190  break;
1191  case CObject_id::e_Id:
1192  taxonIdStr = NStr::IntToString(objid.GetId());
1193  break;
1194  }
1195  break;
1196  }
1197  string curDisplayName = displayName;
1198  xPrepareTableColumn(colName, displayName, "");
1199  xAppendColumnValue(colName, taxonIdStr);
1200  return true;
1201 }
1202 
1203 
1204 // ----------------------------------------------------------------------------
1206  const CBioSource& src,
1207  const string& colName,
1209 // ----------------------------------------------------------------------------
1210 {
1211  const string pcrPrimersFwdNames = "pcr-primers.names.fwd";
1212  const string pcrPrimersFwdSequences = "pcr-primers.sequences.fwd";
1213  const string pcrPrimersRevNames = "pcr-primers.names.reverse";
1214  const string pcrPrimersRevSequences = "pcr-primers.sequences.reverse";
1215 
1216  unsigned int columnSetCounter = 0;
1217 
1218  if (!src.IsSetPcr_primers()) {
1219  return true;
1220  }
1221  string fwdName, fwdSequence, revName, revSequence;
1222  const CPCRReactionSet& pcrset = src.GetPcr_primers();
1223 
1224  typedef list<CRef<CPCRReaction> > REACTIONS;
1225  const REACTIONS& reactions = pcrset.Get();
1226  for (REACTIONS::const_iterator cit = reactions.begin();
1227  cit != reactions.end(); ++cit) {
1228  const CPCRReaction& reaction = **cit;
1229  if (reaction.IsSetForward()) {
1230  if (fwdName.empty()) {
1231  fwdName += ";";
1232  fwdSequence += ";";
1233  }
1234  fwdName += CSrcWriter::xPrimerSetNames(reaction.GetForward());
1235  fwdSequence += CSrcWriter::xPrimerSetSequences(reaction.GetForward());
1236  }
1237  if (reaction.IsSetReverse()) {
1238  if (revName.empty()) {
1239  revName += ";";
1240  revSequence += ";";
1241  }
1242  revName += CSrcWriter::xPrimerSetNames(reaction.GetReverse());
1243  revSequence += CSrcWriter::xPrimerSetSequences(reaction.GetReverse());
1244  }
1245  }
1246  string keyPcrPrimersFwdNames = pcrPrimersFwdNames;
1247  string keyPcrPrimersFwdSequences = pcrPrimersFwdSequences;
1248  string keyPcrPrimersRevNames = pcrPrimersRevNames;
1249  string keyPcrPrimersRevSequences = pcrPrimersRevSequences;
1250  if (columnSetCounter > 0) {
1251  keyPcrPrimersFwdNames += "#" + NStr::IntToString(columnSetCounter);
1252  keyPcrPrimersFwdSequences += "#" + NStr::IntToString(columnSetCounter);
1253  keyPcrPrimersRevNames += "#" + NStr::IntToString(columnSetCounter);
1254  keyPcrPrimersRevSequences += "#" + NStr::IntToString(columnSetCounter);
1255  }
1257  keyPcrPrimersFwdNames, keyPcrPrimersFwdNames, "");
1258  xAppendColumnValue(keyPcrPrimersFwdNames, fwdName);
1260  keyPcrPrimersFwdSequences, keyPcrPrimersFwdSequences, "");
1261  xAppendColumnValue(keyPcrPrimersFwdSequences, fwdSequence);
1262 
1264  keyPcrPrimersRevNames, keyPcrPrimersRevNames, "");
1265  xAppendColumnValue(keyPcrPrimersRevNames, revName);
1267  keyPcrPrimersRevSequences, keyPcrPrimersRevSequences, "");
1268  xAppendColumnValue(keyPcrPrimersRevSequences, revSequence);
1269  return true;
1270 }
1271 
1272 
1273 // ----------------------------------------------------------------------------
1275  // ----------------------------------------------------------------------------
1276 {
1277  string names;
1278  typedef list<CRef<CPCRPrimer> > PRIMERS;
1279  const PRIMERS& primers = pset.Get();
1280  for (PRIMERS::const_iterator cit = primers.begin();
1281  cit != primers.end(); ++cit) {
1282  const CPCRPrimer& primer = **cit;
1283  names += ",";
1284  if (primer.IsSetName()) {
1285  names += primer.GetName();
1286  }
1287  }
1288  return names.substr(1);
1289 }
1290 
1291 
1292 // ----------------------------------------------------------------------------
1294  // ----------------------------------------------------------------------------
1295 {
1296  string sequences;
1297  typedef list<CRef<CPCRPrimer> > PRIMERS;
1298  const PRIMERS& primers = pset.Get();
1299  for (PRIMERS::const_iterator cit = primers.begin();
1300  cit != primers.end(); ++cit) {
1301  const CPCRPrimer& primer = **cit;
1302  sequences += ",";
1303  if (primer.IsSetSeq()) {
1304  sequences += primer.GetSeq();
1305  }
1306  }
1307  return sequences.substr(1);
1308 }
1309 
1310 
1311 // ----------------------------------------------------------------------------
1313  const FIELDS& colStubs,
1314  CNcbiOstream& out)
1315 // ----------------------------------------------------------------------------
1316 {
1317  // Print columns in the order given in colStubs
1318  map<string,NAMELIST > ColstubToColnames;
1319  typedef map<string,NAMELIST > COLSTUBNAMESMAP;
1320 
1321 
1323  cit != mColnameToIndex.end(); ++cit) {
1324  string colName = cit->first;
1325  string colStub = xGetColStub(colName);
1326  if (ColstubToColnames.find(colStub) == ColstubToColnames.end()) {
1327  ColstubToColnames[colStub] = NAMELIST(1,colName);
1328  } else {
1329  ColstubToColnames[colStub].push_back(colName);
1330  }
1331  }
1332 
1333 
1334  NAMELIST colNames;
1335  for (FIELDS::const_iterator cit = colStubs.begin();
1336  cit != colStubs.end(); ++cit) {
1337  COLSTUBNAMESMAP::iterator mapIter = ColstubToColnames.find(*cit);
1338  if (mapIter != ColstubToColnames.end()) {
1339  colNames.insert(colNames.end(), mapIter->second.begin(),
1340  mapIter->second.end());
1341  }
1342  }
1343 
1344  // Write the output table
1345  for (NAMELIST::const_iterator cit = colNames.begin();
1346  cit != colNames.end(); ++cit) {
1347  const CSeqTable_column& column = mSrcTable->GetColumn(*cit);
1348  string displayName = column.GetHeader().GetTitle();
1349  if (NStr::Equal(displayName, "country") && CSubSource::NCBI_UseGeoLocNameForCountry()) {
1350  displayName = "geo_loc_name";
1351  }
1352  out << displayName << CSrcWriter::mDelimiter;
1353  }
1354  out << '\n';
1355 
1356 
1357  unsigned int numRows = mSrcTable->GetNum_rows();
1358  for (unsigned int u=0; u < numRows; ++u) {
1359  for (NAMELIST::const_iterator cit = colNames.begin();
1360  cit != colNames.end(); ++cit) {
1361  const CSeqTable_column& column = mSrcTable->GetColumn(*cit);
1362  const string* pValue = column.GetStringPtr(u);
1363  bool needsQuotes = xValueNeedsQuoting(*pValue);
1364  if (needsQuotes) {
1365  out << "\"";
1366  }
1367  out << xDequotedValue(*pValue) << CSrcWriter::mDelimiter;
1368  if (needsQuotes) {
1369  out << "\"";
1370  }
1371  }
1372  out << '\n';
1373  }
1374  return true;
1375 }
1376 
1377 
1378 // ----------------------------------------------------------------------------
1380  const string& colName)
1381 // ----------------------------------------------------------------------------
1382 {
1383  // pcr-primers special case
1384  if (NStr::Find(colName,"pcr-primers") != NPOS) {
1385  return "pcr-primers";
1386  }
1387 
1388  // case where column name takes the form colStub#Number
1389  size_t position;
1390  if ((position = NStr::Find(colName,"#")) != NPOS) {
1391  return colName.substr(0,position);
1392  }
1393  return colName;
1394 }
1395 
1396 
1397 // ----------------------------------------------------------------------------
1399  const string& colName,
1400  const string& colValue)
1401 // ----------------------------------------------------------------------------
1402 {
1403  size_t index = mColnameToIndex[colName];
1404  CSeqTable_column& column = *mSrcTable->SetColumns().at(index);
1405  column.SetData().SetString().push_back(colValue);
1406 }
1407 
1408 
1409 // ----------------------------------------------------------------------------
1411  const FIELDS& fields,
1412  ILineErrorListener* pEC)
1413 // ----------------------------------------------------------------------------
1414 {
1415  for (FIELDS::const_iterator cit = fields.begin(); cit != fields.end(); ++cit) {
1416  string field = *cit;
1418  if (mapIter == sFieldnameToColname.end()) {
1421  "Field name \"" + field + "\" not recognized.");
1422  pEC->PutError(*pE);
1423  delete pE;
1424  return false;
1425  }
1426  }
1427  return true;
1428 }
1429 
1430 
1431 // ----------------------------------------------------------------------------
1433  const string& value)
1434 // ----------------------------------------------------------------------------
1435 {
1436  return (value.find(mDelimiter) != string::npos);
1437 }
1438 
1439 
1440 // ----------------------------------------------------------------------------
1442  const string& value)
1443 // For lack of better idea, replace all occurences of "\"" with "\'\'"
1444 // -----------------------------------------------------------------------------
1445 {
1446  return NStr::Replace(value, "\"", "\'\'");
1447 }
1448 
1449 
1450 // -----------------------------------------------------------------------------
1452  EDiagSev severity,
1453  const string& message):
1454  // -----------------------------------------------------------------------------
1455  CLineError(ILineError::eProblem_Unset, severity, "", 0,
1456  "", "", "", message, CLineError::TVecOfLines())
1457 {
1458 }
1459 
1460 
1461 // -----------------------------------------------------------------------------
1463  EDiagSev severity,
1464  const string& message)
1465 // -----------------------------------------------------------------------------
1466 {
1467  return new CSrcError(severity, message);
1468 }
1469 
Data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
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
const string & GetTaxname(void) const
Definition: BioSource.cpp:340
bool IsSetOrgMod(void) const
Definition: BioSource.cpp:415
static string GetOrganelleByGenome(unsigned int genome)
Definition: BioSource.cpp:216
const COrgName & GetOrgname(void) const
Definition: BioSource.cpp:410
static string GetStringFromOrigin(unsigned int origin)
Definition: BioSource.cpp:320
bool IsSetTaxname(void) const
Definition: BioSource.cpp:335
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
Definition: Date.hpp:53
ECompare Compare(const CDate &date) const
Definition: Date.cpp:83
@ eCompare_before
*this comes first.
Definition: Date.hpp:74
Definition: Dbtag.hpp:53
@Name_std.hpp User-defined methods of the data storage class.
Definition: Name_std.hpp:56
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
@ eVocabulary_raw
Definition: OrgMod.hpp:68
static bool IsDiscouraged(const TSubtype stype, bool indexer=false)
Definition: OrgMod.cpp:159
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:62
const string & GetDivision(void) const
Definition: Org_ref.cpp:164
bool IsSetDivision(void) const
Definition: Org_ref.cpp:159
CPCRPrimerSet –.
CPCRPrimer –.
Definition: PCRPrimer.hpp:66
CPCRReactionSet –.
CPCRReaction –.
Definition: PCRReaction.hpp:66
@Pubdesc.hpp User-defined methods of the data storage class.
Definition: Pubdesc.hpp:54
CScope –.
Definition: scope.hpp:92
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
const CSeqTable_column & GetColumn(CTempString column_name) const
Definition: Seq_table.cpp:65
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
static CSrcError * Create(ncbi::EDiagSev severity, const std::string &)
CSrcError(const CLineError &other)
Definition: src_writer.hpp:54
virtual bool xTryDefaultId(const string &id, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:532
static NAMEMAP sFieldnameToColname
Definition: src_writer.hpp:185
virtual bool xGatherOrigin(const CBioSource &, const string &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:998
virtual bool xFormatTabDelimited(const FIELDS &, CNcbiOstream &)
static string xPrimerSetSequences(const CPCRPrimerSet &)
static bool xIsOrgmodTypeSuppressed(COrgMod::TSubtype)
Definition: src_writer.cpp:486
virtual bool xGatherDb(const CBioSource &, const string &, ILineErrorListener *=nullptr)
static bool ValidateFields(const FIELDS &fields, ILineErrorListener *=nullptr)
Verify that each string in fields is a valid qualifier name.
virtual bool xGatherOrgCommon(const CBioSource &, const string &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:917
virtual bool xGatherLocalId(CBioseq_Handle, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:800
virtual bool WriteBioseqHandle(CBioseq_Handle, const FIELDS &, CNcbiOstream &)
Write a table of the specified qualifier-field entries found in the BioSource of a given Bioseq.
Definition: src_writer.cpp:146
virtual bool xGatherPcrPrimers(const CBioSource &, const string &, ILineErrorListener *=nullptr)
static HANDLER xGetHandler(const string &)
Definition: src_writer.cpp:501
static const FIELDS sAllSrcCheckFields
All possible fields processed by srchck application, in their canonical order.
Definition: src_writer.hpp:179
string mDelimiter
Definition: src_writer.hpp:189
void xPrepareTableColumn(const string &, const string &, const string &="")
Definition: src_writer.cpp:232
static const FIELDS sDefaultSrcCheckFields
Default fields processed by srcchk application, in their canonical order.
Definition: src_writer.hpp:178
static const FIELDS sDefaultSeqEntryFields
Definition: src_writer.hpp:182
static const FIELDS sAllSeqEntryFields
Definition: src_writer.hpp:183
virtual bool xGatherSubtypeFeat(const CBioSource &, const string &, ILineErrorListener *=nullptr)
bool xValueNeedsQuoting(const string &)
static bool xIsSubsourceTypeSuppressed(CSubSource::TSubtype)
Definition: src_writer.cpp:474
void xAppendColumnValue(const string &, const string &)
static string xPrimerSetNames(const CPCRPrimerSet &)
COLUMNMAP mColnameToIndex
Definition: src_writer.hpp:187
void xInit()
Definition: src_writer.cpp:257
virtual bool xGatherId(CBioseq_Handle, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:715
string xDequotedValue(const string &)
virtual bool xGather(CBioseq_Handle, string id, const FIELDS &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:560
CRef< CSeq_table > mSrcTable
Definition: src_writer.hpp:186
vector< string > FIELDS
Definition: src_writer.hpp:78
static FIELDS xGetOrderedFieldNames(const FIELDS &)
Definition: src_writer.cpp:360
virtual bool xGatherGi(CBioseq_Handle, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:739
static FIELDS xProcessFieldNames(const FIELDS &)
Definition: src_writer.cpp:210
static NAMELIST xGetOrgModSubtypeNames()
Definition: src_writer.cpp:424
static string xCompressFieldName(const string &)
Definition: src_writer.cpp:458
bool(CSrcWriter::* HANDLER)(const CBioSource &, const string &, ILineErrorListener *)
Definition: src_writer.hpp:79
virtual bool xGatherTaxonId(const CBioSource &, const string &, ILineErrorListener *=nullptr)
virtual bool xGatherOrgnameLineage(const CBioSource &, const string &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:937
static NAMELIST xGetSubSourceSubtypeNames()
Definition: src_writer.cpp:441
virtual bool WriteBioseqHandles(const vector< pair< string, CBioseq_Handle > > &, const FIELDS &, CNcbiOstream &, ILineErrorListener *=nullptr)
Write a table of the specified qualifier-field entries found in the BioSources of a vector of Bioseqs...
Definition: src_writer.cpp:165
virtual bool xGatherOrgModFeat(const CBioSource &, const string &, ILineErrorListener *=nullptr)
string xGetColStub(const string &)
list< string > NAMELIST
Definition: src_writer.hpp:77
virtual bool xGatherDefline(CBioseq_Handle, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:871
string xGetOriginalId(const CBioseq_Handle &) const
Definition: src_writer.cpp:770
virtual bool xHandleSourceField(const CBioSource &, const string &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:510
virtual bool xGatherGenome(const CBioSource &, const string &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:978
virtual bool xGatherTaxname(const CBioSource &, const string &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:897
virtual bool xGatherBankitId(CBioseq_Handle, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:832
virtual bool WriteSeqEntry(const CSeq_entry &, CScope &, CNcbiOstream &, bool=false)
Write a table of all qualifier-field entries occurring in the BioSources for a given Seq-entry,...
Definition: src_writer.cpp:189
static HANDLERMAP sHandlerMap
Definition: src_writer.hpp:184
virtual bool xGatherDivision(const CBioSource &, const string &, ILineErrorListener *=nullptr)
Definition: src_writer.cpp:958
static bool NCBI_UseGeoLocNameForCountry(void)
Definition: SubSource.cpp:94
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: SubSource.cpp:128
@ eVocabulary_raw
Definition: SubSource.hpp:82
static bool NeedsNoText(const TSubtype &subtype)
Definition: SubSource.cpp:233
static bool IsDiscouraged(const TSubtype subtype)
Definition: SubSource.cpp:247
virtual bool PutError(const ILineError &)=0
Store error in the container, and return true if error was stored fine, and return false if the calle...
container_type::const_iterator const_iterator
Definition: map.hpp:53
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
bool empty() const
Definition: map.hpp:149
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
API (CDeflineGenerator) for computing sequences' titles ("definitions").
std::ofstream out("events_result.xml")
main entry point for tests
static const struct name_t names[]
static const char * column
Definition: stats.c:23
Utility macros and typedefs for exploring NCBI objects from general.asn.
#define FOR_EACH_USERFIELD_ON_USEROBJECT(Itr, Var)
FOR_EACH_USERFIELD_ON_USEROBJECT EDIT_EACH_USERFIELD_ON_USEROBJECT.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
list< pair< string, TEnumValueType > > TValues
Definition: enumvalues.hpp:54
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2040
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
string GetAccessionForId(const objects::CSeq_id &id, CScope &scope, EAccessionVersion use_version=eWithAccessionVersion, EGetIdType flags=0)
Retrieve the accession string for a Seq-id.
Definition: sequence.cpp:708
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
Definition: scope.cpp:522
vector< CSeq_id_Handle > TId
CConstRef< CSeq_id > GetLocalIdOrNull(void) const
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
CScope & GetScope(void) const
Get scope this handle belongs to.
const TId & GetId(void) const
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
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 IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2891
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3314
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
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:5384
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
Definition: ncbistr.cpp:3186
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
@ fConvErr_NoThrow
Do not throw an exception on error.
Definition: ncbistr.hpp:285
static const char label[]
const TDate & GetDate(void) const
Get the Date member data.
Definition: Cit_sub_.hpp:455
bool IsSetAffil(void) const
author affiliation Check if a value has been assigned to Affil data member.
Definition: Auth_list_.hpp:498
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Auth_list_.hpp:510
const TStr & GetStr(void) const
Get the variant data.
Definition: Affil_.hpp:1193
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_sub_.hpp:357
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
const TName & GetName(void) const
Get the Name member data.
Definition: Author_.hpp:352
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Affil_.hpp:700
list< CRef< CAuthor > > TStd
Definition: Auth_list_.hpp:170
bool IsStr(void) const
Check if variant Str is selected.
Definition: Affil_.hpp:1187
bool IsSetDate(void) const
replaces imp, will become required Check if a value has been assigned to Date data member.
Definition: Cit_sub_.hpp:443
bool IsSetNames(void) const
Check if a value has been assigned to Names data member.
Definition: Auth_list_.hpp:464
const TStd & GetStd(void) const
Get the variant data.
Definition: Affil_.cpp:214
bool IsSetName(void) const
Author, Primary or Secondary Check if a value has been assigned to Name data member.
Definition: Author_.hpp:340
const TNames & GetNames(void) const
Get the Names member data.
Definition: Auth_list_.hpp:478
bool IsStd(void) const
Check if variant Std is selected.
Definition: Affil_.hpp:1207
bool IsSetAffil(void) const
Author Affiliation, Name Check if a value has been assigned to Affil data member.
Definition: Affil_.hpp:688
const Tdata & Get(void) const
Get the member data.
const TSubtype & GetSubtype(void) const
Get the Subtype member data.
Definition: BioSource_.hpp:539
const TPcr_primers & GetPcr_primers(void) const
Get the Pcr_primers member data.
Definition: BioSource_.hpp:588
TGenome GetGenome(void) const
Get the Genome member data.
Definition: BioSource_.hpp:422
TOrigin GetOrigin(void) const
Get the Origin member data.
Definition: BioSource_.hpp:472
bool IsSetSeq(void) const
Check if a value has been assigned to Seq data member.
Definition: PCRPrimer_.hpp:199
const Tdata & Get(void) const
Get the member data.
bool IsSetName(void) const
Check if a value has been assigned to Name data member.
Definition: PCRPrimer_.hpp:234
bool IsSetOrg(void) const
Check if a value has been assigned to Org data member.
Definition: BioSource_.hpp:497
bool IsSetSubtype(void) const
Check if a value has been assigned to Subtype data member.
Definition: BioSource_.hpp:527
bool IsSetPcr_primers(void) const
Check if a value has been assigned to Pcr_primers data member.
Definition: BioSource_.hpp:576
const TForward & GetForward(void) const
Get the Forward member data.
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
bool IsSetOrigin(void) const
Check if a value has been assigned to Origin data member.
Definition: BioSource_.hpp:447
TSubtype GetSubtype(void) const
Get the Subtype member data.
Definition: SubSource_.hpp:310
bool IsSetGenome(void) const
Check if a value has been assigned to Genome data member.
Definition: BioSource_.hpp:397
const TSeq & GetSeq(void) const
Get the Seq member data.
Definition: PCRPrimer_.hpp:211
bool IsSetReverse(void) const
Check if a value has been assigned to Reverse data member.
const TName & GetName(void) const
Get the Name member data.
Definition: SubSource_.hpp:350
const TReverse & GetReverse(void) const
Get the Reverse member data.
const TName & GetName(void) const
Get the Name member data.
Definition: PCRPrimer_.hpp:246
bool IsSetForward(void) const
Check if a value has been assigned to Forward data member.
bool IsSetName(void) const
Check if a value has been assigned to Name data member.
Definition: SubSource_.hpp:338
const TStr & GetStr(void) const
Get the variant data.
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
bool IsConsortium(void) const
Check if variant Consortium is selected.
Definition: Person_id_.hpp:405
bool IsSetType(void) const
type of object within class Check if a value has been assigned to Type data member.
const TData & GetData(void) const
Get the Data member data.
const TInitials & GetInitials(void) const
Get the Initials member data.
Definition: Name_std_.hpp:610
bool IsName(void) const
Check if variant Name is selected.
Definition: Person_id_.hpp:359
E_Choice Which(void) const
Which variant is currently selected.
Definition: Object_id_.hpp:235
bool IsSetInitials(void) const
first + middle initials Check if a value has been assigned to Initials data member.
Definition: Name_std_.hpp:598
bool IsStr(void) const
Check if variant Str is selected.
bool IsSetLast(void) const
Check if a value has been assigned to Last data member.
Definition: Name_std_.hpp:410
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
const TConsortium & GetConsortium(void) const
Get the variant data.
Definition: Person_id_.hpp:411
const TLabel & GetLabel(void) const
Get the Label member data.
const TType & GetType(void) const
Get the Type member data.
const TLast & GetLast(void) const
Get the Last member data.
Definition: Name_std_.hpp:422
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
const TName & GetName(void) const
Get the variant data.
Definition: Person_id_.cpp:137
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
const TMod & GetMod(void) const
Get the Mod member data.
Definition: OrgName_.hpp:839
bool IsSetDb(void) const
ids in taxonomic or culture dbases Check if a value has been assigned to Db data member.
Definition: Org_ref_.hpp:479
const TLineage & GetLineage(void) const
Get the Lineage member data.
Definition: OrgName_.hpp:864
TSubtype GetSubtype(void) const
Get the Subtype member data.
Definition: OrgMod_.hpp:307
const TSubname & GetSubname(void) const
Get the Subname member data.
Definition: OrgMod_.hpp:347
bool IsSetCommon(void) const
common name Check if a value has been assigned to Common data member.
Definition: Org_ref_.hpp:407
bool IsSetLineage(void) const
lineage with semicolon separators Check if a value has been assigned to Lineage data member.
Definition: OrgName_.hpp:852
const TCommon & GetCommon(void) const
Get the Common member data.
Definition: Org_ref_.hpp:419
const TDb & GetDb(void) const
Get the Db member data.
Definition: Org_ref_.hpp:491
bool IsSetOrgname(void) const
Check if a value has been assigned to Orgname data member.
Definition: Org_ref_.hpp:529
const TOrgname & GetOrgname(void) const
Get the Orgname member data.
Definition: Org_ref_.hpp:541
@ eSubtype_old_name
Definition: OrgMod_.hpp:124
list< CRef< CPub > > Tdata
Definition: Pub_equiv_.hpp:90
bool IsSet(void) const
Check if a value has been assigned to data member.
Definition: Pub_equiv_.hpp:153
const Tdata & Get(void) const
Get the member data.
Definition: Pub_equiv_.hpp:165
@ e_Sub
submission
Definition: Pub_.hpp:103
const TColumns & GetColumns(void) const
Get the Columns member data.
Definition: Seq_table_.hpp:433
void SetHeader(THeader &value)
Assign a value to Header data member.
void SetNum_rows(TNum_rows value)
Assign a value to Num_rows data member.
Definition: Seq_table_.hpp:402
TNum_rows GetNum_rows(void) const
Get the Num_rows member data.
Definition: Seq_table_.hpp:393
void SetDefault(TDefault &value)
Assign a value to Default data member.
TColumns & SetColumns(void)
Assign a value to Columns data member.
Definition: Seq_table_.hpp:439
const TUser & GetUser(void) const
Get the variant data.
Definition: Seqdesc_.cpp:384
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
bool IsUser(void) const
Check if variant User is selected.
Definition: Seqdesc_.hpp:1122
@ e_Pub
a reference to the publication
Definition: Seqdesc_.hpp:122
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
constexpr auto sort(_Init &&init)
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 defaultValue
Definition: pointer.h:1126
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const char * tag
Utility macros and typedefs for exploring NCBI objects from seq.asn.
#define FOR_EACH_SEQDESC_ON_SEQDESCR(Itr, Var)
FOR_EACH_SEQDESC_ON_SEQDESCR EDIT_EACH_SEQDESC_ON_SEQDESCR.
Definition: seq_macros.hpp:657
#define FIELD_IS_SET_AND_IS(Var, Fld, Chs)
FIELD_IS_SET_AND_IS base macro.
#define GET_FIELD(Var, Fld)
GET_FIELD base macro.
USING_SCOPE(objects)
const size_t countDefaultSrcCheckFields
Definition: src_writer.cpp:129
static const string arrDefaultSrcCheckFields[]
Definition: src_writer.cpp:79
const size_t countDefaultSeqEntryFields
Definition: src_writer.cpp:137
static const string arrDefaultSeqEntryFields[]
Definition: src_writer.cpp:103
Definition: type.c:6
Modified on Wed Apr 17 13:10:03 2024 by modify_doxy.py rev. 669887