libpappsomspp
Library for mass spectrometry
pappso::FastaFileIndexer Class Reference

#include <fastafileindexer.h>

Inheritance diagram for pappso::FastaFileIndexer:
pappso::FastaFileIndexerInterface

Public Member Functions

 FastaFileIndexer (const QFileInfo &fastaFile)
 
 FastaFileIndexer (const FastaFileIndexer &other)
 
virtual ~FastaFileIndexer ()
 
void getSequenceByIndex (FastaHandlerInterface &fasta_handler, std::size_t index) override
 
void open () override
 
void close () override
 
FastaFileIndexerSPtr makeFastaFileIndexerSPtr () const
 

Private Member Functions

void parseFastaFile ()
 

Private Attributes

QFile m_fasta_file
 
std::vector< qint64 > m_indexArray
 
QTextStream * mpa_sequenceTxtIn = nullptr
 

Detailed Description

Definition at line 69 of file fastafileindexer.h.

Constructor & Destructor Documentation

◆ FastaFileIndexer() [1/2]

pappso::FastaFileIndexer::FastaFileIndexer ( const QFileInfo &  fastaFile)

Definition at line 57 of file fastafileindexer.cpp.

60  : m_fasta_file(other.m_fasta_file.fileName())
61 {
62 
63  m_indexArray = other.m_indexArray;
64  mpa_sequenceTxtIn = nullptr;
65 }
67 {
68  close();
69 }
70 
71 
72 void
74 {
75 

◆ FastaFileIndexer() [2/2]

pappso::FastaFileIndexer::FastaFileIndexer ( const FastaFileIndexer other)

Definition at line 77 of file fastafileindexer.cpp.

85  { // eat Windows \r\n

◆ ~FastaFileIndexer()

pappso::FastaFileIndexer::~FastaFileIndexer ( )
virtual

Definition at line 84 of file fastafileindexer.cpp.

85  { // eat Windows \r\n
86  position++;
87  bin_in >> char_in;

Member Function Documentation

◆ close()

void pappso::FastaFileIndexer::close ( )
overridevirtual

Implements pappso::FastaFileIndexerInterface.

Definition at line 156 of file fastafileindexer.cpp.

158  {
159 
160  qDebug() << " realpos=" << mpa_sequenceTxtIn->pos();
161  ;
162  if(!seek_ok)
163  {
164 

References mpa_sequenceTxtIn.

◆ getSequenceByIndex()

void pappso::FastaFileIndexer::getSequenceByIndex ( FastaHandlerInterface fasta_handler,
std::size_t  index 
)
overridevirtual

Implements pappso::FastaFileIndexerInterface.

Definition at line 167 of file fastafileindexer.cpp.

174  {
175  throw ExceptionOutOfRange(
176  QObject::tr("ERROR reading FASTA file %1 : sequence index %2 "
177  "unreachable, array size=%3")
178  .arg(m_fasta_file.fileName())
179  .arg(index)
180  .arg(m_indexArray.size()));
181  }
182 }
183 
184 
187 {
188 
189  return std::make_shared<FastaFileIndexer>(*this);
190 }
191 } // namespace pappso

◆ makeFastaFileIndexerSPtr()

FastaFileIndexerSPtr pappso::FastaFileIndexer::makeFastaFileIndexerSPtr ( ) const

Definition at line 204 of file fastafileindexer.cpp.

◆ open()

void pappso::FastaFileIndexer::open ( )
overridevirtual

Implements pappso::FastaFileIndexerInterface.

Definition at line 140 of file fastafileindexer.cpp.

141  {
142  delete mpa_sequenceTxtIn;
143  mpa_sequenceTxtIn = nullptr;
144  m_fasta_file.close();
145  }
146 }
147 
148 void
149 FastaFileIndexer::getSequenceByIndex(FastaHandlerInterface &fasta_handler,
150  std::size_t index)
151 {
152  open();
153 

References m_fasta_file, and mpa_sequenceTxtIn.

◆ parseFastaFile()

void pappso::FastaFileIndexer::parseFastaFile ( )
private

Definition at line 91 of file fastafileindexer.cpp.

94  {
95 
96  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
97  // << " index=" << m_indexArray.size()
98  // << " position=" << position;
99  m_indexArray.push_back(position);
100  }
101  // eat line
102  position++;
103  bin_in >> char_in;
104  while(!bin_in.atEnd() && (char_in > (qint8)20))
105  {
106  position++;
107  bin_in >> char_in;
108  }
109  position++;
110  bin_in >> char_in;
111 
112  if(!bin_in.atEnd() && (char_in < (qint8)21))
113  { // eat Windows \r\n
114  position++;
115  bin_in >> char_in;
116  }
117  }
118  qDebug();
119 }
120 
121 void
123 {
124  if(mpa_sequenceTxtIn != nullptr)
125  return;
126  if(m_fasta_file.open(QIODevice::ReadOnly))
127  {
128  mpa_sequenceTxtIn = new QTextStream(&m_fasta_file);
129  }
130  else
131  {
132  throw PappsoException(QObject::tr("ERROR opening FASTA file %1 for read")
133  .arg(m_fasta_file.fileName()));
134  }
135 }
136 
137 void

References m_indexArray.

Member Data Documentation

◆ m_fasta_file

QFile pappso::FastaFileIndexer::m_fasta_file
private

Definition at line 89 of file fastafileindexer.h.

Referenced by open().

◆ m_indexArray

std::vector<qint64> pappso::FastaFileIndexer::m_indexArray
private

Definition at line 90 of file fastafileindexer.h.

Referenced by parseFastaFile().

◆ mpa_sequenceTxtIn

QTextStream* pappso::FastaFileIndexer::mpa_sequenceTxtIn = nullptr
private

Definition at line 91 of file fastafileindexer.h.

Referenced by close(), and open().


The documentation for this class was generated from the following files:
pappso::FastaFileIndexer::mpa_sequenceTxtIn
QTextStream * mpa_sequenceTxtIn
Definition: fastafileindexer.h:91
pappso::FastaFileIndexer::m_fasta_file
QFile m_fasta_file
Definition: fastafileindexer.h:89
pappso::FastaFileIndexer::~FastaFileIndexer
virtual ~FastaFileIndexer()
Definition: fastafileindexer.cpp:84
pappso::FastaFileIndexer::m_indexArray
std::vector< qint64 > m_indexArray
Definition: fastafileindexer.h:90
pappso::FastaFileIndexer::open
void open() override
Definition: fastafileindexer.cpp:140
pappso::FastaFileIndexer::parseFastaFile
void parseFastaFile()
Definition: fastafileindexer.cpp:91
pappso::FastaFileIndexer::close
void close() override
Definition: fastafileindexer.cpp:156
pappso::FastaFileIndexer::makeFastaFileIndexerSPtr
FastaFileIndexerSPtr makeFastaFileIndexerSPtr() const
Definition: fastafileindexer.cpp:204
pappso::FastaFileIndexerSPtr
std::shared_ptr< FastaFileIndexer > FastaFileIndexerSPtr
Definition: fastafileindexer.h:66
pappso::FastaFileIndexer::getSequenceByIndex
void getSequenceByIndex(FastaHandlerInterface &fasta_handler, std::size_t index) override
Definition: fastafileindexer.cpp:167