ARB
ED4_naligner.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : ED4_naligner.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "ed4_naligner.hxx"
12 
13 #include <aw_window.hxx>
14 #include <aw_awars.hxx>
15 #include <aw_root.hxx>
16 #include <awt_sel_boxes.hxx>
17 #include <arbdbt.h>
18 #include <arb_strbuf.h>
19 
20 #include <iostream>
21 
23  AW_root *root = aw->get_root();
24  int i, j;
25 
26  // @@@ use GB_xcmd (do not fiddle with LD_LIBRARY_PATH here)
27  GBS_strstruct cmd(1000);
28  cmd.cat("xterm -sl 1000 -sb -e sh -c 'LD_LIBRARY_PATH=\"");
29  cmd.cat(GB_getenv("LD_LIBRARY_PATH"));
30  cmd.cat("\";export LD_LIBRARY_PATH;for i in ");
31  if (root->awar("naligner/what")->read_int()) {
32  GB_transaction ta(gb_main);
33 
34  for (GBDATA *gb_species = GBT_first_marked_species(gb_main);
35  gb_species;
36  gb_species = GBT_next_marked_species(gb_species))
37  {
38  cmd.put('\"');
39  cmd.cat(GBT_get_name_or_description(gb_species));
40  cmd.cat("\" ");
41  }
42  }
43  else {
44  const char *species_name = root->awar(AWAR_SPECIES_NAME)->read_char_pntr();
45  cmd.put('\"');
46  cmd.cat(species_name);
47  cmd.cat("\" ");
48  }
49 
50 
51  cmd.cat("; do arb_naligner");
52 
53 
54  if (root->awar("naligner/against")->read_int()) {
55  cmd.cat(" -PARB_PT_SERVER");
56  cmd.putlong(root->awar("naligner/pt_server")->read_int());
57  }
58  else {
59  const char *family = root->awar("naligner/sagainst")->read_char_pntr();
60  cmd.cat(" \"-f");
61  cmd.cat(family);
62  cmd.put('\"');
63  }
64  cmd.cat(" \"-s$i\" ");
65 
66  if (root->awar("naligner/mark_profile")->read_int()) cmd.cat(" -mf");
67  if (root->awar("naligner/unmark_sequence")->read_int()) cmd.cat(" -us");
68 
69  cmd.cat(" -minf"); cmd.putlong (root->awar("naligner/minf")->read_int());
70  cmd.cat(" -maxf"); cmd.putlong (root->awar("naligner/maxf")->read_int());
71  cmd.cat(" -minw"); cmd.putfloat(root->awar("naligner/minw")->read_float());
72  cmd.cat(" -maxew"); cmd.putfloat(root->awar("naligner/maxew")->read_float());
73  cmd.cat(" -ib"); cmd.putlong (root->awar("naligner/det/ib")->read_int());
74  cmd.cat(" -ic"); cmd.putlong (root->awar("naligner/det/ic")->read_int());
75  cmd.cat(" -cl"); cmd.putfloat(root->awar("naligner/det/cl")->read_float());
76 
77  cmd.cat(" -cm"); cmd.putfloat(root->awar("naligner/det/cm")->read_float());
78  cmd.cat(" -ch"); cmd.putfloat(root->awar("naligner/det/ch")->read_float());
79  cmd.cat(" -mgf"); cmd.putfloat(root->awar("naligner/igap_panelty")->read_float());
80  cmd.cat(" -mma1");
81  cmd.cat(" -msub");
82 
83  for (i=0; i<5; i++) {
84  for (j=0; j<5; j++) {
85  if (i==4 || j==4) { // gap panelty
86  if (i==4 && j==4) {
87  cmd.putfloat(0.0);
88  }
89  else {
90  cmd.putfloat(root->awar("naligner/gap_panelty")->read_float());
91  cmd.put(',');
92  }
93  }
94  else {
95  char var[100];
96  if (i<j) sprintf(var, "naligner/%c%c", "acgt-"[i], "acgt-"[j]);
97  else sprintf(var, "naligner/%c%c", "acgt-"[j], "acgt-"[i]);
98  cmd.putfloat(root->awar(var)->read_float());
99  if (i<4 || j<4) cmd.put(',');
100  }
101  }
102  }
103  cmd.cat(" || echo \"Aligner failed\";done;");
104  cmd.cat("echo press \"(return)\" to close window;read a' &");
105 
107  if (error) fputs(error, stderr);
108 }
109 
110 
112  root->awar_int("naligner/what", 0, db1);
113 
114  root->awar_int ("naligner/against", 0, db1);
115  root->awar_string("naligner/sagainst", "", db1);
116  root->awar_int ("naligner/pt_server", -1, db1);
117 
118  root->awar_int("naligner/mark_profile", 1, db1);
119  root->awar_int("naligner/unmark_sequence", 0, db1);
120 
121  root->awar_float("naligner/aa", 0.0, db1);
122  root->awar_float("naligner/ac", 3.0, db1);
123  root->awar_float("naligner/ag", 1.0, db1);
124  root->awar_float("naligner/at", 3.0, db1);
125  root->awar_float("naligner/cc", 0.0, db1);
126  root->awar_float("naligner/cg", 3.0, db1);
127  root->awar_float("naligner/ct", 1.0, db1);
128  root->awar_float("naligner/gg", 0.0, db1);
129  root->awar_float("naligner/gt", 3.0, db1);
130  root->awar_float("naligner/tt", 0.0, db1);
131  root->awar_float("naligner/gap_panelty", 5.0, db1);
132  root->awar_float("naligner/igap_panelty", 0.2, db1);
133  root->awar_int ("naligner/minf", 3, db1);
134  root->awar_int ("naligner/maxf", 30, db1);
135 
136  root->awar_float("naligner/minw", .7, db1);
137  root->awar_float("naligner/maxew", .2, db1);
138 
139  root->awar_float("naligner/det/cl", .25, db1);
140  root->awar_float("naligner/det/cm", .5, db1);
141  root->awar_float("naligner/det/ch", .8, db1);
142  root->awar_int ("naligner/det/ib", 5, db1);
143  root->awar_int ("naligner/det/ic", 5, db1);
144 }
145 
147  const int mwidth = 5;
148  AW_window_simple *aws = new AW_window_simple;
149  aws->init(root, "ALIGNER_V2_EXPERT2", "ALIGNER V2.0 EXPERT 2");
150  aws->load_xfig("ed_al_ex.fig");
151 
152  aws->at("close");
153  aws->callback(AW_POPDOWN);
154  aws->create_button("CLOSE", "CLOSE", "C");
155 
156  aws->at("minw"); aws->create_input_field("naligner/minw", mwidth);
157  aws->at("maxew"); aws->create_input_field("naligner/maxew", mwidth);
158 
159  aws->at("ib"); aws->create_input_field("naligner/det/ib", mwidth);
160  aws->at("ic"); aws->create_input_field("naligner/det/ic", mwidth);
161  aws->at("cl"); aws->create_input_field("naligner/det/cl", mwidth);
162  aws->at("cm"); aws->create_input_field("naligner/det/cm", mwidth);
163  aws->at("ch"); aws->create_input_field("naligner/det/ch", mwidth);
164 
165  return aws;
166 }
167 
169  AW_window_simple *aws = new AW_window_simple;
170  const int mwidth = 3;
171 
172  aws->init(root, "ALIGNER_V2_EXPERT", "ALIGNER V2.0 EXPERT");
173  aws->load_xfig("ed_al_sp.fig");
174 
175  aws->label_length(22);
176 
177  aws->at("close");
178  aws->callback(AW_POPDOWN);
179  aws->create_button("CLOSE", "CLOSE", "C");
180 
181  aws->at("minr"); aws->create_input_field("naligner/minf", 6);
182  aws->at("maxr"); aws->create_input_field("naligner/maxf", 6);
183 
184  aws->at("aa"); aws->create_input_field("naligner/aa", mwidth);
185  aws->at("ac"); aws->create_input_field("naligner/ac", mwidth);
186  aws->at("ag"); aws->create_input_field("naligner/ag", mwidth);
187  aws->at("at"); aws->create_input_field("naligner/at", mwidth);
188 
189  aws->at("ca"); aws->create_input_field("naligner/ac", mwidth);
190  aws->at("cc"); aws->create_input_field("naligner/cc", mwidth);
191  aws->at("cg"); aws->create_input_field("naligner/cg", mwidth);
192  aws->at("ct"); aws->create_input_field("naligner/ct", mwidth);
193 
194  aws->at("ga"); aws->create_input_field("naligner/ag", mwidth);
195  aws->at("gc"); aws->create_input_field("naligner/cg", mwidth);
196  aws->at("gg"); aws->create_input_field("naligner/gg", mwidth);
197  aws->at("gt"); aws->create_input_field("naligner/gt", mwidth);
198 
199  aws->at("ta"); aws->create_input_field("naligner/at", mwidth);
200  aws->at("tc"); aws->create_input_field("naligner/ct", mwidth);
201  aws->at("tg"); aws->create_input_field("naligner/gt", mwidth);
202  aws->at("tt"); aws->create_input_field("naligner/tt", mwidth);
203 
204  aws->at("gap"); aws->create_input_field("naligner/gap_panelty", 4);
205  aws->at("igap"); aws->create_input_field("naligner/igap_panelty", 4);
206 
207  aws->at("expert");
208  aws->callback(create_expert_naligner_window);
209  aws->create_button("EXPERT_OPTIONS", "EXPERT2", "E");
210 
211  return aws;
212 }
213 
215  AW_window_simple *aws = new AW_window_simple;
216  aws->init(root, "ALIGNER_V2", "ALIGNER V2.0");
217  aws->load_xfig("awt/align.fig");
218 
219  aws->label_length(10);
220  aws->button_length(10);
221 
222  aws->at("close");
223  aws->callback(AW_POPDOWN);
224  aws->create_button("CLOSE", "CLOSE", "O");
225 
226  aws->at("help");
227  aws->callback(makeHelpCallback("ne_align_seq.hlp"));
228  aws->create_button("HELP", "HELP");
229 
230  aws->at("align");
231  aws->callback(makeWindowCallback(aed_start_naligning, gb_main));
232  aws->highlight();
233  aws->create_button("GO", "GO", "G");
234 
235  aws->at("expert");
236  aws->callback(create_special_naligner_window);
237  aws->create_button("OPTIONS", "PARAMETERS", "E");
238 
239  aws->at("what");
240  aws->create_toggle_field("naligner/what", "Align");
241  aws->insert_toggle("Selected Species:", "S", 0);
242  aws->insert_default_toggle("Marked Species", "M", 1);
243  aws->update_toggle_field();
244 
245  aws->at("swhat");
246  aws->create_input_field(AWAR_SPECIES_NAME, 2);
247 
248  aws->at("against");
249  aws->create_toggle_field("naligner/against", "Reference");
250  aws->insert_toggle("Species by name", "S", 0);
251  aws->insert_default_toggle("Auto search by pt_server", "S", 1);
252  aws->update_toggle_field();
253 
254  aws->at("sagainst");
255  aws->create_input_field("naligner/sagainst", 2);
256 
257  aws->label_length(25);
258 
259  aws->at("pt_server");
260  aws->label("PT_SERVER:");
261  awt_create_PTSERVER_selection_button(aws, "naligner/pt_server");
262 
263  aws->at("mark");
264  aws->label_length(40);
265  aws->label("Mark sequences found by the pt_server");
266  aws->create_toggle("naligner/mark_profile");
267 
268  return aws;
269 }
GB_ERROR GBK_system(const char *system_command)
Definition: arb_msg.cxx:571
const char * GB_ERROR
Definition: arb_core.h:25
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:113
void load_xfig(const char *file, bool resize=true)
Definition: AW_window.cxx:720
long read_int() const
Definition: AW_awar.cxx:184
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
void cat(const char *from)
Definition: arb_strbuf.h:183
const char * read_char_pntr() const
Definition: AW_awar.cxx:168
void putlong(long l)
Definition: arb_strbuf.h:224
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
static AW_window * create_expert_naligner_window(AW_root *root)
AW_awar * awar_float(const char *var_name, float default_value=0.0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:560
static AW_window * create_special_naligner_window(AW_root *root)
void putfloat(float f)
Definition: arb_strbuf.h:225
static void error(const char *msg)
Definition: mkptypes.cxx:96
void create_naligner_variables(AW_root *root, AW_default db1)
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
Definition: aditem.cxx:116
static void aed_start_naligning(AW_window *aw, GBDATA *gb_main)
#define AWAR_SPECIES_NAME
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
void awt_create_PTSERVER_selection_button(AW_window *aws, const char *varname)
float read_float() const
Definition: AW_awar.cxx:177
GB_CSTR GB_getenv(const char *env)
Definition: adsocket.cxx:709
fputs(TRACE_PREFIX, stderr)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
AW_window * create_naligner_window(AW_root *root, GBDATA *gb_main)
AW_root * get_root()
Definition: aw_window.hxx:354
const char * get_data() const
Definition: arb_strbuf.h:120
GB_transaction ta(gb_var)
GBDATA * gb_main
Definition: adname.cxx:32
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
Definition: aditem.cxx:459
void put(char c)
Definition: arb_strbuf.h:158