add function for marking 'N' regions
[mussa.git] / alg / glsequence.cpp
index 340a9ada0719b475753e9780fb082fbfe974a5d1..89150d3a0068aba3cf1d169cf6b322ab4c88bacf 100644 (file)
@@ -66,6 +66,59 @@ DrawableRef GlSequence::copy_drawable(DrawableRef old_d)
   return d;
 }
 
+SeqSpanRef GlSequence::make_undefined_sequence_annotation(
+  Drawable::draw_func_ptr draw,
+  size_type start,
+  size_type count)
+{
+  // create all the components of our annotation
+  // (should seq_i-start_i 
+  SeqSpanRef empty_seq(seq->subseq(start, count)); 
+  AnnotationsRef empty_seq_annot(new Annotations("null"));
+  DrawableRef drawable(default_drawable());
+  // glue everything to gether
+  drawable->setDrawFunction(draw);
+  empty_seq->setAnnotations(empty_seq_annot);
+  empty_seq->setDrawable(drawable);
+  return empty_seq;
+}
+
+void GlSequence::add_annotations_for_undefined_sequence(Drawable::draw_func_ptr draw)
+{
+  Sequence::const_iterator start_i = begin();
+  Sequence::const_iterator seq_i = begin();
+  Sequence::const_iterator end_i = end();
+  
+  Sequence::const_iterator start_block_i = end();
+  
+  for(; seq_i != end_i; ++seq_i)
+  {
+    // need a better set of characters to serch for
+    if (*seq_i == 'N' or *seq_i == 'n') {
+      if (start_block_i == end_i) {
+        start_block_i = seq_i;
+      }
+    } else {
+      if (start_block_i != end_i) {
+        // we got one.
+        size_type start = start_block_i - start_i;
+        size_type count = seq_i - start_block_i;
+        // add the annotation
+        add_annotation(make_undefined_sequence_annotation(draw, start, count));        
+        // reset our counter...
+        start_block_i = end_i;
+      }
+    }
+  }
+  // catch stuff at the end
+  if( start_block_i != end_i ) {
+    size_type start = start_block_i - start_i;
+    size_type count = seq_i - start_block_i;
+    add_annotation(make_undefined_sequence_annotation(draw, start, count));        
+  }
+}
+
+
 void GlSequence::setX(float value)
 {
   seq->drawable()->setX(value);