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

Go to the SVN repository for this file.

1 /* $Id: adjust_feats_for_introns.cpp 37208 2016-12-15 15:58:06Z 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: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
32 #include <objmgr/util/feature.hpp>
33 #include <objmgr/util/sequence.hpp>
37 
40 
42 {
43  if (!tse)
44  return CRef<CCmdComposite>(NULL);
45  bool modified = false;
46  CScope &scope = tse.GetScope();
47  CRef<CCmdComposite> composite( new CCmdComposite("Adjust Features for Introns") );
48  for (CFeat_CI feat_ci(tse, subtype); feat_ci; ++feat_ci)
49  {
50  CRef<CSeq_feat> new_feat(new CSeq_feat());
51  new_feat->Assign(feat_ci->GetOriginalFeature());
52  CBioseq_Handle bsh = scope.GetBioseqHandle(feat_ci->GetLocation());
53  if (!bsh)
54  continue;
55  CRef<CSeq_loc> new_loc(new CSeq_loc);
56  new_loc->Assign(feat_ci->GetLocation());
57  for (CFeat_CI intron_ci(bsh, CSeqFeatData::eSubtype_intron); intron_ci; ++intron_ci)
58  {
59  new_loc = sequence::Seq_loc_Subtract(*new_loc, intron_ci->GetLocation(), CSeq_loc::fMerge_All|CSeq_loc::fSort, &scope);
60  }
61  if (!new_loc->Equals(feat_ci->GetLocation()))
62  {
63  if ( sequence::GetCoverage(*new_loc, &scope) == 0)
64  {
65  composite->AddCommand(*CRef<CCmdDelSeq_feat>(new CCmdDelSeq_feat(feat_ci->GetSeq_feat_Handle())));
66  }
67  else
68  {
69  new_feat->SetLocation(*new_loc);
71  composite->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(feat_ci->GetSeq_feat_Handle(), *new_feat)));
72  }
73  modified = true;
74  }
75  }
76 
77  if (!modified)
78  composite.Reset();
79  return composite;
80 }
81 
82 
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
USING_SCOPE(ncbi::objects)
static CRef< CCmdComposite > apply(CSeq_entry_Handle tse, CSeqFeatData::ESubtype subtype)
CBioseq_Handle –.
void AddCommand(IEditCommand &command)
CFeat_CI –.
Definition: feat_ci.hpp:64
CScope –.
Definition: scope.hpp:92
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
#define NULL
Definition: ncbistd.hpp:225
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.
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
Definition: Seq_loc.cpp:337
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
@ fMerge_All
Definition: Seq_loc.hpp:331
TSeqPos GetCoverage(const CSeq_loc &loc, CScope *scope)
Get number of unique bases in the location.
CRef< CSeq_loc > Seq_loc_Subtract(const CSeq_loc &loc1, const CSeq_loc &loc2, CSeq_loc::TOpFlags flags, CScope *scope)
Subtract the second seq-loc from the first one.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
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
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
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
Modified on Wed Sep 04 15:04:09 2024 by modify_doxy.py rev. 669887