1 #include "alg/conserved_path.hpp"
8 ConservedPath::ConservedPath()
14 ConservedPath::ConservedPath(const ConservedPath::ConservedPath& other)
16 track_indexes(other.track_indexes)
20 ConservedPath::ConservedPath(double s, ConservedPath::path_type path)
26 void ConservedPath::clear()
29 track_indexes.clear();
32 ConservedPath::path_element&
33 ConservedPath::operator[](ConservedPath::size_type index)
35 return track_indexes[index];
38 bool operator==(const ConservedPath::ConservedPath& a,
39 const ConservedPath::ConservedPath& b)
41 // this isn't good as score is now a double
42 return ( (a.score == b.score)
43 and (a.track_indexes.size() == b.track_indexes.size())
44 and (a.track_indexes == b.track_indexes));
47 bool operator!=(const ConservedPath::ConservedPath& a,
48 const ConservedPath::ConservedPath& b)
53 std::ostream& operator<<(std::ostream& out, const ConservedPath& path)
55 out << "<path score=" << path.score
56 << " len=" << path.track_indexes.size();
57 if (path.track_indexes.size() > 0)
59 // print the first element
60 ConservedPath::const_iterator itor = path.begin();
62 // print the remaining elements
73 // if we had no elements just close the block
79 void ConservedPath::push_back(const ConservedPath::path_element& element)
81 track_indexes.push_back(element);
84 void ConservedPath::pop_back()
86 track_indexes.pop_back();
89 ConservedPath::size_type ConservedPath::size() const
91 return track_indexes.size();
94 ConservedPath::iterator ConservedPath::begin()
96 return track_indexes.begin();
99 ConservedPath::const_iterator ConservedPath::begin() const
101 return track_indexes.begin();
104 ConservedPath::iterator ConservedPath::end()
106 return track_indexes.end();
109 ConservedPath::const_iterator ConservedPath::end() const
111 return track_indexes.end();
114 bool ConservedPath::nextTo(const ConservedPath& next) const
116 if (size() != next.size() ) {
117 throw runtime_error("paths must be the same length");
119 ConservedPath::const_iterator this_itor = begin();
120 ConservedPath::const_iterator next_itor = next.begin();
121 for (; this_itor != end(); ++this_itor, ++next_itor)
123 if ( (*this_itor + 1) != *next_itor )
129 vector<bool> ConservedPath::reverseComplimented() const
131 vector<bool> reversed;
132 for (ConservedPath::const_iterator this_itor = begin();
137 reversed.push_back(true);
139 reversed.push_back(false);
145 /////////////////////
146 ExtendedConservedPath::ExtendedConservedPath()
152 ExtendedConservedPath::ExtendedConservedPath(const ExtendedConservedPath& other)
153 : ConservedPath(other),
154 window_size(other.window_size)
158 ExtendedConservedPath::ExtendedConservedPath(int win_size, ConservedPath other)
159 : ConservedPath(other),
160 window_size(win_size)
164 ExtendedConservedPath::ExtendedConservedPath(int win_size,
166 ConservedPath::path_type p)
167 : ConservedPath(s, p),
168 window_size(win_size)
172 ExtendedConservedPath& ExtendedConservedPath::extend(int growth)
174 window_size += growth;
176 // What does this actually do? Tristan's code was doing this operation
177 // but I don't understand how it properly adjusts reverse compliment
179 for(ConservedPath::iterator path_i = begin();