2626#include " smithlab_utils.hpp"
2727
2828using std::string;
29+ using std::runtime_error;
2930
3031static bool
3132check_formats (char c, bool &solexa, bool &phred) {
@@ -39,8 +40,8 @@ fastq_score_type(const string filename) {
3940 static const size_t MAX_LINE_SIZE = 1000 ;
4041 std::ifstream f (filename.c_str ());
4142 if (!f)
42- throw SMITHLABException (" cannot open input file " + string ( filename) );
43-
43+ throw runtime_error (" cannot open input file " + filename);
44+
4445 char line[MAX_LINE_SIZE];
4546 bool solexa = true , phred = true ;
4647 size_t line_count = 0 ;
@@ -49,7 +50,7 @@ fastq_score_type(const string filename) {
4950 char *c = line;
5051 while (*c != ' \0 ' && check_formats (*c, solexa, phred)) ++c;
5152 if (!check_formats (*c, solexa, phred))
52- return ((phred) ? FASTQ_Phred : FASTQ_Solexa);
53+ return ((phred) ? FASTQ_Phred : FASTQ_Solexa);
5354 }
5455 ++line_count;
5556 }
@@ -61,25 +62,25 @@ mapped_reads_score_type(const string filename) {
6162 static const size_t MAX_LINE_SIZE = 10000 ;
6263 std::ifstream f (filename.c_str ());
6364 if (!f)
64- throw SMITHLABException (" cannot open input file " + string ( filename) );
65-
65+ throw runtime_error (" cannot open input file " + filename);
66+
6667 char line[MAX_LINE_SIZE];
6768 bool solexa = true , phred = true ;
6869 while (f.getline (line, MAX_LINE_SIZE)) {
6970 size_t space_count = 0 , position = 0 ;
7071 while (space_count < 7 ) {
7172 while (position < MAX_LINE_SIZE && isspace (line[position]))
72- ++position;
73+ ++position;
7374 if (position == MAX_LINE_SIZE)
74- throw SMITHLABException (" line too long in file: " + filename);
75+ throw runtime_error (" line too long in file: " + filename);
7576 while (position < MAX_LINE_SIZE && !isspace (line[position]))
76- ++position;
77+ ++position;
7778 if (position == MAX_LINE_SIZE)
78- throw SMITHLABException (" line too long in file: " + filename);
79+ throw runtime_error (" line too long in file: " + filename);
7980 ++space_count;
8081 }
8182 if (space_count < 7 )
82- throw SMITHLABException (" malformed line in file: " + filename);
83+ throw runtime_error (" malformed line in file: " + filename);
8384 while (position < MAX_LINE_SIZE && isspace (line[position]))
8485 ++position;
8586 char *c = line + position;
0 commit comments