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

Go to the SVN repository for this file.

1 /* $Id: cmd_propagate_feat.cpp 42666 2019-04-01 14:27:25Z 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: Frank Ludwig, adapting code by Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
37 
40 
41 
42 void PropagateToTarget(CRef<CCmdComposite> composite, const vector<CConstRef<CSeq_feat>>& feat_list,
43  CBioseq_Handle src, CBioseq_Handle target, const CSeq_align& align,
44  bool stop_at_stop, bool cleanup_partials, bool merge_abutting, bool extend_over_gaps, bool create_general_only,
45  CMessageListener_Basic* listener, CObject_id::TId* feat_id)
46 {
49  if (bssh && bssh.CanGetClass() && bssh.GetClass() == CBioseq_set::eClass_nuc_prot)
50  {
51  seh = bssh.GetParentEntry();
52  }
53  edit::CFeaturePropagator propagator(src, target, align, stop_at_stop, cleanup_partials, merge_abutting, extend_over_gaps, listener, feat_id);
54  vector<CRef<CSeq_feat>> prop_feats = propagator.PropagateFeatureList(feat_list);
55  int offset = 1;
56 
57  // The product of the propagated coding region is not set
58  // The location of propagated protein points to the 'src' sequence
59  auto it = prop_feats.begin();
60  while (it != prop_feats.end()) {
61  auto& feat = **it;
62  //LOG_POST(Info << "To be propagated:\n" << MSerial_AsnText << feat);
63 
64  if (feat.IsSetData() && feat.GetData().IsCdregion()) {
65  CRef<CSeq_feat> prot_feat;
66  auto prot_it = it;
67  ++prot_it;
68  if (prot_it != prop_feats.end() &&
69  (*prot_it)->IsSetData() && (*prot_it)->GetData().IsProt()) {
70  prot_feat.Reset(new CSeq_feat);
71  prot_feat->Assign(**prot_it);
72  ++it;
73  }
74  vector<CRef<CSeq_id>> new_prot_id;
75  bool has_product = !CCmdCreateCDS::s_GetProductSequence(feat, target.GetScope()).empty();
76  if (has_product) {
77  string id_label;
78  new_prot_id.push_back(objects::edit::GetNewProtId(target, offset, id_label, create_general_only));
79  offset++;
80  }
81  CRef<CCmdCreateCDS> add_cds(new CCmdCreateCDS(seh, feat, prot_feat, new_prot_id));
82  composite->AddCommand(*add_cds);
83  }
84  else {
85  CRef<CCmdCreateFeatBioseq> add_f(new CCmdCreateFeatBioseq(target, feat));
86  composite->AddCommand(*add_f);
87  }
88  ++it;
89  }
90 }
91 
CRef< objects::CSeq_id > GetNewProtId(objects::CBioseq_Handle bsh, int &offset, string &id_label, bool general_only)
CBioseq_Handle –.
CBioseq_set_Handle –.
void AddCommand(IEditCommand &command)
static string s_GetProductSequence(const objects::CSeq_feat &cds, objects::CScope &scope)
Default implementation of IMessageListener: collects all messages posted.
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
USING_SCOPE(objects)
void PropagateToTarget(CRef< CCmdComposite > composite, const vector< CConstRef< CSeq_feat >> &feat_list, CBioseq_Handle src, CBioseq_Handle target, const CSeq_align &align, bool stop_at_stop, bool cleanup_partials, bool merge_abutting, bool extend_over_gaps, bool create_general_only, CMessageListener_Basic *listener, CObject_id::TId *feat_id)
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
TClass GetClass(void) const
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
bool CanGetClass(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
CScope & GetScope(void) const
Get scope this handle belongs to.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
int offset
Definition: replacements.h:160
Modified on Mon Dec 11 02:37:10 2023 by modify_doxy.py rev. 669887