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 101605 2024-01-10 18:33:11Z foleyjp $
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) {
180  }
181 }
182 
183 
184 // -------------------------------------------------------------------------
186 // -------------------------------------------------------------------------
187 {
188 
189  const CSeq_feat& cds = mappedCds.GetOriginalFeature();
190  CConstRef<CSeq_feat> pOverlappingRna =
192  cds.GetLocation(),
195  *mpScope);
196 
197  if (pOverlappingRna) {
198  return;
199  }
200 
201  CRef<CSeq_feat> pRna(new CSeq_feat);
202  pRna->SetData().SetRna().SetType(CRNA_ref::eType_mRNA);
203  pRna->SetLocation().Assign(cds.GetLocation());
204  pRna->SetLocation().SetPartialStart(false, eExtreme_Positional);
205  pRna->SetLocation().SetPartialStop(false, eExtreme_Positional);
206  pRna->ResetPartial();
207 
208  //product name
209  pRna->SetData().SetRna().SetExt().SetName(
210  sGetCdsProductName(cds, *mpScope));
211 
212  //find proper name for rna
213  string rnaId(xNextFeatId());
214  pRna->SetId().SetLocal().SetStr(rnaId);
215 
216  //add rna xref to cds
218  feh.AddFeatXref(rnaId);
219 
220  //add cds xref to rna
221  CRef<CFeat_id> pFeatId(new CFeat_id);
222  pFeatId->Assign(cds.GetId());
223  CRef<CSeqFeatXref> pRnaXref(new CSeqFeatXref);
224  pRnaXref->SetId(*pFeatId);
225  pRna->SetXref().push_back(pRnaXref);
226 
227  CMappedFeat parentGene = feature::GetBestGeneForFeat(mappedCds, &mTree);
228  if (parentGene) {
229  //if gene exists, add gene xref to rna
231  parentGene.GetOriginalFeature()));
232  geh.AddFeatXref(rnaId);
233  //if gene exists, add rna xref to gene
234  CRef<CFeat_id> pGeneId(new CFeat_id);
235  pGeneId->Assign(parentGene.GetId());
236  CRef<CSeqFeatXref> pRnaXref(new CSeqFeatXref);
237  pRnaXref->SetId(*pGeneId);
238  pRna->SetXref().push_back(pRnaXref);
239  }
240 
241  //add new rna to feature table
242  mEditHandle.AddFeat(*pRna);
243  mTree.AddFeature(mpScope->GetObjectHandle(*pRna));
244 }
245 
246 // -------------------------------------------------------------------------
248 // -------------------------------------------------------------------------
249 {
251 }
252 
253 // ---------------------------------------------------------------------------
255 // ---------------------------------------------------------------------------
256 {
258 }
259 
260 // ---------------------------------------------------------------------------
262 // ---------------------------------------------------------------------------
263 {
265 }
266 
267 // ----------------------------------------------------------------------------
269 // ----------------------------------------------------------------------------
270 {
271  bool infered(false);
272  edit::CLocationEditPolicy editPolicy(
273  edit::CLocationEditPolicy::ePartialPolicy_eSetForBadEnd,
274  edit::CLocationEditPolicy::ePartialPolicy_eSetForBadEnd,
275  false, //extend 5'
276  false, //extend 3'
277  edit::CLocationEditPolicy::eMergePolicy_NoChange);
278 
279  SAnnotSelector sel;
281  CFeat_CI it(mHandle, sel);
282  for (; it; ++it) {
283  const CSeq_feat& cds = it->GetOriginalFeature();
284  CRef<CSeq_feat> pEditedCds(new CSeq_feat);
285  pEditedCds->Assign(cds);
286  infered = editPolicy.ApplyPolicyToFeature(*pEditedCds, *mpScope);
287  if (!infered) {
288  continue;
289  }
291  cdsEh.Replace(*pEditedCds);
292 
293  // make sure the parent rna is partial as well
294  CMappedFeat parentRna = feature::GetBestMrnaForCds(*it, &mTree);
295  if (parentRna &&
296  !(parentRna.IsSetPartial() && parentRna.GetPartial())) {
297  CRef<CSeq_feat> pEditedRna(new CSeq_feat);
298  pEditedRna->Assign(parentRna.GetOriginalFeature());
299  pEditedRna->SetPartial(true);
300  CSeq_feat_EditHandle rnaEh(
302  rnaEh.Replace(*pEditedRna);
303  }
304 
305  // make sure the gene parent is partial as well
306  CMappedFeat parentGene = feature::GetBestGeneForCds(*it);
307  if (parentGene &&
308  !(parentGene.IsSetPartial() && parentGene.GetPartial())) {
309  CRef<CSeq_feat> pEditedGene(new CSeq_feat);
310  pEditedGene->Assign(parentGene.GetOriginalFeature());
311  pEditedGene->SetPartial(true);
312  CSeq_feat_EditHandle geneEh(
314  geneEh.Replace(*pEditedGene);
315  }
316  }
317 }
318 
319 // ----------------------------------------------------------------------------
321 // ----------------------------------------------------------------------------
322 {
323  SAnnotSelector sel;
326  for (CFeat_CI it(mHandle, sel); it; ++it) {
327  CMappedFeat mf = *it;
328  if (mf.IsSetProduct()) {
329  continue;
330  }
331  //debug CSeqFeatData::ESubtype st = mf.GetFeatSubtype();
332  string product = mf.GetNamedQual("Product");
333  CRef<CSeq_feat> pEditedFeature(new CSeq_feat);
334  pEditedFeature->Assign(mf.GetOriginalFeature());
335  pEditedFeature->ResetProduct();
336  if (!product.empty()) {
337  pEditedFeature->AddQualifier("product", product);
338  pEditedFeature->RemoveQualifier("Product");
339  }
340  CSeq_feat_EditHandle feh(mf);
341  feh.Replace(*pEditedFeature);
342  }
343 }
344 
345 // ----------------------------------------------------------------------------
347 // ----------------------------------------------------------------------------
348 {
349  typedef CSeq_feat::TQual QUALS;
350 
351  vector<string> specialQuals{
352  "Protein", "protein",
353  "go_function", "go_component", "go_process" };
354 
355  CFeat_CI it(mHandle);
356  for (; it; ++it) {
357  CSeqFeatData::ESubtype subtype = it->GetData().GetSubtype();
359  (it)->GetOriginalFeature()));
360  const QUALS& quals = (*it).GetQual();
361  vector<string> badQuals;
362  for (QUALS::const_iterator qual = quals.begin(); qual != quals.end();
363  ++qual) {
364  string qualKey = (*qual)->GetQual();
365  if (std::find(specialQuals.begin(), specialQuals.end(), qualKey)
366  != specialQuals.end()) {
367  continue;
368  }
369  if (subtype == CSeqFeatData::eSubtype_cdregion ||
370  subtype == CSeqFeatData::eSubtype_mRNA) {
371  if (qualKey == "protein_id" || qualKey == "transcript_id") {
372  continue;
373  }
374  if (qualKey == "orig_protein_id" || qualKey == "orig_transcript_id") {
375  continue;
376  }
377  }
378  if (subtype != CSeqFeatData::eSubtype_gene && qualKey == "gene") {
379  //rw-570: remove gene qualifiers fro non-gene features before cleanup sees them
380  badQuals.push_back(qualKey);
381  continue;
382  }
384  if (CSeqFeatData::IsLegalQualifier(subtype, qualType)) {
385  continue;
386  }
387  badQuals.push_back(qualKey);
388  }
389  for (vector<string>::const_iterator badIt = badQuals.begin();
390  badIt != badQuals.end(); ++badIt) {
391  feh.RemoveQualifier(*badIt);
392  }
393  }
394 }
395 
396 // ----------------------------------------------------------------------------
398 // ----------------------------------------------------------------------------
399 {
400  static map<char, list<char>> sIUPACmap {
401  {'A', list<char>({'A'})},
402  {'G', list<char>({'G'})},
403  {'C', list<char>({'C'})},
404  {'T', list<char>({'T'})},
405  {'U', list<char>({'U'})},
406  {'M', list<char>({'A', 'C'})},
407  {'R', list<char>({'A', 'G'})},
408  {'W', list<char>({'A', 'T'})},
409  {'S', list<char>({'C', 'G'})},
410  {'Y', list<char>({'C', 'T'})},
411  {'K', list<char>({'G', 'T'})},
412  {'V', list<char>({'A', 'C', 'G'})},
413  {'H', list<char>({'A', 'C', 'T'})},
414  {'D', list<char>({'A', 'G', 'T'})},
415  {'B', list<char>({'C', 'G', 'T'})},
416  {'N', list<char>({'A', 'C', 'G', 'T'})}
417  };
418 
419  SAnnotSelector sel;
421  CFeat_CI it(mHandle, sel);
422  for (; it; ++it) {
423  CMappedFeat mf = *it;
424  auto codonRecognized = mf.GetNamedQual("codon_recognized");
425  if (codonRecognized.empty()) {
426  continue;
427  }
428  if (codonRecognized.size() != 3) {
429  xPutErrorBadCodonRecognized(codonRecognized);
430  return;
431  }
432  NStr::ToUpper(codonRecognized);
433 
434  const CSeq_feat& origFeat = mf.GetOriginalFeature();
435 
436  CRef<CSeq_feat> pEditedFeat(new CSeq_feat);
437  pEditedFeat->Assign(origFeat);
438  CRNA_ref::C_Ext::TTRNA & extTrna = pEditedFeat->SetData().SetRna().SetExt().SetTRNA();
439 
441  try {
442  for (char char1 : sIUPACmap.at(codonRecognized[0])) {
443  for (char char2 : sIUPACmap.at(codonRecognized[1])) {
444  for (char char3 : sIUPACmap.at(codonRecognized[2])) {
445  const auto codonIndex = CGen_code_table::CodonToIndex(char1, char2, char3);
446  codons.insert(codonIndex);
447  }
448  }
449  }
450  }
451  catch(CException&) {
452  xPutErrorBadCodonRecognized(codonRecognized);
453  return;
454  }
455  if (!codons.empty()) {
456  for (const auto codonIndex : codons) {
457  extTrna.SetCodon().push_back(codonIndex);
458  }
460  feh.Replace(*pEditedFeat);
461  feh.RemoveQualifier("codon_recognized");
462  }
463  }
464 }
465 
466 // ---------------------------------------------------------------------------
468 // ---------------------------------------------------------------------------
469 {
471  {
472  SAnnotSelector sel;
474  for (CFeat_CI it(mHandle, sel); it; ++it) {
475  CMappedFeat cds = *it;
477  }
478  }
479  {
480  SAnnotSelector sel;
482  for (CFeat_CI it(mHandle, sel); it; ++it) {
483  CMappedFeat mrna = *it;
485  }
486  }
487 }
488 
489 
490 // ---------------------------------------------------------------------------
491 static bool s_ShouldConvertToGeneral(const string& id)
492 // ---------------------------------------------------------------------------
493 {
494  return (!NStr::StartsWith(id, "gb|") &&
495  !NStr::StartsWith(id, "gnl|") &&
496  !NStr::StartsWith(id, "cds.gnl|") &&
497  !NStr::StartsWith(id, "mrna.gnl|"));
498 }
499 
500 
501 // ---------------------------------------------------------------------------
502 static string s_GetTranscriptIdFromMrna(const CMappedFeat& mrna)
503 // ---------------------------------------------------------------------------
504 {
505  string transcript_id = mrna.GetNamedQual("transcript_id");
506  if (NStr::IsBlank(transcript_id)) {
507  return mrna.GetNamedQual("ID");
508  }
509 
510  return transcript_id;
511 }
512 
513 static bool s_IsGenbankId(const string& id)
514 {
515  return NStr::StartsWith(id, "gb|");
516 }
517 
518 static bool s_IsGeneralId(const string& id)
519 {
520  return NStr::StartsWith(id, "gnl|");
521 }
522 
523 // ---------------------------------------------------------------------------
525 // ---------------------------------------------------------------------------
526 {
528 
529  string proteinId = cds.GetNamedQual("protein_id");
530  const bool noProteinIdQual = NStr::IsBlank(proteinId);
531  if (noProteinIdQual) { // no protein_id qual on CDS - check mRNA and ID qual
532  if (mrna) {
533  proteinId = mrna.GetNamedQual("protein_id");
534  }
535  if (NStr::IsBlank(proteinId)) {
536  proteinId = cds.GetNamedQual("ID");
537  }
538  }
539 
540  const bool isGenbankProtein = s_IsGenbankId(proteinId);
541 
542  string transcriptId = cds.GetNamedQual("transcript_id");
543  const bool noTranscriptIdQual = NStr::IsBlank(transcriptId);
544  if (noTranscriptIdQual && mrna) { // no transcript_id qual on CDS - check mRNA
545  transcriptId = s_GetTranscriptIdFromMrna(mrna);
546  }
547 
548  const bool isGenbankTranscript = s_IsGenbankId(transcriptId);
549 
550 
551  if ((isGenbankProtein || s_IsGeneralId(proteinId)) &&
552  (isGenbankTranscript || s_IsGeneralId(transcriptId))) {
553 
554  // No further processing of ids is required - simply assign to features
555  if (noProteinIdQual) {
556  // proteinId from ID qualifier or mRNA => need to add protein_id qual to CDS
557  xFeatureSetQualifier(cds, "protein_id", proteinId);
558  }
559 
560  if (mrna) {
561  if (noTranscriptIdQual) {
562  // transcript_id from mRNA => need to add transcript_id qual to CDS
563  xFeatureSetQualifier(cds, "transcript_id", transcriptId);
564  }
565  xAddTranscriptAndProteinIdsToMrna(transcriptId, proteinId, mrna);
566  }
567  return;
568  }
569 
570  // else need to generate and/or process ids before we add them to features
571  bool hasProteinId = !NStr::IsBlank(proteinId);
572  bool hasTranscriptId = !NStr::IsBlank(transcriptId);
573 
574  if (hasProteinId && hasTranscriptId) {
575  if (!isGenbankProtein && (transcriptId == proteinId)) {
576  proteinId = "cds." + proteinId;
577  }
578  }
579  else {
580  if (hasProteinId && !isGenbankProtein) {
581  transcriptId = "mrna." + proteinId;
582  hasTranscriptId = true;
583  }
584  else if (hasTranscriptId && !isGenbankTranscript) {
585  proteinId = "cds." + transcriptId;
586  hasProteinId = true;
587  }
588 
589  // Generate new transcriptId and proteinId if necessary
590  if (!hasTranscriptId && mrna) {
591  transcriptId = xNextTranscriptId(cds);
592  }
593  if (!hasProteinId) {
594  proteinId = xNextProteinId(cds);
595  }
596  }
597 
598  xConvertToGeneralIds(cds, transcriptId, proteinId);
599 
600  if (mrna) {
601  xAddTranscriptAndProteinIdsToMrna(transcriptId, proteinId, mrna);
602  xFeatureSetQualifier(cds, "transcript_id", transcriptId);
603  }
604  xFeatureSetQualifier(cds, "protein_id", proteinId);
605 }
606 
607 
608 // ---------------------------------------------------------------------------
610  const string& cds_transcript_id,
611  const string& cds_protein_id,
612  CMappedFeat& mrna)
613 // ---------------------------------------------------------------------------
614 {
615  if (mProcessedMrnas.find(mrna) != mProcessedMrnas.end()) {
616  return;
617  }
618 
619  bool use_local_ids = false;
620 
621  string transcript_id = mrna.GetNamedQual("transcript_id");
622  if (NStr::IsBlank(transcript_id)) {
623  transcript_id = cds_transcript_id;
624  }
625  else {
626  use_local_ids = true;
627  }
628 
629  string protein_id = mrna.GetNamedQual("protein_id");
630  if (NStr::IsBlank(protein_id)) {
631  protein_id = cds_protein_id;
632  }
633  else {
634  if ((protein_id == transcript_id) && !NStr::StartsWith(protein_id, "gb|")) {
635  protein_id = "cds." + protein_id;
636  }
637  use_local_ids = true;
638  }
639 
640  if (use_local_ids) {
641  // protein id and/or transcript id specified on mRNA.
642  // Process these ids and check that the processed quals match the qualifiers on the child CDS feature
643  xConvertToGeneralIds(mrna, transcript_id, protein_id);
644 
645  if (transcript_id != cds_transcript_id) {
647  }
648 
649  if (protein_id != cds_protein_id) {
651  }
652  }
653 
654  xFeatureSetQualifier(mrna, "transcript_id", transcript_id);
655  xFeatureSetQualifier(mrna, "protein_id", protein_id);
656 
657  mProcessedMrnas.insert(mrna);
658 }
659 
660 
661 // ---------------------------------------------------------------------------
663 // ---------------------------------------------------------------------------
664 {
665  if (mProcessedMrnas.find(mrna) != mProcessedMrnas.end()) {
666  return;
667  }
668 
669  string transcriptId = mrna.GetNamedQual("transcript_id");
670  bool noTranscriptIdQual = NStr::IsBlank(transcriptId);
671  if (noTranscriptIdQual) {
672  transcriptId = mrna.GetNamedQual("ID");
673  }
674  const bool isGenbankTranscript = s_IsGenbankId(transcriptId);
675 
676  string proteinId = mrna.GetNamedQual("protein_id");
677  const bool isGenbankProtein = s_IsGenbankId(proteinId);
678 
679  if ((isGenbankProtein || s_IsGeneralId(proteinId)) &&
680  (isGenbankTranscript || s_IsGeneralId(transcriptId))) {
681  if (noTranscriptIdQual) {
682  xFeatureSetQualifier(mrna, "transcript_id", transcriptId);
683  }
684  return;
685  }
686 
687  if (!NStr::IsBlank(proteinId) &&
688  !NStr::IsBlank(transcriptId)) {
689  if ((transcriptId == proteinId) &&
690  !isGenbankTranscript) {
691  proteinId = "cds." + proteinId;
692  }
693  }
694  else { // Empty proteinId and/or transcriptId
695  if (!isGenbankProtein && !NStr::IsBlank(proteinId)) {
696  transcriptId = "mrna." + proteinId;
697  }
698  else if (!isGenbankTranscript && !NStr::IsBlank(transcriptId)) {
699  proteinId = "cds." + transcriptId;
700  }
701  }
702 
703  if (NStr::IsBlank(proteinId)) {
704  proteinId = xNextProteinId(mrna);
705  }
706  if (NStr::IsBlank(transcriptId)) {
707  transcriptId = xNextTranscriptId(mrna);
708  }
709 
710  xConvertToGeneralIds(mrna, transcriptId, proteinId);
711 
712  xFeatureSetQualifier(mrna, "transcript_id", transcriptId);
713  xFeatureSetQualifier(mrna, "protein_id", proteinId);
714 
715  mProcessedMrnas.insert(mrna);
716 }
717 
718 
720  string& transcript_id,
721  string& protein_id)
722 {
723  const bool update_protein_id = s_ShouldConvertToGeneral(protein_id);
724  const bool update_transcript_id = s_ShouldConvertToGeneral(transcript_id);
725 
726  string locus_tag_prefix;
727  if (update_protein_id || update_transcript_id) {
728  locus_tag_prefix = xGetCurrentLocusTagPrefix(mf);
729  if (!NStr::IsBlank(locus_tag_prefix)) {
730  if (update_protein_id) {
731  protein_id = "gnl|" + locus_tag_prefix + "|" + protein_id;
732  }
733 
734  if (update_transcript_id) {
735  transcript_id = "gnl|" + locus_tag_prefix + "|" + transcript_id;
736  }
737  }
738  else {
739  string seq_label;
740  mf.GetLocation().GetId()->GetLabel(&seq_label, CSeq_id::eContent);
741 
742  if (update_protein_id) {
743  protein_id = "gnl|" + seq_label + "|" + protein_id;
744  }
745 
746  if (update_transcript_id) {
747  transcript_id = "gnl|" + seq_label + "|" + transcript_id;
748  }
749  }
750  }
751 }
752 
753 
754 // ----------------------------------------------------------------------------
756 // ----------------------------------------------------------------------------
757 {
758  SAnnotSelector sel1;
761  for (CFeat_CI it(mHandle, sel1); it; ++it) {
762  CMappedFeat mf = *it;
763 
764  auto tid = mf.GetNamedQual("transcript_id");
765  if (!tid.empty()) {
766  xFeatureRemoveQualifier(mf, "transcript_id");
767  xFeatureAddQualifier(mf, "orig_transcript_id", tid);
768  }
769 
771  auto pid = mf.GetNamedQual("protein_id");
772  if (!pid.empty()) {
773  if (!mf.IsSetProduct()) {
774  xFeatureSetProduct(mf, pid);
775  }
776  xFeatureRemoveQualifier(mf, "protein_id");
777  }
778  }
779  }
780 }
781 
782 // ---------------------------------------------------------------------------
784  CSeqFeatData::E_Choice choice,
785  const CGff3LocationMerger* pMerger)
786  // ---------------------------------------------------------------------------
787 {
788  SAnnotSelector sel;
789  sel.IncludeFeatType(choice);
790  xGenerateMissingGeneForFeats(sel, pMerger);
791 }
792 
793 
794 // ---------------------------------------------------------------------------
796  const SAnnotSelector& sel,
797  const CGff3LocationMerger* pMerger)
798 // ---------------------------------------------------------------------------
799 {
800  CFeat_CI it(mHandle, sel);
801  for (; it; ++it) {
802  CMappedFeat mf = *it;
803  auto seqId = mf.GetLocationId().AsString();
804  auto sequenceSize =
805  (pMerger ? pMerger->GetSequenceSize(seqId) : mSequenceSize);
806  if (xCreateMissingParentGene(mf, sequenceSize)) {
808  }
809  }
810 }
811 
812 
813 // ---------------------------------------------------------------------------
815  const CMappedFeat& feat)
816 // ---------------------------------------------------------------------------
817 {
820  }
821 }
822 
823 
824 // ---------------------------------------------------------------------------
826  CSeqFeatData::ESubtype subType,
827  const CGff3LocationMerger* pMerger)
828 // ---------------------------------------------------------------------------
829 {
830  SAnnotSelector sel;
831  sel.IncludeFeatSubtype(subType);
832  xGenerateMissingGeneForFeats(sel, pMerger);
833 }
834 
835 // ----------------------------------------------------------------------------
836 bool
838  CMappedFeat mf)
839  // ----------------------------------------------------------------------------
840 {
841  if (!mf.IsSetPartial() || !mf.GetPartial()) {
842  return true;
843  }
844  CMappedFeat parentGene = feature::GetBestGeneForFeat(mf, &mTree);
845  if (!parentGene) {
846  return false;
847  }
848 
849  if (parentGene.IsSetPartial() && parentGene.GetPartial()) {
850  return true;
851  }
852  CRef<CSeq_feat> pEditedGene(new CSeq_feat);
853  pEditedGene->Assign(parentGene.GetOriginalFeature());
854  pEditedGene->SetPartial(true);
855  CSeq_feat_EditHandle geneEH(
857  geneEH.Replace(*pEditedGene);
858  return true;
859 }
860 
861 // ----------------------------------------------------------------------------
862 bool
864  CMappedFeat mf,
865  TSeqPos sequenceSize)
866  // ----------------------------------------------------------------------------
867 {
868  if (sequenceSize == 0) {
869  sequenceSize = mSequenceSize;
870  }
871  CRef<CSeq_feat> pGene = xMakeGeneForFeature(mf, sequenceSize);
872  if (!pGene) {
873  return false;
874  }
875  // missing gene was created. now attach ids and xrefs:
876  string geneId(xNextFeatId());
877  pGene->SetId().SetLocal().SetStr(geneId);
880  feh.AddFeatXref(geneId);
881 
882  CRef<CFeat_id> pFeatId(new CFeat_id);
883  pFeatId->Assign(mf.GetId());
884  CRef<CSeqFeatXref> pGeneXref(new CSeqFeatXref);
885  pGeneXref->SetId(*pFeatId);
886  pGene->SetXref().push_back(pGeneXref);
887 
888  mEditHandle.AddFeat(*pGene);
889  mTree.AddFeature(mpScope->GetObjectHandle(*pGene));
890  return true;
891 }
892 
893 // ----------------------------------------------------------------------------
895  CMappedFeat mf)
896  // ----------------------------------------------------------------------------
897 {
898  //rw-451 rules for mRNA:
899  // no mRNA survives with an orig_protein_id
900  // almost all mRNA features should have protein_ids
901  // if one exists already then police it
902  // if none exists then if possible inherit it from the decendent CDS
903 
904  auto orig_tid = mf.GetNamedQual("orig_protein_id");
905  if (!orig_tid.empty()) {
906  xFeatureRemoveQualifier(mf, "orig_protein_id");
907  }
908  auto pid = mf.GetNamedQual("protein_id");
909  if (NStr::StartsWith(pid, "gb|") || NStr::StartsWith(pid, "gnl|")) {
910  // already what we want
911  return;
912  }
913  //reformat any tags we already have:
914  if (!pid.empty()) {
915  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + pid;
916  xFeatureSetQualifier(mf, "protein_id", pid);
917  return;
918  }
919 
921  if (!child) {
922  // only permitted case of an mRNA without a protein_id
923  return;
924  }
925  pid = child.GetNamedQual("protein_id");
926  xFeatureAddQualifier(mf, "protein_id", pid);
927  return;
928 }
929 
930 // ----------------------------------------------------------------------------
932  CMappedFeat mf)
933  // ----------------------------------------------------------------------------
934 {
935  //rw-451 rules for CDS:
936  // no CDS survives with an orig_protein_id
937  // all CDS features should have transcript_ids
938  // if one exists already then police it
939  // if it doen't have one then generate one following a strict set of rules
940 
941  auto orig_pid = mf.GetNamedQual("orig_protein_id");
942  if (!orig_pid.empty()) {
943  xFeatureRemoveQualifier(mf, "orig_protein_id");
944  }
945 
946  auto pid = mf.GetNamedQual("protein_id");
947  if (NStr::StartsWith(pid, "gb|") || NStr::StartsWith(pid, "gnl|")) {
948  // already what we want
949  return;
950  }
951  //reformat any tags we already have:
952  if (!pid.empty()) {
953  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + pid;
954  xFeatureSetQualifier(mf, "protein_id", pid);
955  return;
956  }
957 
958  auto id = mf.GetNamedQual("ID");
959  if (!id.empty()) {
960  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + id;
961  xFeatureSetQualifier(mf, "protein_id", pid);
962  return;
963  }
964 
965  auto tid = mf.GetNamedQual("transcript_id");
966  if (!tid.empty()) {
968  auto mRnaTid = parent.GetNamedQual("transcript_id");
969  if (tid == mRnaTid) {
970  tid = string("cds.") + tid;
971  }
972  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
973  xFeatureSetQualifier(mf, "protein_id", pid);
974  return;
975  }
976 
977  pid = xNextProteinId(mf);
978  if (!pid.empty()) {
979  xFeatureSetQualifier(mf, "protein_id", pid);
980  }
981 }
982 
983 // ----------------------------------------------------------------------------
985  CMappedFeat mf)
986  // ----------------------------------------------------------------------------
987 {
988  //rw-451 rules for non CDS, non mRNA:
989  // we won't touch orig_protein_id
990  // we don't generate any protein_ids
991  // if it comes with a protein_id then we add it to the "gnl|locus_tag|"
992  // namespace if necessary.
993 
994  auto pid = mf.GetNamedQual("protein_id");
995  if (pid.empty()) {
996  return;
997  }
998  if (NStr::StartsWith(pid, "gb|") || NStr::StartsWith(pid, "gnl|")) {
999  // already what we want
1000  return;
1001  }
1002  //reformat any tags we already have:
1003  if (!pid.empty()) {
1004  pid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + pid;
1005  xFeatureSetQualifier(mf, "protein_id", pid);
1006  return;
1007  }
1008 
1009  //pid = xGenerateTranscriptOrProteinId(mf, pid);
1010  pid = xNextProteinId(mf);
1011  if (!pid.empty()) {
1012  xFeatureSetQualifier(mf, "protein_id", pid);
1013  }
1014 }
1015 
1016 
1017 // ----------------------------------------------------------------------------
1019  CMappedFeat mf)
1020  // ----------------------------------------------------------------------------
1021 {
1022  //rw-451 rules for mRNA:
1023  // no mRNA survives with an orig_transcript_id
1024  // every mRNA must have a transcript_id.
1025  // if it already got one then police it.
1026  // if it doen't have one then generate one following a strict set of rules
1027 
1028  auto orig_tid = mf.GetNamedQual("orig_transcript_id");
1029  if (!orig_tid.empty()) {
1030  xFeatureRemoveQualifier(mf, "orig_transcript_id");
1031  }
1032 
1033  auto tid = mf.GetNamedQual("transcript_id");
1034  if (NStr::StartsWith(tid, "gb|") || NStr::StartsWith(tid, "gnl|")) {
1035  // already what we want
1036  return;
1037  }
1038  //reformat any tags we already have:
1039  if (!tid.empty()) {
1040  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
1041  xFeatureSetQualifier(mf, "transcript_id", tid);
1042  return;
1043  }
1044  else {
1045  }
1046 
1047 
1048 
1049  auto id = mf.GetNamedQual("ID");
1050  if (!id.empty()) {
1051  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + id;
1052  xFeatureSetQualifier(mf, "transcript_id", tid);
1053  return;
1054  }
1055 
1056  //tid = xGenerateTranscriptOrProteinId(mf, tid);
1057  tid = xNextTranscriptId(mf);
1058  if (!tid.empty()) {
1059  xFeatureSetQualifier(mf, "transcript_id", tid);
1060  }
1061 }
1062 
1063 
1064 // ----------------------------------------------------------------------------
1066  CMappedFeat mf)
1067  // ----------------------------------------------------------------------------
1068 {
1069  //rw-451 rules for CDS:
1070  // no CDS survives with an orig_transcript_id
1071  // almost all CDS features should have transcript_ids
1072  // if one exists already then police it
1073  // if none exists then if possible inherit it from the parent mRNA
1074 
1075  auto orig_tid = mf.GetNamedQual("orig_transcript_id");
1076  if (!orig_tid.empty()) {
1077  xFeatureRemoveQualifier(mf, "orig_transcript_id");
1078  }
1079 
1080  auto tid = mf.GetNamedQual("transcript_id");
1081  // otherwise, we need to police the existing transcript_id:
1082  if (NStr::StartsWith(tid, "gb|") || NStr::StartsWith(tid, "gnl|")) {
1083  // already what we want
1084  return;
1085  }
1086  //reformat any tags we already have:
1087  if (!tid.empty()) {
1088  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
1089  xFeatureSetQualifier(mf, "transcript_id", tid);
1090  return;
1091  }
1092 
1094  if (!parent) {
1095  // only permitted case of a CDS without a transcript_id
1096  return;
1097  }
1098  tid = parent.GetNamedQual("transcript_id");
1099  xFeatureAddQualifier(mf, "transcript_id", tid);
1100 }
1101 
1102 
1103 // ----------------------------------------------------------------------------
1105  CMappedFeat mf)
1106  // ----------------------------------------------------------------------------
1107 {
1108  //rw-451 rules for non CDS, non mRNA:
1109  // we won't touch orig_transcript_id
1110  // we don't generate any transcript_ids
1111  // if it comes with a transcript_id then we add it to the "gnl|locus_tag|"
1112  // namespace if necessary.
1113 
1114  auto tid = mf.GetNamedQual("transcript_id");
1115  if (tid.empty()) {
1116  return;
1117  }
1118  if (NStr::StartsWith(tid, "gb|") || NStr::StartsWith(tid, "gnl|")) {
1119  // already what we want
1120  return;
1121  }
1122  if (!tid.empty()) {
1123  tid = string("gnl|") + xGetCurrentLocusTagPrefix(mf) + "|" + tid;
1124  xFeatureSetQualifier(mf, "transcript_id", tid);
1125  return;
1126  }
1127 
1128  tid = this->xNextTranscriptId(mf);
1129  if (!tid.empty()) {
1130  xFeatureSetQualifier(mf, "transcript_id", tid);
1131  }
1132 }
1133 
1134 
1135 // ----------------------------------------------------------------------------
1137  CMappedFeat mf,
1138  const string& rawId)
1139  // ----------------------------------------------------------------------------
1140 {
1141  //weed out badly formatted original tags:
1142  if (string::npos != rawId.find("|")) {
1143  xPutError(
1144  "Feature " + xGetIdStr(mf) +
1145  " does not have a usable transcript_ or protein_id.");
1146  return "";
1147  }
1148 
1149  //make sure we got the locus tag prefix necessary for tag generation:
1150  auto locusTagPrefix = xGetCurrentLocusTagPrefix(mf);
1151  if (locusTagPrefix.empty()) {
1152  xPutError(
1153  "Cannot generate transcript_/protein_id for feature " + xGetIdStr(mf) +
1154  " without a locus tag.");
1155  return "";
1156  }
1157 
1158  //reformat any tags we already have:
1159  if (!rawId.empty()) {
1160  return string("gnl|") + locusTagPrefix + "|" + rawId;
1161  }
1162 
1163  //attempt to make transcript_id from protein_id, or protein_id from transcript_id:
1164  switch (mf.GetFeatSubtype()) {
1166  auto id = mf.GetNamedQual("protein_id");
1167  if (id.empty()) {
1168  id = mf.GetNamedQual("ID");
1169  }
1170  if (id.empty()) {
1171  if (mf.GetId().IsLocal()) {
1172  id = mf.GetId().GetLocal().GetStr();
1173  }
1174  }
1175  if (!id.empty()) {
1176  return string("gnl|") + locusTagPrefix + "|mrna." + id;
1177  }
1178  }
1179  break;
1180 
1182  auto id = mf.GetNamedQual("transcript_id");
1183  if (id.empty()) {
1184  id = mf.GetNamedQual("ID");
1185  }
1186  if (!id.empty()) {
1187  return string("gnl|") + locusTagPrefix + "|cds." + id;
1188  }
1189  }
1190  break;
1191 
1192  default:
1193  break;
1194  }
1195 
1196 
1197  xPutError(
1198  "Cannot generate transcript_/protein_id for feature " + xGetIdStr(mf) +
1199  " - insufficient context.");
1200  return "";
1201 }
1202 
1203 
1204 // ----------------------------------------------------------------------------
1206 // ----------------------------------------------------------------------------
1207 {
1208  SAnnotSelector sel;
1210 
1211  if (mLocusTagPrefix.empty()) {
1213  }
1214  else {
1215  return xGenerateLocusIdsRegenerate();
1216  }
1217 }
1218 
1219 // ----------------------------------------------------------------------------
1221 // ----------------------------------------------------------------------------
1222 {
1223  //mss-362:
1224  // blow away any locus_tag, protein_id, transcript_id attributes and
1225  // regenerate from scratch using mLocusTagPrefix
1226 
1227  //make sure genes got proper locus tags
1228  SAnnotSelector selGenes;
1231  for (CFeat_CI it(mHandle, selGenes); it; ++it) {
1232  CMappedFeat mf = *it;
1233  CSeq_feat_EditHandle feh(mf);
1234  CRef<CSeq_feat> pReplacement(new CSeq_feat);
1235  pReplacement->Assign(*mf.GetSeq_feat());
1236  pReplacement->SetData().SetGene().SetLocus_tag(xNextLocusTag());
1237  feh.Replace(*pReplacement);
1238  }
1239 
1240  //make sure all locus related junk is removed and that rnas are
1241  // labeled properly
1242  SAnnotSelector selOthers;
1244  for (CFeat_CI it(mHandle, selOthers); it; ++it) {
1245  CMappedFeat mf = *it;
1246  CSeq_feat_EditHandle feh(mf);
1247 
1248  feh.RemoveQualifier("orig_protein_id");
1249  feh.RemoveQualifier("orig_transcript_id");
1250 
1251  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1252  switch (subtype) {
1254  string proteinId = xNextProteinId(mf);
1255  feh.AddQualifier("orig_protein_id", proteinId);
1256  string transcriptId = xNextTranscriptId(mf);
1257  feh.AddQualifier("orig_transcript_id", transcriptId);
1258  break;
1259  }
1260  default: {
1261  break;
1262  }
1263  }
1264  }
1265 
1266  //finally, down inherit transcript ids from the mrna's to the cdregions
1267  SAnnotSelector selCds;
1269 
1270  for (CFeat_CI it(mHandle, selCds); it; ++it) {
1271 
1272  CMappedFeat mf = *it;
1273  CSeq_feat_EditHandle feh(mf);
1275  string transcriptId = rna.GetNamedQual("transcript_id");
1276  feh.AddQualifier("orig_transcript_id", transcriptId);
1277  string proteinId = rna.GetNamedQual("protein_id");
1278  feh.AddQualifier("orig_protein_id", proteinId);
1279  }
1280 }
1281 
1282 // ----------------------------------------------------------------------------
1284 // ----------------------------------------------------------------------------
1285 {
1286  SAnnotSelector sel;
1288 
1289  for (CFeat_CI it(mHandle, sel); it; ++it) {
1290  //mss-362: every feature that needs them must come with a complete set
1291  // of locus_tag, protein_id, and transcript_id.
1292 
1293  CMappedFeat mf = *it;
1294  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1295 
1296  switch (subtype) {
1298  if (!mf.GetData().GetGene().IsSetLocus_tag()) {
1300  }
1301  break;
1302  }
1304  string transcriptId = mf.GetNamedQual("transcript_id");
1305  if (transcriptId.empty()) {
1307  }
1308  string proteinId = mf.GetNamedQual("protein_id");
1309  if (proteinId.empty()) {
1311  }
1312  break;
1313  }
1315  string transcriptId = mf.GetNamedQual("transcript_id");
1316  if (transcriptId.empty()) {
1318  }
1319  break;
1320  }
1321  default: {
1322  break;
1323  }
1324  }
1325  }
1326 }
1327 
1328 bool idAlpha(const CSeq_id_Handle& idh1, const CSeq_id_Handle idh2) {
1329  return (idh1.AsString() < idh2.AsString());
1330 }
1331 
1332 // ----------------------------------------------------------------------------
1334 // ----------------------------------------------------------------------------
1335 {
1336  SAnnotSelector selGenes;
1338  CFeat_CI itGenes(mHandle, selGenes);
1339  for (; itGenes; ++itGenes) {
1340  CSeq_feat_Handle fh = *itGenes;
1341  if (!fh.GetData().GetGene().IsSetLocus_tag()) {
1342  return false;
1343  }
1344  }
1345  return true;
1346 }
1347 
1348 // ----------------------------------------------------------------------------
1350 // ----------------------------------------------------------------------------
1351 {
1352  if (mLocusTagPrefix.empty()) {
1353  return;
1354  }
1355 
1356  CRef<CGb_qual> pLocusTag;
1357  SAnnotSelector selGenes;
1358  vector<CSeq_id_Handle> annotIds;
1361  CFeat_CI itGenes(mHandle, selGenes);
1362  for (; itGenes; ++itGenes) {
1363  CSeq_feat_Handle fh = *itGenes;
1364  CSeq_id_Handle idh = fh.GetLocationId();
1365  vector<CSeq_id_Handle>::const_iterator compIt;
1366  for (compIt = annotIds.begin();
1367  compIt != annotIds.end();
1368  ++compIt) {
1369  if (*compIt == idh) {
1370  break;
1371  }
1372  }
1373  if (compIt == annotIds.end()) {
1374  annotIds.push_back(idh);
1375  }
1376  }
1377  std::sort(annotIds.begin(), annotIds.end(), idAlpha);
1378 
1379  for (vector<CSeq_id_Handle>::const_iterator idIt = annotIds.begin();
1380  idIt != annotIds.end();
1381  ++idIt) {
1382  CSeq_id_Handle curId = *idIt;
1383 
1384  CRef<CGb_qual> pLocusTag;
1385  SAnnotSelector selGenes;
1388  CFeat_CI itGenes(mHandle, selGenes);
1389  for (; itGenes; ++itGenes) {
1390  CSeq_feat_Handle fh = *itGenes;
1391  string id1 = fh.GetLocationId().AsString();
1392  string id2 = curId.AsString();
1393  if (fh.GetLocationId() != curId) {
1394  continue;
1395  }
1397  itGenes->GetOriginalFeature()));
1398  CRef<CSeq_feat> pEditedFeat(new CSeq_feat);
1399  pEditedFeat->Assign(itGenes->GetOriginalFeature());
1400  pEditedFeat->RemoveQualifier("locus_tag");
1401  pEditedFeat->SetData().SetGene().SetLocus_tag(xNextLocusTag());
1402  feh.Replace(*pEditedFeat);
1403  }
1404  }
1405  SAnnotSelector selOther;
1407  CFeat_CI itOther(mHandle, selOther);
1408 
1409  // mss-315:
1410  // only the genes get the locus_tags. they are inherited down
1411  // to the features that live on them when we generate a flat file,
1412  // but we don't want them here in the ASN.1
1413  for (; itOther; ++itOther) {
1415  (itOther)->GetOriginalFeature()));
1416  feh.RemoveQualifier("locus_tag");
1417  }
1418 }
1419 
1420 
1421 // ----------------------------------------------------------------------------
1423  bool forEukaryote,
1424  const CGff3LocationMerger* pMerger)
1425  // ----------------------------------------------------------------------------
1426 {
1427  if (forEukaryote) {
1429  }
1430  else {
1432  }
1433  mTree = feature::CFeatTree(mHandle);
1434 }
1435 
1436 
1437 // ----------------------------------------------------------------------------
1439  const CGff3LocationMerger* pMerger)
1440 // ----------------------------------------------------------------------------
1441 {
1442  {
1443  SAnnotSelector sel;
1445  for (CFeat_CI it(mHandle, sel); it; ++it) {
1446  if (auto parent = mTree.GetParent(*it); parent) {
1447  auto subtype = parent.GetOriginalFeature().GetData().GetSubtype();
1448  if (subtype == CSeqFeatData::eSubtype_mRNA ||
1449  subtype == CSeqFeatData::eSubtype_V_segment ||
1450  subtype == CSeqFeatData::eSubtype_D_segment ||
1451  subtype == CSeqFeatData::eSubtype_J_segment ||
1452  subtype == CSeqFeatData::eSubtype_C_region) {
1453  continue;
1454  }
1455  }
1457  }
1458  }
1459 
1460  {
1461  SAnnotSelector sel;
1467  xGenerateMissingGeneForFeats(sel, nullptr); //sequence not circular for eukaryote
1468  }
1469 }
1470 
1471 
1472 // ----------------------------------------------------------------------------
1474  const CGff3LocationMerger* pMerger)
1475 // ----------------------------------------------------------------------------
1476 {
1479 }
1480 
1481 
1482 // ----------------------------------------------------------------------------
1484  CMappedFeat mf,
1485  const string& qualKey,
1486  const string& qualVal)
1487  // ----------------------------------------------------------------------------
1488 {
1489  const CSeq_feat& origFeat = mf.GetOriginalFeature();
1491  feh.AddQualifier(qualKey, qualVal);
1492 }
1493 
1494 
1495 // ----------------------------------------------------------------------------
1497  CMappedFeat mf,
1498  const string& qualKey)
1499  // ----------------------------------------------------------------------------
1500 {
1501  const CSeq_feat& origFeat = mf.GetOriginalFeature();
1503  feh.RemoveQualifier(qualKey);
1504 }
1505 
1506 // ----------------------------------------------------------------------------
1508  CMappedFeat mf,
1509  const string& qualKey,
1510  const string& qualVal)
1511  // ----------------------------------------------------------------------------
1512 {
1513  auto existing = mf.GetNamedQual(qualKey);
1514  if (!existing.empty()) {
1515  xFeatureRemoveQualifier(mf, qualKey);
1516  }
1517  xFeatureAddQualifier(mf, qualKey, qualVal);
1518 }
1519 
1520 // ----------------------------------------------------------------------------
1522  CMappedFeat mf,
1523  const string& proteinIdStr)
1524  // ----------------------------------------------------------------------------
1525 {
1526  CRef<CSeq_id> pProteinId(
1527  new CSeq_id(proteinIdStr,
1529 
1530  const CSeq_feat& origFeat = mf.GetOriginalFeature();
1531  CRef<CSeq_feat> pEditedFeat(new CSeq_feat);
1532  pEditedFeat->Assign(origFeat);
1533  pEditedFeat->SetProduct().SetWhole(*pProteinId);
1535  feh.Replace(*pEditedFeat);
1536 }
1537 
1538 // ----------------------------------------------------------------------------
1540 // ----------------------------------------------------------------------------
1541 {
1542  const int WIDTH = 6;
1543  const string padding = string(WIDTH, '0');
1545  if (suffix.size() < WIDTH) {
1546  suffix = padding.substr(0, WIDTH - suffix.size()) + suffix;
1547  }
1548  string nextTag("auto");
1549  return nextTag + suffix;
1550 }
1551 
1552 // ----------------------------------------------------------------------------
1554 // ----------------------------------------------------------------------------
1555 {
1556  const int WIDTH = 6;
1557  const string padding = string(WIDTH, '0');
1559  if (suffix.size() < WIDTH) {
1560  suffix = padding.substr(0, WIDTH - suffix.size()) + suffix;
1561  }
1562  string nextTag = mLocusTagPrefix + "_" + suffix;
1563  return nextTag;
1564 }
1565 
1566 // ----------------------------------------------------------------------------
1568  const CMappedFeat& mf)
1569 // ----------------------------------------------------------------------------
1570 {
1571  const string dbPrefix("gnl|");
1572 
1573  // format: mLocusTagPrefix|<locus tag of gene or hash>[_numeric disambiguation]
1574  CMappedFeat parentGene = feature::GetBestGeneForFeat(mf, &mTree);
1575  if (!parentGene ||
1576  !parentGene.GetData().GetGene().IsSetLocus_tag()) {
1578  return "";
1579  }
1580 
1581  int offset = 0;
1582  string locusTag = parentGene.GetData().GetGene().GetLocus_tag();
1584  if (it == mMapProtIdCounts.end()) {
1585  mMapProtIdCounts[locusTag] = 0;
1586  }
1587  else {
1588  ++mMapProtIdCounts[locusTag];
1589  offset = mMapProtIdCounts[locusTag];
1590  }
1591  string db = mLocusTagPrefix;
1592  if (locusTag.empty() &&
1593  db.empty()) {
1595  }
1596 
1597  if (db.empty()) {
1598  string prefix, suffix;
1599  NStr::SplitInTwo(locusTag, "_", prefix, suffix);
1600  db = prefix;
1601  }
1602  string proteinId = dbPrefix + db + "|" + GetIdHashOrValue(locusTag, offset);
1603  return proteinId;
1604 }
1605 
1606 // ----------------------------------------------------------------------------
1608  const CMappedFeat& cds)
1609 // ----------------------------------------------------------------------------
1610 {
1611  const string dbPrefix("gnl|");
1612 
1613 
1614  // format: mLocusTagPrefix|mrna.<locus tag of gene or hash>[_numeric disambiguation]
1615  CMappedFeat parentGene = feature::GetBestGeneForFeat(cds, &mTree);
1616  if (!parentGene ||
1617  !parentGene.GetData().GetGene().IsSetLocus_tag()) {
1619  return "";
1620  }
1621 
1622 
1623  string locusTag = parentGene.GetData().GetGene().GetLocus_tag();
1624  int offset = 0;
1626  if (it != mMapProtIdCounts.end() && mMapProtIdCounts[locusTag] != 0) {
1627  offset = mMapProtIdCounts[locusTag];
1628  }
1629  string db = mLocusTagPrefix;
1630 
1631  if (locusTag.empty() &&
1632  db.empty()) {
1634  }
1635 
1636 
1637  if (db.empty()) {
1638  string prefix, suffix;
1639  NStr::SplitInTwo(locusTag, "_", prefix, suffix);
1640  db = prefix;
1641  }
1642 
1643  string transcriptId = dbPrefix + db + "|mrna." + GetIdHashOrValue(locusTag, offset);
1644  return transcriptId;
1645 }
1646 
1647 // ----------------------------------------------------------------------------
1649  const CSeq_loc& baseLoc,
1650  TSeqPos sequenceSize)
1651 // ----------------------------------------------------------------------------
1652 {
1653  CRef<CSeq_loc> pEnvelope(new CSeq_loc);
1654 
1655  auto baseStart = baseLoc.GetStart(eExtreme_Positional);
1656  auto baseStop = baseLoc.GetStop(eExtreme_Positional);
1657  auto& baseId = *baseLoc.GetId();
1658 
1659  if (sequenceSize == 0 || baseStart <= baseStop) {
1660  pEnvelope->SetInt();
1661  pEnvelope->SetId(baseId);
1662  pEnvelope->SetInt().SetFrom(baseStart);
1663  pEnvelope->SetInt().SetTo(baseStop);
1664  pEnvelope->SetInt().SetStrand(baseLoc.GetStrand());
1665  }
1666  else {
1667  if (baseLoc.GetStrand() != eNa_strand_minus) {
1669  pTop->SetId().Assign(baseId);
1670  pTop->SetFrom(baseStart);
1671  pTop->SetTo(sequenceSize-1);
1672  pTop->SetStrand(baseLoc.GetStrand());
1673  pEnvelope->SetPacked_int().AddInterval(*pTop);
1674  CRef<CSeq_interval> pBottom(new CSeq_interval);
1675  pBottom->SetId().Assign(baseId);
1676  pBottom->SetFrom(0);
1677  pBottom->SetTo(baseStop);
1678  pBottom->SetStrand(baseLoc.GetStrand());
1679  pEnvelope->SetPacked_int().AddInterval(*pBottom);
1680  pEnvelope->ChangeToMix();
1681  }
1682  else {
1683  CRef<CSeq_interval> pBottom(new CSeq_interval);
1684  pBottom->SetId().Assign(baseId);
1685  pBottom->SetFrom(0);
1686  pBottom->SetTo(baseStop);
1687  pBottom->SetStrand(baseLoc.GetStrand());
1688  pEnvelope->SetPacked_int().AddInterval(*pBottom);
1690  pTop->SetId().Assign(baseId);
1691  pTop->SetFrom(baseStart);
1692  pTop->SetTo(sequenceSize-1);
1693  pTop->SetStrand(baseLoc.GetStrand());
1694  pEnvelope->SetPacked_int().AddInterval(*pTop);
1695  pEnvelope->ChangeToMix();
1696  }
1697  }
1698  return pEnvelope;
1699 }
1700 
1701 // ----------------------------------------------------------------------------
1703  const CMappedFeat& rna,
1704  TSeqPos sequenceSize)
1705 // ----------------------------------------------------------------------------
1706 {
1707  CRef<CSeq_feat> pGene;
1708  CSeq_feat_Handle sfh = mpScope->GetSeq_featHandle(rna.GetOriginalFeature());
1709  CSeq_annot_Handle sah = sfh.GetAnnot();
1710  if (!sah) {
1711  return pGene;
1712  }
1714  if (existingGene) {
1715  return pGene;
1716  }
1717  pGene.Reset(new CSeq_feat);
1718  pGene->SetLocation(*xGetGeneLocation(rna.GetLocation(), sequenceSize));
1719  pGene->SetData().SetGene();
1720  return pGene;
1721 }
1722 
1723 
1724 // ----------------------------------------------------------------------------
1725 void
1727  const string& message)
1728  // ----------------------------------------------------------------------------
1729 {
1730  if (!mpMessageListener) {
1731  return;
1732  }
1733 
1735  CObjEditMessage(message, eDiag_Error));
1736 }
1737 
1738 
1739 // ----------------------------------------------------------------------------
1740 void
1742  CMappedFeat mf)
1743  // ----------------------------------------------------------------------------
1744 {
1745  if (!mpMessageListener) {
1746  return;
1747  }
1748 
1749  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1750  string subName = CSeqFeatData::SubtypeValueToName(subtype);
1751  unsigned int lower = mf.GetLocation().GetStart(eExtreme_Positional);
1752  unsigned int upper = mf.GetLocation().GetStop(eExtreme_Positional);
1753  subName = NStr::IntToString(lower) + ".." + NStr::IntToString(upper) + " " +
1754  subName;
1755 
1756  string message = subName + " feature is missing locus tag.";
1757  xPutError(message);
1758 }
1759 
1760 // ----------------------------------------------------------------------------
1761 void
1763  CMappedFeat mf)
1764  // ----------------------------------------------------------------------------
1765 {
1766  if (!mpMessageListener) {
1767  return;
1768  }
1769 
1770  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1771  string subName = CSeqFeatData::SubtypeValueToName(subtype);
1772  unsigned int lower = mf.GetLocation().GetStart(eExtreme_Positional);
1773  unsigned int upper = mf.GetLocation().GetStop(eExtreme_Positional);
1774  subName = NStr::IntToString(lower) + ".." + NStr::IntToString(upper) + " " +
1775  subName;
1776 
1777  string message = subName + " feature is missing transcript ID.";
1778  xPutError(message);
1779 }
1780 
1781 // ----------------------------------------------------------------------------
1782 void
1784  const string codonRecognized)
1785 // ----------------------------------------------------------------------------
1786 {
1787  if (!mpMessageListener) {
1788  return;
1789  }
1790  string message = "tRNA with bad codon recognized attribute \"" +
1791  codonRecognized + "\".";
1792  xPutError(message);
1793 }
1794 
1795 // ----------------------------------------------------------------------------
1796 void
1798  CMappedFeat mf)
1799  // ----------------------------------------------------------------------------
1800 {
1801  if (!mpMessageListener) {
1802  return;
1803  }
1804 
1805  CSeqFeatData::ESubtype subtype = mf.GetFeatSubtype();
1806  string subName = CSeqFeatData::SubtypeValueToName(subtype);
1807  unsigned int lower = mf.GetLocation().GetStart(eExtreme_Positional);
1808  unsigned int upper = mf.GetLocation().GetStop(eExtreme_Positional);
1809  subName = NStr::IntToString(lower) + ".." + NStr::IntToString(upper) + " " +
1810  subName;
1811 
1812  string message = subName + " feature is missing protein ID.";
1813  xPutError(message);
1814 }
1815 
1816 
1817 // ----------------------------------------------------------------------------
1818 void
1820  const CMappedFeat& mrna)
1821 // ----------------------------------------------------------------------------
1822 {
1823  if (!mpMessageListener) {
1824  return;
1825  }
1826 
1828  return;
1829  }
1830  xPutError("Protein ID on mRNA feature differs from protein ID on child CDS.");
1831 }
1832 
1833 void
1835  const CMappedFeat& mrna)
1836 // ----------------------------------------------------------------------------
1837 {
1838  if (!mpMessageListener) {
1839  return;
1840  }
1841 
1843  return;
1844  }
1845 
1846  xPutError("Transcript ID on mRNA feature differs from transcript ID on child CDS.");
1847 }
1848 
1849 
1850 // ----------------------------------------------------------------------------
1851 string
1853  CMappedFeat mf)
1854  // ----------------------------------------------------------------------------
1855 {
1856  stringstream strstr;
1857  auto& id = mf.GetId();
1858  switch (id.Which()) {
1859  default:
1860  return "\"UNKNOWN ID\"";
1861  case CFeat_id::e_Local:
1862  id.GetLocal().AsString(strstr);
1863  return strstr.str();
1864  }
1865 }
1866 
1867 // ----------------------------------------------------------------------------
1868 string
1870  CMappedFeat mf)
1871  // ----------------------------------------------------------------------------
1872 {
1873  if (!mLocusTagPrefix.empty()) {
1874  return mLocusTagPrefix;
1875  }
1876  CMappedFeat geneFeature = mf;
1877  if (geneFeature.GetFeatSubtype() != CSeqFeatData::eSubtype_gene) {
1878  geneFeature = feature::GetBestGeneForFeat(mf, &mTree);
1879  }
1880  if (!geneFeature) {
1881  return "";
1882  }
1883  const auto& geneRef = geneFeature.GetData().GetGene();
1884  if (geneRef.IsSetLocus_tag()) {
1885  const auto& locusTag = geneFeature.GetData().GetGene().GetLocus_tag();
1886  string prefix, suffix;
1887  NStr::SplitInTwo(locusTag, "_", prefix, suffix);
1888  return prefix;
1889  }
1890  auto locusTagFromQualifier = geneFeature.GetNamedQual("locus_tag");
1891  if (!locusTagFromQualifier.empty()) {
1892  string prefix, suffix;
1893  NStr::SplitInTwo(locusTagFromQualifier, "_", prefix, suffix);
1894  return prefix;
1895  }
1896  return "";
1897 }
1898 
1900 {
1901  CConstRef<CSeq_feat> feature;
1902  if (feature.Empty())
1903  {
1904 
1905  CMappedFeat cds(mpScope->GetSeq_featHandle(cd_feature));
1906  CMappedFeat other;
1907  if (gene)
1908  other = feature::GetBestGeneForCds(cds, &mTree);
1909  else
1910  other = feature::GetBestMrnaForCds(cds, &mTree);
1911 
1912  if (other)
1913  feature.Reset(&other.GetOriginalFeature());
1914 
1915  }
1916  return feature;
1917 }
1918 
1919 
1920 static void s_AppendProtRefInfo(CProt_ref& current_ref, const CProt_ref& other_ref)
1921 {
1922 
1923  auto append_nonduplicated_item = [](list<string>& current_list,
1924  const list<string>& other_list)
1925  {
1926  unordered_set<string> current_set;
1927  for (const auto& item : current_list) {
1928  current_set.insert(item);
1929  }
1930 
1931  for (const auto& item : other_list) {
1932  if (current_set.find(item) == current_set.end()) {
1933  current_list.push_back(item);
1934  }
1935  }
1936  };
1937 
1938  if (other_ref.IsSetName()) {
1939  append_nonduplicated_item(current_ref.SetName(),
1940  other_ref.GetName());
1941  }
1942 
1943  if (other_ref.IsSetDesc()) {
1944  current_ref.SetDesc() = other_ref.GetDesc();
1945  }
1946 
1947  if (other_ref.IsSetEc()) {
1948  append_nonduplicated_item(current_ref.SetEc(),
1949  other_ref.GetEc());
1950  }
1951 
1952  if (other_ref.IsSetActivity()) {
1953  append_nonduplicated_item(current_ref.SetActivity(),
1954  other_ref.GetActivity());
1955  }
1956 
1957  if (other_ref.IsSetDb()) {
1958  for (const auto& pDBtag : other_ref.GetDb()) {
1959  current_ref.SetDb().push_back(pDBtag);
1960  }
1961  }
1962 
1963  if (current_ref.GetProcessed() == CProt_ref::eProcessed_not_set) {
1964  const auto processed = other_ref.GetProcessed();
1965  if (processed != CProt_ref::eProcessed_not_set) {
1966  current_ref.SetProcessed(processed);
1967  }
1968  }
1969 }
1970 
1971 static void s_SetProtRef(const CSeq_feat& cds,
1972  CConstRef<CSeq_feat> pMrna,
1973  CProt_ref& prot_ref)
1974 {
1975  const CProt_ref* pProtXref = cds.GetProtXref();
1976  if (pProtXref) {
1977  s_AppendProtRefInfo(prot_ref, *pProtXref);
1978  }
1979 
1980 
1981  if (!prot_ref.IsSetName()) {
1982  const string& product_name = cds.GetNamedQual("product");
1983  if (product_name != kEmptyStr) {
1984  prot_ref.SetName().push_back(product_name);
1985  }
1986  }
1987 
1988  if (pMrna.Empty()) { // Nothing more we can do here
1989  return;
1990  }
1991 
1992  if (prot_ref.IsSetName()) {
1993  for (auto& prot_name : prot_ref.SetName()) {
1994  if (NStr::CompareNocase(prot_name, "hypothetical protein") == 0) {
1995  if (pMrna->GetData().GetRna().IsSetExt() &&
1996  pMrna->GetData().GetRna().GetExt().IsName()) {
1997  prot_name = pMrna->GetData().GetRna().GetExt().GetName();
1998  break;
1999  }
2000  }
2001  }
2002  } // prot_ref.IsSetName()
2003 }
2004 
2005 static bool AssignLocalIdIfEmpty(CSeq_feat& feature, unsigned& id)
2006 {
2007  if (feature.IsSetId())
2008  return true;
2009  else
2010  {
2011  feature.SetId().SetLocal().SetId(id++);
2012  return false;
2013  }
2014 }
2015 
2017 {
2018  for (auto feat : mAnnot.GetData().GetFtable())
2019  {
2020  if (feat.NotEmpty() && feat->IsSetData() && feat->GetData().IsCdregion())
2021  {
2022  xGenerate_mRNA_Product(*feat);
2023  }
2024  }
2025 }
2026 
2028 {
2029  if (sequence::IsPseudo(cd_feature, *mpScope))
2030  return; // CRef<CSeq_entry>();
2031 
2032 #if 0
2033  CBioseq_Handle bsh = m_scope->GetBioseqHandle(bioseq);
2034 
2035  CConstRef<CSeq_entry> replacement = LocateProtein(m_replacement_protein, cd_feature);
2036 #endif
2037 
2038  CConstRef<CSeq_feat> mrna = xGetLinkedFeature(cd_feature, false);
2039  CConstRef<CSeq_feat> gene = xGetLinkedFeature(cd_feature, true);
2040 
2041 #if 0
2042  CRef<CBioseq> protein;
2043  bool was_extended = false;
2044  if (replacement.Empty())
2045  {
2046  was_extended = CCleanup::ExtendToStopIfShortAndNotPartial(cd_feature, bsh);
2047 
2048  protein = CSeqTranslator::TranslateToProtein(cd_feature, *m_scope);
2049 
2050  if (protein.Empty())
2051  return CRef<CSeq_entry>();
2052  }
2053  else
2054  {
2055  protein.Reset(new CBioseq());
2056  protein->Assign(replacement->GetSeq());
2057  }
2058 
2059  CRef<CSeq_entry> protein_entry(new CSeq_entry);
2060  protein_entry->SetSeq(*protein);
2061 
2062  CAutoAddDesc molinfo_desc(protein->SetDescr(), CSeqdesc::e_Molinfo);
2065  feature::AdjustProteinMolInfoToMatchCDS(molinfo_desc.Set().SetMolinfo(), cd_feature);
2066 
2067  string org_name;
2068  CTable2AsnContext::GetOrgName(org_name, *top_entry_h.GetCompleteObject());
2069 
2070  CTempString locustag;
2071  if (!gene.Empty() && gene->IsSetData() && gene->GetData().IsGene() && gene->GetData().GetGene().IsSetLocus_tag())
2072  {
2073  locustag = gene->GetData().GetGene().GetLocus_tag();
2074  }
2075 
2076  string base_name;
2077  CRef<CSeq_id> newid;
2078  CTempString qual_to_remove;
2079 
2080  if (protein->GetId().empty())
2081  {
2082  const string* protein_ids = 0;
2083 
2084  qual_to_remove = "protein_id";
2085  protein_ids = &cd_feature.GetNamedQual(qual_to_remove);
2086 
2087  if (protein_ids->empty())
2088  {
2089  qual_to_remove = "orig_protein_id";
2090  protein_ids = &cd_feature.GetNamedQual(qual_to_remove);
2091  }
2092 
2093  if (protein_ids->empty())
2094  {
2095  if (mrna.NotEmpty())
2096  protein_ids = &mrna->GetNamedQual("protein_id");
2097  }
2098 
2099  if (protein_ids->empty())
2100  {
2101  protein_ids = &cd_feature.GetNamedQual("product_id");
2102  }
2103 
2104  if (!protein_ids->empty())
2105  {
2106  CBioseq::TId new_ids;
2108 
2109  MergeSeqIds(*protein, new_ids);
2110  cd_feature.RemoveQualifier(qual_to_remove);
2111  }
2112  }
2113  else {
2114  cd_feature.RemoveQualifier("protein_id");
2115  cd_feature.RemoveQualifier("orig_protein_id");
2116  }
2117 
2118  if (protein->GetId().empty())
2119  {
2120  if (base_name.empty() && !bioseq.GetId().empty())
2121  {
2122  bioseq.GetId().front()->GetLabel(&base_name, CSeq_id::eContent);
2123  }
2124 
2125  newid = GetNewProteinId(*m_scope, base_name);
2126  protein->SetId().push_back(newid);
2127  }
2128 
2129 #endif
2130 
2131 #if 0
2132  CSeq_feat& prot_feat = CreateOrSetFTable(*protein);
2133  CProt_ref& prot_ref = prot_feat.SetData().SetProt();
2134 #else
2135  CRef<CProt_ref> p_prot_ref(new CProt_ref);
2136  CProt_ref& prot_ref = *p_prot_ref;
2137 #endif
2138 
2139  s_SetProtRef(cd_feature, mrna, prot_ref);
2140  if ((!prot_ref.IsSetName() || prot_ref.GetName().empty()) && m_use_hypothetic_protein)
2141  {
2142  prot_ref.SetName().push_back("hypothetical protein");
2143  cd_feature.SetProtXref().SetName().clear();
2144  cd_feature.SetProtXref().SetName().push_back("hypothetical protein");
2145  //cd_feature.RemoveQualifier("product");
2146  }
2147 
2148 
2149 #if 0
2150  prot_feat.SetLocation().SetInt().SetFrom(0);
2151  prot_feat.SetLocation().SetInt().SetTo(protein->GetInst().GetLength() - 1);
2152  prot_feat.SetLocation().SetInt().SetId().Assign(*GetAccessionId(protein->GetId()));
2153  feature::CopyFeaturePartials(prot_feat, cd_feature);
2154 
2155  if (!cd_feature.IsSetProduct())
2156  cd_feature.SetProduct().SetWhole().Assign(*GetAccessionId(protein->GetId()));
2157 
2158  CBioseq_Handle protein_handle = m_scope->AddBioseq(*protein);
2159 
2160  AssignLocalIdIfEmpty(cd_feature, m_local_id_counter);
2161  if (gene.NotEmpty() && mrna.NotEmpty())
2162  cd_feature.SetXref().clear();
2163 
2164  if (gene.NotEmpty())
2165  {
2166  CSeq_feat& gene_feature = (CSeq_feat&)*gene;
2167  AssignLocalIdIfEmpty(gene_feature, m_local_id_counter);
2168  cd_feature.AddSeqFeatXref(gene_feature.GetId());
2169  gene_feature.AddSeqFeatXref(cd_feature.GetId());
2170  }
2171 #endif
2172 
2173  if (mrna.NotEmpty())
2174  {
2175  CSeq_feat& mrna_feature = (CSeq_feat&)*mrna;
2176 
2177  AssignLocalIdIfEmpty(mrna_feature, mNextFeatId);
2178 
2179  if (prot_ref.IsSetName() && !prot_ref.GetName().empty())
2180  {
2181  auto& ext = mrna_feature.SetData().SetRna().SetExt();
2182  if (ext.Which() == CRNA_ref::C_Ext::e_not_set ||
2183  (ext.IsName() && ext.SetName().empty()))
2184  ext.SetName() = prot_ref.GetName().front();
2185  }
2186  mrna_feature.AddSeqFeatXref(cd_feature.GetId());
2187  cd_feature.AddSeqFeatXref(mrna_feature.GetId());
2188  }
2189 
2190 #if 0
2191  if (prot_ref.IsSetName() && !prot_ref.GetName().empty())
2192  {
2193  //cd_feature.ResetProduct();
2194  cd_feature.SetProtXref().SetName().clear();
2195  cd_feature.SetProtXref().SetName().push_back(prot_ref.GetName().front());
2196  cd_feature.RemoveQualifier("product");
2197  }
2198 
2199 
2200  if (was_extended)
2201  {
2202  if (!mrna.Empty() && mrna->IsSetLocation() && CCleanup::LocationMayBeExtendedToMatch(mrna->GetLocation(), cd_feature.GetLocation()))
2203  CCleanup::ExtendStopPosition((CSeq_feat&)*mrna, &cd_feature);
2204  if (!gene.Empty() && gene->IsSetLocation() && CCleanup::LocationMayBeExtendedToMatch(gene->GetLocation(), cd_feature.GetLocation()))
2205  CCleanup::ExtendStopPosition((CSeq_feat&)*gene, &cd_feature);
2206  }
2207 
2208  return protein_entry;
2209 #endif
2210 }
2211 
2212 // ============================================================================
2213 string
2214 sGetFeatMapKey(const CObject_id& objectId)
2215 // ============================================================================
2216 {
2217  if (objectId.IsStr()) {
2218  return objectId.GetStr();
2219  }
2220  return string("id:") + NStr::NumericToString(objectId.GetId());
2221 }
2222 
2223 // ============================================================================
2224 void
2226  const CSeq_annot::TData::TFtable& otherFeatures)
2227 // ============================================================================
2228 {
2229  FeatMap featMap;
2230 
2231  auto& thisFeatures = mAnnot.SetData().SetFtable();
2232  for (auto pThisFeat: thisFeatures) {
2233  //(assumption: only local IDs are at issue)
2234  if (!pThisFeat->IsSetId() || !pThisFeat->GetId().IsLocal()) {
2235  continue;
2236  }
2237  const auto& this_oid = pThisFeat->GetId().GetLocal();
2238  featMap[sGetFeatMapKey(this_oid)] = pThisFeat;
2239  }
2240  for (auto pOtherFeat: otherFeatures) {
2241  if (!pOtherFeat->IsSetId() || !pOtherFeat->GetId().IsLocal()) {
2242  thisFeatures.push_back(pOtherFeat);
2243  continue;
2244  }
2245  const auto& other_oid = pOtherFeat->GetId().GetLocal();
2246  if (featMap.find(sGetFeatMapKey(other_oid)) == featMap.end()) {
2247  thisFeatures.push_back(pOtherFeat);
2248  continue;
2249  }
2250  xRenameFeatureId(other_oid, featMap);
2251  thisFeatures.push_back(pOtherFeat);
2252  }
2253 }
2254 
2255 // ==============================================================================
2257 // ==============================================================================
2258  const CObject_id& lhs,
2259  const CObject_id& rhs)
2260 {
2261  if (lhs.Which() != rhs.Which()) {
2262  return false;
2263  }
2264  if (lhs.IsStr()) {
2265  return (lhs.GetStr() == rhs.GetStr());
2266  }
2267  return (lhs.GetId() == rhs.GetId());
2268 };
2269 
2270 // =============================================================================
2271 void
2273  const CObject_id& oldFeatId,
2274  FeatMap& featMap)
2275 // =============================================================================
2276 {
2277  string oldFeatIdAsStr;
2278  if (oldFeatId.IsStr()) {
2279  oldFeatIdAsStr = oldFeatId.GetStr();
2280  }
2281  else {
2282  oldFeatIdAsStr = NStr::NumericToString(oldFeatId.GetId());
2283  }
2284 
2285  string newFeatIdAsStr = oldFeatIdAsStr + "x";
2286  CRef<CObject_id> pNewFeatId(new CObject_id);
2287  pNewFeatId->SetStr(oldFeatIdAsStr + "x");
2288  while (featMap.find(sGetFeatMapKey(*pNewFeatId)) != featMap.end()) {
2289  pNewFeatId->SetStr() += "x";
2290  }
2291 
2292  auto pBaseFeat = featMap[sGetFeatMapKey(oldFeatId)];
2293  pBaseFeat->SetId().SetLocal(*pNewFeatId);
2294  featMap.erase(sGetFeatMapKey(oldFeatId));
2295  featMap[sGetFeatMapKey(*pNewFeatId)] = pBaseFeat;
2296 
2297  for (auto it = featMap.begin(); it != featMap.end(); ++it) {
2298  auto pFeat = it->second;
2299  for (auto& pXref: pFeat->SetXref()) {
2300  if (!pXref->IsSetId() || !pXref->GetId().IsLocal()) {
2301  continue;
2302  }
2303  if (OjectIdsAreEqual(pXref->GetId().GetLocal(), oldFeatId)) {
2304  pXref->SetId().SetLocal(*pNewFeatId);
2305  }
2306  }
2307  }
2308 }
2309 
2310 END_SCOPE(edit)
2313 
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:1291
static bool ExtendStopPosition(CSeq_feat &f, const CSeq_feat *cdregion, size_t extension=0)
Definition: cleanup.cpp:1072
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:1333
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 xGenerateMissingMrnaForCds(const CMappedFeat &cds)
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 xGenerateMissingGeneForFeats(const SAnnotSelector &sel, const CGff3LocationMerger *=nullptr)
void xPutErrorMissingProteinId(CMappedFeat)
string xNextProteinId(const CMappedFeat &)
void xGenerateMissingGeneForFeat(const CMappedFeat &feat)
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 s_IsGenbankId(const string &id)
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)
static bool s_IsGeneralId(const string &id)
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:726
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:5084
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:5412
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 Sun Mar 03 03:13:19 2024 by modify_doxy.py rev. 669887