Last change
on this file since 786 was
780,
checked in by Maciej Komosinski, 7 years ago
|
Added sources for genetic encodings fB, fH, fL
|
File size:
900 bytes
|
Rev | Line | |
---|
[780] | 1 | #ifndef _FB_GENERAL_H_ |
---|
| 2 | #define _FB_GENERAL_H_ |
---|
| 3 | |
---|
| 4 | #include <frams/util/sstring.h> |
---|
| 5 | |
---|
| 6 | class fB_GenoHelpers |
---|
| 7 | { |
---|
| 8 | public: |
---|
| 9 | static int geneCount(SString geno) |
---|
| 10 | { |
---|
| 11 | int start = 0; |
---|
| 12 | int count = -1; |
---|
| 13 | do { |
---|
| 14 | count++; |
---|
| 15 | start = geno.indexOf("aa", start) + 1; // +1 is for progress, starting codons can overlap |
---|
| 16 | } while (start - 1 != -1); |
---|
| 17 | return count; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | static SString getGene(int i, SString genotype, int &start, int &end) |
---|
| 21 | { |
---|
| 22 | start = 0; |
---|
| 23 | int count = -1; |
---|
| 24 | do { |
---|
| 25 | count++; |
---|
| 26 | start = genotype.indexOf("aa", start) + 1; |
---|
| 27 | } while (start - 1 != -1 && count != i); |
---|
| 28 | if (start - 1 == -1) // there is no gene with a given "i" |
---|
| 29 | { |
---|
| 30 | start = -1; |
---|
| 31 | end = -1; |
---|
| 32 | return ""; |
---|
| 33 | } |
---|
| 34 | end = start; |
---|
| 35 | end = genotype.indexOf("zz", end); |
---|
| 36 | if (end == -1) end = genotype.len(); |
---|
| 37 | else end += 2; |
---|
| 38 | start -= 1; |
---|
| 39 | return genotype.substr(start, end - start); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | private: |
---|
| 43 | fB_GenoHelpers() {} |
---|
| 44 | }; |
---|
| 45 | |
---|
| 46 | #endif // _FB_GENERAL_H_ |
---|
Note: See
TracBrowser
for help on using the repository browser.