ARB
ps_make_sample_db.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : ps_make_sample_db.cxx //
4 // Purpose : //
5 // //
6 // Coded by Wolfram Foerster in October 2002 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // =============================================================== //
11 
12 #include "ps_node.hxx"
13 
14 // ====================================================
15 // ====================================================
16 
17 int main(int argc, char *argv[]) {
18  // create probe-set-database
19  if (argc < 4) {
20  printf("Missing arguments\n Usage %s <probequality> <probelength> <output filename> [print]\n", argv[0]);
21  exit(1);
22  }
23 
24  unsigned short quality = atoi(argv[1]);
25  unsigned short probelength = atoi(argv[2]);
26  const char *output_DB_name = argv[3];
27 
28  printf("creating probe-set-database '%s'..", output_DB_name);
29  PS_FileBuffer *ps_db_fb = new PS_FileBuffer(output_DB_name, false);
30  printf("done\n");
31 
32  // create sample tree
33  printf("making sample tree...");
34  PS_NodePtr root(new PS_Node(-1));
35 
36  for (int id = 10; id < 15; ++id) {
37  PS_NodePtr new_child(new PS_Node(id));
38 
39  if (id % 2 != 0) {
40  for (int pnr = 0; pnr < 5; ++pnr) {
41  PS_ProbePtr new_probe(new PS_Probe);
42  new_probe->length = probelength;
43  new_probe->quality = quality;
44  new_probe->GC_content = (unsigned short) (random() % probelength);
45  new_child->addProbe(new_probe);
46  }
47  }
48 
49  root->addChild(new_child);
50  }
51 
52  for (PS_NodeMapIterator child = root->getChildrenBegin(); child != root->getChildrenEnd(); ++child) {
53 
54  for (int id = child->second->getNum()*100; id < (child->second->getNum()*100)+10; ++id) {
55 
56  PS_NodePtr new_child(new PS_Node(id));
57 
58  if (random() % 3 != 0) {
59  for (int pnr = 0; pnr < 50; ++pnr) {
60  PS_ProbePtr new_probe(new PS_Probe);
61  new_probe->length = probelength;
62  new_probe->quality = quality;
63  new_probe->GC_content = (unsigned short) (random() % probelength);
64  new_child->addProbe(new_probe);
65  }
66  }
67 
68  child->second->addChild(new_child);
69  }
70  }
71  printf("done (enter to continue)\n");
72  getchar();
73 
74  if (argc >= 4) {
75  root->print();
76  printf("\n(enter to continue)\n");
77  getchar();
78  }
79 
80  // write sample tree
81  root->save(ps_db_fb);
82 
83  // clean up
84  delete ps_db_fb;
85  root.setNull();
86  printf("root should be destroyed now (enter to continue)\n");
87  getchar();
88 
89  return 0;
90 }
const char * id
Definition: AliAdmin.cxx:17
PS_NodeMapIterator getChildrenBegin()
Definition: ps_node.hxx:114
bool save(PS_FileBuffer *_fb)
Definition: ps_node.cxx:63
void print()
Definition: ps_node.hxx:199
void setNull()
set SmartPtr to NULp
Definition: smartptr.h:251
#define short
Definition: ureadseq.h:8
int main(int argc, char *argv[])
PS_NodeMapIterator getChildrenEnd()
Definition: ps_node.hxx:118
bool addProbe(const PS_ProbePtr &probe)
Definition: ps_node.hxx:126
bool addChild(PS_NodePtr &_child)
Definition: ps_node.hxx:77
PS_NodeMap::iterator PS_NodeMapIterator
Definition: ps_node.hxx:56