libpappsomspp
Library for mass spectrometry
fastafileindexer.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/fasta/fastafileindexer.h
3  * \date 22/06/2109
4  * \author Olivier Langella
5  * \brief Quick random access to sequences in a fasta file using an index
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  ******************************************************************************/
27 
28 #pragma once
29 
30 #include <QFileInfo>
31 #include <QTextStream>
32 #include <memory>
33 #include "fastahandlerinterface.h"
34 
35 namespace pappso
36 {
38 {
39 
40  public:
41  virtual void open() = 0;
42  virtual void getSequenceByIndex(FastaHandlerInterface &fasta_handler,
43  std::size_t index) = 0;
44 
45  virtual void close() = 0;
46 };
47 
48 class FastaFileIndexer;
49 typedef std::shared_ptr<FastaFileIndexer> FastaFileIndexerSPtr;
50 
52 {
53 
54  public:
55  FastaFileIndexer(const QFileInfo &fastaFile);
56  FastaFileIndexer(const FastaFileIndexer &other);
57  virtual ~FastaFileIndexer();
58 
59  void getSequenceByIndex(FastaHandlerInterface &fasta_handler,
60  std::size_t index) override;
61  void open() override;
62  void close() override;
63 
64 
65  FastaFileIndexerSPtr makeFastaFileIndexerSPtr() const;
66 
67  private:
68  void parseFastaFile();
69 
70  private:
71  QFile m_fasta_file;
72  std::vector<qint64> m_indexArray;
73  QTextStream *mpa_sequenceTxtIn = nullptr;
74 };
75 } // namespace pappso
virtual void getSequenceByIndex(FastaHandlerInterface &fasta_handler, std::size_t index)=0
std::vector< qint64 > m_indexArray
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< FastaFileIndexer > FastaFileIndexerSPtr