JASSv2
instream_document_fasta.h
Go to the documentation of this file.
1 /*
2  INSTREAM_DOCUMENT_FASTA.H
3  -------------------------
4  Copyright (c) 2019 Andrew Trotman
5  Released under the 2-clause BSD license (See:https://en.wikipedia.org/wiki/BSD_licenses)
6 */
14 #pragma once
15 
16 #include <stdint.h>
17 
18 #include <string>
19 
20 #include "slice.h"
21 #include "instream.h"
22 
23 namespace JASS
24  {
25  /*
26  CLASS INSTREAM_DOCUMENT_FASTA
27  -----------------------------
28  */
34  {
35  protected:
36  size_t buffer_size;
37 
38  protected:
39  uint8_t *buffer;
40  uint8_t *buffer_end;
41  size_t buffer_used;
42 
43  protected:
44  /*
45  INSTREAM_DOCUMENT_FASTA::INSTREAM_DOCUMENT_FASTA()
46  --------------------------------------------------
47  */
53  instream_document_fasta(std::shared_ptr<instream> &source, size_t buffer_size);
54 
55  /*
56  INSTREAM_DOCUMENT_FASTA::FETCH()
57  --------------------------------
58  */
64  void fetch(void *buffer, size_t bytes)
65  {
66  buffer_end = (uint8_t *)buffer + source->fetch(buffer, bytes);
67  }
68 
69  public:
70  /*
71  INSTREAM_DOCUMENT_FASTA::INSTREAM_DOCUMENT_FASTA()
72  --------------------------------------------------
73  */
78  instream_document_fasta(const instream_document_fasta &previous) = delete;
79 
80  /*
81  INSTREAM_DOCUMENT_FASTA::INSTREAM_DOCUMENT_FASTA()
82  --------------------------------------------------
83  */
88  instream_document_fasta(std::shared_ptr<instream> &source);
89 
90  /*
91  INSTREAM_DOCUMENT_FASTA::INSTREAM_DOCUMENT_FASTA()
92  --------------------------------------------------
93  */
97  virtual ~instream_document_fasta();
98 
99  /*
100  INSTREAM_DOCUMENT_FASTA::READ()
101  -------------------------------
102  */
107  virtual void read(document &buffer);
108 
109  /*
110  INSTREAM_DOCUMENT_FASTA::UNITTEST()
111  -----------------------------------
112  */
116  static void unittest(void);
117  } ;
118 }
std::shared_ptr< instream > source
If this object is reading from another instream then this is that instream.
Definition: instream.h:48
Read data from an input stream.
Definition: instream.h:45
size_t buffer_used
The number of bytes of buffer that have already been used from buffer (buffer + buffer_used is a poin...
Definition: instream_document_fasta.h:41
Container class representing a document through the indexing pipeline.
Definition: document.h:31
uint8_t * buffer
Pointer to the interal buffer from which documents are extracted. Filled by calling source...
Definition: instream_document_fasta.h:39
Base class for reading data from some input source.
instream_document_fasta(std::shared_ptr< instream > &source, size_t buffer_size)
Protected constructor used to set the size of the internal buffer in the unittest.
Definition: instream_document_fasta.cpp:24
uint8_t * buffer_end
Pointer to the end of the buffer (used to prevent read past EOF).
Definition: instream_document_fasta.h:40
Child class of instream for creating documents from FASTA genome sequence files.
Definition: instream_document_fasta.h:33
static void unittest(void)
Unit test this class.
Definition: instream_document_fasta.cpp:148
virtual ~instream_document_fasta()
Destructor.
Definition: instream_document_fasta.cpp:53
size_t buffer_size
Size of the disk read buffer. Normally 16MB.
Definition: instream_document_fasta.h:36
Slices (also known as string-descriptors) for C++.
void fetch(void *buffer, size_t bytes)
Fetch another block of data from the source.
Definition: instream_document_fasta.h:64
Definition: compress_integer_elias_delta_simd.c:23
virtual void read(document &buffer)
Read the next document from the source instream into document.
Definition: instream_document_fasta.cpp:62