#ifndef _FB_GENERAL_H_ #define _FB_GENERAL_H_ #include class fB_GenoHelpers { public: static int geneCount(SString geno) { int start = 0; int count = -1; do { count++; start = geno.indexOf("aa", start) + 1; // +1 is for progress, starting codons can overlap } while (start - 1 != -1); return count; } static SString getGene(int i, SString genotype, int &start, int &end) { start = 0; int count = -1; do { count++; start = genotype.indexOf("aa", start) + 1; } while (start - 1 != -1 && count != i); if (start - 1 == -1) // there is no gene with a given "i" { start = -1; end = -1; return ""; } end = start; end = genotype.indexOf("zz", end); if (end == -1) end = genotype.len(); else end += 2; start -= 1; return genotype.substr(start, end - start); } private: fB_GenoHelpers() {} }; #endif // _FB_GENERAL_H_