1 | // This file is a part of the Framsticks GDK library. |
---|
2 | // Copyright (C) 2002-2011 Szymon Ulatowski. See LICENSE.txt for details. |
---|
3 | // Refer to http://www.framsticks.com/ for further information. |
---|
4 | |
---|
5 | #include "genotypeloader.h" |
---|
6 | |
---|
7 | /** |
---|
8 | @file |
---|
9 | Sample code: Loading genotypes from Framsticks files |
---|
10 | |
---|
11 | \include loader_test.cpp |
---|
12 | */ |
---|
13 | |
---|
14 | int main(int argc,char*argv[]) |
---|
15 | { |
---|
16 | puts("This example shows how to load genotypes from the standard Framsticks genotype file"); |
---|
17 | if (argc<2) |
---|
18 | { |
---|
19 | puts("(Please give the file name as command line argument)"); |
---|
20 | return 1; |
---|
21 | } |
---|
22 | |
---|
23 | long count=0,totalsize=0; |
---|
24 | MiniGenotypeLoader loader(argv[1]); |
---|
25 | // using char* constructor (passing the file name to open) |
---|
26 | MiniGenotype *loaded; |
---|
27 | while(loaded=loader.loadNextGenotype()) |
---|
28 | { // if loaded != NULL then the "org:" object data was |
---|
29 | // loaded into MiniGenotype object |
---|
30 | count++; |
---|
31 | totalsize+=loaded->genotype.len(); |
---|
32 | printf("%d. %s\t(%d characters)\n",count,(const char*)loaded->name,loaded->genotype.len()); |
---|
33 | } |
---|
34 | // the loop repeats until loaded==NULL, which could be beacause of error |
---|
35 | if (loader.getStatus()==MiniGenotypeLoader::OnError) |
---|
36 | printf("Error: %s",(const char*)loader.getError()); |
---|
37 | // (otherwise it was the end of the file) |
---|
38 | |
---|
39 | printf("\ntotal: %d items, %d characters\n",count,totalsize); |
---|
40 | return 0; |
---|
41 | } |
---|