X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=src%2Fgenealgorithms.h;h=59e8f9caee921c452553829d3b1e66bedf32250b;hb=HEAD;hp=4c938e394bd42fa1ea3eb710239811dd32277e99;hpb=e7953f0050007cd1999d64d985d0a063b9ddc99b;p=germs.git diff --git a/src/genealgorithms.h b/src/genealgorithms.h index 4c938e3..59e8f9c 100644 --- a/src/genealgorithms.h +++ b/src/genealgorithms.h @@ -24,14 +24,23 @@ #include class GeneOrder; +struct Component; -struct Component{ - Component(int b,int e,int s):begin(b),end(e),sign(s){} - int begin; - int end; - int sign; +/** + * Simple interval struct, holds the indexes + information if the interval is + * oriented or not. + */ +struct Interval{ + Interval(size_t f,size_t s,bool o = false):first(f),second(s),oriented(o){} + bool operator==(const Interval& i){ + return first == i.first && second == i.second && oriented == i.oriented; + } + //!The start index for this elementary interval + size_t first; + //!The end interval for this elementary interval + size_t second; + bool oriented; }; -typedef std::pair Interval; /** * Returns the length of the longest increasing sequence and the longest @@ -40,13 +49,20 @@ typedef std::pair Interval; std::pair longestSequences(const GeneOrder& go); /** + * Uses the Robinson-Schensted algorithm on the gene order. Gives the longest + * increasing and decreasing subsequences. */ std::vector > robinsonSchensted(const GeneOrder& go); /** * Counts the number of cycles in the gene order. */ -int countCycles(const GeneOrder& go); +size_t countCycles(const GeneOrder& go); + +/** + * Calculates the inversion distance for this gene order + */ +size_t inversionDistance(const GeneOrder& go); /** * Finds the components in the gene order. @@ -58,5 +74,12 @@ std::vector findComponents(const GeneOrder& go); */ std::vector findIntervals(const GeneOrder& go); +/** + * Creates a list with the intervals at each point. The first and second members + * of the returned Intervals are elementary intervals that start, or end, at the + * specific point. + */ +std::vector findIntervalsAtPoints(const std::vector& intervals); + #endif