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

Go to the SVN repository for this file.

1 /* $Id: link_mrna_cds.cpp 42162 2019-01-07 20:09:12Z filippov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrea Asztalos
27  *
28  * Place reciprocal cross-references between mRNA and CDS. The features are selected
29  * according to some criteria.
30  */
31 
32 #include <ncbi_pch.hpp>
38 #include <objmgr/feat_ci.hpp>
39 #include <objmgr/util/sequence.hpp>
40 
41 #include <gui/objutils/label.hpp>
50 #include <wx/msgdlg.h>
51 
54 
56 {
57  if (objects.empty()) {
58  wxMessageBox(wxT("No features are selected"), wxT("Error"), wxOK | wxICON_ERROR, NULL);
59  return;
60  }
61 
62  CConstRef<CSeq_feat> mrna, cds;
64  const CObject* ptr = it->object.GetPointer();
65  const CSeq_feat* seqfeat = dynamic_cast<const CSeq_feat*>(ptr);
66  if (seqfeat && seqfeat->IsSetData()) {
67  if (seqfeat->GetData().IsCdregion()) {
68  cds.Reset(seqfeat);
69  } else if (seqfeat->GetData().GetSubtype() == CSeqFeatData::eSubtype_mRNA) {
70  mrna.Reset(seqfeat);
71  }
72  }
73  }
74 
75  if (!x_OkForLinking(mrna, cds)) {
76  return;
77  }
78 
79  CRef<CCmdComposite> cmd(new CCmdComposite("Link Selected CDS and mRNA Pair"));
80  CScope& scope = m_TopSeqEntry.GetScope();
81 
82  bool cds_hasid = cds->IsSetId() && cds->GetId().IsLocal();
83  bool mrna_hasid = mrna->IsSetId() && mrna->GetId().IsLocal();
84 
85  bool modified = false;
86  // assign feature ids in case there is none:
87  if (!cds_hasid || !mrna_hasid) {
88 
89  CRef<CSeq_feat> new_mrna, new_cds;
91  for (CFeat_CI feat_it(m_TopSeqEntry); feat_it; ++feat_it) {
92  CSeq_feat_Handle fh = feat_it->GetSeq_feat_Handle();
93  if (fh.IsSetId() && fh.GetId().IsLocal()) {
94  continue;
95  }
96 
97  CConstRef<CSeq_feat> orig_feat = feat_it->GetOriginalSeq_feat();
98  CRef<CSeq_feat> new_feat(new CSeq_feat);
99  new_feat->Assign(*orig_feat);
100  top_id++;
101  new_feat->SetId().SetLocal().SetId(top_id);
102 
103  if (orig_feat == mrna ) {
104  new_mrna.Reset(new_feat.GetPointer());
105  } else if (orig_feat == cds) {
106  new_cds.Reset(new_feat.GetPointer());
107  } else {
108  CIRef<IEditCommand> chg_feat(new CCmdChangeSeq_feat(fh, *new_feat));
109  cmd->AddCommand(*chg_feat);
110  modified = true;
111  }
112  }
113 
114  if (new_mrna.NotEmpty() && new_cds.NotEmpty()) {
115  s_CreateXRefLink(*new_mrna, *new_cds);
116  s_CreateXRefLink(*new_cds, *new_mrna);
117 
118  CIRef<IEditCommand> chg_mrna(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(*mrna), *new_mrna));
119  cmd->AddCommand(*chg_mrna);
120  CIRef<IEditCommand> chg_cds(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(*cds), *new_cds));
121  cmd->AddCommand(*chg_cds);
122  modified = true;
123  }
124  } else if (cds_hasid && mrna_hasid) { //both features have feat_id
125  modified = SetReciprocalXrefs(*mrna, *cds, cmd);
126  }
127 
128  if (modified) {
129  cmdProcessor->Execute(cmd);
130  }
131 }
132 
134 {
135  bool modified = false;
136  CScope& scope = m_TopSeqEntry.GetScope();
137  if (!s_IsDirectXrefBetween(mrna, cds)) {
138  CRef<CSeq_feat> new_mrna(new CSeq_feat);
139  new_mrna->Assign(mrna);
140  s_CreateXRefLink(*new_mrna, cds);
141  CIRef<IEditCommand> chg_mrna(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(mrna), *new_mrna));
142  cmd->AddCommand(*chg_mrna);
143  modified = true;
144  }
145 
146  if (!s_IsDirectXrefBetween(cds, mrna)) {
147  CRef<CSeq_feat> new_cds(new CSeq_feat);
148  new_cds->Assign(cds);
149  s_CreateXRefLink(*new_cds, mrna);
150  CIRef<IEditCommand> chg_cds(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(cds), *new_cds));
151  cmd->AddCommand(*chg_cds);
152  modified = true;
153  }
154  return modified;
155 }
156 
158 {
159  if (!mrna.IsSetId() || !(cds.IsSetId() && cds.GetId().IsLocal())) {
160  return false;
161  }
162 
163  CScope& scope = m_TopSeqEntry.GetScope();
164 
165  CRef<CSeq_feat> new_mrna(new CSeq_feat);
166  new_mrna->Assign(mrna);
167 
168  bool replaced = x_ReplaceExistingFeatIdXrefs(*new_mrna, cds);
169  if (!replaced) {
170  s_CreateXRefLink(*new_mrna, cds);
171  }
172  CIRef<IEditCommand> chg_mrna(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(mrna), *new_mrna));
173  cmd->AddCommand(*chg_mrna);
174 
175  CRef<CSeq_feat> new_cds(new CSeq_feat);
176  new_cds->Assign(cds);
177  replaced = false;
178  replaced = x_ReplaceExistingFeatIdXrefs(*new_cds, mrna);
179  if (!replaced) {
180  s_CreateXRefLink(*new_cds, mrna);
181  }
182  CIRef<IEditCommand> chg_cds(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(cds), *new_cds));
183  cmd->AddCommand(*chg_cds);
184 
185  return true;
186 }
187 
189 {
190  if (!from_feat.IsSetXref()) {
191  return false;
192  }
193 
194  EDIT_EACH_XREF_ON_SEQFEAT(xref_it, from_feat) {
195  CRef<CSeqFeatXref> xref = *xref_it;
196  if (xref->IsSetId() && xref->GetId().IsLocal()) {
197  xref->SetId().SetLocal().Assign(to_feat.GetId().GetLocal());
198  return true;
199  }
200  }
201  return false;
202 }
203 
204 
206 {
207  bool assigned = false;
209  for (CFeat_CI feat_it(m_TopSeqEntry); feat_it; ++feat_it) {
210  CSeq_feat_Handle fh = feat_it->GetSeq_feat_Handle();
211  if (fh.IsSetId() && fh.GetId().IsLocal()) {
212  continue;
213  }
214 
215  CRef<CSeq_feat> new_feat(new CSeq_feat);
216  new_feat->Assign(*feat_it->GetOriginalSeq_feat());
217  top_id++;
218  new_feat->SetId().SetLocal().SetId(top_id);
219  CIRef<IEditCommand> chg_feat(new CCmdChangeSeq_feat(fh, *new_feat));
220  chg_feat->Execute();
221  cmd->AddCommand(*chg_feat);
222  assigned = true;
223  }
224  return assigned;
225 }
226 
228 {
229  CRef<CMacroCmdComposite> link_cmd(new CMacroCmdComposite("Link CDS-mRNA pair by overlap"));
230  bool assigned = AssignFeatureIds(link_cmd);
231 
232  CRef<CCmdComposite> cmd(new CCmdComposite("Actual linking of cds and mRNA pairs by overlap"));
233  CScope& scope = m_TopSeqEntry.GetScope();
234 
235  set<CConstRef<CSeq_feat> > linked_mRNAs;
236  for (CFeat_CI cds_it(m_TopSeqEntry, SAnnotSelector(CSeqFeatData::e_Cdregion)); cds_it; ++cds_it) {
237 
238  // find single, unused mRNA
240  (cds_it->GetLocation(),
243  scope);
244 
245  if (!mrna) {
246  continue;
247  }
248  // check if the mRNA was already linked to a different CDS
249  if (linked_mRNAs.find(mrna) != linked_mRNAs.end()) {
250  continue;
251  }
252 
253  CConstRef<CSeq_feat> cds = cds_it->GetOriginalSeq_feat();
254  if (SetReciprocalXrefs(*mrna, *cds, cmd)) {
255  linked_mRNAs.insert(mrna);
256  }
257  }
258 
259  if (!linked_mRNAs.empty()) {
260  cmd->Execute();
261  link_cmd->AddCommand(*cmd);
262  }
263  if (assigned || !linked_mRNAs.empty()) {
264  cmdProcessor->Execute(link_cmd);
265  }
266 }
267 
268 
269 
271 {
272  CRef<CMacroCmdComposite> link_cmd(new CMacroCmdComposite("Link CDS-mRNA pair by product"));
273  bool assigned = AssignFeatureIds(link_cmd);
274 
275  CRef<CCmdComposite> cmd(new CCmdComposite("Actual linking of cds and mRNA pairs by product"));
276  CScope& scope = m_TopSeqEntry.GetScope();
277 
280 
281  for (CFeat_CI mrna_it(m_TopSeqEntry, SAnnotSelector(CSeqFeatData::eSubtype_mRNA)); mrna_it; ++mrna_it) {
282  if (mrna_it->IsSetProduct()) {
283  CSeq_id_Handle idh = mrna_it->GetProductId();
284  mrna_products.emplace(idh, mrna_it->GetOriginalSeq_feat());
285  }
286  }
287 
288  for (CFeat_CI cds_it(m_TopSeqEntry, SAnnotSelector(CSeqFeatData::eSubtype_cdregion)); cds_it; ++cds_it) {
289  if (cds_it->IsSetProduct()) {
290  CSeq_id_Handle idh = cds_it->GetProductId();
291  cds_products.emplace(idh, cds_it->GetOriginalSeq_feat());
292  }
293  }
294 
295  if (mrna_products.empty() || cds_products.empty()) {
296  return;
297  }
298 
299  set<CConstRef<CSeq_feat>> linked_feats;
300  for (auto& mrna_it : mrna_products) {
301  if (linked_feats.find(mrna_it.second) != linked_feats.end()) {
302  continue;
303  }
304 
305  CBioseq_Handle cdna = scope.GetBioseqHandle(mrna_it.first);
306  if (!cdna) continue;
307 
308  CBioseq_set_Handle cdna_parenth = cdna.GetParentBioseq_set();
309  if (cdna_parenth.IsSetClass() && cdna_parenth.GetClass() == CBioseq_set::eClass_nuc_prot) {
310  for (CBioseq_CI prot_it(cdna_parenth, CSeq_inst::eMol_aa); prot_it; ++prot_it) {
311  vector<CSeq_id_Handle> prot_ids = prot_it->GetId();
312  for (auto&& id_it : prot_ids) {
313  auto found_cds_it = cds_products.find(id_it);
314  if (found_cds_it != cds_products.end()) {
315  if (linked_feats.find(found_cds_it->second) != linked_feats.end()) {
316  continue;
317  }
318  if (ReplaceExistingXrefs(*mrna_it.second, *found_cds_it->second, cmd)) {
319  linked_feats.insert(mrna_it.second);
320  linked_feats.insert(found_cds_it->second);
321  }
322  }
323  }
324  }
325  }
326  }
327 
328  if (!linked_feats.empty()) {
329  cmd->Execute();
330  link_cmd->AddCommand(*cmd);
331  }
332  if (assigned || !linked_feats.empty()) {
333  cmdProcessor->Execute(link_cmd);
334  }
335 }
336 
337 static string s_GetFeatureLabel(const CSeq_feat_Handle& fh)
338 {
339  const CSeq_feat& feat = *fh.GetOriginalSeq_feat();
340 
341  string label;
342  // cds label will be the same as protein name
343  if (feat.GetData().IsCdregion() && feat.IsSetProduct()) {
345  }
346  // mrna label will be equal to the mRNA's product name
347  else if (feat.GetData().GetSubtype() == CSeqFeatData::eSubtype_mRNA) {
348  label = feat.GetData().GetRna().GetRnaProductName();
349  }
350  return label;
351 }
352 
354 {
355  CRef<CMacroCmdComposite> link_cmd(new CMacroCmdComposite("Link CDS-mRNA pair by label"));
356  bool assigned = AssignFeatureIds(link_cmd);
357 
358  CRef<CCmdComposite> cmd(new CCmdComposite("Actual linking of cds and mRNA pairs by label"));
359  CScope& scope = m_TopSeqEntry.GetScope();
360 
361  // loop through CDS features, finding mRNA partner by label
362  set<CConstRef<CSeq_feat> > linked_mRNAs;
363  for (CFeat_CI cds_it(m_TopSeqEntry, SAnnotSelector(CSeqFeatData::e_Cdregion)); cds_it; ++cds_it) {
364  CConstRef<CSeq_feat> cds_feat = cds_it->GetOriginalSeq_feat();
365  string cds_label = s_GetFeatureLabel(*cds_it);
366 
367  for (CFeat_CI mrna_it(m_TopSeqEntry, SAnnotSelector(CSeqFeatData::eSubtype_mRNA)); mrna_it; ++mrna_it) {
368  CConstRef<CSeq_feat> mrna = mrna_it->GetOriginalSeq_feat();
369  string mrna_label = s_GetFeatureLabel(*mrna_it);
370 
371  if (NStr::EqualNocase(cds_label, mrna_label)) {
372  // check if the mRNA was already linked to a different CDS
373  if (linked_mRNAs.find(mrna) != linked_mRNAs.end()) {
374  continue;
375  }
376 
377  if (SetReciprocalXrefs(*mrna, *cds_feat, cmd)) {
378  linked_mRNAs.insert(mrna);
379  }
380  }
381  }
382  }
383 
384  if (!linked_mRNAs.empty()) {
385  cmd->Execute();
386  link_cmd->AddCommand(*cmd);
387  }
388  if (assigned || !linked_mRNAs.empty()) {
389  cmdProcessor->Execute(link_cmd);
390  }
391 }
392 
393 static bool s_DoesFeatureHasXRef(const CSeq_feat& feat)
394 {
395  FOR_EACH_SEQFEATXREF_ON_SEQFEAT(xref_it, feat) {
396  if ((*xref_it)->IsSetId() && (*xref_it)->GetId().IsLocal()) {
397  return true;
398  }
399  }
400  return false;
401 }
402 
404 {
405  // group cds and mRNAs based on label, and for each CDS/mRNA in a given group find the match with the best location
406  CRef<CMacroCmdComposite> link_cmd(new CMacroCmdComposite("Link CDS-mRNA pair by label and location"));
407  bool assigned = AssignFeatureIds(link_cmd);
408 
409  CRef<CCmdComposite> cmd(new CCmdComposite("Actual linking of cds and mRNA pairs by label and location"));
410  CScope& scope = m_TopSeqEntry.GetScope();
411 
412  SAnnotSelector sel;
415  set<CConstRef<CSeq_feat>> linked_feats;
416  for (CFeat_CI feat_it(m_TopSeqEntry, sel); feat_it; ++feat_it) {
417  CConstRef<CSeq_feat> feat = feat_it->GetOriginalSeq_feat();
418 
419  // skip if it already has an Xrefpp
420  if (s_DoesFeatureHasXRef(*feat) || linked_feats.find(feat) != linked_feats.end()) {
421  continue;
422  }
423 
424  string feat_label = s_GetFeatureLabel(*feat_it);
425 
426  CFeat_CI pair_it = feat_it;
427  ++pair_it;
428  CConstRef<CSeq_feat> best_fit;
429  TSeqPos best_diff = 0;
430  for (; pair_it; ++pair_it) {
431  CConstRef<CSeq_feat> feat_pair = pair_it->GetOriginalSeq_feat();
432  if (feat_pair->GetData().GetSubtype() == feat->GetData().GetSubtype()) {
433  continue;
434  }
435 
436  // skip if it already has an Xref
437  if (s_DoesFeatureHasXRef(*feat_pair) || linked_feats.find(feat_pair) != linked_feats.end()) {
438  continue;
439  }
440 
441  string pair_label = s_GetFeatureLabel(*pair_it);
442 
443  if (NStr::EqualNocase(feat_label, pair_label)) {
444  CConstRef<CSeq_feat> mRNA, cds;
445  if (feat->GetData().IsCdregion()) {
446  cds = feat;
447  mRNA = feat_pair;
448  }
449  else {
450  cds = feat_pair;
451  mRNA = feat;
452  }
453 
455  if (located == sequence::eContains || located == sequence::eSame) {
456  if (best_fit.IsNull()) {
457  best_fit = feat_pair;
458  TSeqPos best_fit_length = best_fit->GetLocation().GetTotalRange().GetLength();
459  TSeqPos feat_length = feat->GetLocation().GetTotalRange().GetLength();
460  best_diff = (best_fit_length > feat_length) ? (best_fit_length - feat_length) : (feat_length - best_fit_length);
461  }
462  else {
463  TSeqPos candidate_length = feat_pair->GetLocation().GetTotalRange().GetLength();
464  TSeqPos feat_length = feat->GetLocation().GetTotalRange().GetLength();
465  TSeqPos current_diff = (candidate_length > feat_length) ? (candidate_length - feat_length) : (feat_length - candidate_length);
466  if (current_diff < best_diff) {
467  best_fit = feat_pair;
468  best_diff = current_diff;
469  }
470  }
471  }
472  }
473  }
474 
475  if (best_fit) {
476  SetReciprocalXrefs(*feat, *best_fit, cmd);
477  linked_feats.insert(feat);
478  linked_feats.insert(best_fit);
479  }
480  }
481 
482  if (!linked_feats.empty()) {
483  cmd->Execute();
484  link_cmd->AddCommand(*cmd);
485  }
486  if (assigned || !linked_feats.empty()) {
487  cmdProcessor->Execute(link_cmd);
488  }
489 }
490 
492 {
493  // assumed that feature IDs are already assigned
494  SAnnotSelector sel;
497  CTSE_Handle tse = m_TopSeqEntry.GetTSE_Handle();
498 
499  CRef<CCmdComposite> link_cmd(new CCmdComposite("Complete CDS and mRNA XRef pair"));
500  bool linked = false;
501  for (CFeat_CI feat_it(m_TopSeqEntry, sel); feat_it; ++feat_it) {
502  CConstRef<CSeq_feat> feat = feat_it->GetOriginalSeq_feat();
503  if (!feat->IsSetXref() || !feat->IsSetId()) {
504  continue;
505  }
506 
507  ITERATE(CSeq_feat::TXref, xref_it, feat->GetXref()) {
508  if ((*xref_it)->IsSetId() && (*xref_it)->GetId().IsLocal() && (*xref_it)->GetId().GetLocal().IsId()) {
509  CSeq_feat_Handle pair_fh; // potential pair feature
510 
511  if (feat->GetData().IsCdregion()) {
512  pair_fh = tse.GetFeatureWithId(CSeqFeatData::eSubtype_mRNA, (*xref_it)->GetId().GetLocal().GetId());
513  }
514  else if (feat->GetData().GetSubtype() == CSeqFeatData::eSubtype_mRNA) {
515  pair_fh = tse.GetFeatureWithId(CSeqFeatData::eSubtype_cdregion, (*xref_it)->GetId().GetLocal().GetId());
516  }
517 
518  if (!pair_fh) {
519  continue;
520  }
521 
522  // check if the other feature has already have an Xref to this feature
523  bool has_xref = false;
524  if (pair_fh.IsSetXref()) {
525  ITERATE(CSeq_feat::TXref, it, pair_fh.GetXref()) {
526  if ((*it)->IsSetId() && (*it)->GetId().IsLocal() && (*it)->GetId().GetLocal().IsId()) {
527  const CFeat_id& pair_feat_id = (*it)->GetId();
528  if (pair_feat_id.Equals(feat->GetId())) {
529  has_xref = true;
530  break;
531  }
532  }
533  }
534  }
535 
536  if (!has_xref) {
537  linked = SetReciprocalXrefs(*feat, *pair_fh.GetOriginalSeq_feat(), link_cmd);
538  }
539  }
540  }
541  }
542 
543  if (linked) {
544  cmdProcessor->Execute(link_cmd);
545  }
546 }
547 
549 {
550  string msg;
551  if (!cds && !mrna) {
552  msg.assign("No features are selected");
553  } else if (cds && !mrna) {
554  msg.assign("No mRNA is selected");
555  } else if (!cds && mrna) {
556  msg.assign("No CDS is selected");
557  }
558 
559  if (!NStr::IsBlank(msg)) {
560  wxMessageBox(ToWxString(msg), wxT("Error"), wxOK | wxICON_ERROR, NULL);
561  return false;
562  }
563 
564  return true;
565 }
566 
567 void CmRNACDSLinker::s_CreateXRefLink(CSeq_feat& from_feat, const CSeq_feat& to_feat)
568 {
570  xref->SetId().Assign(to_feat.GetId());
571  from_feat.SetXref().push_back(xref);
572 }
573 
574 bool CmRNACDSLinker::s_IsDirectXrefBetween(const CSeq_feat& from_feat, const CSeq_feat& to_feat)
575 {
576  if (!from_feat.IsSetXref() || !to_feat.IsSetId()) {
577  return false;
578  }
579 
580  const CFeat_id& feat_id = to_feat.GetId();
581  FOR_EACH_SEQFEATXREF_ON_SEQFEAT(it, from_feat) {
582  if ((*it)->IsSetId()
583  && (*it)->GetId().IsLocal()
584  && feat_id.Equals((*it)->GetId()))
585  return true;
586  }
587 
588  return false;
589 }
590 
592 {
593  vector<CConstRef<CObject> > objs;
594  if (objects.empty()) {
595  wxMessageBox(ToWxString("No feature selected"), ToWxString("Message"),
596  wxOK | wxICON_INFORMATION);
597  return objs;
598  }
599 
600  size_t count_feat = 0;
602  const CObject* sel_obj = it->object.GetPointer();
603  const CSeq_feat* seqfeat = dynamic_cast<const CSeq_feat*>(sel_obj);
604  if (seqfeat) {
605  count_feat++;
606  }
607  }
608 
609  if (count_feat > 1) {
610  wxMessageBox(ToWxString("Please select only one feature"), ToWxString("Message"),
611  wxOK | wxICON_INFORMATION);
612  return objs;
613  }
614 
615  const CObject* sel_obj = objects[0].object.GetPointer();
616  const CSeq_feat* seqfeat = dynamic_cast<const CSeq_feat*>(sel_obj);
617  if (!seqfeat) {
618  wxMessageBox(ToWxString("No feature selected"), ToWxString("Message"),
619  wxOK | wxICON_INFORMATION);
620  return objs;
621  }
622 
623  bool is_cds = seqfeat->IsSetData() && seqfeat->GetData().IsCdregion();
624  bool is_mrna = seqfeat->IsSetData() && (seqfeat->GetData().GetSubtype() == CSeqFeatData::eSubtype_mRNA);
625  if (!is_cds && !is_mrna) {
626  wxMessageBox(ToWxString("A CDS or an mRNA should be selected"), ToWxString("Message"),
627  wxOK | wxICON_INFORMATION);
628  return objs;
629  }
630 
631  CConstRef<CSeq_feat> ref_feat;
632  if (seqfeat->IsSetXref()) {
633  CBioseq_Handle bsh = m_TopSeqEntry.GetScope().GetBioseqHandle(seqfeat->GetLocation());
634  CTSE_Handle tse = bsh.GetTSE_Handle();
635  FOR_EACH_SEQFEATXREF_ON_SEQFEAT (it, *seqfeat) {
636  if ((*it)->IsSetId() && (*it)->GetId().IsLocal() && (*it)->GetId().GetLocal().IsId()) {
638  CSeq_feat_Handle fh = tse.GetFeatureWithId(search_type, (*it)->GetId().GetLocal().GetId());
639  if (fh) {
640  ref_feat = fh.GetSeq_feat();
641  }
642  }
643  }
644  }
645 
646  if (!ref_feat) {
647  wxMessageBox(ToWxString("Unable to find referenced feature"), ToWxString("Message"),
648  wxOK | wxICON_INFORMATION);
649  return objs;
650  }
651 
652  objs.push_back(CConstRef<CObject>(ref_feat.GetPointer()));
653  objs.push_back(objects[0].object);
654  return objs;
655 }
656 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CBioseq_set_Handle –.
void AddCommand(IEditCommand &command)
static const string & s_GetProteinName(const objects::CSeq_feat_Handle &fh)
CFeat_CI –.
Definition: feat_ci.hpp:64
CFeat_id –.
Definition: Feat_id.hpp:66
static TId s_FindHighestFeatureId(const objects::CSeq_entry_Handle &entry)
implements special composite command, which does not call to its internal commands when run the very ...
CObject –.
Definition: ncbiobj.hpp:180
string GetRnaProductName(void) const
Definition: RNA_ref.cpp:145
CScope –.
Definition: scope.hpp:92
ESubtype GetSubtype(void) const
CSeqFeatXref –.
Definition: SeqFeatXref.hpp:66
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeq_feat_Handle GetFeatureWithId(CSeqFeatData::E_Choice type, TFeatureIdInt id) const
Definition: tse_handle.cpp:635
bool AssignFeatureIds(CRef< CMacroCmdComposite > cmd)
bool x_ReplaceExistingFeatIdXrefs(objects::CSeq_feat &from_feat, const objects::CSeq_feat &to_feat)
void LinkByOverlap(ICommandProccessor *cmdProcessor)
void CompleteHalfFormedXrefPairs(ICommandProccessor *cmdProcessor)
static void s_CreateXRefLink(objects::CSeq_feat &from_feat, const objects::CSeq_feat &to_feat)
static bool s_IsDirectXrefBetween(const objects::CSeq_feat &from_feat, const objects::CSeq_feat &to_feat)
bool ReplaceExistingXrefs(const objects::CSeq_feat &mrna, const objects::CSeq_feat &cds, CRef< CCmdComposite > cmd)
void LinkSelectedFeatures(TConstScopedObjects &objects, ICommandProccessor *cmdProcessor)
void LinkByLabelAndLocation(ICommandProccessor *cmdProcessor)
objects::CSeq_entry_Handle m_TopSeqEntry
bool SetReciprocalXrefs(const objects::CSeq_feat &mrna, const objects::CSeq_feat &cds, CRef< CCmdComposite > cmd)
void LinkByLabel(ICommandProccessor *cmdProcessor)
void LinkByProduct(ICommandProccessor *cmdProcessor)
vector< CConstRef< CObject > > GetReferencedmRNA_CDS(TConstScopedObjects &objects)
returns the pair of cross-referenced mRNA and CDS features, when one of them is selected
bool x_OkForLinking(CConstRef< objects::CSeq_feat > mrna, CConstRef< objects::CSeq_feat > cds)
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
const_iterator end() const
Definition: map.hpp:152
bool empty() const
Definition: map.hpp:149
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
bool empty() const
Definition: set.hpp:133
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
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
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual bool Equals(const CSerialObject &object, ESerialRecursionMode how=eRecursive) const
Check if both objects contain the same values.
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
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
sequence::ECompare Compare(const CSeq_loc &loc1, const CSeq_loc &loc2, CScope *scope)
Returns the sequence::ECompare containment relationship between CSeq_locs.
ECompare
@ fCompareOverlapping
Check if seq-locs are overlapping.
@ eOverlap_CheckIntRev
1st is a subset of 2nd with matching boundaries
@ eContains
First CSeq_loc contains second.
@ eSame
CSeq_locs contain each other.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
const CFeat_id & GetId(void) const
const CSeq_feat::TXref & GetXref(void) const
bool IsSetId(void) const
const CTSE_Handle & GetTSE_Handle(void) const
Get CTSE_Handle of containing TSE.
TClass GetClass(void) const
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
virtual CConstRef< CSeq_feat > GetSeq_feat(void) const
bool IsSetXref(void) const
bool IsSetClass(void) const
CConstRef< CSeq_feat > GetOriginalSeq_feat(void) const
const TId & GetId(void) const
SAnnotSelector & IncludeFeatSubtype(TFeatSubtype subtype)
Include feature subtype in the search.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:1401
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
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 CRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:726
position_type GetLength(void) const
Definition: range.hpp:158
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
static const char label[]
TXref & SetXref(void)
Assign a value to Xref data member.
Definition: Seq_feat_.hpp:1314
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
bool IsCdregion(void) const
Check if variant Cdregion is selected.
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
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Feat_id_.hpp:353
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetId(TId &value)
Assign a value to Id data member.
Definition: Seq_feat_.cpp:73
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Seq_feat_.hpp:892
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
vector< CRef< CSeqFeatXref > > TXref
Definition: Seq_feat_.hpp:122
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
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
#define wxT(x)
Definition: muParser.cpp:41
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define EDIT_EACH_XREF_ON_SEQFEAT(Itr, Var)
#define FOR_EACH_SEQFEATXREF_ON_SEQFEAT(Itr, Var)
FOR_EACH_SEQFEATXREF_ON_SEQFEAT EDIT_EACH_SEQFEATXREF_ON_SEQFEAT.
SAnnotSelector –.
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Sat May 25 14:19:41 2024 by modify_doxy.py rev. 669887