]> ruin.nu Git - germs.git/blobdiff - src/reverseaction.h
Only show models with positive score, and convert the enum to strings
[germs.git] / src / reverseaction.h
index 0330597a90b775c7da1ed89fb118ee59482e1241..006c9eb4de9df4446b27ccaee6da4068d435a4a2 100644 (file)
 #define __REVERSEACTION_H__
 
 #include "sortaction.h"
+#include "genealgorithms.h"
+
+#include <algorithm>
+#include <sstream>
+
 /**
  * Reverses an interval
  *
@@ -35,6 +40,10 @@ class ReverseAction : public SortAction{
                 */
                ReverseAction(size_t i, size_t j): SortAction(0),_i(i),_j(j){
                }
+               ReverseAction(Interval i): SortAction(0){
+                       _i = std::min(i.first,i.second);
+                       _j = std::max(i.first,i.second)-1;
+               }
 
                /**
                 * Applies the sort action on the gene order
@@ -51,6 +60,15 @@ class ReverseAction : public SortAction{
                        }
                        return false;
                }
+
+               /**
+                * Gives a string representation of the action, for output
+                */
+               virtual std::string toString() const{
+                       std::ostringstream os;
+                       os << "[" << _i << "," << _j << "]";
+                       return os.str();
+               }
        private:
                size_t _i;
                size_t _j;