File: FASTAReader.hpp

package info (click to toggle)
pbseqlib 5.3.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 7,020 kB
  • sloc: cpp: 77,246; python: 331; sh: 103; makefile: 42
file content (82 lines) | stat: -rw-r--r-- 1,888 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef _BLASR_FASTA_READER_HPP_
#define _BLASR_FASTA_READER_HPP_

#include <cstdint>
#include <string>

#include <pbdata/FASTASequence.hpp>
#include <pbdata/metagenome/SequenceIndexDatabase.hpp>

class FASTAReader
{
protected:
    GenomeLength fileSize;
    int fileDes;
    char *filePtr;
    GenomeLength curPos;
    int padding;
    char endOfReadDelim;
    char readStartDelim;
    bool doToUpper;
    unsigned char *convMat;
    //
    // Quick check to see how much to read.
    //
    void SetFileSize();

    void ReadTitle(GenomeLength &p, char *&title, int &titleLength);

public:
    bool computeMD5;
    std::string curReadMD5;

    void Init();

    FASTAReader();

    FASTAReader(std::string &fileName);

    void SetSpacePadding(int _padding);

    void SetToUpper();

    //
    // Synonym for Init() for consistency.
    //
    int Initialize(std::string &seqInName);

    int Init(std::string &seqInName, int passive = 0);

    void AdvanceToTitleStart(GenomeLength &p, char delim = '>');

    void CheckValidTitleStart(GenomeLength &p, char delim = '>');

    GenomeLength ReadAllSequencesIntoOne(FASTASequence &seq,
                                         SequenceIndexDatabase<FASTASequence> *seqDBPtr = NULL);

    void ReadTitle(GenomeLength &p, FASTASequence &seq);

    int GetNext(FASTASequence &seq);
    /*
       Advance to the read nSeq forward.

input: nSeq, the number of sequences to skip.
output:
returns 1 if after advancing nSeq sequences, the file pointer is pointing to
a new sequence.
0 otherwise.
A return value of 0 will signal that the file is done being processed if it is
iterting over reads.
*/
    int Advance(int nSeq);

    int CriticalGetNext(FASTASequence &seq);

    int ConcatenateNext(FASTASequence &cur);

    void Close();

    void ReadAllSequences(std::vector<FASTASequence> &sequences);
};

#endif  // _BLASR_FASTA_READER_HPP_