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

Go to the SVN repository for this file.

1 /* $Id: text_fasta.cpp 16877 2008-05-15 01:27:53Z dicuccio $
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: Mike DiCuccio
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
36 
37 #include <gui/utils/clipboard.hpp>
38 #include <objmgr/bioseq_handle.hpp>
40 
41 #include <objmgr/util/sequence.hpp>
42 
45 
46 
47 CFastaTextDisplay::CFastaTextDisplay(int x, int y, int w, int h,
48  const char* label)
49  : CTextEditor(x, y, w, h, label, true)
50 {
51 }
52 
53 
55 {
56 }
57 
58 
60 {
61  m_DataSource.Reset(&ds);
62  Update();
63 }
64 
65 
67 {
68  if ( !buffer() ) {
69  return;
70  }
71 
72  if ( !m_DataSource ) {
73  return;
74  }
75 
76  string str;
78  if (handle) {
79  CConn_MemoryStream ostr;
80  {{
81  CFastaOstream fasta_str(ostr);
84  fasta_str.Write(handle, &m_DataSource->GetLocation());
85  }}
86  ostr.flush();
87  str.resize(ostr.tellp() - CT_POS_TYPE(0));
88  ostr.read(const_cast<char*>(str.data()), str.size());
89  }
90 
91  buffer()->text(str.c_str());
92 }
93 
94 
CBioseq_Handle –.
In-memory stream (a la strstream or stringstream)
FASTA-format output; see also ReadFasta in <objtools/readers/fasta.hpp>
Definition: sequence.hpp:770
const objects::CSeq_loc & GetLocation(void) const
const objects::CBioseq_Handle & GetBioseqHandle(void) const
void SetDataSource(CFastaTextDS &ds)
Definition: text_fasta.cpp:59
CFastaTextDisplay(int x, int y, int w, int h, const char *label=NULL)
Definition: text_fasta.cpp:47
CRef< CFastaTextDS > m_DataSource
Definition: text_fasta.hpp:63
#define true
Definition: bool.h:35
static const char * str(char *buf, int n)
Definition: stats.c:84
virtual void Write(const CSeq_entry_Handle &handle, const CSeq_loc *location=0)
Unspecified locations designate complete sequences; non-empty custom titles override the usual title ...
Definition: sequence.cpp:2727
void SetFlag(EFlags flag)
Definition: sequence.hpp:859
@ fInstantiateGaps
honor specifed gap mode; on by default
Definition: sequence.hpp:774
@ fAssembleParts
assemble FAR delta sequences; on by dflt
Definition: sequence.hpp:773
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
#define CT_POS_TYPE
Definition: ncbistre.hpp:730
static const char label[]
static uint8_t * buffer
Definition: pcre2test.c:1016
USING_SCOPE(objects)
Modified on Fri Sep 20 14:57:13 2024 by modify_doxy.py rev. 669887