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

Go to the SVN repository for this file.

1 /* $Id: 5col_export_job.cpp 26968 2012-11-30 18:22:25Z 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 
32 #include <corelib/ncbifile.hpp>
33 
35 #include <gui/objutils/label.hpp>
36 #include <gui/objutils/utils.hpp>
37 
40 
42 
45 
47  SConstScopedObject seqLoc,
48  const wxString& fileName)
49 : CAppJob("5 Column Export"), m_Params(params), m_SeqLoc(seqLoc), m_FileName(fileName)
50 {
51 }
52 
54 {
55  const CSeq_loc* loc =
56  dynamic_cast<const CSeq_loc*> (m_SeqLoc.object.GetPointer());
57  CScope& scope = m_SeqLoc.scope.GetObject();
58 
59  string err_msg;
60 
61  CBioseq_Handle bsh = scope.GetBioseqHandle(*loc);
62  if ( !bsh) {
63  err_msg = "Can't load location: ";
64  CLabel::GetLabel(*loc, &err_msg, CLabel::eDefault, &scope);
65  LOG_POST(Error << err_msg);
66  m_Error.Reset(new CAppJobError(err_msg));
67  return eFailed;
68  }
69 
70 
71  try {
72  CFlatFileConfig ff_config;
73  ff_config.SetFormatFTable();
74 
75  ff_config
78 
79  CFlatFileGenerator ff(ff_config);
81 
82  if (m_Params.GetExactFlevel()) {
83  unsigned long depth;
84  m_Params.GetFeatureDepth().ToULong(&depth);
85  ff.SetAnnotSelector()
86  .SetExactDepth(true)
87  .SetResolveDepth(depth);
88  }
89 
90  CNcbiOfstream ostr(m_FileName.fn_str());
91  ff.Generate(*loc, scope, ostr);
92  }
93  catch (CException& e) {
94  err_msg = "Failed to save file:\n";
95  err_msg += e.GetMsg();
96  }
97 
98  if (err_msg.empty()) {
99  LOG_POST(Info << "C5ColExportJob::Run() Finished " << m_Descr);
100  return eCompleted;
101  } else {
102  m_Error.Reset(new CAppJobError(err_msg));
103  return eFailed;
104  }
105 }
106 
CBioseq_Handle –.
void Generate(CSeq_submit &submit, CScope &scope, CNcbiOstream &os)
CFlatFileConfig & SetShowContigSources(bool val=true)
static unsigned char depth[2 *(256+1+29)+1]
SAnnotSelector & SetResolveDepth(int depth)
SetResolveDepth sets the limit of subsegment resolution in searching annotations. ...
string m_Descr
mutex to sync our internals
C5ColExportParams m_Params
CConstRef< CObject > object
Definition: objects.hpp:52
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:157
void SetFormatFTable(void)
CFlatFileConfig & SetShowContigFeatures(bool val=true)
CRef< CAppJobError > m_Error
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
C5ColExportJob(const C5ColExportParams &params, SConstScopedObject seqLoc, const wxString &fileName)
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
SConstScopedObject m_SeqLoc
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:198
bool GetExactFlevel() const
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1041
CScope –.
Definition: scope.hpp:90
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock, CFileIO, CFileReader, CFileWriter, CFileReaderWriter, CFileException.
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CAppJob - default implementation of IAppJob that could be used as a base class.
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1029
SAnnotSelector & SetAnnotSelector(void)
USING_SCOPE(ncbi::objects)
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1621
TObjectType & GetObject(void)
Get object.
Definition: ncbiobj.hpp:1002
wxString GetFeatureDepth() const
virtual EJobState Run()
implement Run() in derived classes, make sure that exceptions are handled and m_StopRequested flag is...
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:318
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:459
static std::unique_ptr< CParams > params
Definition: wgs_params.cpp:491
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:768
SAnnotSelector & SetExactDepth(bool value=true)
SetExactDepth() specifies that annotations will be searched on the segment level specified by SetReso...
CRef< objects::CScope > scope
Definition: objects.hpp:53
Modified on Fri Apr 20 12:43:07 2018 by modify_doxy.py rev. 546573