Last change
on this file since 141 was
141,
checked in by sz, 10 years ago
|
Improved genotype validation in geno_test and genooper_test (using GenMan?'s genetic operators)
|
-
Property svn:eol-style set to
native
|
File size:
1.2 KB
|
Rev | Line | |
---|
[121] | 1 | // This file is a part of the Framsticks GDK. |
---|
| 2 | // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. |
---|
[109] | 3 | // Refer to http://www.framsticks.com/ for further information. |
---|
| 4 | |
---|
[121] | 5 | #include <frams/genetics/geno.h> |
---|
[109] | 6 | #include <frams/virtfile/stdiofile.h> |
---|
| 7 | #include <frams/util/sstringutils.h> |
---|
[121] | 8 | #include <frams/genetics/defgenoconv.h> |
---|
[141] | 9 | #include <frams/genetics/genman.h> |
---|
[109] | 10 | |
---|
| 11 | /** |
---|
| 12 | @file |
---|
| 13 | Sample code: Testing genotype validity |
---|
| 14 | |
---|
| 15 | \include geno_test.cpp |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes |
---|
| 19 | |
---|
| 20 | int main(int argc,char*argv[]) |
---|
| 21 | { |
---|
[141] | 22 | GenMan gm; |
---|
| 23 | Geno::validators.insert(0,&gm); //GenMan is available in this application so let's use the extended validity checking! |
---|
| 24 | // Note: insert() makes it the first validator in the list, this is important for formats that rely on genetic operators to perform reasonable validation, |
---|
| 25 | // otherwise the default validator (genotype converter) would "win" and most converters are less strict in detecting invalid genotypes. |
---|
[109] | 26 | if (argc<=1) |
---|
| 27 | { |
---|
| 28 | puts("no genotype"); |
---|
| 29 | return 10; |
---|
| 30 | } |
---|
| 31 | SString gen(argv[1]); |
---|
| 32 | if (!strcmp(gen,"-")) |
---|
| 33 | { |
---|
| 34 | gen=0; |
---|
| 35 | StdioFILEDontClose in(stdin); |
---|
| 36 | loadSString(&in,gen); |
---|
| 37 | } |
---|
| 38 | Geno g(gen); |
---|
| 39 | puts(g.isValid()?"valid":"invalid"); |
---|
| 40 | return !g.isValid(); |
---|
| 41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.