int read_sequences(Auto_Unzip & input, int num_seq, Mask sequences[], Fasta::FASTQ_encoding format_type, bool gui_output) { if (&input == NULL) return 0; Fasta read; read.set_FASTQ_type(format_type); int n_seq = 0; { mutex::scoped_lock lock(read_mutex); istream & in = input.filtered(); while (not input.eof() and n_seq < num_seq) { in >> read; if (read.length() > MAX_READ_LENGTH) { cerr << "Read " << read.get_id() << " too long. Max allowed read size is " << MAX_READ_LENGTH << endl; exit(5); } //Reset and take a ref Mask & r = sequences[n_seq] = Mask(); r.set_id(read.get_id()); r.set_sequence(read.get_sequence()); r.set_quality(read.get_quality()); n_seq++; } output_progress(input, gui_output); } return n_seq; }
int read_sequences(Auto_Unzip & first, Auto_Unzip & second, int num_seq, Mask sequences[], Fasta::FASTQ_encoding format_type, bool gui_output) { if (&first == NULL or &second == NULL) return 0; Fasta read; read.set_FASTQ_type(format_type); int n_seq = 0; { mutex::scoped_lock lock(read_mutex); istream & first_in = first.filtered(); istream & second_in = second.filtered(); while (not first.eof() and not second.eof() and (n_seq + 1) < num_seq) { first_in >> read; if (read.length() > MAX_READ_LENGTH) { cerr << "Read " << read.get_id() << " too long. Max allowed read size is " << MAX_READ_LENGTH << endl; exit(5); } Mask & rf = sequences[n_seq]; rf.set_id(read.get_id()); rf.set_sequence(read.get_sequence()); rf.set_quality(read.get_quality()); n_seq++; second_in >> read; if (read.length() > MAX_READ_LENGTH) { cerr << "Read " << read.get_id() << " too long. Max allowed read size is " << MAX_READ_LENGTH << endl; exit(5); } Mask & rs = sequences[n_seq]; rs.set_id(read.get_id()); rs.set_sequence(read.get_sequence()); rs.set_quality(read.get_quality()); n_seq++; //CHECK!! if (rf.id.compare(0, rf.id.size() - 1, rs.id, 0, rs.id.size() - 1) != 0) { ERROR_CHANNEL << "wrong paired reads IDs: '" << rf.id << "' and '" << rs.id << '\'' << endl; exit(2); } } output_progress(first, gui_output); } return n_seq; }