Changeset 802 for cpp/frams/genetics/fB/fB_general.h
- Timestamp:
- 06/07/18 17:41:59 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fB/fB_general.h
r797 r802 11 11 { 12 12 public: 13 static int geneCount( SStringgeno)13 static int geneCount(const SString& geno) 14 14 { 15 15 int start = 0; … … 27 27 } 28 28 29 static SString getGene(int i, SString genotype, int &start, int &end) 29 static SString getNonNestedGene(int i, const SString& genotype, int &start, int &end) 30 { 31 int count = -1; 32 start = 0; 33 int tmp = 0; 34 SString result = ""; 35 do { 36 count++; 37 if (start < genotype.len()) 38 result = getNextGene(start, genotype, tmp, start); 39 else 40 start = -1; 41 } while (start != -1 && count < i); 42 start = tmp; 43 end = start; 44 return result; 45 } 46 47 static int geneCountNoNested(const SString& geno) 48 { 49 int start = 0; 50 int count = -1; 51 int tmp = 0; 52 do { 53 count++; 54 if (start < geno.len()) 55 getNextGene(start, geno, tmp, start); 56 else 57 start = -1; 58 } while (start != -1); 59 return count; 60 } 61 62 static SString getGene(int i, const SString& genotype, int &start, int &end) 30 63 { 31 64 start = 0; … … 62 95 } 63 96 97 static SString getNextGene(int searchbegin, const SString& genotype, int &start, int &end) 98 { 99 start = searchbegin; 100 int count = -1; 101 do { 102 count++; 103 start = genotype.indexOf("aa", start) + 1; 104 int quotecount = 0; 105 for (int q = 0; q < start; q++) if (genotype[q] == '\"') quotecount++; 106 if (quotecount % 2 != 0) count--; // 'aa' sequence is within quotes 107 } while (start - 1 != -1 && count != 0); 108 if (start - 1 == -1) // there is no gene with a given "i" 109 { 110 start = -1; 111 end = -1; 112 return ""; 113 } 114 end = start; 115 int quotecount = 0; 116 do { 117 quotecount = 0; 118 end = genotype.indexOf("zz", end); 119 if (end != -1) 120 { 121 for (int q = start; q < end; q++) if (genotype[q] == '\"') quotecount++; 122 if (quotecount % 2 != 0) end++; 123 } 124 } while (quotecount % 2 != 0 && end != -1); 125 126 if (end == -1) end = genotype.len(); 127 else end += 2; 128 start -= 1; 129 return genotype.substr(start, end - start); 130 } 64 131 private: 65 132 fB_GenoHelpers() {}
Note: See TracChangeset
for help on using the changeset viewer.