libpappsomspp
Library for mass spectrometry
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
 
FastaHandlerInterfacem_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.

29 : m_handler(handler)
30{
31}
FastaHandlerInterface & m_handler
Definition: fastareader.h:48

◆ ~FastaReader()

pappso::FastaReader::~FastaReader ( )

Definition at line 33 of file fastareader.cpp.

34{
35}

Member Function Documentation

◆ parse() [1/2]

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

Definition at line 39 of file fastareader.cpp.

40{
41 if(fastaFile.fileName().isEmpty())
42 {
43 throw PappsoException(QObject::tr("No FASTA file name specified"));
44 }
45 if(fastaFile.open(QIODevice::ReadOnly))
46 {
47 parse(&fastaFile);
48 fastaFile.close();
49 }
50 else
51 {
52 throw PappsoException(QObject::tr("ERROR opening FASTA file %1 for read")
53 .arg(fastaFile.fileName()));
54 }
55}
void parse(QFile &fastaFile)
Definition: fastareader.cpp:39

References parse().

Referenced by parse().

◆ parse() [2/2]

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

Definition at line 58 of file fastareader.cpp.

59{
60
61 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
62 QTextStream p_in(p_inputstream);
63
64
65 QString accession = "";
66 QString sequence = "";
67 // Search accession conta
68 // QTextStream in(p_in);
69 QString line = p_in.readLine();
70 while(!p_in.atEnd())
71 {
72 if(line.startsWith(">"))
73 {
74 if(!accession.isEmpty())
75 {
76 m_handler.setSequence(accession, sequence);
77 }
78 sequence = "";
79 accession = line.remove(0, 1);
80 }
81 else
82 {
83 sequence.append(line);
84 // m_handler.setSequence(line);
85 }
86 line = p_in.readLine();
87 }
88 if(!accession.isEmpty())
89 {
90 sequence.append(line);
91 m_handler.setSequence(accession, sequence);
92 }
93 // p_in->close();
94 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
95}
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.

100{
101
102
103 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
104
105
106 QString accession = "";
107 QString sequence = "";
108 // Search accession conta
109 // QTextStream in(p_in);
110 QString line = p_in.readLine();
111 while(!p_in.atEnd())
112 {
113 if(line.startsWith(">"))
114 {
115 if(!accession.isEmpty())
116 {
117 m_handler.setSequence(accession, sequence);
118 return;
119 }
120 sequence = "";
121 accession = line.remove(0, 1);
122 }
123 else
124 {
125 sequence.append(line);
126 // m_handler.setSequence(line);
127 }
128 line = p_in.readLine();
129 }
130 if(!accession.isEmpty())
131 {
132 sequence.append(line);
133 m_handler.setSequence(accession, sequence);
134 }
135 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
136}

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: