| 212 | |
| 213 | |
| 214 | int countPattern(const string &seq, const string &pattern, bool ignoreCase) |
| 215 | { |
| 216 | string s = seq; |
| 217 | string p = pattern; |
| 218 | // standardize the seq and the pattern |
| 219 | // if case should be ignored |
| 220 | if (ignoreCase) { |
| 221 | toUpperCase(s); |
| 222 | toUpperCase(p); |
| 223 | } |
| 224 | int patternLength = p.size(); |
| 225 | int patternCount = 0; |
| 226 | for(unsigned int i = 0; i < s.length(); i++) { |
| 227 | if (s.substr(i,patternLength) == p) { |
| 228 | patternCount++; |
| 229 | } |
| 230 | } |
| 231 | return patternCount; |
| 232 | } |
| 233 | |
| 234 |
no test coverage detected