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

Go to the SVN repository for this file.

1 /* $Id: text_item_seq_loc.cpp 37249 2016-12-20 18:04:04Z katargir $
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: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include "text_item_seq_loc.hpp"
37 
38 
39 #include <gui/objutils/label.hpp>
40 
41 #include <objmgr/seq_map_ci.hpp>
42 
43 #include <objmgr/util/sequence.hpp>
44 #include <serial/iterator.hpp>
45 
48 
50 {
51  CTextItemSeq_loc* itemObject = new CTextItemSeq_loc(object, mode, 1);
52  if (mode != kFull)
53  return itemObject;
54 
56  group->AddItem(new CTextItemSeq_loc(object, mode, 1), false);
57 
58  const objects::CSeq_loc* seq_loc =
59  dynamic_cast<const objects::CSeq_loc*>(object.object.GetPointerOrNull());
60  CScope* scope = object.scope;
61 
62  try {
63  CBioseq_Handle bsh = scope->GetBioseqHandle(*seq_loc);
64  if (bsh) {
66  bsh.GetSeqMap().ResolvedRangeIterator (scope,
67  seq_loc->GetTotalRange().GetFrom(),
68  seq_loc->GetTotalRange().GetLength(),
69  seq_loc->GetStrand(),
70  -1,
72  for ( ; segI; ++segI ) {
73  if (cancel && cancel->IsCanceled())
74  break;
75 
76  if (segI.GetType() != CSeqMap::eSeqRef)
77  continue;
78  CSeq_id_Handle seq_id_handle = segI.GetRefSeqid();
79  int c_start = segI.GetRefPosition();
80  int c_stop = segI.GetRefEndPosition() - 1;
81  CRef<CSeq_loc> s_loc(new CSeq_loc(
82  const_cast<CSeq_id&>(*seq_id_handle.GetSeqId()),
83  c_start, c_stop,
85 
86  SConstScopedObject object(s_loc, scope);
87  group->AddItem(new CTextItemSeq_loc(object, kBrief, 2), false);
88  }
89  }
90  } catch (const exception&) {
91  }
92 
93  if (group->GetItemCount() > 1) {
94  return new CExpandItem(itemObject, group, false);
95  } else {
96  delete group;
97  return itemObject;
98  }
99 }
100 
102 {
103  x_Indent(ostream);
104 
105  string text;
107  ostream.WriteMultiLineText(text);
108  return;
109 }
110 
CBioseq_Handle –.
size_t GetItemCount() const
void AddItem(ITextItem *item, bool updatePositions=true)
CRef< objects::CScope > m_Scope
CConstRef< CObject > m_Object
CScope –.
Definition: scope.hpp:92
Iterator over CSeqMap.
Definition: seq_map_ci.hpp:252
void WriteMultiLineText(const string &text)
CTextItemSeq_loc(SConstScopedObject &object, EMode mode, int indent)
static ITextItem * CreateObject(SConstScopedObject &object, EMode mode, ICanceled *cancel=0)
virtual void x_RenderText(CStyledTextOStream &ostream, CTextPanelContext *context) const
virtual void x_Indent(CStyledTextOStream &ostream) const
Definition: text_item.cpp:166
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
@ eContent
Definition: label.hpp:62
CConstRef< CSeq_id > GetSeqId(void) const
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
const CSeqMap & GetSeqMap(void) const
Get sequence map.
TSeqPos GetRefPosition(void) const
Definition: seq_map_ci.hpp:693
bool GetRefMinusStrand(void) const
Definition: seq_map_ci.hpp:700
CSeqMap::ESegmentType GetType(void) const
Definition: seq_map_ci.hpp:651
CSeq_id_Handle GetRefSeqid(void) const
The following function makes sense only when the segment is a reference to another seq.
Definition: seq_map_ci.cpp:312
TSeqPos GetRefEndPosition(void) const
Definition: seq_map_ci.hpp:707
CSeqMap_CI ResolvedRangeIterator(CScope *scope, TSeqPos from, TSeqPos length, ENa_strand strand=eNa_strand_plus, size_t maxResolve=size_t(-1), TFlags flags=fDefaultFlags) const
Iterate segments in the range with specified strand coordinates.
Definition: seq_map.cpp:868
@ fFindRef
Definition: seq_map.hpp:137
@ eSeqRef
reference to Bioseq
Definition: seq_map.hpp:100
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
virtual bool IsCanceled(void) const =0
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
static void text(MDB_val *v)
Definition: mdb_dump.c:62
mdb_mode_t mode
Definition: lmdb++.h:38
USING_SCOPE(objects)
Modified on Fri Sep 20 14:57:31 2024 by modify_doxy.py rev. 669887