-
Notifications
You must be signed in to change notification settings - Fork 2
/
Cfastq-sequences.h
93 lines (75 loc) · 2.04 KB
/
Cfastq-sequences.h
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
83
84
85
86
87
88
89
90
91
92
93
#ifndef CFASTQ_SEQUENCES_H
#define CFASTQ_SEQUENCES_H
#include <iostream>
#include <vector>
#include "CSequence_Mol2_1.h"
#include "CSequences2.h"
#include "CFile/CFile2_1.h"
#include <list>
#include "fastq.h"
#include "faststring2.h"
class fastq_sequences
{
std::list<fastq_record *> list_of_sequences;
public:
fastq_sequences()
{}
// This function wants to have the opened infile as well as the file name.
// The file name is used to print an error message. In the future this could be handled nicer
// e.g. by using the return value and let the caller print the error message.
short read_fastq(CFile &infile, const char *filename, unsigned processing_flag = 1)
{
short status_error_flag = 0;
fastq_record *tmp;
while(status_error_flag == 0)
{
tmp = new fastq_record;
tmp->read_next_record(infile, processing_flag);
if (infile.fail_reason1())
{
std::cerr << "ERROR: Found malformed fastq record starting in line "
<< infile.line()-4 << " of the input file "
<< filename << std::endl;
tmp->print(std::cerr);
return -1;
}
else if (infile.fail() ) // This includes eof.
status_error_flag = 1;
else
list_of_sequences.push_back(tmp);
}
return 0;
}
void print(std::ostream &os)
{
std::list<fastq_record *>::iterator it, it_end;
it = list_of_sequences.begin();
it_end = list_of_sequences.end();
// int count = 0;
while(it != it_end)
{
// os << "Number " << count << std::endl;
(**it).print(os);
++it;
// ++count;
}
}
void add_sequences_to_CSequences_object(CSequences2 *pseqs)
{
std::list<fastq_record *>::iterator it, it_end;
it = list_of_sequences.begin();
it_end = list_of_sequences.end();
while(it != it_end)
{
fastq_record *tmp = *it;
pseqs->add_seq_to_dataset(CSequence_Mol::dna, tmp->get_identifier(), tmp->get_seq(), 'N');
++it;
// ++count;
}
}
unsigned size()
{
return list_of_sequences.size();
}
};
#endif