pappso::FastaReader Class Reference

`#include <fastareader.h>`

## Public Member Functions

| FastaReader (FastaHandlerInterface &handler)
| ~FastaReader ()
void | parse (QFile &fastaFile)
void | parse (QIODevice *p_inputstream)

## Protected Member Functions

void | parseOnlyOne (QTextStream &p_in)

## Private Attributes

friend | FastaFileIndexer
FastaHandlerInterface & | m_handler

## Detailed Description

Definition at line 33 of file fastareader.h.

## Constructor & Destructor Documentation

## FastaReader()

pappso::FastaReader::FastaReader | ( | FastaHandlerInterface & | handler | ) |

Definition at line 29 of file fastareader.cpp.

: m_handler(handler)
{
}
pappso::FastaReader::m_handler
FastaHandlerInterface & m_handler
Definition: fastareader.h:48

## ~FastaReader()

pappso::FastaReader::~FastaReader | ( |  | ) |

Definition at line 33 of file fastareader.cpp.

{
}

## Member Function Documentation

## parse() [1/2]

void pappso::FastaReader::parse | ( | QFile & | fastaFile | ) |

Definition at line 39 of file fastareader.cpp.

{
if(fastaFile.fileName().isEmpty())
{
throw PappsoException(QObject::tr("No FASTA file name specified"));
}
if(fastaFile.open(QIODevice::ReadOnly))
{
parse(&fastaFile);
fastaFile.close();
}
else
{
throw PappsoException(QObject::tr("ERROR opening FASTA file %1 for read")
.arg(fastaFile.fileName()));
}
}
pappso::FastaReader::parse
void parse(QFile &fastaFile)
Definition: fastareader.cpp:39

## parse() [2/2]

void pappso::FastaReader::parse | ( | QIODevice * | p_inputstream | ) |

Definition at line 58 of file fastareader.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
QTextStream p_in(p_inputstream);
QString accession = "";
QString sequence = "";
// Search accession conta
// QTextStream in(p_in);
QString line = p_in.readLine();
while(!p_in.atEnd())
{
if(line.startsWith(">"))
{
if(!accession.isEmpty())
{
m_handler.setSequence(accession, sequence);
}
sequence = "";
accession = line.remove(0, 1);
}
else
{
sequence.append(line);
// m_handler.setSequence(line);
}
line = p_in.readLine();
}
if(!accession.isEmpty())
{
sequence.append(line);
m_handler.setSequence(accession, sequence);
}
// p_in->close();
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}
pappso::FastaHandlerInterface::setSequence
virtual void setSequence(const QString &description, const QString &sequence)=0

References m_handler, and pappso::FastaHandlerInterface::setSequence().

## parseOnlyOne()

void pappso::FastaReader::parseOnlyOne | ( | QTextStream & | p_in | ) |

protected

Definition at line 99 of file fastareader.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
QString accession = "";
QString sequence = "";
// Search accession conta
// QTextStream in(p_in);
QString line = p_in.readLine();
while(!p_in.atEnd())
{
if(line.startsWith(">"))
{
if(!accession.isEmpty())
{
m_handler.setSequence(accession, sequence);
return;
}
sequence = "";
accession = line.remove(0, 1);
}
else
{
sequence.append(line);
// m_handler.setSequence(line);
}
line = p_in.readLine();
}
if(!accession.isEmpty())
{
sequence.append(line);
m_handler.setSequence(accession, sequence);
}
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}

References m_handler, and pappso::FastaHandlerInterface::setSequence().

Referenced by pappso::FastaFileIndexer::getSequenceByIndex().

## Member Data Documentation

## FastaFileIndexer

friend pappso::FastaReader::FastaFileIndexer

private

Definition at line 35 of file fastareader.h.

## m_handler

FastaHandlerInterface& pappso::FastaReader::m_handler

private

Definition at line 48 of file fastareader.h.

Referenced by parse(), and parseOnlyOne().

The documentation for this class was generated from the following files:

- pappsomspp/fasta/fastareader.h
- pappsomspp/fasta/fastareader.cpp