Handle subseq when the parent is on the minus strand
[mussa.git] / alg / seq_span.cpp
index bf9a3dc3664bb72d40a613a28521795db1265402..1eb5e9344982cce4cf04b1b6ce364a14149de3a9 100644 (file)
@@ -113,6 +113,14 @@ SeqSpan::SeqSpan(const SeqSpanRef parent_,
     throw sequence_invalid_strand("unrecognized strand identifier");
     break;
   }
+  
+  // Ack the complexity increases!
+  // If our parent is on the minus strand, we need to adjust the start
+  // and count to look like we're selecting from the right side of the 
+  // parent sequence (AKA the start of the minus strand)
+  if (parent and parent->strand() == MinusStrand) {
+    seq_start = parent->start() + parent->size() - (start_ + seq_count);
+  }
 }
 
 //////