- string seq;
- float red;
- float green;
- float blue;
-
- while(in.good())
- {
- in >> seq >> red >> green >> blue;
- // if we couldn't read this line 'cause we're like at the end of the file
- // try to exit the loop
- if (!in.good())
- break;
- try {
- seq = Sequence::motif_normalize(seq);
- } catch(motif_normalize_error e) {
- clog << "unable to parse " << seq << " skipping" << endl;
- clog << e.what() << endl;
- continue;
- }
- if (red < 0.0 or red > 1.0) {
- clog << "invalid red value " << red << ". must be in range [0..1]"
- << endl;
- continue;
- }
- if (green < 0.0 or green > 1.0) {
- clog << "invalid green value " << green << ". must be in range [0..1]"
- << endl;
- continue;
- }
- if (blue < 0.0 or blue > 1.0) {
- clog << "invalid blue value " << blue << ". must be in range [0..1]"
- << endl;
- continue;
- }
- if (motif_sequences.find(seq) == motif_sequences.end()) {
- // sequence wasn't found
- motif_sequences.insert(seq);
- Color c(red, green, blue);
- color_mapper->appendInstanceColor("motif", seq, c);
- } else {
- clog << "sequence " << seq << " was already defined skipping"
- << endl;
- continue;
- }
+ std::string data;
+ const char *alphabet = Alphabet::dna_cstr;
+ motif_parser::ParsedMotifs parsed_motifs(motif_sequences, color_mapper);
+
+ // slurp our data into a string
+ std::streamsize bytes_read = 1;
+ while (in.good() and bytes_read) {
+ const std::streamsize bufsiz=512;
+ char buf[bufsiz];
+ bytes_read = in.readsome(buf, bufsiz);
+ data.append(buf, buf+bytes_read);