Changeset 732 for cpp/frams/_demos/genoconv_test.cpp
- Timestamp:
- 02/15/18 00:42:07 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/genoconv_test.cpp
r727 r732 27 27 in_format = 'x'; 28 28 } 29 SString convert(SString &i, MultiMap *map ) { return SString("after conversion..."); }29 SString convert(SString &i, MultiMap *map, bool using_checkpoints) { return SString("after conversion..."); } 30 30 ~GenoConv_Test() {} 31 31 }; … … 42 42 } 43 43 44 SString convert(SString &i, MultiMap *map )44 SString convert(SString &i, MultiMap *map, bool using_checkpoints) 45 45 { 46 46 Model mod; … … 53 53 return mod.getF0Geno().getGenes(); 54 54 } 55 55 56 56 ~GenoConv_Test2() {} 57 57 }; … … 70 70 mapsupport = 1; 71 71 } 72 SString convert(SString &in, MultiMap *map );72 SString convert(SString &in, MultiMap *map, bool using_checkpoints); 73 73 ~GenoConv_Test3() {} 74 74 }; 75 75 76 76 /** main converting routine - most important: direct conversion map example */ 77 SString GenoConv_Test3::convert(SString &in, MultiMap *map )77 SString GenoConv_Test3::convert(SString &in, MultiMap *map, bool using_checkpoints) 78 78 { 79 79 SString dst; … … 116 116 } 117 117 118 // arguments: 119 // genotype (or - meaning "read from stdin") [default: X] 120 // target format [default: 0] 121 // "checkpoints" (just write this exact word) [default: not using checkpoints] 118 122 int main(int argc, char *argv[]) 119 123 { … … 146 150 src = "X"; 147 151 char dst = (argc > 2) ? *argv[2] : '0'; 152 bool using_checkpoints = (argc > 3) ? (strcmp(argv[3], "checkpoints") == 0) : false; 148 153 149 154 printf("*** Source genotype:\n"); … … 151 156 printGen(g1); 152 157 MultiMap m; 153 Geno g2 = g1.getConverted(dst, &m );158 Geno g2 = g1.getConverted(dst, &m, using_checkpoints); 154 159 printf("*** Converted to f%c:\n", dst); 155 160 printGen(g2); 156 if (m.isEmpty()) 157 printf("(conversion map not available)\n"); 161 162 if (using_checkpoints) 163 { // using Model with checkpoints 164 Model m1(g2, false, true);//true=using_checkpoints 165 printf("\nModel built from the converted f%c genotype has %d checkpoints\n", g2.getFormat(), m1.getCheckpointCount()); 166 Model m2(g1, false, true);//true=using_checkpoints 167 printf("Model built from the source f%c genotype has %d checkpoints\n", g1.getFormat(), m2.getCheckpointCount()); 168 // accessing individual checkpoint models (if available) 169 if (m1.getCheckpointCount() > 0) 170 { 171 int c = m1.getCheckpointCount() / 2; 172 Model *cm = m1.getCheckpoint(c); 173 printf("Checkpoint #%d (%d parts, %d joint, %d neurons)\n%s", c, cm->getPartCount(), cm->getJointCount(), cm->getNeuroCount(), cm->getF0Geno().getGenesAndFormat().c_str()); 174 } 175 } 158 176 else 159 { 160 printf("Conversion map:\n"); 161 m.print(); 162 printConvMap(g1.getGenes(), g2.getGenes(), m); 163 printf("Reverse conversion map:\n"); 164 MultiMap rm; 165 rm.addReversed(m); 166 rm.print(); 167 printConvMap(g2.getGenes(), g1.getGenes(), rm); 168 } 169 170 Model mod1(g1, 1); 171 printf("\nModel map for f%c genotype:\n", g1.getFormat()); 172 printModelMap(g1.getGenes(), mod1.getMap()); 173 mod1.getMap().print(); 174 Model mod2(g2, 1); 175 printf("\nModel map for f%c genotype:\n", g2.getFormat()); 176 printModelMap(g2.getGenes(), mod2.getMap()); 177 mod2.getMap().print(); 177 { // there is no mapping for checkpoints so it's nothing interesting to see here in the checkpoints mode 178 if (m.isEmpty()) 179 printf("(conversion map not available)\n"); 180 else 181 { 182 printf("Conversion map:\n"); 183 m.print(); 184 printConvMap(g1.getGenes(), g2.getGenes(), m); 185 printf("Reverse conversion map:\n"); 186 MultiMap rm; 187 rm.addReversed(m); 188 rm.print(); 189 printConvMap(g2.getGenes(), g1.getGenes(), rm); 190 } 191 192 Model mod1(g1, 1); 193 printf("\nModel map for f%c genotype:\n", g1.getFormat()); 194 printModelMap(g1.getGenes(), mod1.getMap()); 195 MultiMap mod1combined; 196 mod1combined.addCombined(mod1.getMap(), getModelDisplayMap()); 197 mod1combined.print(); 198 Model mod2(g2, 1); 199 printf("\nModel map for f%c genotype:\n", g2.getFormat()); 200 printModelMap(g2.getGenes(), mod2.getMap()); 201 MultiMap mod2combined; 202 mod2combined.addCombined(mod2.getMap(), getModelDisplayMap()); 203 mod2combined.print(); 204 } 178 205 return 0; 179 206 }
Note: See TracChangeset
for help on using the changeset viewer.