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

Go to the SVN repository for this file.

1 /* $Id: feattable_edit.cpp 96162 2022-02-17 15:02:17Z ludwigf $
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 * Author: Frank Ludwig, NCBI
27 *
28 * File Description:
29 * Convenience wrapper around some of the other feature processing functions
30 * in the xobjedit library.
31 */
32 
33 #include <ncbi_pch.hpp>
34 
43 
45 #include <objmgr/scope.hpp>
46 #include <objmgr/feat_ci.hpp>
47 #include <objmgr/util/sequence.hpp>
48 #include <objmgr/util/feature.hpp>
49 
53 #include <corelib/ncbi_message.hpp>
57 
59 
60 #include <unordered_set>
61 #include <sstream>
62 
66 
67 // ----------------------------------------------------------------------------
69  const string str)
70  // ----------------------------------------------------------------------------
71 {
74  pProduct->SetId(*pId);
75  return pProduct;
76 }
77 
78 // ----------------------------------------------------------------------------
80  const CSeq_feat& cds,
81  CScope& scope)
82  // ----------------------------------------------------------------------------
83 {
84  string productName;
85  if (cds.IsSetProduct()) {
87  if (bsh) {
88  CFeat_CI protCi(bsh, CSeqFeatData::e_Prot);
89  if (protCi) {
90  const CProt_ref& prot = protCi->GetOriginalFeature().GetData().GetProt();
91  if (prot.IsSetName() && prot.GetName().size() > 0) {
92  productName = prot.GetName().front();
93  }
94  }
95  return productName;
96  }
97  }
98  if (cds.IsSetXref()) {
99  ITERATE(CSeq_feat::TXref, it, cds.GetXref()) {
100  const CSeqFeatXref& xref = **it;
101  if (xref.IsSetData() && xref.GetData().IsProt()) {
102  const CProt_ref& prot = xref.GetData().GetProt();
103  if (prot.IsSetName() && prot.GetName().size() > 0) {
104  productName = prot.GetName().front();
105  }
106  }
107  return productName;
108  }
109  }
110  return productName;
111 }
112 
113 // -------------------------------------------------------------------------
115  CSeq_annot& annot,
116  const string& locusTagPrefix,
117  unsigned int locusTagNumber,
118  unsigned int startingFeatId,
119  IObjtoolsListener* pMessageListener) :
120 // -------------------------------------------------------------------------
121  mAnnot(annot),
122  mSequenceSize(0),
123  mpMessageListener(pMessageListener),
124  mLocusTagPrefix(locusTagPrefix),
125  mLocusTagNumber(locusTagNumber),
126  mNextFeatId(startingFeatId)
127 {
129  mpScope->AddDefaults();
132  mTree = feature::CFeatTree(mHandle);
133 };
134 
135 
136 // -------------------------------------------------------------------------
138  CSeq_annot& annot,
139  unsigned int sequenceSize,
140  const string& locusTagPrefix,
141  unsigned int locusTagNumber,
142  unsigned int startingFeatId,
143  IObjtoolsListener* pMessageListener) :
144 // -------------------------------------------------------------------------
145  mAnnot(annot),
146  mSequenceSize(sequenceSize),
147  mpMessageListener(pMessageListener),
148  mLocusTagPrefix(locusTagPrefix),
149  mLocusTagNumber(locusTagNumber),
150  mNextFeatId(startingFeatId)
151 {
153  mpScope->AddDefaults();
156  mTree = feature::CFeatTree(mHandle);
157 };
158 
159 
160 // -------------------------------------------------------------------------
162 // -------------------------------------------------------------------------
163 
164 // -------------------------------------------------------------------------
166 // -------------------------------------------------------------------------
167 {
169 }
170 
171 // -------------------------------------------------------------------------
173 // -------------------------------------------------------------------------
174 {
175  SAnnotSelector sel;
177  CFeat_CI it(mHandle, sel);
178  for (; it; ++it) {
179  const CSeq_feat& cds = it->GetOriginalFeature();
180  CConstRef<CSeq_feat> pOverlappingRna =
182  cds.GetLocation(),
185  *mpScope);
186  if (pOverlappingRna) {
187  continue;
188  }
189  CRef<CSeq_feat> pRna(new CSeq_feat);
190  pRna->SetData().SetRna().SetType(CRNA_ref::eType_mRNA);
191  pRna->SetLocation().Assign(cds.GetLocation());
192  pRna->SetLocation().SetPartialStart(false, eExtreme_Positional);
193  pRna->SetLocation().SetPartialStop(false, eExtreme_Positional);
194  pRna->ResetPartial();
195  //product name
196  pRna->SetData().SetRna().SetExt().SetName(
197  sGetCdsProductName(cds, *mpScope));
198 
199  //find proper name for rna
200  string rnaId(xNextFeatId());
201  pRna->SetId().SetLocal().SetStr(rnaId);
202 
203  //add rna xref to cds
205  feh.AddFeatXref(rnaId);
206 
207  //add cds xref to rna
208  CRef<CFeat_id> pFeatId(new CFeat_id);
209  pFeatId->Assign(cds.GetId());
210  CRef<CSeqFeatXref> pRnaXref(new CSeqFeatXref);
211  pRnaXref->SetId(*pFeatId);
212  pRna->SetXref().push_back(pRnaXref);
213 
214  CMappedFeat parentGene = feature::GetBestGeneForFeat(*it, &mTree);
215  if (parentGene) {
216  //if gene exists, add gene xref to rna
218  parentGene.GetOriginalFeature()));
219  geh.AddFeatXref(rnaId);
220  //if gene exists, add rna xref to gene
221  CRef<CFeat_id> pGeneId(new CFeat_id);
222  pGeneId->Assign(parentGene.GetId());
223  CRef<CSeqFeatXref> pRnaXref(new CSeqFeatXref);
224  pRnaXref->SetId(*pGeneId);
225  pRna->SetXref().push_back(pRnaXref);
226  }
227 
228  //add new rna to feature table
229  mEditHandle.AddFeat(*pRna);
230  mTree.AddFeature(mpScope->GetObjectHandle(*pRna));
231  }
232 }
233 
234 // -------------------------------------------------------------------------
236 // -------------------------------------------------------------------------
237 {
239 }
240 
241 // ---------------------------------------------------------------------------
243 // ---------------------------------------------------------------------------
244 {
246 }
247 
248 // ---------------------------------------------------------------------------
250 // ---------------------------------------------------------------------------
251 {
253 }
254 
255 // ----------------------------------------------------------------------------
257 // ----------------------------------------------------------------------------
258 {
259  bool infered(false);
260  edit::CLocationEditPolicy editPolicy(
261  edit::CLocationEditPolicy::ePartialPolicy_eSetForBadEnd,
262  edit::CLocationEditPolicy::ePartialPolicy_eSetForBadEnd,
263  false, //extend 5'
264  false, //extend 3'
265  edit::CLocationEditPolicy::eMergePolicy_NoChange);
266 
267  SAnnotSelector sel;
269  CFeat_CI it(mHandle, sel);
270  for (; it; ++it) {
271  const CSeq_feat& cds = it->GetOriginalFeature();
272  CRef<CSeq_feat> pEditedCds(new CSeq_feat);
273  pEditedCds->Assign(cds);
274  infered = editPolicy.ApplyPolicyToFeature(*pEditedCds, *mpScope);
275  if (!infered) {
276  continue;
277  }
279  cdsEh.Replace(*pEditedCds);
280 
281  // make sure the parent rna is partial as well
282  CMappedFeat parentRna = feature::GetBestMrnaForCds(*it, &mTree);
283  if (parentRna &&
284  !(parentRna.IsSetPartial() && parentRna.GetPartial())) {
285  CRef<CSeq_feat> pEditedRna(new CSeq_feat);
286  pEditedRna->Assign(parentRna.GetOriginalFeature());
287  pEditedRna->SetPartial(true);
288  CSeq_feat_EditHandle rnaEh(
290  rnaEh.Replace(*pEditedRna);
291  }
292 
293  // make sure the gene parent is partial as well
294  CMappedFeat parentGene = feature::GetBestGeneForCds(*it);
295  if (parentGene &&
296  !(parentGene.IsSetPartial() && parentGene.GetPartial())) {
297  CRef<CSeq_feat> pEditedGene(new CSeq_feat);
298  pEditedGene->Assign(parentGene.GetOriginalFeature());
299  pEditedGene->SetPartial(true);
300  CSeq_feat_EditHandle geneEh(
302  geneEh.Replace(*pEditedGene);
303  }
304  }
305 }
306 
307 // ----------------------------------------------------------------------------
309 // ----------------------------------------------------------------------------
310 {
311  SAnnotSelector sel;
314  for (CFeat_CI it(mHandle, sel); it; ++it) {
315  CMappedFeat mf = *it;
316  if (mf.IsSetProduct()) {
317  continue;
318  }
319  //debug CSeqFeatData::ESubtype st = mf.GetFeatSubtype();
320  string product = mf.GetNamedQual("Product");
321  CRef<CSeq_feat> pEditedFeature(new CSeq_feat);
322  pEditedFeature->Assign(mf.GetOriginalFeature());
323  pEditedFeature->ResetProduct();
324  if (!product.empty()) {
325  pEditedFeature->AddQualifier("product", product);
326  pEditedFeature->RemoveQualifier("Product");
327  }
328  CSeq_feat_EditHandle feh(mf);
329  feh.Replace(*pEditedFeature);
330  }
331 }
332 
333 // ----------------------------------------------------------------------------
335 // ----------------------------------------------------------------------------
336 {
337  typedef CSeq_feat::TQual QUALS;
338 
339  vector<string> specialQuals{
340  "Protein", "protein",
341  "go_function", "go_component", "go_process" };
342 
343  CFeat_CI it(mHandle);
344  for (; it; ++it) {
345  CSeqFeatData::ESubtype subtype = it->GetData().GetSubtype();
347  (it)->GetOriginalFeature()));
348  const QUALS& quals = (*it).GetQual();
349  vector<string> badQuals;
350  for (QUALS::const_iterator qual = quals.begin(); qual != quals.end();
351  ++qual) {
352  string qualKey = (*qual)->GetQual();
353  if (std::find(specialQuals.begin(), specialQuals.end(), qualKey)
354  != specialQuals.end()) {
355  continue;
356  }
357  if (subtype == CSeqFeatData::eSubtype_cdregion ||
358  subtype == CSeqFeatData::eSubtype_mRNA) {
359  if (qualKey == "protein_id" || qualKey == "transcript_id") {
360  continue;
361  }
362  if (qualKey == "orig_protein_id" || qualKey == "orig_transcript_id") {
363  continue;
364  }
365  }
366  if (subtype != CSeqFeatData::eSubtype_gene && qualKey == "gene") {
367  //rw-570: remove gene qualifiers fro non-gene features before cleanup sees them
368  badQuals.push_back(qualKey);
369  continue;
370  }
372  if (CSeqFeatData::IsLegalQualifier(subtype, qualType)) {
373  continue;
374  }
375  badQuals.push_back(qualKey);
376  }
377  for (vector<string>::const_iterator badIt = badQuals.begin();
378  badIt != badQuals.end(); ++badIt) {
379  feh.RemoveQualifier(*badIt);
380  }
381  }
382 }
383 
384 // ----------------------------------------------------------------------------
386 // ----------------------------------------------------------------------------
387 {
388  static map<char, list<char>> sIUPACmap {
389  {'A', list<char>({'A'})},
390  {'G', list<char>({'G'})},
391  {'C', list<char>({'C'})},
392  {'T', list<char>({'T'})},
393  {'U', list<char>({'U'})},
394  {'M', list<char>({'A', 'C'})},
395  {'R', list<char>({'A', 'G'})},
396  {'W', list<char>({'A', 'T'})},
397  {'S', list<char>({'C', 'G'})},
398  {'Y', list<char>({'C', 'T'})},
399  {'K', list<char>({'G', 'T'})},
400  {'V', list<char>({'A', 'C', 'G'})},
401  {'H', list<char>({'A', 'C', 'T'})},
402  {'D', list<char>({'A', 'G', 'T'})},
403  {'B', list<char>({'C', 'G', 'T'})},
404  {'N', list<char>({'A', 'C', 'G', 'T'})}
405  };
406 
407  SAnnotSelector sel;
409  CFeat_CI it(mHandle, sel);
410  for (; it; ++it) {
411  CMappedFeat mf = *it;
412  auto codonRecognized = mf.GetNamedQual("codon_recognized");
413  if (codonRecognized.empty()) {
414  continue;
415  }
416  if (codonRecognized.size() != 3) {
417  xPutErrorBadCodonRecognized(codonRecognized);
418  return;
419  }
420  NStr::ToUpper(codonRecognized);
421 
422  const CSeq_feat& origFeat = mf.GetOriginalFeature();
423 
424  CRef<CSeq_feat> pEditedFeat(new CSeq_feat);
425  pEditedFeat->Assign(origFeat);
426  CRNA_ref::C_Ext::TTRNA & extTrna = pEditedFeat->SetData().SetRna().SetExt().SetTRNA();
427 
429  try {
430  for (char char1 : sIUPACmap.at(codonRecognized[0])) {
431  for (char char2 : sIUPACmap.at(codonRecognized[1])) {
432  for (char char3 : sIUPACmap.at(codonRecognized[2])) {
433  const auto codonIndex = CGen_code_table::CodonToIndex(char1, char2, char3);
434  codons.insert(codonIndex);
435  }
436  }
437  }
438  }
439  catch(CException&) {
440  xPutErrorBadCodonRecognized(codonRecognized);
441  return;
442  }
443  if (!codons.empty()) {
444  for (const auto codonIndex : codons) {
445  extTrna.SetCodon().push_back(codonIndex);
446  }
448  feh.Replace(*pEditedFeat);
449  feh.RemoveQualifier("codon_recognized");
450  }
451  }
452 }
453 
454 // ---------------------------------------------------------------------------
456 // ---------------------------------------------------------------------------
457 {
459  {
460  SAnnotSelector sel;
462  for (CFeat_CI it(mHandle, sel); it; ++it) {
463  CMappedFeat cds = *it;
465  }
466  }
467  {
468  SAnnotSelector sel;
470  for (CFeat_CI it(mHandle, sel); it; ++it) {
471  CMappedFeat mrna = *it;
473  }
474  }
475 }
476 
477 
478 // ---------------------------------------------------------------------------
479 static bool s_ShouldConvertToGeneral(const string& id)
480 // ---------------------------------------------------------------------------
481 {
482  return (!NStr::StartsWith(id, "gb|") &&
483  !NStr::StartsWith(id, "gnl|") &&
484  !NStr::StartsWith(id, "cds.gnl|") &&
485  !NStr::StartsWith(id, "mrna.gnl|"));
486 }
487 
488 
489 // ---------------------------------------------------------------------------
490 static string s_GetTranscriptIdFromMrna(const CMappedFeat& mrna)
491 // ---------------------------------------------------------------------------
492 {
493  string transcript_id = mrna.GetNamedQual("transcript_id");
494  if (NStr::IsBlank(transcript_id)) {
495  return mrna.GetNamedQual("ID");
496  }
497 
498  return transcript_id;
499 }
500 
501 
502 // ---------------------------------------------------------------------------
504 // ---------------------------------------------------------------------------
505 {
507  string protein_id = cds.GetNamedQual("protein_id");
508  const bool no_protein_id_qual = NStr::IsBlank(protein_id);
509  if (no_protein_id_qual) { // no protein_id qual on CDS - check mRNA and ID qual
510  if (mrna) {
511  protein_id = mrna.GetNamedQual("protein_id");
512  }
513  if (NStr::IsBlank(protein_id)) {
514  protein_id = cds.GetNamedQual("ID");
515  }
516  }
517  bool is_genbank_protein = NStr::StartsWith(protein_id, "gb|");
518 
519  string transcript_id = cds.GetNamedQual("transcript_id");
520  const bool no_transcript_id_qual = NStr::IsBlank(transcript_id);
521  if (no_transcript_id_qual) { // no transcript_id qual on CDS - check mRNA
522  if (mrna) {
523  transcript_id = s_GetTranscriptIdFromMrna(mrna);
524  }
525  }
526  bool is_genbank_transcript = NStr::StartsWith(transcript_id, "gb|");
527 
528 
529  if ((is_genbank_protein || NStr::StartsWith(protein_id, "gnl|")) &&
530  (is_genbank_transcript || NStr::StartsWith(transcript_id, "gnl|"))) {
531 
532  // No further processing of ids is required - simply assign to features
533  if (no_protein_id_qual) {
534  // protein_id from ID qualifier or mRNA => need to add protein_id qual to CDS
535  xFeatureSetQualifier(cds, "protein_id", protein_id);
536  }
537 
538  if (no_transcript_id_qual) {
539  // transcript_id from mRNA => need to add transcript_id qual to CDS
540  xFeatureSetQualifier(cds, "transcript_id", transcript_id);
541  }
542 
543  if (mrna) {
544  xAddTranscriptAndProteinIdsToMrna(transcript_id, protein_id, mrna);
545  }
546  return;
547  }
548 
549  // else need to generate and/or process ids before we add them to features
550  bool has_protein_id = !NStr::IsBlank(protein_id);
551  bool has_transcript_id = !NStr::IsBlank(transcript_id);
552 
553  if (has_protein_id && has_transcript_id) {
554  if (!is_genbank_protein && (transcript_id == protein_id)) {
555  protein_id = "cds." + protein_id;
556  }
557  }
558  else {
559  if (has_protein_id && !is_genbank_protein) {
560  transcript_id = "mrna." + protein_id;
561  has_transcript_id = true;
562  }
563  else if (has_transcript_id && !is_genbank_transcript) {
564  protein_id = "cds." + transcript_id;
565  has_protein_id = true;
566  }
567 
568  // Generate new transcript_id and protein_id if necessary
569  if (!has_transcript_id) {
570  transcript_id = xNextTranscriptId(cds);
571  }
572  if (!has_protein_id) {
573  protein_id = xNextProteinId(cds);
574  }
575  }
576 
577  xConvertToGeneralIds(cds, transcript_id, protein_id);
578 
579  if (mrna) {
580  xAddTranscriptAndProteinIdsToMrna(transcript_id, protein_id, mrna);
581  }
582 
583  xFeatureSetQualifier(cds, "transcript_id", transcript_id);
584  xFeatureSetQualifier(cds, "protein_id", protein_id);
585 }
586 
587 
588 // ---------------------------------------------------------------------------
590  const string& cds_transcript_id,
591  const string& cds_protein_id,
592  CMappedFeat& mrna)
593 // ---------------------------------------------------------------------------
594 {
595  if (mProcessedMrnas.find(mrna) != mProcessedMrnas.end()) {
596  return;
597  }
598 
599  bool use_local_ids = false;
600 
601  string transcript_id = mrna.GetNamedQual("transcript_id");
602  if (NStr::IsBlank(transcript_id)) {
603  transcript_id = cds_transcript_id;
604  }
605  else {
606  use_local_ids = true;
607  }
608 
609  string protein_id = mrna.GetNamedQual("protein_id");
610  if (NStr::IsBlank(protein_id)) {
611  protein_id = cds_protein_id;
612  }
613  else {
614  if ((protein_id == transcript_id) && !NStr::StartsWith(protein_id, "gb|")) {
615  protein_id = "cds." + protein_id;
616  }
617  use_local_ids = true;
618  }
619 
620  if (use_local_ids) {
621  // protein id and/or transcript id specified on mRNA.
622  // Process these ids and check that the processed quals match the qualifiers on the child CDS feature
623  xConvertToGeneralIds(mrna, transcript_id, protein_id);
624 
625  if (transcript_id != cds_transcript_id) {
627  }
628 
629  if (protein_id != cds_protein_id) {
631  }
632  }
633 
634  xFeatureSetQualifier(mrna, "transcript_id", transcript_id);
635  xFeatureSetQualifier(mrna, "protein_id", protein_id);
636 
637  mProcessedMrnas.insert(mrna);
638 }
639 
640 
641 // ---------------------------------------------------------------------------
643 // ---------------------------------------------------------------------------
644 {
645  if (mProcessedMrnas.find(mrna) != mProcessedMrnas.end()) {
646  return;
647  }
648 
649  string transcript_id = mrna.GetNamedQual("transcript_id");
650  bool no_transcript_id_qual = NStr::IsBlank(transcript_id);
651  if (no_transcript_id_qual) {
652  transcript_id = mrna.GetNamedQual("ID");
653  }
654  const bool is_genbank_transcript = NStr::StartsWith(transcript_id, "gb|");
655 
656  string protein_id = mrna.GetNamedQual("protein_id");
657  const bool is_genbank_protein = NStr::StartsWith(protein_id, "gb|");
658 
659  if ((is_genbank_protein ||
660  NStr::StartsWith(protein_id, "gnl|")) &&
661  (is_genbank_transcript ||
662  NStr::StartsWith(transcript_id, "gnl|"))) {
663  if (no_transcript_id_qual) {
664  xFeatureSetQualifier(mrna, "transcript_id", transcript_id);
665  }
666  return;
667  }
668 
669  if (!NStr::IsBlank(protein_id) &&
670  !NStr::IsBlank(transcript_id)) {
671  if ((transcript_id == protein_id) &&
672  !is_genbank_transcript) {
673  protein_id = "cds." + protein_id;
674  }
675  }
676  else
677  if (!is_genbank_protein && !NStr::IsBlank(protein_id)) {
678  transcript_id = "mrna." + protein_id;
679  }
680  else
681  if (!is_genbank_transcript && !NStr::IsBlank(transcript_id)) {
682  protein_id = "cds." + transcript_id;
683  }
684 
685  if (NStr::IsBlank(protein_id)) {
686  protein_id = xNextProteinId(mrna);
687  }
688  if (NStr::IsBlank(transcript_id)) {
689  transcript_id = xNextTranscriptId(mrna);
690  }
691 
692  xConvertToGeneralIds(mrna, transcript_id, protein_id);
693 
694  xFeatureSetQualifier(mrna, "transcript_id", transcript_id);
695  xFeatureSetQualifier(mrna, "protein_id", protein_id);
696 
697  mProcessedMrnas.insert(mrna);
698 }
699 
700 
702  string& transcript_id,
703  string& protein_id)
704 {
705  const bool update_protein_id = s_ShouldConvertToGeneral(protein_id);
706  const bool update_transcript_id = s_ShouldConvertToGeneral(transcript_id);
707 
708  string locus_tag_prefix;
709  if (update_protein_id || update_transcript_id) {
710  locus_tag_prefix = xGetCurrentLocusTagPrefix(mf);
711  if (!NStr::IsBlank(locus_tag_prefix)) {
712  if (update_protein_id) {
713  protein_id = "gnl|" + locus_tag_prefix + "|" + protein_id;
714  }
715 
716  if (update_transcript_id) {
717  transcript_id = "gnl|" + locus_tag_prefix + "|" + transcript_id;
718  }
719  }
720  else {
721  string seq_label;
722  mf.GetLocation().GetId()->GetLabel(&seq_label, CSeq_id::eContent);
723 
724  if (update_protein_id) {
725  protein_id = "gnl|" + seq_label + "|" + protein_id;
726  }
727 
728  if (update_transcript_id) {
729  transcript_id = "gnl|" + seq_label + "|" + transcript_id;
730  }
731  }
732  }
733 }
734 
735 
736 // ----------------------------------------------------------------------------
738 // ----------------------------------------------------------------------------
739 {
740  SAnnotSelector sel1;
743  for (CFeat_CI it(mHandle, sel1); it; ++it) {
744  CMappedFeat mf = *it;
745 
746  auto tid = mf.GetNamedQual("transcript_id");
747  if (!tid.empty()) {
748  xFeatureRemoveQualifier(mf, "transcript_id");
749  xFeatureAddQualifier(mf, "orig_transcript_id", tid);
750  }
751 
753  auto pid = mf.GetNamedQual("protein_id");
754  if (!pid.empty()) {
755  if (!mf.IsSetProduct()) {
756  xFeatureSetProduct(mf, pid);
757  }
758  xFeatureRemoveQualifier(mf, "protein_id");
759  }
760  }
761  }
762 }
763 
764 // ---------------------------------------------------------------------------
766  CSeqFeatData::E_Choice choice,
767  const CGff3LocationMerger* pMerger)
768  // ---------------------------------------------------------------------------
769 {
770  SAnnotSelector sel;
771  sel.IncludeFeatType(choice);
772  CFeat_CI it(mHandle, sel);
773  for (; it; ++it) {
774  CMappedFeat mf = *it;
775  auto seqId = mf.GetLocationId().AsString();
776  auto sequenceSize =
777  (pMerger ? pMerger->GetSequenceSize(seqId) : mSequenceSize);
778  if (xCreateMissingParentGene(mf, sequenceSize)) {
780  }
781  }
782 }
783 
784 
785 // ---------------------------------------------------------------------------
787  CSeqFeatData::ESubtype subType,
788  const CGff3LocationMerger* pMerger)
789  // ---------------------------------------------------------------------------
790 {
791  SAnnotSelector sel;
792  sel.IncludeFeatSubtype(subType);
793  CFeat_CI it(mHandle, sel);
794  for (; it; ++it) {
795  CMappedFeat mf = *it;
796  auto seqId = mf.GetLocationId().AsString();
797  auto sequenceSize =
798  (pMerger ? pMerger->GetSequenceSize(seqId) : mSequenceSize);
799  if (xCreateMissingParentGene(mf, sequenceSize)) {
801  }
802  }
803 }
804 
805 // ----------------------------------------------------------------------------
806 bool
808  CMappedFeat mf)
809  // ----------------------------------------------------------------------------
810 {
811  if (!mf.IsSetPartial() || !mf.GetPartial()) {
812  return true;
813  }
814  CMappedFeat parentGene = feature::GetBestGeneForFeat(mf, &mTree);
815  if (!parentGene) {
816  return false;
817  }
818 
819  if (parentGene.IsSetPartial() && parentGene.GetPartial()) {
820  return true;
821  }
822  CRef<CSeq_feat> pEditedGene(new CSeq_feat);
823  pEditedGene->Assign(parentGene.GetOriginalFeature());
824  pEditedGene->SetPartial(true);
825  CSeq_feat_EditHandle geneEH(
827  geneEH.Replace(*pEditedGene);
828  return true;
829 }
830 
831 // ----------------------------------------------------------------------------
832 bool
834  CMappedFeat mf,
835  TSeqPos sequenceSize)
836  // ----------------------------------------------------------------------------
837 {
838  if (sequenceSize == 0) {
839  sequenceSize = mSequenceSize;
840  }
841  CRef<CSeq_feat> pGene = xMakeGeneForFeature(mf, sequenceSize);
842  if (!pGene) {
843  return false;
844  }
845  // missing gene was created. now attach ids and xrefs:
846  string geneId(xNextFeatId());
847  pGene->SetId().SetLocal().SetStr(geneId);
850  feh.AddFeatXref(geneId);
851 
852  CRef<CFeat_id> pFeatId(new CFeat_id);
853  pFeatId->Assign(mf.GetId());
854  CRef<CSeqFeatXref> pGeneXref(new CSeqFeatXref);
855  pGeneXref->SetId(*pFeatId);
856  pGene->SetXref().push_back(pGeneXref);
857 
858  mEditHandle.AddFeat(*pGene);
859  mTree.AddFeature(mpScope->GetObjectHandle(*pGene));
860  return true;
861 }
862 
863 // ----------------------------------------------------------------------------
865  CMappedFeat mf)
866  // ----------------------------------------------------------------------------
867 {
868  //rw-451 rules for mRNA:
869  // no mRNA survives with an orig_protein_id
870  // almost all mRNA features should have protein_ids
871  // if one exists already then police it
872  // if none exists then if possible inherit it from the decendent CDS
873 
874  auto orig_tid = mf.GetNamedQual("orig_protein_id");
875  if (!orig_tid.empty()) {
876  xFeatureRemoveQualifier(mf, "orig_protein_id");
877  }
878  auto pid = mf.GetNamedQual("protein_id");
879  if (NStr::StartsWith(pid, "gb|") || NStr::StartsWith(pid, "gnl|")) {
880  // already what we want
881  return;
882  }
883  //reformat any tags we already have:
884  if (!pid.empty()) {
885  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + pid;
886  xFeatureSetQualifier(mf, "protein_id", pid);
887  return;
888  }
889 
891  if (!child) {
892  // only permitted case of an mRNA without a protein_id
893  return;
894  }
895  pid = child.GetNamedQual("protein_id");
896  xFeatureAddQualifier(mf, "protein_id", pid);
897  return;
898 }
899 
900 // ----------------------------------------------------------------------------
902  CMappedFeat mf)
903  // ----------------------------------------------------------------------------
904 {
905  //rw-451 rules for CDS:
906  // no CDS survives with an orig_protein_id
907  // all CDS features should have transcript_ids
908  // if one exists already then police it
909  // if it doen't have one then generate one following a strict set of rules
910 
911  auto orig_pid = mf.GetNamedQual("orig_protein_id");
912  if (!orig_pid.empty()) {
913  xFeatureRemoveQualifier(mf, "orig_protein_id");
914  }
915 
916  auto pid = mf.GetNamedQual("protein_id");
917  if (NStr::StartsWith(pid, "gb|") || NStr::StartsWith(pid, "gnl|")) {
918  // already what we want
919  return;
920  }
921  //reformat any tags we already have:
922  if (!pid.empty()) {
923  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + pid;
924  xFeatureSetQualifier(mf, "protein_id", pid);
925  return;
926  }
927 
928  auto id = mf.GetNamedQual("ID");
929  if (!id.empty()) {
930  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + id;
931  xFeatureSetQualifier(mf, "protein_id", pid);
932  return;
933  }
934 
935  auto tid = mf.GetNamedQual("transcript_id");
936  if (!tid.empty()) {
938  auto mRnaTid = parent.GetNamedQual("transcript_id");
939  if (tid == mRnaTid) {
940  tid = string("cds.") + tid;
941  }
942  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
943  xFeatureSetQualifier(mf, "protein_id", pid);
944  return;
945  }
946 
947  pid = xNextProteinId(mf);
948  if (!pid.empty()) {
949  xFeatureSetQualifier(mf, "protein_id", pid);
950  }
951 }
952 
953 // ----------------------------------------------------------------------------
955  CMappedFeat mf)
956  // ----------------------------------------------------------------------------
957 {
958  //rw-451 rules for non CDS, non mRNA:
959  // we won't touch orig_protein_id
960  // we don't generate any protein_ids
961  // if it comes with a protein_id then we add it to the "gnl|locus_tag|"
962  // namespace if necessary.
963 
964  auto pid = mf.GetNamedQual("protein_id");
965  if (pid.empty()) {
966  return;
967  }
968  if (NStr::StartsWith(pid, "gb|") || NStr::StartsWith(pid, "gnl|")) {
969  // already what we want
970  return;
971  }
972  //reformat any tags we already have:
973  if (!pid.empty()) {
974  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + pid;
975  xFeatureSetQualifier(mf, "protein_id", pid);
976  return;
977  }
978 
979  //pid = xGenerateTranscriptOrProteinId(mf, pid);
980  pid = xNextProteinId(mf);
981  if (!pid.empty()) {
982  xFeatureSetQualifier(mf, "protein_id", pid);
983  }
984 }
985 
986 
987 // ----------------------------------------------------------------------------
989  CMappedFeat mf)
990  // ----------------------------------------------------------------------------
991 {
992  //rw-451 rules for mRNA:
993  // no mRNA survives with an orig_transcript_id
994  // every mRNA must have a transcript_id.
995  // if it already got one then police it.
996  // if it doen't have one then generate one following a strict set of rules
997 
998  auto orig_tid = mf.GetNamedQual("orig_transcript_id");
999  if (!orig_tid.empty()) {
1000  xFeatureRemoveQualifier(mf, "orig_transcript_id");
1001  }
1002 
1003  auto tid = mf.GetNamedQual("transcript_id");
1004  if (NStr::StartsWith(tid, "gb|") || NStr::StartsWith(tid, "gnl|")) {
1005  // already what we want
1006  return;
1007  }
1008  //reformat any tags we already have:
1009  if (!tid.empty()) {
1010  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
1011  xFeatureSetQualifier(mf, "transcript_id", tid);
1012  return;
1013  }
1014  else {
1015  }
1016 
1017 
1018 
1019  auto id = mf.GetNamedQual("ID");
1020  if (!id.empty()) {
1021  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + id;
1022  xFeatureSetQualifier(mf, "transcript_id", tid);
1023  return;
1024  }
1025 
1026  //tid = xGenerateTranscriptOrProteinId(mf, tid);
1027  tid = xNextTranscriptId(mf);
1028  if (!tid.empty()) {
1029  xFeatureSetQualifier(mf, "transcript_id", tid);
1030  }
1031 }
1032 
1033 
1034 // ----------------------------------------------------------------------------
1036  CMappedFeat mf)
1037  // ----------------------------------------------------------------------------
1038 {
1039  //rw-451 rules for CDS:
1040  // no CDS survives with an orig_transcript_id
1041  // almost all CDS features should have transcript_ids
1042  // if one exists already then police it
1043  // if none exists then if possible inherit it from the parent mRNA
1044 
1045  auto orig_tid = mf.GetNamedQual("orig_transcript_id");
1046  if (!orig_tid.empty()) {
1047  xFeatureRemoveQualifier(mf, "orig_transcript_id");
1048  }
1049 
1050  auto tid = mf.GetNamedQual("transcript_id");
1051  // otherwise, we need to police the existing transcript_id:
1052  if (NStr::StartsWith(tid, "gb|") || NStr::StartsWith(tid, "gnl|")) {
1053  // already what we want
1054  return;
1055  }
1056  //reformat any tags we already have:
1057  if (!tid.empty()) {
1058  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
1059  xFeatureSetQualifier(mf, "transcript_id", tid);
1060  return;
1061  }
1062 
1064  if (!parent) {
1065  // only permitted case of a CDS without a transcript_id
1066  return;
1067  }
1068  tid = parent.GetNamedQual("transcript_id");
1069  xFeatureAddQualifier(mf, "transcript_id", tid);
1070 }
1071 
1072 
1073 // ----------------------------------------------------------------------------
1075  CMappedFeat mf)
1076  // ----------------------------------------------------------------------------
1077 {
1078  //rw-451 rules for non CDS, non mRNA:
1079  // we won't touch orig_transcript_id
1080  // we don't generate any transcript_ids
1081  // if it comes with a transcript_id then we add it to the "gnl|locus_tag|"
1082  // namespace if necessary.
1083 
1084  auto tid = mf.GetNamedQual("transcript_id");
1085  if (tid.empty()) {
1086  return;
1087  }
1088  if (NStr::StartsWith(tid, "gb|") || NStr::StartsWith(tid, "gnl|")) {
1089  // already what we want
1090  return;
1091  }
1092  if (!tid.empty()) {
1093  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
1094  xFeatureSetQualifier(mf, "transcript_id", tid);
1095  return;
1096  }
1097 
1098  tid = this->xNextTranscriptId(mf);
1099  if (!tid.empty()) {
1100  xFeatureSetQualifier(mf, "transcript_id", tid);
1101  }
1102 }
1103 
1104 
1105 // ----------------------------------------------------------------------------
1107  CMappedFeat mf,
1108  const string& rawId)
1109  // ----------------------------------------------------------------------------
1110 {
1111  //weed out badly formatted original tags:
1112  if (string::npos != rawId.find("|")) {
1113  xPutError(
1114  "Feature " + xGetIdStr(mf) +
1115  " does not have a usable transcript_ or protein_id.");
1116  return "";
1117  }
1118 
1119  //make sure we got the locus tag prefix necessary for tag generation:
1120  auto locusTagPrefix = xGetCurrentLocusTagPrefix(mf);
1121  if (locusTagPrefix.empty()) {
1122  xPutError(
1123  "Cannot generate transcript_/protein_id for feature " + xGetIdStr(mf) +
1124  " without a locus tag.");
1125  return "";
1126  }
1127 
1128  //reformat any tags we already have:
1129  if (!rawId.empty()) {
1130  return string("gnl|") + locusTagPrefix + "|" + rawId;
1131  }
1132 
1133  //attempt to make transcript_id from protein_id, or protein_id from transcript_id:
1134  switch (mf.GetFeatSubtype()) {
1136  auto id = mf.GetNamedQual("protein_id");
1137  if (id.empty()) {
1138  id = mf.GetNamedQual("ID");
1139  }
1140  if (id.empty()) {
1141  if (mf.GetId().IsLocal()) {
1142  id = mf.GetId().GetLocal().GetStr();
1143  }
1144  }
1145  if (!id.empty()) {
1146  return string("gnl|") + locusTagPrefix + "|mrna." + id;
1147  }
1148  }
1149  break;
1150 
1152  auto id = mf.GetNamedQual("transcript_id");
1153  if (id.empty()) {
1154  id = mf.GetNamedQual("ID");
1155  }
1156  if (!id.empty()) {
1157  return string("gnl|") + locusTagPrefix + "|cds." + id;
1158  }
1159  }
1160  break;
1161 
1162  default:
1163  break;
1164  }
1165 
1166 
1167  xPutError(
1168  "Cannot generate transcript_/protein_id for feature " + xGetIdStr(mf) +
1169  " - insufficient context.");
1170  return "";
1171 }
1172 
1173 
1174 // ----------------------------------------------------------------------------
1176 // ----------------------------------------------------------------------------
1177 {
1178  SAnnotSelector sel;
1180 
1181  if (mLocusTagPrefix.empty()) {
1183  }
1184  else {
1185  return xGenerateLocusIdsRegenerate();
1186  }
1187 }
1188 
1189 // ----------------------------------------------------------------------------
1191 // ----------------------------------------------------------------------------
1192 {
1193  //mss-362:
1194  // blow away any locus_tag, protein_id, transcript_id attributes and
1195  // regenerate from scratch using mLocusTagPrefix
1196 
1197  //make sure genes got proper locus tags
1198  SAnnotSelector selGenes;
1201  for (CFeat_CI it(mHandle, selGenes); it; ++it) {
1202  CMappedFeat mf = *it;
1203  CSeq_feat_EditHandle feh(mf);
1204  CRef<CSeq_feat> pReplacement(new CSeq_feat);
1205  pReplacement->Assign(*mf.GetSeq_feat());
1206  pReplacement->SetData().SetGene().SetLocus_tag(xNextLocusTag());
1207  feh.Replace(*pReplacement);
1208  }
1209 
1210  //make sure all locus related junk is removed and that rnas are
1211  // labeled properly
1212  SAnnotSelector selOthers;
1214  for (CFeat_CI it(mHandle, selOthers); it; ++it) {
1215  CMappedFeat mf = *it;
1216  CSeq_feat_EditHandle feh(mf);
1217 
1218  feh.RemoveQualifier("orig_protein_id");
1219  feh.RemoveQualifier("orig_transcript_id");
1220 
1221  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1222  switch (subtype) {
1224  string proteinId = xNextProteinId(mf);
1225  feh.AddQualifier("orig_protein_id", proteinId);
1226  string transcriptId = xNextTranscriptId(mf);
1227  feh.AddQualifier("orig_transcript_id", transcriptId);
1228  break;
1229  }
1230  default: {
1231  break;
1232  }
1233  }
1234  }
1235 
1236  //finally, down inherit transcript ids from the mrna's to the cdregions
1237  SAnnotSelector selCds;
1239 
1240  for (CFeat_CI it(mHandle, selCds); it; ++it) {
1241 
1242  CMappedFeat mf = *it;
1243  CSeq_feat_EditHandle feh(mf);
1245  string transcriptId = rna.GetNamedQual("transcript_id");
1246  feh.AddQualifier("orig_transcript_id", transcriptId);
1247  string proteinId = rna.GetNamedQual("protein_id");
1248  feh.AddQualifier("orig_protein_id", proteinId);
1249  }
1250 }
1251 
1252 // ----------------------------------------------------------------------------
1254 // ----------------------------------------------------------------------------
1255 {
1256  SAnnotSelector sel;
1258 
1259  for (CFeat_CI it(mHandle, sel); it; ++it) {
1260  //mss-362: every feature that needs them must come with a complete set
1261  // of locus_tag, protein_id, and transcript_id.
1262 
1263  CMappedFeat mf = *it;
1264  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1265 
1266  switch (subtype) {
1268  if (!mf.GetData().GetGene().IsSetLocus_tag()) {
1270  }
1271  break;
1272  }
1274  string transcriptId = mf.GetNamedQual("transcript_id");
1275  if (transcriptId.empty()) {
1277  }
1278  string proteinId = mf.GetNamedQual("protein_id");
1279  if (proteinId.empty()) {
1281  }
1282  break;
1283  }
1285  string transcriptId = mf.GetNamedQual("transcript_id");
1286  if (transcriptId.empty()) {
1288  }
1289  break;
1290  }
1291  default: {
1292  break;
1293  }
1294  }
1295  }
1296 }
1297 
1298 bool idAlpha(const CSeq_id_Handle& idh1, const CSeq_id_Handle idh2) {
1299  return (idh1.AsString() < idh2.AsString());
1300 }
1301 
1302 // ----------------------------------------------------------------------------
1304 // ----------------------------------------------------------------------------
1305 {
1306  SAnnotSelector selGenes;
1308  CFeat_CI itGenes(mHandle, selGenes);
1309  for (; itGenes; ++itGenes) {
1310  CSeq_feat_Handle fh = *itGenes;
1311  if (!fh.GetData().GetGene().IsSetLocus_tag()) {
1312  return false;
1313  }
1314  }
1315  return true;
1316 }
1317 
1318 // ----------------------------------------------------------------------------
1320 // ----------------------------------------------------------------------------
1321 {
1322  if (mLocusTagPrefix.empty()) {
1323  return;
1324  }
1325 
1326  CRef<CGb_qual> pLocusTag;
1327  SAnnotSelector selGenes;
1328  vector<CSeq_id_Handle> annotIds;
1331  CFeat_CI itGenes(mHandle, selGenes);
1332  for (; itGenes; ++itGenes) {
1333  CSeq_feat_Handle fh = *itGenes;
1334  CSeq_id_Handle idh = fh.GetLocationId();
1335  vector<CSeq_id_Handle>::const_iterator compIt;
1336  for (compIt = annotIds.begin();
1337  compIt != annotIds.end();
1338  ++compIt) {
1339  if (*compIt == idh) {
1340  break;
1341  }
1342  }
1343  if (compIt == annotIds.end()) {
1344  annotIds.push_back(idh);
1345  }
1346  }
1347  std::sort(annotIds.begin(), annotIds.end(), idAlpha);
1348 
1349  for (vector<CSeq_id_Handle>::const_iterator idIt = annotIds.begin();
1350  idIt != annotIds.end();
1351  ++idIt) {
1352  CSeq_id_Handle curId = *idIt;
1353 
1354  CRef<CGb_qual> pLocusTag;
1355  SAnnotSelector selGenes;
1358  CFeat_CI itGenes(mHandle, selGenes);
1359  for (; itGenes; ++itGenes) {
1360  CSeq_feat_Handle fh = *itGenes;
1361  string id1 = fh.GetLocationId().AsString();
1362  string id2 = curId.AsString();
1363  if (fh.GetLocationId() != curId) {
1364  continue;
1365  }
1367  itGenes->GetOriginalFeature()));
1368  CRef<CSeq_feat> pEditedFeat(new CSeq_feat);
1369  pEditedFeat->Assign(itGenes->GetOriginalFeature());
1370  pEditedFeat->RemoveQualifier("locus_tag");
1371  pEditedFeat->SetData().SetGene().SetLocus_tag(xNextLocusTag());
1372  feh.Replace(*pEditedFeat);
1373  }
1374  }
1375  SAnnotSelector selOther;
1377  CFeat_CI itOther(mHandle, selOther);
1378 
1379  // mss-315:
1380  // only the genes get the locus_tags. they are inherited down
1381  // to the features that live on them when we generate a flat file,
1382  // but we don't want them here in the ASN.1
1383  for (; itOther; ++itOther) {
1385  (itOther)->GetOriginalFeature()));
1386  feh.RemoveQualifier("locus_tag");
1387  }
1388 }
1389 
1390 
1391 // ----------------------------------------------------------------------------
1393  bool forEukaryote,
1394  const CGff3LocationMerger* pMerger)
1395  // ----------------------------------------------------------------------------
1396 {
1397  if (forEukaryote) {
1399  }
1400  else {
1402  }
1403  mTree = feature::CFeatTree(mHandle);
1404 }
1405 
1406 
1407 // ----------------------------------------------------------------------------
1409  const CGff3LocationMerger* pMerger)
1410  // ----------------------------------------------------------------------------
1411 {
1414  CSeqFeatData::e_Rna, nullptr); //sequence not circular for eukaryote
1415 }
1416 
1417 
1418 // ----------------------------------------------------------------------------
1420  const CGff3LocationMerger* pMerger)
1421 // ----------------------------------------------------------------------------
1422 {
1425 }
1426 
1427 
1428 // ----------------------------------------------------------------------------
1430  CMappedFeat mf,
1431  const string& qualKey,
1432  const string& qualVal)
1433  // ----------------------------------------------------------------------------
1434 {
1435  const CSeq_feat& origFeat = mf.GetOriginalFeature();
1437  feh.AddQualifier(qualKey, qualVal);
1438 }
1439 
1440 
1441 // ----------------------------------------------------------------------------
1443  CMappedFeat mf,
1444  const string& qualKey)
1445  // ----------------------------------------------------------------------------
1446 {
1447  const CSeq_feat& origFeat = mf.GetOriginalFeature();
1449  feh.RemoveQualifier(qualKey);
1450 }
1451 
1452 // ----------------------------------------------------------------------------
1454  CMappedFeat mf,
1455  const string& qualKey,
1456  const string& qualVal)
1457  // ----------------------------------------------------------------------------
1458 {
1459  auto existing = mf.GetNamedQual(qualKey);
1460  if (!existing.empty()) {
1461  xFeatureRemoveQualifier(mf, qualKey);
1462  }
1463  xFeatureAddQualifier(mf, qualKey, qualVal);
1464 }
1465 
1466 // ----------------------------------------------------------------------------
1468  CMappedFeat mf,
1469  const string& proteinIdStr)
1470  // ----------------------------------------------------------------------------
1471 {
1472  CRef<CSeq_id> pProteinId(
1473  new CSeq_id(proteinIdStr,
1475 
1476  const CSeq_feat& origFeat = mf.GetOriginalFeature();
1477  CRef<CSeq_feat> pEditedFeat(new CSeq_feat);
1478  pEditedFeat->Assign(origFeat);
1479  pEditedFeat->SetProduct().SetWhole(*pProteinId);
1481  feh.Replace(*pEditedFeat);
1482 }
1483 
1484 // ----------------------------------------------------------------------------
1486 // ----------------------------------------------------------------------------
1487 {
1488  const int WIDTH = 6;
1489  const string padding = string(WIDTH, '0');
1491  if (suffix.size() < WIDTH) {
1492  suffix = padding.substr(0, WIDTH - suffix.size()) + suffix;
1493  }
1494  string nextTag("auto");
1495  return nextTag + suffix;
1496 }
1497 
1498 // ----------------------------------------------------------------------------
1500 // ----------------------------------------------------------------------------
1501 {
1502  const int WIDTH = 6;
1503  const string padding = string(WIDTH, '0');
1505  if (suffix.size() < WIDTH) {
1506  suffix = padding.substr(0, WIDTH - suffix.size()) + suffix;
1507  }
1508  string nextTag = mLocusTagPrefix + "_" + suffix;
1509  return nextTag;
1510 }
1511 
1512 // ----------------------------------------------------------------------------
1514  const CMappedFeat& mf)
1515 // ----------------------------------------------------------------------------
1516 {
1517  const string dbPrefix("gnl|");
1518 
1519  // format: mLocusTagPrefix|<locus tag of gene or hash>[_numeric disambiguation]
1520  CMappedFeat parentGene = feature::GetBestGeneForFeat(mf, &mTree);
1521  if (!parentGene ||
1522  !parentGene.GetData().GetGene().IsSetLocus_tag()) {
1524  return "";
1525  }
1526 
1527  int offset = 0;
1528  string locusTag = parentGene.GetData().GetGene().GetLocus_tag();
1530  if (it == mMapProtIdCounts.end()) {
1531  mMapProtIdCounts[locusTag] = 0;
1532  }
1533  else {
1534  ++mMapProtIdCounts[locusTag];
1535  offset = mMapProtIdCounts[locusTag];
1536  }
1537  string db = mLocusTagPrefix;
1538  if (locusTag.empty() &&
1539  db.empty()) {
1541  }
1542 
1543  if (db.empty()) {
1544  string prefix, suffix;
1545  NStr::SplitInTwo(locusTag, "_", prefix, suffix);
1546  db = prefix;
1547  }
1548  string proteinId = dbPrefix + db + "|" + GetIdHashOrValue(locusTag, offset);
1549  return proteinId;
1550 }
1551 
1552 // ----------------------------------------------------------------------------
1554  const CMappedFeat& cds)
1555 // ----------------------------------------------------------------------------
1556 {
1557  const string dbPrefix("gnl|");
1558 
1559 
1560  // format: mLocusTagPrefix|mrna.<locus tag of gene or hash>[_numeric disambiguation]
1561  CMappedFeat parentGene = feature::GetBestGeneForFeat(cds, &mTree);
1562  if (!parentGene ||
1563  !parentGene.GetData().GetGene().IsSetLocus_tag()) {
1565  return "";
1566  }
1567 
1568 
1569  string locusTag = parentGene.GetData().GetGene().GetLocus_tag();
1570  int offset = 0;
1572  if (it != mMapProtIdCounts.end() && mMapProtIdCounts[locusTag] != 0) {
1573  offset = mMapProtIdCounts[locusTag];
1574  }
1575  string db = mLocusTagPrefix;
1576 
1577  if (locusTag.empty() &&
1578  db.empty()) {
1580  }
1581 
1582 
1583  if (db.empty()) {
1584  string prefix, suffix;
1585  NStr::SplitInTwo(locusTag, "_", prefix, suffix);
1586  db = prefix;
1587  }
1588 
1589  string transcriptId = dbPrefix + db + "|mrna." + GetIdHashOrValue(locusTag, offset);
1590  return transcriptId;
1591 }
1592 
1593 // ----------------------------------------------------------------------------
1595  const CSeq_loc& baseLoc,
1596  TSeqPos sequenceSize)
1597 // ----------------------------------------------------------------------------
1598 {
1599  CRef<CSeq_loc> pEnvelope(new CSeq_loc);
1600 
1601  auto baseStart = baseLoc.GetStart(eExtreme_Positional);
1602  auto baseStop = baseLoc.GetStop(eExtreme_Positional);
1603  auto& baseId = *baseLoc.GetId();
1604 
1605  if (sequenceSize == 0 || baseStart <= baseStop) {
1606  pEnvelope->SetInt();
1607  pEnvelope->SetId(baseId);
1608  pEnvelope->SetInt().SetFrom(baseStart);
1609  pEnvelope->SetInt().SetTo(baseStop);
1610  pEnvelope->SetInt().SetStrand(baseLoc.GetStrand());
1611  }
1612  else {
1613  if (baseLoc.GetStrand() != eNa_strand_minus) {
1615  pTop->SetId().Assign(baseId);
1616  pTop->SetFrom(baseStart);
1617  pTop->SetTo(sequenceSize-1);
1618  pTop->SetStrand(baseLoc.GetStrand());
1619  pEnvelope->SetPacked_int().AddInterval(*pTop);
1620  CRef<CSeq_interval> pBottom(new CSeq_interval);
1621  pBottom->SetId().Assign(baseId);
1622  pBottom->SetFrom(0);
1623  pBottom->SetTo(baseStop);
1624  pBottom->SetStrand(baseLoc.GetStrand());
1625  pEnvelope->SetPacked_int().AddInterval(*pBottom);
1626  pEnvelope->ChangeToMix();
1627  }
1628  else {
1629  CRef<CSeq_interval> pBottom(new CSeq_interval);
1630  pBottom->SetId().Assign(baseId);
1631  pBottom->SetFrom(0);
1632  pBottom->SetTo(baseStop);
1633  pBottom->SetStrand(baseLoc.GetStrand());
1634  pEnvelope->SetPacked_int().AddInterval(*pBottom);
1636  pTop->SetId().Assign(baseId);
1637  pTop->SetFrom(baseStart);
1638  pTop->SetTo(sequenceSize-1);
1639  pTop->SetStrand(baseLoc.GetStrand());
1640  pEnvelope->SetPacked_int().AddInterval(*pTop);
1641  pEnvelope->ChangeToMix();
1642  }
1643  }
1644  return pEnvelope;
1645 }
1646 
1647 // ----------------------------------------------------------------------------
1649  const CMappedFeat& rna,
1650  TSeqPos sequenceSize)
1651 // ----------------------------------------------------------------------------
1652 {
1653  CRef<CSeq_feat> pGene;
1654  CSeq_feat_Handle sfh = mpScope->GetSeq_featHandle(rna.GetOriginalFeature());
1655  CSeq_annot_Handle sah = sfh.GetAnnot();
1656  if (!sah) {
1657  return pGene;
1658  }
1660  if (existingGene) {
1661  return pGene;
1662  }
1663  pGene.Reset(new CSeq_feat);
1664  pGene->SetLocation(*xGetGeneLocation(rna.GetLocation(), sequenceSize));
1665  pGene->SetData().SetGene();
1666  return pGene;
1667 }
1668 
1669 
1670 // ----------------------------------------------------------------------------
1671 void
1673  const string& message)
1674  // ----------------------------------------------------------------------------
1675 {
1676  if (!mpMessageListener) {
1677  return;
1678  }
1679 
1681  CObjEditMessage(message, eDiag_Error));
1682 }
1683 
1684 
1685 // ----------------------------------------------------------------------------
1686 void
1688  CMappedFeat mf)
1689  // ----------------------------------------------------------------------------
1690 {
1691  if (!mpMessageListener) {
1692  return;
1693  }
1694 
1695  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1696  string subName = CSeqFeatData::SubtypeValueToName(subtype);
1697  unsigned int lower = mf.GetLocation().GetStart(eExtreme_Positional);
1698  unsigned int upper = mf.GetLocation().GetStop(eExtreme_Positional);
1699  subName = NStr::IntToString(lower) + ".." + NStr::IntToString(upper) + " " +
1700  subName;
1701 
1702  string message = subName + " feature is missing locus tag.";
1703  xPutError(message);
1704 }
1705 
1706 // ----------------------------------------------------------------------------
1707 void
1709  CMappedFeat mf)
1710  // ----------------------------------------------------------------------------
1711 {
1712  if (!mpMessageListener) {
1713  return;
1714  }
1715 
1716  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1717  string subName = CSeqFeatData::SubtypeValueToName(subtype);
1718  unsigned int lower = mf.GetLocation().GetStart(eExtreme_Positional);
1719  unsigned int upper = mf.GetLocation().GetStop(eExtreme_Positional);
1720  subName = NStr::IntToString(lower) + ".." + NStr::IntToString(upper) + " " +
1721  subName;
1722 
1723  string message = subName + " feature is missing transcript ID.";
1724  xPutError(message);
1725 }
1726 
1727 // ----------------------------------------------------------------------------
1728 void
1730  const string codonRecognized)
1731 // ----------------------------------------------------------------------------
1732 {
1733  if (!mpMessageListener) {
1734  return;
1735  }
1736  string message = "tRNA with bad codon recognized attribute \"" +
1737  codonRecognized + "\".";
1738  xPutError(message);
1739 }
1740 
1741 // ----------------------------------------------------------------------------
1742 void
1744  CMappedFeat mf)
1745  // ----------------------------------------------------------------------------
1746 {
1747  if (!mpMessageListener) {
1748  return;
1749  }
1750 
1751  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1752  string subName = CSeqFeatData::SubtypeValueToName(subtype);
1753  unsigned int lower = mf.GetLocation().GetStart(eExtreme_Positional);
1754  unsigned int upper = mf.GetLocation().GetStop(eExtreme_Positional);
1755  subName = NStr::IntToString(lower) + ".." + NStr::IntToString(upper) + " " +
1756  subName;
1757 
1758  string message = subName + " feature is missing protein ID.";
1759  xPutError(message);
1760 }
1761 
1762 
1763 // ----------------------------------------------------------------------------
1764 void
1766  const CMappedFeat& mrna)
1767 // ----------------------------------------------------------------------------
1768 {
1769  if (!mpMessageListener) {
1770  return;
1771  }
1772 
1774  return;
1775  }
1776  xPutError("Protein ID on mRNA feature differs from protein ID on child CDS.");
1777 }
1778 
1779 void
1781  const CMappedFeat& mrna)
1782 // ----------------------------------------------------------------------------
1783 {
1784  if (!mpMessageListener) {
1785  return;
1786  }
1787 
1789  return;
1790  }
1791 
1792  xPutError("Transcript ID on mRNA feature differs from transcript ID on child CDS.");
1793 }
1794 
1795 
1796 // ----------------------------------------------------------------------------
1797 string
1799  CMappedFeat mf)
1800  // ----------------------------------------------------------------------------
1801 {
1802  stringstream strstr;
1803  auto& id = mf.GetId();
1804  switch (id.Which()) {
1805  default:
1806  return "\"UNKNOWN ID\"";
1807  case CFeat_id::e_Local:
1808  id.GetLocal().AsString(strstr);
1809  return strstr.str();
1810  }
1811 }
1812 
1813 // ----------------------------------------------------------------------------
1814 string
1816  CMappedFeat mf)
1817  // ----------------------------------------------------------------------------
1818 {
1819  if (!mLocusTagPrefix.empty()) {
1820  return mLocusTagPrefix;
1821  }
1822  CMappedFeat geneFeature = mf;
1823  if (geneFeature.GetFeatSubtype() != CSeqFeatData::eSubtype_gene) {
1824  geneFeature = feature::GetBestGeneForFeat(mf, &mTree);
1825  }
1826  if (!geneFeature) {
1827  return "";
1828  }
1829  const auto& geneRef = geneFeature.GetData().GetGene();
1830  if (geneRef.IsSetLocus_tag()) {
1831  const auto& locusTag = geneFeature.GetData().GetGene().GetLocus_tag();
1832  string prefix, suffix;
1833  NStr::SplitInTwo(locusTag, "_", prefix, suffix);
1834  return prefix;
1835  }
1836  auto locusTagFromQualifier = geneFeature.GetNamedQual("locus_tag");
1837  if (!locusTagFromQualifier.empty()) {
1838  string prefix, suffix;
1839  NStr::SplitInTwo(locusTagFromQualifier, "_", prefix, suffix);
1840  return prefix;
1841  }
1842  return "";
1843 }
1844 
1846 {
1847  CConstRef<CSeq_feat> feature;
1848  if (feature.Empty())
1849  {
1850 
1851  CMappedFeat cds(mpScope->GetSeq_featHandle(cd_feature));
1852  CMappedFeat other;
1853  if (gene)
1854  other = feature::GetBestGeneForCds(cds, &mTree);
1855  else
1856  other = feature::GetBestMrnaForCds(cds, &mTree);
1857 
1858  if (other)
1859  feature.Reset(&other.GetOriginalFeature());
1860 
1861  }
1862  return feature;
1863 }
1864 
1865 
1866 static void s_AppendProtRefInfo(CProt_ref& current_ref, const CProt_ref& other_ref)
1867 {
1868 
1869  auto append_nonduplicated_item = [](list<string>& current_list,
1870  const list<string>& other_list)
1871  {
1872  unordered_set<string> current_set;
1873  for (const auto& item : current_list) {
1874  current_set.insert(item);
1875  }
1876 
1877  for (const auto& item : other_list) {
1878  if (current_set.find(item) == current_set.end()) {
1879  current_list.push_back(item);
1880  }
1881  }
1882  };
1883 
1884  if (other_ref.IsSetName()) {
1885  append_nonduplicated_item(current_ref.SetName(),
1886  other_ref.GetName());
1887  }
1888 
1889  if (other_ref.IsSetDesc()) {
1890  current_ref.SetDesc() = other_ref.GetDesc();
1891  }
1892 
1893  if (other_ref.IsSetEc()) {
1894  append_nonduplicated_item(current_ref.SetEc(),
1895  other_ref.GetEc());
1896  }
1897 
1898  if (other_ref.IsSetActivity()) {
1899  append_nonduplicated_item(current_ref.SetActivity(),
1900  other_ref.GetActivity());
1901  }
1902 
1903  if (other_ref.IsSetDb()) {
1904  for (const auto& pDBtag : other_ref.GetDb()) {
1905  current_ref.SetDb().push_back(pDBtag);
1906  }
1907  }
1908 
1909  if (current_ref.GetProcessed() == CProt_ref::eProcessed_not_set) {
1910  const auto processed = other_ref.GetProcessed();
1911  if (processed != CProt_ref::eProcessed_not_set) {
1912  current_ref.SetProcessed(processed);
1913  }
1914  }
1915 }
1916 
1917 static void s_SetProtRef(const CSeq_feat& cds,
1918  CConstRef<CSeq_feat> pMrna,
1919  CProt_ref& prot_ref)
1920 {
1921  const CProt_ref* pProtXref = cds.GetProtXref();
1922  if (pProtXref) {
1923  s_AppendProtRefInfo(prot_ref, *pProtXref);
1924  }
1925 
1926 
1927  if (!prot_ref.IsSetName()) {
1928  const string& product_name = cds.GetNamedQual("product");
1929  if (product_name != kEmptyStr) {
1930  prot_ref.SetName().push_back(product_name);
1931  }
1932  }
1933 
1934  if (pMrna.Empty()) { // Nothing more we can do here
1935  return;
1936  }
1937 
1938  if (prot_ref.IsSetName()) {
1939  for (auto& prot_name : prot_ref.SetName()) {
1940  if (NStr::CompareNocase(prot_name, "hypothetical protein") == 0) {
1941  if (pMrna->GetData().GetRna().IsSetExt() &&
1942  pMrna->GetData().GetRna().GetExt().IsName()) {
1943  prot_name = pMrna->GetData().GetRna().GetExt().GetName();
1944  break;
1945  }
1946  }
1947  }
1948  } // prot_ref.IsSetName()
1949 }
1950 
1951 static bool AssignLocalIdIfEmpty(CSeq_feat& feature, unsigned& id)
1952 {
1953  if (feature.IsSetId())
1954  return true;
1955  else
1956  {
1957  feature.SetId().SetLocal().SetId(id++);
1958  return false;
1959  }
1960 }
1961 
1963 {
1964  for (auto feat : mAnnot.GetData().GetFtable())
1965  {
1966  if (feat.NotEmpty() && feat->IsSetData() && feat->GetData().IsCdregion())
1967  {
1968  xGenerate_mRNA_Product(*feat);
1969  }
1970  }
1971 }
1972 
1974 {
1975  if (sequence::IsPseudo(cd_feature, *mpScope))
1976  return; // CRef<CSeq_entry>();
1977 
1978 #if 0
1979  CBioseq_Handle bsh = m_scope->GetBioseqHandle(bioseq);
1980 
1981  CConstRef<CSeq_entry> replacement = LocateProtein(m_replacement_protein, cd_feature);
1982 #endif
1983 
1984  CConstRef<CSeq_feat> mrna = xGetLinkedFeature(cd_feature, false);
1985  CConstRef<CSeq_feat> gene = xGetLinkedFeature(cd_feature, true);
1986 
1987 #if 0
1988  CRef<CBioseq> protein;
1989  bool was_extended = false;
1990  if (replacement.Empty())
1991  {
1992  was_extended = CCleanup::ExtendToStopIfShortAndNotPartial(cd_feature, bsh);
1993 
1994  protein = CSeqTranslator::TranslateToProtein(cd_feature, *m_scope);
1995 
1996  if (protein.Empty())
1997  return CRef<CSeq_entry>();
1998  }
1999  else
2000  {
2001  protein.Reset(new CBioseq());
2002  protein->Assign(replacement->GetSeq());
2003  }
2004 
2005  CRef<CSeq_entry> protein_entry(new CSeq_entry);
2006  protein_entry->SetSeq(*protein);
2007 
2008  CAutoAddDesc molinfo_desc(protein->SetDescr(), CSeqdesc::e_Molinfo);
2011  feature::AdjustProteinMolInfoToMatchCDS(molinfo_desc.Set().SetMolinfo(), cd_feature);
2012 
2013  string org_name;
2014  CTable2AsnContext::GetOrgName(org_name, *top_entry_h.GetCompleteObject());
2015 
2016  CTempString locustag;
2017  if (!gene.Empty() && gene->IsSetData() && gene->GetData().IsGene() && gene->GetData().GetGene().IsSetLocus_tag())
2018  {
2019  locustag = gene->GetData().GetGene().GetLocus_tag();
2020  }
2021 
2022  string base_name;
2023  CRef<CSeq_id> newid;
2024  CTempString qual_to_remove;
2025 
2026  if (protein->GetId().empty())
2027  {
2028  const string* protein_ids = 0;
2029 
2030  qual_to_remove = "protein_id";
2031  protein_ids = &cd_feature.GetNamedQual(qual_to_remove);
2032 
2033  if (protein_ids->empty())
2034  {
2035  qual_to_remove = "orig_protein_id";
2036  protein_ids = &cd_feature.GetNamedQual(qual_to_remove);
2037  }
2038 
2039  if (protein_ids->empty())
2040  {
2041  if (mrna.NotEmpty())
2042  protein_ids = &mrna->GetNamedQual("protein_id");
2043  }
2044 
2045  if (protein_ids->empty())
2046  {
2047  protein_ids = &cd_feature.GetNamedQual("product_id");
2048  }
2049 
2050  if (!protein_ids->empty())
2051  {
2052  CBioseq::TId new_ids;
2054 
2055  MergeSeqIds(*protein, new_ids);
2056  cd_feature.RemoveQualifier(qual_to_remove);
2057  }
2058  }
2059  else {
2060  cd_feature.RemoveQualifier("protein_id");
2061  cd_feature.RemoveQualifier("orig_protein_id");
2062  }
2063 
2064  if (protein->GetId().empty())
2065  {
2066  if (base_name.empty() && !bioseq.GetId().empty())
2067  {
2068  bioseq.GetId().front()->GetLabel(&base_name, CSeq_id::eContent);
2069  }
2070 
2071  newid = GetNewProteinId(*m_scope, base_name);
2072  protein->SetId().push_back(newid);
2073  }
2074 
2075 #endif
2076 
2077 #if 0
2078  CSeq_feat& prot_feat = CreateOrSetFTable(*protein);
2079  CProt_ref& prot_ref = prot_feat.SetData().SetProt();
2080 #else
2081  CRef<CProt_ref> p_prot_ref(new CProt_ref);
2082  CProt_ref& prot_ref = *p_prot_ref;
2083 #endif
2084 
2085  s_SetProtRef(cd_feature, mrna, prot_ref);
2086  if ((!prot_ref.IsSetName() || prot_ref.GetName().empty()) && m_use_hypothetic_protein)
2087  {
2088  prot_ref.SetName().push_back("hypothetical protein");
2089  cd_feature.SetProtXref().SetName().clear();
2090  cd_feature.SetProtXref().SetName().push_back("hypothetical protein");
2091  //cd_feature.RemoveQualifier("product");
2092  }
2093 
2094 
2095 #if 0
2096  prot_feat.SetLocation().SetInt().SetFrom(0);
2097  prot_feat.SetLocation().SetInt().SetTo(protein->GetInst().GetLength() - 1);
2098  prot_feat.SetLocation().SetInt().SetId().Assign(*GetAccessionId(protein->GetId()));
2099  feature::CopyFeaturePartials(prot_feat, cd_feature);
2100 
2101  if (!cd_feature.IsSetProduct())
2102  cd_feature.SetProduct().SetWhole().Assign(*GetAccessionId(protein->GetId()));
2103 
2104  CBioseq_Handle protein_handle = m_scope->AddBioseq(*protein);
2105 
2106  AssignLocalIdIfEmpty(cd_feature, m_local_id_counter);
2107  if (gene.NotEmpty() && mrna.NotEmpty())
2108  cd_feature.SetXref().clear();
2109 
2110  if (gene.NotEmpty())
2111  {
2112  CSeq_feat& gene_feature = (CSeq_feat&)*gene;
2113  AssignLocalIdIfEmpty(gene_feature, m_local_id_counter);
2114  cd_feature.AddSeqFeatXref(gene_feature.GetId());
2115  gene_feature.AddSeqFeatXref(cd_feature.GetId());
2116  }
2117 #endif
2118 
2119  if (mrna.NotEmpty())
2120  {
2121  CSeq_feat& mrna_feature = (CSeq_feat&)*mrna;
2122 
2123  AssignLocalIdIfEmpty(mrna_feature, mNextFeatId);
2124 
2125  if (prot_ref.IsSetName() && !prot_ref.GetName().empty())
2126  {
2127  auto& ext = mrna_feature.SetData().SetRna().SetExt();
2128  if (ext.Which() == CRNA_ref::C_Ext::e_not_set ||
2129  (ext.IsName() && ext.SetName().empty()))
2130  ext.SetName() = prot_ref.GetName().front();
2131  }
2132  mrna_feature.AddSeqFeatXref(cd_feature.GetId());
2133  cd_feature.AddSeqFeatXref(mrna_feature.GetId());
2134  }
2135 
2136 #if 0
2137  if (prot_ref.IsSetName() && !prot_ref.GetName().empty())
2138  {
2139  //cd_feature.ResetProduct();
2140  cd_feature.SetProtXref().SetName().clear();
2141  cd_feature.SetProtXref().SetName().push_back(prot_ref.GetName().front());
2142  cd_feature.RemoveQualifier("product");
2143  }
2144 
2145 
2146  if (was_extended)
2147  {
2148  if (!mrna.Empty() && mrna->IsSetLocation() && CCleanup::LocationMayBeExtendedToMatch(mrna->GetLocation(), cd_feature.GetLocation()))
2149  CCleanup::ExtendStopPosition((CSeq_feat&)*mrna, &cd_feature);
2150  if (!gene.Empty() && gene->IsSetLocation() && CCleanup::LocationMayBeExtendedToMatch(gene->GetLocation(), cd_feature.GetLocation()))
2151  CCleanup::ExtendStopPosition((CSeq_feat&)*gene, &cd_feature);
2152  }
2153 
2154  return protein_entry;
2155 #endif
2156 }
2157 
2158 // ============================================================================
2159 string
2160 sGetFeatMapKey(const CObject_id& objectId)
2161 // ============================================================================
2162 {
2163  if (objectId.IsStr()) {
2164  return objectId.GetStr();
2165  }
2166  return string("id:") + NStr::NumericToString(objectId.GetId());
2167 }
2168 
2169 // ============================================================================
2170 void
2172  const CSeq_annot::TData::TFtable& otherFeatures)
2173 // ============================================================================
2174 {
2175  FeatMap featMap;
2176 
2177  auto& thisFeatures = mAnnot.SetData().SetFtable();
2178  for (auto pThisFeat: thisFeatures) {
2179  //(assumption: only local IDs are at issue)
2180  if (!pThisFeat->IsSetId() || !pThisFeat->GetId().IsLocal()) {
2181  continue;
2182  }
2183  const auto& this_oid = pThisFeat->GetId().GetLocal();
2184  featMap[sGetFeatMapKey(this_oid)] = pThisFeat;
2185  }
2186  for (auto pOtherFeat: otherFeatures) {
2187  if (!pOtherFeat->IsSetId() || !pOtherFeat->GetId().IsLocal()) {
2188  thisFeatures.push_back(pOtherFeat);
2189  continue;
2190  }
2191  const auto& other_oid = pOtherFeat->GetId().GetLocal();
2192  if (featMap.find(sGetFeatMapKey(other_oid)) == featMap.end()) {
2193  thisFeatures.push_back(pOtherFeat);
2194  continue;
2195  }
2196  xRenameFeatureId(other_oid, featMap);
2197  thisFeatures.push_back(pOtherFeat);
2198  }
2199 }
2200 
2201 // ==============================================================================
2203 // ==============================================================================
2204  const CObject_id& lhs,
2205  const CObject_id& rhs)
2206 {
2207  if (lhs.Which() != rhs.Which()) {
2208  return false;
2209  }
2210  if (lhs.IsStr()) {
2211  return (lhs.GetStr() == rhs.GetStr());
2212  }
2213  return (lhs.GetId() == rhs.GetId());
2214 };
2215 
2216 // =============================================================================
2217 void
2219  const CObject_id& oldFeatId,
2220  FeatMap& featMap)
2221 // =============================================================================
2222 {
2223  string oldFeatIdAsStr;
2224  if (oldFeatId.IsStr()) {
2225  oldFeatIdAsStr = oldFeatId.GetStr();
2226  }
2227  else {
2228  oldFeatIdAsStr = NStr::NumericToString(oldFeatId.GetId());
2229  }
2230 
2231  string newFeatIdAsStr = oldFeatIdAsStr + "x";
2232  CRef<CObject_id> pNewFeatId(new CObject_id);
2233  pNewFeatId->SetStr(oldFeatIdAsStr + "x");
2234  while (featMap.find(sGetFeatMapKey(*pNewFeatId)) != featMap.end()) {
2235  pNewFeatId->SetStr() += "x";
2236  }
2237 
2238  auto pBaseFeat = featMap[sGetFeatMapKey(oldFeatId)];
2239  pBaseFeat->SetId().SetLocal(*pNewFeatId);
2240  featMap.erase(sGetFeatMapKey(oldFeatId));
2241  featMap[sGetFeatMapKey(*pNewFeatId)] = pBaseFeat;
2242 
2243  for (auto it = featMap.begin(); it != featMap.end(); ++it) {
2244  auto pFeat = it->second;
2245  for (auto& pXref: pFeat->SetXref()) {
2246  if (!pXref->IsSetId() || !pXref->GetId().IsLocal()) {
2247  continue;
2248  }
2249  if (OjectIdsAreEqual(pXref->GetId().GetLocal(), oldFeatId)) {
2250  pXref->SetId().SetLocal(*pNewFeatId);
2251  }
2252  }
2253  }
2254 }
2255 
2256 END_SCOPE(edit)
2259 
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
User-defined methods of the data storage class.
User-defined methods of the data storage class.
string GetIdHashOrValue(const string &base, int offset)
Definition: cds_fix.cpp:1133
CSeqdesc & Set(bool skip_lookup=false)
Definition: Seq_descr.cpp:93
CBioseq_Handle –.
static bool ExtendToStopIfShortAndNotPartial(CSeq_feat &f, CBioseq_Handle bsh, bool check_for_stop=true)
Extends a coding region up to 50 nt.
Definition: cleanup.cpp:1302
static bool ExtendStopPosition(CSeq_feat &f, const CSeq_feat *cdregion, size_t extension=0)
Definition: cleanup.cpp:1083
static bool LocationMayBeExtendedToMatch(const CSeq_loc &orig, const CSeq_loc &improved)
Checks whether it is possible to extend the original location up to improved one.
Definition: cleanup.cpp:1344
void InstantiateProducts()
void xFeatureSetQualifier(CMappedFeat, const std::string &, const std::string &)
unsigned int mSequenceSize
CConstRef< CSeq_feat > xGetLinkedFeature(const CSeq_feat &cd_feature, bool gene)
void GenerateMissingGeneForMrna()
void GenerateMissingGeneForCds()
void xFeatureAddTranscriptIdMrna(CMappedFeat)
IObjtoolsListener * mpMessageListener
set< CMappedFeat > mProcessedMrnas
bool xAdjustExistingParentGene(CMappedFeat)
CRef< CScope > mpScope
void xGenerateLocusIdsRegenerate()
void xFeatureRemoveQualifier(CMappedFeat, const std::string &)
CRef< CSeq_loc > xGetGeneLocation(const CSeq_loc &, TSeqPos)
unsigned int mLocusTagNumber
void xPutError(const string &message)
void ProcessCodonRecognized()
void xFeatureAddTranscriptIdCds(CMappedFeat)
void xGenerateMissingGeneForChoice(CSeqFeatData::E_Choice, const CGff3LocationMerger *=nullptr)
static std::string xGetIdStr(CMappedFeat)
CSeq_annot_EditHandle mEditHandle
void xPutErrorMissingLocustag(CMappedFeat)
void GenerateProteinAndTranscriptIds()
CRef< CSeq_feat > xMakeGeneForFeature(const CMappedFeat &, TSeqPos)
void GenerateMissingParentFeaturesForProkaryote(const objects::CGff3LocationMerger *=nullptr)
bool AnnotHasAllLocusTags() const
void xFeatureAddProteinIdCds(CMappedFeat)
void xAddTranscriptAndProteinIdsToUnmatchedMrna(CMappedFeat &mrna)
std::string xGetCurrentLocusTagPrefix(CMappedFeat)
void GenerateMissingParentFeaturesForEukaryote(const objects::CGff3LocationMerger *=nullptr)
void xConvertToGeneralIds(const CMappedFeat &mf, string &transcript_id, string &protein_id)
void xFeatureAddTranscriptIdDefault(CMappedFeat)
feature::CFeatTree mTree
CSeq_annot_Handle mHandle
void xGenerateLocusIdsUseExisting()
void xFeatureAddQualifier(CMappedFeat, const std::string &, const std::string &)
string xNextTranscriptId(const CMappedFeat &)
void xPutErrorBadCodonRecognized(const string codonRecognized)
void xPutErrorMissingProteinId(CMappedFeat)
string xNextProteinId(const CMappedFeat &)
void xPutErrorMissingTranscriptId(CMappedFeat)
void xGenerateMissingGeneForSubtype(CSeqFeatData::ESubtype, const CGff3LocationMerger *=nullptr)
void GenerateMissingParentFeatures(bool forEukaryote, const objects::CGff3LocationMerger *=nullptr)
void xFeatureAddProteinIdDefault(CMappedFeat)
void xFeatureSetProduct(CMappedFeat, const string &)
map< string, int > mMapProtIdCounts
bool xCreateMissingParentGene(CMappedFeat, TSeqPos)
void MergeFeatures(const CSeq_annot::TData::TFtable &other)
std::string xGenerateTranscriptOrProteinId(CMappedFeat, const std::string &)
void GenerateMissingMrnaForCds()
void xAddTranscriptAndProteinIdsToCdsAndParentMrna(CMappedFeat &cds)
void EliminateBadQualifiers()
void xGenerate_mRNA_Product(CSeq_feat &cd_feature)
CSeq_annot & mAnnot
void InstantiateProductsNames()
void xAddTranscriptAndProteinIdsToMrna(const string &cds_transcript_id, const string &cds_protein_id, CMappedFeat &mrna)
void xPutErrorDifferingTranscriptIds(const CMappedFeat &mrna)
CFeatTableEdit(CSeq_annot &, const string &="", unsigned int=1, unsigned int=1, IObjtoolsListener *=nullptr)
void xFeatureAddProteinIdMrna(CMappedFeat)
void xPutErrorDifferingProteinIds(const CMappedFeat &mrna)
unsigned int mNextFeatId
void xRenameFeatureId(const CObject_id &, FeatMap &)
CFeat_CI –.
Definition: feat_ci.hpp:64
CFeat_id –.
Definition: Feat_id.hpp:66
static int CodonToIndex(char base1, char base2, char base3)
TSeqPos GetSequenceSize(const string &) const
CMappedFeat –.
Definition: mapped_feat.hpp:59
CRef –.
Definition: ncbiobj.hpp:618
CScope –.
Definition: scope.hpp:92
bool IsLegalQualifier(EQualifier qual) const
Test wheather a certain qualifier is legal for the feature.
EQualifier
List of available qualifiers for feature keys.
ESubtype GetSubtype(void) const
static EQualifier GetQualifierType(CTempString qual)
convert qual string to enumerated value
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
CSeqFeatXref –.
Definition: SeqFeatXref.hpp:66
CSeq_annot_Handle –.
Definition: Seq_entry.hpp:56
CSeq_feat_EditHandle –.
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
const CProt_ref * GetProtXref(void) const
get protein (if present) from Seq-feat.xref list
Definition: Seq_feat.cpp:222
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
Definition: Seq_feat.cpp:429
void AddQualifier(const string &qual_name, const string &qual_val)
Add a qualifier to this feature.
Definition: Seq_feat.cpp:291
void RemoveQualifier(const string &qual_name)
Remove all qualifiers with the given name; do nothing if no such qualifier exists.
Definition: Seq_feat.cpp:315
bool AddSeqFeatXref(const CSeqFeatXref::TId &id)
Definition: Seq_feat.cpp:279
void SetProtXref(CProt_ref &value)
Definition: Seq_feat.cpp:233
static bool GetOrgName(string &name, const objects::CSeq_entry &entry)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
virtual bool PutMessage(const IObjtoolsMessage &message)=0
void erase(iterator pos)
Definition: map.hpp:167
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
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
void clear()
Definition: set.hpp:153
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
#define WIDTH
Definition: ecp_curves.c:888
CRef< CSeq_loc > sProductFromString(const string str)
static string s_GetTranscriptIdFromMrna(const CMappedFeat &mrna)
static void s_SetProtRef(const CSeq_feat &cds, CConstRef< CSeq_feat > pMrna, CProt_ref &prot_ref)
static bool AssignLocalIdIfEmpty(CSeq_feat &feature, unsigned &id)
static void s_AppendProtRefInfo(CProt_ref &current_ref, const CProt_ref &other_ref)
static bool s_ShouldConvertToGeneral(const string &id)
string sGetCdsProductName(const CSeq_feat &cds, CScope &scope)
bool idAlpha(const CSeq_id_Handle &idh1, const CSeq_id_Handle idh2)
bool OjectIdsAreEqual(const CObject_id &lhs, const CObject_id &rhs)
string sGetFeatMapKey(const CObject_id &objectId)
const TResidue codons[4][4]
Definition: gnomon_seq.cpp:76
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
string
Definition: cgiapp.hpp:687
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
static SIZE_TYPE ParseIDs(CBioseq::TId &ids, const CTempString &s, TParseFlags flags=fParse_Default)
Parse a string representing one or more Seq-ids, appending the results to IDS.
Definition: Seq_id.cpp:2612
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:2039
string AsString(void) const
@ fParse_PartialOK
Warn rather than throwing an exception when a FASTA-style ID set contains unparsable portions,...
Definition: Seq_id.hpp:80
@ fParse_ValidLocal
Treat otherwise unidentified strings as raw accessions, provided that they pass rudimentary validatio...
Definition: Seq_id.hpp:87
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:573
void SetPacked_int(TPacked_int &v)
Definition: Seq_loc.hpp:984
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
void SetId(CSeq_id &id)
set the 'id' field in all parts of this location
Definition: Seq_loc.cpp:3474
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
void ChangeToMix(void)
Definition: Seq_loc.cpp:3633
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
CMappedFeat GetBestMrnaForCds(const CMappedFeat &cds_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3341
bool CopyFeaturePartials(CSeq_feat &dst, const CSeq_feat &src)
CopyFeaturePartials A function to copy the start and end partialness from one feature to another.
Definition: feature.cpp:4006
CMappedFeat GetBestGeneForCds(const CMappedFeat &cds_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0, CFeatTree::EBestGeneType lookup_type=CFeatTree::eBestGene_TreeOnly)
Definition: feature.cpp:3321
CMappedFeat GetBestGeneForFeat(const CMappedFeat &feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0, CFeatTree::EBestGeneType lookup_type=CFeatTree::eBestGene_TreeOnly)
Definition: feature.cpp:3443
CMappedFeat GetBestOverlappingFeat(const CMappedFeat &feat, CSeqFeatData::ESubtype need_subtype, sequence::EOverlapType overlap_type, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3653
bool AdjustProteinMolInfoToMatchCDS(CMolInfo &molinfo, const CSeq_feat &cds)
AdjustProteinMolInfoToMatchCDS A function to change an existing MolInfo to match a coding region.
Definition: feature.cpp:4024
CMappedFeat GetBestCdsForMrna(const CMappedFeat &mrna_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3360
@ eOverlap_CheckIntRev
1st is a subset of 2nd with matching boundaries
bool IsPseudo(const CSeq_feat &feat, CScope &scope)
Determines whether given feature is pseudo, using gene associated with feature if necessary Checks to...
Definition: sequence.cpp:1428
CBioseq_Handle GetBioseqFromSeqLoc(const CSeq_loc &loc, CScope &scope, CScope::EGetBioseqFlag flag=CScope::eGetBioseq_Loaded)
Retrieve the Bioseq Handle from a location.
Definition: sequence.cpp:308
static CRef< CBioseq > TranslateToProtein(const CSeq_feat &cds, CScope &scope)
Definition: sequence.cpp:3839
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
CBioseq_EditHandle GetEditHandle(const CBioseq_Handle &seq)
Get editable Biosec handle by regular one.
Definition: scope.cpp:301
CSeq_annot_Handle AddSeq_annot(CSeq_annot &annot, TPriority pri=kPriority_Default, EExist action=eExist_Throw)
Add Seq-annot, return its CSeq_annot_Handle.
Definition: scope.cpp:538
CBioseq_Handle GetObjectHandle(const CBioseq &bioseq, EMissing action=eMissing_Default)
Definition: scope.hpp:715
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
void AddQualifier(const string &qual_name, const string &qual_val)
Add a qualifier to this feature.
virtual CSeq_id_Handle GetLocationId(void) const
const CFeat_id & GetId(void) const
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
const CSeqFeatData & GetData(void) const
CSeq_feat_EditHandle AddFeat(const CSeq_feat &new_obj) const
bool IsSetProduct(void) const
void RemoveQualifier(const string &qual_name)
Remove all qualifiers with the given name on this feature.
CSeqFeatData::ESubtype GetFeatSubtype(void) const
void Replace(const CSeq_feat &new_feat) const
Replace the feature with new Seq-feat object.
SAnnotSelector & IncludeFeatSubtype(TFeatSubtype subtype)
Include feature subtype in the search.
SAnnotSelector & ExcludeFeatSubtype(TFeatSubtype subtype)
Exclude feature subtype from the search.
bool IsSetPartial(void) const
const CSeq_loc & GetLocation(void) const
bool GetPartial(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
SAnnotSelector & IncludeFeatType(TFeatType type)
Include feature type in the search.
SAnnotSelector & SetSortOrder(ESortOrder sort_order)
Set sort order of annotations.
CConstRef< CSeq_feat > GetSeq_feat(void) const
Get current seq-feat.
CSeq_id_Handle GetLocationId(void) const
@ eSortOrder_Normal
default - increasing start, decreasing length
@ eSortOrder_None
do not sort annotations for faster retrieval
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
Definition: ncbiobj.hpp:1385
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool NotEmpty(void) const THROWS_NONE
Check if CConstRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:1392
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
#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 int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5083
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5411
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3550
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
bool IsSetLocus_tag(void) const
systematic gene name (e.g., MI0001, ORF0069) Check if a value has been assigned to Locus_tag data mem...
Definition: Gene_ref_.hpp:781
const TLocus_tag & GetLocus_tag(void) const
Get the Locus_tag member data.
Definition: Gene_ref_.hpp:793
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
E_Choice Which(void) const
Which variant is currently selected.
Definition: Object_id_.hpp:235
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
TStr & SetStr(void)
Select the variant.
Definition: Object_id_.hpp:304
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
TActivity & SetActivity(void)
Assign a value to Activity data member.
Definition: Prot_ref_.hpp:481
bool IsSetDesc(void) const
description (instead of name) Check if a value has been assigned to Desc data member.
Definition: Prot_ref_.hpp:391
const TDb & GetDb(void) const
Get the Db member data.
Definition: Prot_ref_.hpp:500
const TActivity & GetActivity(void) const
Get the Activity member data.
Definition: Prot_ref_.hpp:475
TEc & SetEc(void)
Assign a value to Ec data member.
Definition: Prot_ref_.hpp:456
const TName & GetName(void) const
Get the Name member data.
Definition: Prot_ref_.hpp:378
bool IsSetDb(void) const
ids in other dbases Check if a value has been assigned to Db data member.
Definition: Prot_ref_.hpp:488
bool IsSetEc(void) const
E.C.
Definition: Prot_ref_.hpp:438
void SetDesc(const TDesc &value)
Assign a value to Desc data member.
Definition: Prot_ref_.hpp:412
TProcessed GetProcessed(void) const
Get the Processed member data.
Definition: Prot_ref_.hpp:538
void SetProcessed(TProcessed value)
Assign a value to Processed data member.
Definition: Prot_ref_.hpp:544
bool IsSetName(void) const
protein name Check if a value has been assigned to Name data member.
Definition: Prot_ref_.hpp:366
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Prot_ref_.hpp:403
bool IsSetActivity(void) const
activities Check if a value has been assigned to Activity data member.
Definition: Prot_ref_.hpp:463
const TEc & GetEc(void) const
Get the Ec member data.
Definition: Prot_ref_.hpp:450
TDb & SetDb(void)
Assign a value to Db data member.
Definition: Prot_ref_.hpp:506
TName & SetName(void)
Assign a value to Name data member.
Definition: Prot_ref_.hpp:384
bool IsSetExt(void) const
generic fields for ncRNA, tmRNA, miscRNA Check if a value has been assigned to Ext data member.
Definition: RNA_ref_.hpp:604
const TName & GetName(void) const
Get the variant data.
Definition: RNA_ref_.hpp:484
const TExt & GetExt(void) const
Get the Ext member data.
Definition: RNA_ref_.hpp:616
bool IsName(void) const
Check if variant Name is selected.
Definition: RNA_ref_.hpp:478
@ e_not_set
No variant selected.
Definition: RNA_ref_.hpp:133
TXref & SetXref(void)
Assign a value to Xref data member.
Definition: Seq_feat_.hpp:1314
void ResetPartial(void)
Reset Partial data member.
Definition: Seq_feat_.hpp:955
const TData & GetData(void) const
Get the Data member data.
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
bool IsProt(void) const
Check if variant Prot is selected.
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
void SetProduct(TProduct &value)
Assign a value to Product data member.
Definition: Seq_feat_.cpp:110
const TId & GetId(void) const
Get the Id member data.
Definition: Seq_feat_.hpp:904
const TLocal & GetLocal(void) const
Get the variant data.
Definition: Feat_id_.cpp:134
bool IsSetXref(void) const
cite other relevant features Check if a value has been assigned to Xref data member.
Definition: Seq_feat_.hpp:1296
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Feat_id_.hpp:353
bool IsGene(void) const
Check if variant Gene is selected.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
void SetId(TId &value)
Assign a value to Id data member.
Definition: Seq_feat_.cpp:73
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Seq_feat_.hpp:892
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
const TGene & GetGene(void) const
Get the variant data.
const TProt & GetProt(void) const
Get the variant data.
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
vector< CRef< CSeqFeatXref > > TXref
Definition: Seq_feat_.hpp:122
void ResetProduct(void)
Reset Product data member.
Definition: Seq_feat_.cpp:105
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
const TRna & GetRna(void) const
Get the variant data.
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
Definition: Seq_feat_.hpp:1105
@ e_Local
for local software use
Definition: Feat_id_.hpp:94
void SetTo(TTo value)
Assign a value to To data member.
void SetId(TId &value)
Assign a value to Id data member.
void SetFrom(TFrom value)
Assign a value to From data member.
void SetStrand(TStrand value)
Assign a value to Strand data member.
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ e_Local
local use
Definition: Seq_id_.hpp:95
@ e_Whole
whole sequence
Definition: Seq_loc_.hpp:100
const TSeq & GetSeq(void) const
Get the variant data.
Definition: Seq_entry_.cpp:102
TSeq & SetSeq(void)
Select the variant.
Definition: Seq_entry_.cpp:108
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_annot_.cpp:244
TId & SetId(void)
Assign a value to Id data member.
Definition: Bioseq_.hpp:296
const TInst & GetInst(void) const
Get the Inst member data.
Definition: Bioseq_.hpp:336
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
TLength GetLength(void) const
Get the Length member data.
Definition: Seq_inst_.hpp:659
list< CRef< CSeq_id > > TId
Definition: Bioseq_.hpp:94
void SetBiomol(TBiomol value)
Assign a value to Biomol data member.
Definition: MolInfo_.hpp:453
void SetDescr(TDescr &value)
Assign a value to Descr data member.
Definition: Bioseq_.cpp:65
const TFtable & GetFtable(void) const
Get the variant data.
Definition: Seq_annot_.hpp:621
list< CRef< CSeq_feat > > TFtable
Definition: Seq_annot_.hpp:193
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_annot_.hpp:873
void SetTech(TTech value)
Assign a value to Tech data member.
Definition: MolInfo_.hpp:503
TMolinfo & SetMolinfo(void)
Select the variant.
Definition: Seqdesc_.cpp:594
@ eTech_concept_trans
conceptual translation
Definition: MolInfo_.hpp:131
@ e_Molinfo
info on the molecule and techniques
Definition: Seqdesc_.hpp:134
n padding
constexpr auto sort(_Init &&init)
constexpr bool empty(list< Ts... >) noexcept
Definition: fix_pub.hpp:45
IMessage/IMessageListener interfaces and basic implementations.
The Object manager core.
static const char * suffix[]
Definition: pcregrep.c:408
static const char * prefix[]
Definition: pcregrep.c:405
int offset
Definition: replacements.h:160
static const char * str(char *buf, int n)
Definition: stats.c:84
SAnnotSelector –.
#define const
Definition: zconf.h:230
Modified on Thu Sep 21 03:45:21 2023 by modify_doxy.py rev. 669887