source: branches/port5/PROBE_SET/ps_make_sample_db.cxx

Last change on this file was 5390, checked in by westram, 17 years ago
  • TAB-Ex
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3//#include <string.h>
4
5#include <set>
6#ifndef PS_NODE_HXX
7#include "ps_node.hxx"
8#endif
9#ifndef PS_FILEBUFFER_HXX
10#include "ps_filebuffer.hxx"
11#endif
12
13
14
15//  ====================================================
16//  ====================================================
17
18int main( int argc,  char *argv[] ) {
19    // create probe-set-database
20    if (argc < 4) {
21        printf("Missing arguments\n Usage %s <probequality> <probelength> <output filename> [print]\n",argv[0]);
22        exit(1);
23    }
24
25    unsigned short  quality        = atoi(argv[1]);
26    unsigned short  probelength    = atoi(argv[2]);
27    const char     *output_DB_name = argv[3];
28
29    printf( "creating probe-set-database '%s'..", output_DB_name );
30    PS_FileBuffer *ps_db_fb = new PS_FileBuffer( output_DB_name, false );
31    printf( "done\n" );
32
33    // create sample tree
34    printf( "making sample tree..." );
35    PS_NodePtr root(new PS_Node(-1));
36
37    for (int id = 10; id < 15; ++id) {
38        PS_NodePtr new_child( new PS_Node( id ) );
39
40        if (id % 2 != 0) {
41            for (int pnr = 0; pnr < 5; ++pnr ) {
42                PS_ProbePtr new_probe( new PS_Probe );
43                new_probe->length     = probelength;
44                new_probe->quality    = quality;
45                new_probe->GC_content = (unsigned short) (random() % probelength);
46                new_child->addProbe( new_probe );
47            }
48        }
49
50        root->addChild( new_child );
51    }
52
53    for (PS_NodeMapIterator child = root->getChildrenBegin(); child != root->getChildrenEnd(); ++child ) {
54
55        for (int id = child->second->getNum()*100; id < (child->second->getNum()*100)+10; ++id) {
56
57            PS_NodePtr new_child( new PS_Node( id ) );
58
59            if (random() % 3 != 0) {
60                for (int pnr = 0; pnr < 50; ++pnr ) {
61                    PS_ProbePtr new_probe( new PS_Probe );
62                    new_probe->length     = probelength;
63                    new_probe->quality    = quality;
64                    new_probe->GC_content = (unsigned short) (random() % probelength);
65                    new_child->addProbe( new_probe );
66                }
67            }
68
69            child->second->addChild( new_child );
70        }
71    }
72    printf( "done (enter to continue)\n" );
73    getchar();
74
75    if (argc >= 4) {
76        root->print();
77        printf( "\n(enter to continue)\n" );
78        getchar();
79    }
80
81    // write sample tree
82    root->save( ps_db_fb );
83
84    // clean up
85    delete ps_db_fb;
86    root.SetNull();
87    printf( "root should be destroyed now (enter to continue)\n" );
88    getchar();
89
90    return 0;
91}
Note: See TracBrowser for help on using the repository browser.