NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
CAgpReader Class Reference

Search Toolkit Book for CAgpReader

Detects scaffolds, object boundaries, errors that involve 2 consecutive lines, and is intended as a superclass for more complex readers. More...

#include <objtools/readers/agp_util.hpp>

+ Inheritance diagram for CAgpReader:
+ Collaboration diagram for CAgpReader:

Public Types

enum  EFinalize { eFinalize_No , eFinalize_Yes }
 Whether or not the function should call Finalize() when it's done successfully. More...
 

Public Member Functions

 CAgpReader (CAgpErr *arg, EAgpVersion agp_version=eAgpVersion_auto)
 
 CAgpReader (EAgpVersion agp_version=eAgpVersion_auto)
 
virtual ~CAgpReader ()
 
virtual int ReadStream (CNcbiIstream &is, EFinalize eFinalize=eFinalize_Yes)
 Read an AGP file from the given input stream. More...
 
int ReadStream (CNcbiIstream &is, bool bFinalize)
 Deprecated backward-compatibility wrapper. More...
 
virtual int Finalize ()
 This is called at the end of the file, usually automatically but can be called manually if the automatic call was intentionally disabled. More...
 
virtual string GetErrorMessage (const string &filename=NcbiEmptyString)
 Return a string with one (or two, depending on error) source line(s) on which the error occured, along with the error message(s) themselves. More...
 
bool ProcessThisRow ()
 Invoked from ReadStream(), after the row has been parsed, and seldom needs to be invoked by user. More...
 
virtual void SetVersion (EAgpVersion ver)
 Change what AGP version to use for the next input that's read. More...
 
CAgpErrGetErrorHandler ()
 
void SetErrorHandler (CAgpErr *arg)
 
EAgpVersion GetVersion ()
 

Protected Member Functions

virtual void OnScaffoldEnd ()
 
virtual void OnObjectChange ()
 
virtual void OnGapOrComponent ()
 
virtual bool OnError ()
 
virtual void OnComment ()
 

Protected Attributes

EAgpVersion m_agp_version
 
bool m_at_beg
 
bool m_at_end
 
bool m_line_skipped
 
bool m_prev_line_skipped
 
bool m_new_obj
 
bool m_content_line_seen
 
int m_error_code
 
CRef< CAgpRowm_prev_row
 
CRef< CAgpRowm_this_row
 
int m_line_num
 
int m_prev_line_num
 
string m_line
 

Private Member Functions

void Init ()
 
void x_CheckPragmaComment (void)
 

Private Attributes

CRef< CAgpErrm_AgpErr
 

Detailed Description

Detects scaffolds, object boundaries, errors that involve 2 consecutive lines, and is intended as a superclass for more complex readers.

Definition at line 326 of file agp_util.hpp.

Member Enumeration Documentation

◆ EFinalize

Whether or not the function should call Finalize() when it's done successfully.

Enumerator
eFinalize_No 
eFinalize_Yes 

Definition at line 336 of file agp_util.hpp.

Constructor & Destructor Documentation

◆ CAgpReader() [1/2]

CAgpReader::CAgpReader ( CAgpErr arg,
EAgpVersion  agp_version = eAgpVersion_auto 
)

Definition at line 977 of file agp_util.cpp.

References Init(), and m_AgpErr.

◆ CAgpReader() [2/2]

CAgpReader::CAgpReader ( EAgpVersion  agp_version = eAgpVersion_auto)

Definition at line 970 of file agp_util.cpp.

References Init(), and m_AgpErr.

◆ ~CAgpReader()

CAgpReader::~CAgpReader ( )
virtual

Definition at line 997 of file agp_util.cpp.

Member Function Documentation

◆ Finalize()

int CAgpReader::Finalize ( void  )
virtual

This is called at the end of the file, usually automatically but can be called manually if the automatic call was intentionally disabled.

Returns
Returns error code on whether the "Finalize" operation succeeded, where 0 means "okay".

Reimplemented in CAgpToSeqEntry.

Definition at line 1160 of file agp_util.cpp.

References CAgpErr::fAtPrevLine, CAgpRow::GapEndsScaffold(), CAgpRow::GapValidAtObjectEnd(), CAgpRow::GetObject(), CAgpRow::is_gap, m_AgpErr, m_at_beg, m_at_end, m_error_code, m_new_obj, m_prev_line_skipped, m_prev_row, CAgpErr::Msg(), OnObjectChange(), OnScaffoldEnd(), and CAgpErr::W_GapObjEnd.

Referenced by CAgpToSeqEntry::Finalize(), ProcessStream(), and ReadStream().

◆ GetErrorHandler()

CAgpErr* CAgpReader::GetErrorHandler ( void  )
inline

Definition at line 481 of file agp_util.hpp.

References m_AgpErr.

Referenced by CAgpValidateReader::OnGapOrComponent(), and CAgpRenumber::OnObjectChange().

◆ GetErrorMessage()

string CAgpReader::GetErrorMessage ( const string filename = NcbiEmptyString)
virtual

Return a string with one (or two, depending on error) source line(s) on which the error occured, along with the error message(s) themselves.

Parameters
filenameIf filename is non-empty, each line is preceded with "FILENAME:" (useful when reading several files).

Definition at line 1194 of file agp_util.cpp.

References CAgpErr::AppliesTo(), CAgpErr::fAtNone, CAgpErr::fAtPrevLine, CAgpErr::fAtThisLine, CAgpErr::GetErrorMessage(), i2s, m_AgpErr, m_line, m_line_num, m_prev_line_num, m_prev_row, and CAgpRow::ToString().

Referenced by CAgpObjectLoader::Execute(), and ProcessStream().

◆ GetVersion()

EAgpVersion CAgpReader::GetVersion ( void  )
inline

Definition at line 483 of file agp_util.hpp.

References m_agp_version.

◆ Init()

void CAgpReader::Init ( void  )
private

Definition at line 989 of file agp_util.cpp.

References m_agp_version, m_AgpErr, m_at_beg, m_prev_line_num, m_prev_row, m_this_row, and CAgpRow::New().

Referenced by CAgpReader().

◆ OnComment()

virtual void CAgpReader::OnComment ( )
inlineprotectedvirtual

Reimplemented in CAgpRenumber, and CAgpValidateReader.

Definition at line 466 of file agp_util.hpp.

Referenced by ReadStream().

◆ OnError()

virtual bool CAgpReader::OnError ( )
inlineprotectedvirtual

Reimplemented in CAgpRenumber, and CAgpValidateReader.

Definition at line 450 of file agp_util.hpp.

Referenced by ProcessThisRow(), and ReadStream().

◆ OnGapOrComponent()

virtual void CAgpReader::OnGapOrComponent ( void  )
inlineprotectedvirtual

Reimplemented in CAgpToSeqEntry, CAgpRenumber, and CAgpValidateReader.

Definition at line 445 of file agp_util.hpp.

Referenced by ProcessThisRow().

◆ OnObjectChange()

virtual void CAgpReader::OnObjectChange ( )
inlineprotectedvirtual

Reimplemented in CAgpRenumber, and CAgpValidateReader.

Definition at line 439 of file agp_util.hpp.

Referenced by Finalize(), and ProcessThisRow().

◆ OnScaffoldEnd()

virtual void CAgpReader::OnScaffoldEnd ( )
inlineprotectedvirtual

Reimplemented in CAgpValidateReader.

Definition at line 431 of file agp_util.hpp.

Referenced by Finalize(), and ProcessThisRow().

◆ ProcessThisRow()

bool CAgpReader::ProcessThisRow ( )

◆ ReadStream() [1/2]

int CAgpReader::ReadStream ( CNcbiIstream is,
bool  bFinalize 
)
inline

Deprecated backward-compatibility wrapper.

Deprecated:

Definition at line 358 of file agp_util.hpp.

References eFinalize_No, eFinalize_Yes, and ReadStream().

◆ ReadStream() [2/2]

int CAgpReader::ReadStream ( CNcbiIstream is,
EFinalize  eFinalize = eFinalize_Yes 
)
virtual

Read an AGP file from the given input stream.

Parameters
isThe input stream we're reading the AGP from
eFinalizeIf we successfully read the AGP file, this param determines whether or not we call Finalize().
Returns
Returns the error code, where 0 means "okay". Non-zero error codes are usually values from the unnamed enum in CAgpErr that has E_ColumnCount, E_EmptyColumn, etc., but subclasses can have their own custom error codes, so other values can appear.

Definition at line 1084 of file agp_util.cpp.

References CAgpErr::Clear(), CAgpRow::cols, CAgpErr::E_NoValidLines, eAgpVersion_2_0, eFinalize_Yes, CAgpRow::eGapContig, CAgpErr::fAtNone, Finalize(), CAgpRow::FromString(), CAgpRow::gap_type, CAgpRow::is_gap, CAgpRow::linkage, m_agp_version, m_AgpErr, m_at_beg, m_at_end, m_content_line_seen, m_error_code, m_line, m_line_num, m_line_skipped, m_prev_line_skipped, m_prev_row, m_this_row, CAgpErr::Msg(), NcbiEmptyString, NcbiGetline(), OnComment(), OnError(), ProcessThisRow(), CAgpErr::W_CommentsAfterStart, CAgpErr::W_NoEolAtEof, and x_CheckPragmaComment().

Referenced by CAgpObjectLoader::Execute(), ProcessStream(), ReadStream(), CFileLoader::x_LoadAGP(), CAgpConverter::x_ReadAgpEntries(), CFormatGuessEx::x_TryAgp(), CAgpValidateApplication::x_ValidateFile(), and CMultiReaderApp::xProcessAgp().

◆ SetErrorHandler()

void CAgpReader::SetErrorHandler ( CAgpErr arg)

Definition at line 1187 of file agp_util.cpp.

References m_AgpErr, m_prev_row, m_this_row, and CAgpRow::SetErrorHandler().

Referenced by CAgpRenumber::CAgpRenumber().

◆ SetVersion()

void CAgpReader::SetVersion ( EAgpVersion  ver)
virtual

Change what AGP version to use for the next input that's read.

Please prefer setting the version in the CAgpReader constructor instead and if SetVersion must be used, it's best to use it at a clean stopping point. (Example: immediately after a Finalize() call)

Definition at line 1075 of file agp_util.cpp.

References m_agp_version, m_prev_row, m_this_row, and CAgpRow::SetVersion().

Referenced by CAgpRow::ParseGapCols(), and CAgpValidateApplication::x_ValidateFile().

◆ x_CheckPragmaComment()

void CAgpReader::x_CheckPragmaComment ( void  )
private

Member Data Documentation

◆ m_agp_version

EAgpVersion CAgpReader::m_agp_version
protected

◆ m_AgpErr

CRef<CAgpErr> CAgpReader::m_AgpErr
private

◆ m_at_beg

bool CAgpReader::m_at_beg
protected

◆ m_at_end

bool CAgpReader::m_at_end
protected

◆ m_content_line_seen

bool CAgpReader::m_content_line_seen
protected

Definition at line 406 of file agp_util.hpp.

Referenced by ReadStream().

◆ m_error_code

int CAgpReader::m_error_code
protected

◆ m_line

string CAgpReader::m_line
protected

◆ m_line_num

int CAgpReader::m_line_num
protected

◆ m_line_skipped

bool CAgpReader::m_line_skipped
protected

◆ m_new_obj

bool CAgpReader::m_new_obj
protected

Definition at line 404 of file agp_util.hpp.

Referenced by Finalize(), and ProcessThisRow().

◆ m_prev_line_num

int CAgpReader::m_prev_line_num
protected

Definition at line 417 of file agp_util.hpp.

Referenced by GetErrorMessage(), Init(), and ProcessThisRow().

◆ m_prev_line_skipped

bool CAgpReader::m_prev_line_skipped
protected

Definition at line 401 of file agp_util.hpp.

Referenced by Finalize(), CAgpRenumber::OnError(), ProcessThisRow(), and ReadStream().

◆ m_prev_row

CRef<CAgpRow> CAgpReader::m_prev_row
protected

◆ m_this_row

CRef<CAgpRow> CAgpReader::m_this_row
protected

The documentation for this class was generated from the following files:
Modified on Tue Feb 27 05:54:29 2024 by modify_doxy.py rev. 669887