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

Go to the SVN repository for this file.

1 /* $Id: fasta_align_export_job.cpp 38593 2017-06-01 17:31:50Z evgeniev $
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: Vladislav Evgeniev
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <corelib/ncbifile.hpp>
34 #include <gui/objutils/utils.hpp>
36 #include <objmgr/scope.hpp>
37 
38 
41 
43 : CAppJob("FASTA Alignment Export"), m_Params(params)
44 {
45 }
46 
47 
48 
50 {
51  try {
53  const CSeq_align* align = dynamic_cast<const CSeq_align*> (seq_align.object.GetPointer());
54  CScope& scope = seq_align.scope.GetObject();
55 
56  CNcbiOfstream ostr(m_Params.GetFileName().fn_str());
57  CAlnWriter writer(scope, ostr, CWriterBase::fNormal);
58  writer.WriteAlign(*align);
59  }
60  catch (const CException& e) {
61  string err_msg;
62  err_msg = "Failed to export FASTA alignment:\n";
63  err_msg += e.GetMsg();
64  m_Error.Reset(new CAppJobError(err_msg));
65  return eFailed;
66  }
67 
68  LOG_POST(Info << "CFastaAlignExportJob::Run() Finished " << m_Descr);
69  return eCompleted;
70  }
71 
bool WriteAlign(const CSeq_align &align, const string &name="", const string &descr="") override
Write a raw Seq-align to the internal output stream.
Definition: aln_writer.cpp:84
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
CAppJob - default implementation of IAppJob that could be used as a base class.
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
CFastaAlignExportParams m_Params
CFastaAlignExportJob(const CFastaAlignExportParams &params)
const SConstScopedObject & GetObject() const
CScope –.
Definition: scope.hpp:92
USING_SCOPE(ncbi::objects)
#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:226
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
CRef< CAppJobError > m_Error
CRef< objects::CScope > scope
Definition: objects.hpp:53
string m_Descr
mutex to sync our internals
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
CConstRef< CObject > object
Definition: objects.hpp:52
@ eCompleted
Definition: app_job.hpp:89
@ eFailed
Definition: app_job.hpp:90
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TObjectType & GetObject(void)
Get object.
Definition: ncbiobj.hpp:1011
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Modified on Tue Nov 28 02:22:37 2023 by modify_doxy.py rev. 669887