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

Go to the SVN repository for this file.

1 /* $Id: rm_object_loader.cpp 35156 2016-03-31 13:34:10Z 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 
29 
30 #include <ncbi_pch.hpp>
31 
33 
34 #include <util/icanceled.hpp>
35 
38 
39 #include <gui/objutils/label.hpp>
40 
42 
44 
47 
49  : m_FileNames(filenames)
50 {
51 }
52 
54 {
55  return m_Objects;
56 }
57 
59 {
60  return "Loading RepeatMasker Output Files";
61 }
62 
64 {
65  return true;
66 }
67 
69 {
71  CRef<CScope> scope(new CScope(*obj_mgr));
72  scope->AddDefaults();
73 
74  ITERATE(vector<wxString>, it, m_FileNames) {
75  if (canceled.IsCanceled())
76  return false;
77 
78  CRef<CErrorContainer> errCont;
79  const wxString& fn = *it;
80 
81  try {
83 
85  reader.SetCanceler(&canceled);
86  errCont.Reset(new CErrorContainer(100));
87  CRef<CSeq_annot> annot(reader.ReadSeqAnnot(file.GetIstream(), errCont.GetPointer()));
88  x_UpdateHTMLResults(fn, errCont);
89  errCont.Reset();
90 
91  string label;
92  CLabel::GetLabel(*annot, &label, CLabel::eDefault, scope);
93  m_Objects.push_back(SObject(*annot, label));
94  }
95  catch (const CException& e) {
96  x_UpdateHTMLResults(fn, errCont, e.GetMsg());
97  }
98  catch (const exception& e) {
99  x_UpdateHTMLResults(fn, errCont, e.what());
100  }
101  }
102 
103  return true;
104 }
105 
107 {
108  x_ShowErrorsDlg(wxT("RepeatMasker import errors"));
109  return true;
110 }
111 
CErrorContainer.
void SetCanceler(ICanceled *=nullptr)
Implements a concrete class for reading RepeatMasker output from tabular form and rendering it as ASN...
Definition: rm_reader.hpp:690
CRef< CSeq_annot > ReadSeqAnnot(ILineReader &lr, ILineErrorListener *pMessageListener=0)
Read an object from a given line reader, render it as a single Seq-annot, if possible.
Definition: rm_reader.cpp:775
void x_ShowErrorsDlg(const wxString &title)
void x_UpdateHTMLResults(const wxString &object, objects::ILineErrorListener *errCont, const string &exception="", const string &error_msg="", const wxString &objectName=wxT("File:"))
CScope –.
Definition: scope.hpp:92
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
vector< SObject > TObjects
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
CRMObjectLoader(const vector< wxString > &filenames)
virtual TObjects & GetObjects()
vector< wxString > m_FileNames
virtual bool PostExecute()
virtual string GetDescription() const
virtual bool PreExecute()
virtual bool Execute(ICanceled &canceled)
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
@ eDefault
Definition: label.hpp:73
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
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
virtual bool IsCanceled(void) const =0
static const char label[]
FILE * file
#define wxT(x)
Definition: muParser.cpp:41
The Object manager core.
static int filenames
Definition: pcregrep.c:172
USING_SCOPE(objects)
Modified on Sun Apr 21 03:38:22 2024 by modify_doxy.py rev. 669887