Changeset 655
- Timestamp:
- 20/06/02 16:08:07 (10 years ago)
- Location:
- trunk
- Files:
-
- 183 modified
-
AISC/aisc.c (modified) (14 diffs)
-
AISC/aisc_commands.c (modified) (19 diffs)
-
AISC/aisc_mix.c (modified) (5 diffs)
-
AISC/aisc_var_ref.c (modified) (1 diff)
-
AISC_COM/C/aisc_server.h (modified) (1 diff)
-
AISC_COM/C/client.c (modified) (1 diff)
-
AISC_COM/C/debug.c (modified) (4 diffs)
-
AISC_COM/C/server.c (modified) (2 diffs)
-
AISC_COM/C/struct_man.c (modified) (3 diffs)
-
ALIV3/BI_helix.cxx (modified) (1 diff)
-
ALIV3/a3_bihelix.cxx (modified) (6 diffs)
-
ARBDB/EXAMPLES/write_all_species.c (modified) (4 diffs)
-
ARBDB/ad_core.c (modified) (1 diff)
-
ARBDB/ad_load.c (modified) (1 diff)
-
ARBDB/ad_save_load.c (modified) (1 diff)
-
ARBDB/adcompr.c (modified) (1 diff)
-
ARBDB/adhash.c (modified) (10 diffs)
-
ARBDB/adlang1.c (modified) (1 diff)
-
ARBDB/adlmacros.h (modified) (1 diff)
-
ARBDB/admalloc.c (modified) (34 diffs)
-
ARBDB/admath.c (modified) (2 diffs)
-
ARBDB/adquery.c (modified) (1 diff)
-
ARBDB/adseqcompr.c (modified) (15 diffs)
-
ARBDB/adsocket.c (modified) (1 diff)
-
ARBDB/adsort.c (modified) (3 diffs)
-
ARBDB/adstring.c (modified) (1 diff)
-
ARBDB/adsystem.c (modified) (9 diffs)
-
ARBDB/adtools.c (modified) (1 diff)
-
ARBDB/arbdb.c (modified) (48 diffs)
-
ARBDBPP/adseq.cxx (modified) (30 diffs)
-
ARBDBPP/adt_edit.cxx (modified) (50 diffs)
-
ARBDBPP/adtali.cxx (modified) (12 diffs)
-
ARBDBPP/adtsequence.cxx (modified) (3 diffs)
-
ARBDB_COMPRESS/AC_main.cxx (modified) (6 diffs)
-
ARBDB_COMPRESS/AC_sequence.cxx (modified) (4 diffs)
-
ARBDB_COMPRESS/AC_toys_n_tools.cxx (modified) (9 diffs)
-
ARBDB_COMPRESS/AC_tree.cxx (modified) (41 diffs)
-
ARBDB_COMPRESS/DEBUG_tools.cxx (modified) (4 diffs)
-
ARB_GDE/GDE.cxx (modified) (1 diff)
-
ARB_GDE/GDE_FileIO.cxx (modified) (14 diffs)
-
ARB_GDE/GDE_Genbank.cxx (modified) (1 diff)
-
ARB_GDE/GDE_HGLfile.cxx (modified) (1 diff)
-
ARB_GDE/GDE_ParseMenu.cxx (modified) (1 diff)
-
ARB_GDE/GDE_arbdb_io.cxx (modified) (15 diffs)
-
ARB_GDE/GDE_event.cxx (modified) (1 diff)
-
AWDEMO/demo.cxx (modified) (1 diff)
-
AWT/AWT_codon_table.cxx (modified) (28 diffs)
-
AWT/AWT_file_selection.cxx (modified) (1 diff)
-
AWT/AWT_nds.cxx (modified) (1 diff)
-
AWT/AWT_nei.cxx (modified) (2 diffs)
-
AWT/AWT_pro_a_nucs.cxx (modified) (19 diffs)
-
AWT/AWT_query_and_functions.cxx (modified) (1 diff)
-
AWT/AWT_sel_boxes.cxx (modified) (1 diff)
-
AWT/AWT_seq_colors.cxx (modified) (1 diff)
-
AWT/AWT_species_sel_box.cxx (modified) (1 diff)
-
AWT/AWT_tables.cxx (modified) (1 diff)
-
AWT/AWT_tree.cxx (modified) (1 diff)
-
AWT/AWT_tree_cmp.cxx (modified) (1 diff)
-
AWT/AWT_www.cxx (modified) (1 diff)
-
AWT/BI_helix.cxx (modified) (10 diffs)
-
AWTC/AWTC_ClustalV.cxx (modified) (56 diffs)
-
AWTC/AWTC_rename.cxx (modified) (1 diff)
-
AWTI/AWTI_export.cxx (modified) (1 diff)
-
AWTI/AWTI_import.cxx (modified) (1 diff)
-
CAT/CAT_tree.cxx (modified) (9 diffs)
-
DIST/PH_matr.cxx (modified) (1 diff)
-
DIST/PH_mldist.cxx (modified) (2 diffs)
-
DIST/PH_protdist.cxx (modified) (2 diffs)
-
DIST/PH_save_matr.cxx (modified) (2 diffs)
-
DIST/distanalyse.cxx (modified) (2 diffs)
-
EDIT/edit.cxx (modified) (1 diff)
-
EDIT4/ED4_base.cxx (modified) (1 diff)
-
EDIT4/ED4_edit_string.cxx (modified) (1 diff)
-
EDIT4/ED4_main.cxx (modified) (1 diff)
-
EDIT4/ED4_manager.cxx (modified) (1 diff)
-
EDIT4/ED4_members.cxx (modified) (1 diff)
-
EDIT4/ED4_terminal.cxx (modified) (1 diff)
-
EDIT4/ED4_text_terminals.cxx (modified) (1 diff)
-
GDE/CLUSTALW/clustalw.h (modified) (7 diffs)
-
GDE/CORE/BasicDisplay.c (modified) (4 diffs)
-
GDE/CORE/BuiltIn.c (modified) (16 diffs)
-
GDE/CORE/CutCopyPaste.c (modified) (16 diffs)
-
GDE/CORE/DrawNA.c (modified) (2 diffs)
-
GDE/CORE/EventHandler.c (modified) (9 diffs)
-
GDE/CORE/FileIO.c (modified) (8 diffs)
-
GDE/CORE/Free.c (modified) (1 diff)
-
GDE/CORE/Genbank.c (modified) (1 diff)
-
GDE/CORE/HGLfile.c (modified) (7 diffs)
-
GDE/CORE/ParseMenu.c (modified) (8 diffs)
-
GDE/CORE/Scroll.c (modified) (4 diffs)
-
GDE/CORE/main.c (modified) (2 diffs)
-
GDE/HGL_SRC/Alloc.c (modified) (8 diffs)
-
GDE/HGL_SRC/MakeCons.c (modified) (6 diffs)
-
GDE/HGL_SRC/Translate.c (modified) (7 diffs)
-
GDE/HGL_SRC/global_defs.h (modified) (3 diffs)
-
GDE/LOOPTOOL/Draw.c (modified) (9 diffs)
-
GDE/LOOPTOOL/ReadData.c (modified) (2 diffs)
-
GDE/LOOPTOOL/Window.c (modified) (14 diffs)
-
GDE/LOOPTOOL/WriteData.c (modified) (2 diffs)
-
GDE/MOLPHY/Nucml.c (modified) (2 diffs)
-
GDE/MOLPHY/Nucst.c (modified) (1 diff)
-
GDE/MOLPHY/Nuctpm.c (modified) (2 diffs)
-
GDE/MOLPHY/Prottpm.c (modified) (2 diffs)
-
GDE/MOLPHY/prot_tml.h (modified) (1 diff)
-
GDE/MOLPHY/protml.c (modified) (2 diffs)
-
GDE/MOLPHY/protst.c (modified) (1 diff)
-
GDE/MOLPHY/seqproc.c (modified) (5 diffs)
-
GDE/SUPPORT/Flatio.c (modified) (1 diff)
-
GDE/SUPPORT/lsadt.c (modified) (40 diffs)
-
GDE/TREEPUZZLE/src/ml.h (modified) (3 diffs)
-
GDE/TREEPUZZLE/src/ml1.c (modified) (38 diffs)
-
GENOM/GEN_db.cxx (modified) (1 diff)
-
Makefile (modified) (6 diffs)
-
NALIGNER/ali_aligner.hxx (modified) (8 diffs)
-
NALIGNER/ali_pathmap.cxx (modified) (1 diff)
-
NALIGNER/ali_postree.cxx (modified) (16 diffs)
-
NALIGNER/ali_postree.hxx (modified) (4 diffs)
-
NALIGNER/ali_profile.cxx (modified) (17 diffs)
-
NALIGNER/ali_sequence.cxx (modified) (4 diffs)
-
NALIGNER/ali_sequence.hxx (modified) (2 diffs)
-
NALIGNER/ali_solution.cxx (modified) (14 diffs)
-
NALIGNER/ali_solution.hxx (modified) (3 diffs)
-
NALIGNER/ali_tarray.hxx (modified) (1 diff)
-
NALIGNER/ali_tstack.hxx (modified) (1 diff)
-
NAMES/names_client.c (modified) (2 diffs)
-
NTREE/AP_consensus.cxx (modified) (1 diff)
-
NTREE/AP_cprofile.cxx (modified) (88 diffs)
-
NTREE/AP_pos_var_pars.cxx (modified) (9 diffs)
-
NTREE/ETC_check_gcg.cxx (modified) (1 diff)
-
NTREE/NT_main.cxx (modified) (1 diff)
-
NTREE/NT_sort.cxx (modified) (1 diff)
-
NTREE/ad_ali.cxx (modified) (11 diffs)
-
NTREE/ad_ext.cxx (modified) (1 diff)
-
NTREE/ad_trees.cxx (modified) (1 diff)
-
ORS_CGI/ORS_C_PT.cxx (modified) (7 diffs)
-
ORS_CGI/ORS_C_java.cxx (modified) (15 diffs)
-
ORS_CGI/ORS_C_lib.cxx (modified) (8 diffs)
-
ORS_CGI/ORS_C_main.cxx (modified) (15 diffs)
-
ORS_CGI/ORS_C_probe.cxx (modified) (18 diffs)
-
ORS_CGI/ORS_C_scripts.cxx (modified) (6 diffs)
-
ORS_CGI/ORS_C_user.cxx (modified) (24 diffs)
-
ORS_CGI/ORS_lib.cxx (modified) (12 diffs)
-
ORS_COM/ORS_lib.cxx (modified) (11 diffs)
-
ORS_SERVER/ORS_S_probedb.cxx (modified) (18 diffs)
-
ORS_SERVER/ORS_lib.cxx (modified) (11 diffs)
-
PARSIMONY/AP_main.cxx (modified) (11 diffs)
-
PARSIMONY/AP_tree_nlen.cxx (modified) (60 diffs)
-
PARSIMONY/GA_genetic.cxx (modified) (48 diffs)
-
PARSIMONY/GA_main.cxx (modified) (9 diffs)
-
PARSIMONY/GA_window.cxx (modified) (5 diffs)
-
PARSIMONY/PARS_klprops.cxx (modified) (5 diffs)
-
PARSIMONY/PARS_main.cxx (modified) (1 diff)
-
PHYLO/include.hxx (modified) (1 diff)
-
PRIMER_DESIGN/primer_design.cxx (modified) (1 diff)
-
PROBE/PT_buildtree.cxx (modified) (1 diff)
-
PROBE/PT_etc.cxx (modified) (7 diffs)
-
PROBE/PT_family.cxx (modified) (7 diffs)
-
PROBE/PT_findEx.cxx (modified) (1 diff)
-
PROBE/PT_io.cxx (modified) (7 diffs)
-
PROBE/PT_new_design.cxx (modified) (32 diffs)
-
PROBE/PT_prefixtree.cxx (modified) (1 diff)
-
PROBE/PT_secundaer.cxx (modified) (1 diff)
-
PROBE_COM/PT_extern.c (modified) (4 diffs)
-
PROBE_DESIGN/probe_design.cxx (modified) (1 diff)
-
SERVERCNTRL/servercntrl.c (modified) (1 diff)
-
SOURCE_TOOLS/generate_all_links.sh (modified) (2 diffs)
-
STAT/ST_ml.cxx (modified) (1 diff)
-
TEST/test_pt_compress.cxx (modified) (13 diffs)
-
TESTAWT/TB_main.cxx (modified) (7 diffs)
-
TESTVECTORFONT/TB_main.cxx (modified) (7 diffs)
-
TOOLS/arb_count_chars.cxx (modified) (6 diffs)
-
TOOLS/arb_dnarates.c (modified) (1 diff)
-
TOOLS/arb_primer.cxx (modified) (1 diff)
-
TOOLS/arb_probe.cxx (modified) (6 diffs)
-
TREEGEN/defines.h (modified) (1 diff)
-
TREE_COMPRESS/TC_main.cxx (modified) (13 diffs)
-
TRS/tree_lib.cxx (modified) (25 diffs)
-
TRS/trs_hash.cxx (modified) (5 diffs)
-
TRS/trs_server.cxx (modified) (4 diffs)
-
WINDOW/AW_Xm.cxx (modified) (9 diffs)
-
WINDOW/AW_click.cxx (modified) (5 diffs)
-
WINDOW/AW_xfont.cxx (modified) (1 diff)
-
config.makefile.template (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/AISC/aisc.c
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <string.h> 5 5 #include "aisc.h" … … 15 15 if (gl->lastchar == '\n') gl->line_cnt++;} 16 16 17 char *read_aisc_file(char *path) 17 char *read_aisc_file(char *path) 18 18 { 19 19 FILE *input; … … 38 38 39 39 40 void 40 void 41 41 aisc_init() 42 42 { … … 88 88 if ((i == (int) ' ') || 89 89 (i == (int) '\t') || 90 (i == (int) '\n') 90 (i == (int) '\n') 91 91 ) { 92 92 gl->s3_tab[i] = 1; … … 107 107 } 108 108 gl->outtab['n'] = '\n'; 109 gl->outtab['t'] = '\t'; 110 gl->outtab['0'] = 0; 111 gl->outtab['1'] = 0; 112 gl->outtab['2'] = 0; 113 gl->outtab['3'] = 0; 114 gl->outtab['4'] = 0; 115 gl->outtab['5'] = 0; 116 gl->outtab['6'] = 0; 117 gl->outtab['7'] = 0; 118 gl->outtab['8'] = 0; 119 gl->outtab['9'] = 0; 109 gl->outtab['t'] = '\t'; 110 gl->outtab['0'] = 0; 111 gl->outtab['1'] = 0; 112 gl->outtab['2'] = 0; 113 gl->outtab['3'] = 0; 114 gl->outtab['4'] = 0; 115 gl->outtab['5'] = 0; 116 gl->outtab['6'] = 0; 117 gl->outtab['7'] = 0; 118 gl->outtab['8'] = 0; 119 gl->outtab['9'] = 0; 120 120 gl->outtab['\\'] = 0; 121 121 } 122 void 122 void 123 123 p_err_eof(void) 124 124 { … … 127 127 gl->error_flag = 1; 128 128 } 129 void 129 void 130 130 p_error_brih(void) 131 131 { … … 134 134 gl->error_flag = 1; 135 135 } 136 void 136 void 137 137 p_error_nobr(void) 138 138 { … … 141 141 gl->error_flag = 1; 142 142 } 143 void 143 void 144 144 p_error_nocbr(void) 145 145 { … … 148 148 gl->error_flag = 1; 149 149 } 150 void 150 void 151 151 p_error_emwbr(void) 152 152 { … … 155 155 gl->error_flag = 1; 156 156 } 157 void 157 void 158 158 p_error_hewnoid(void) 159 159 { … … 162 162 gl->error_flag = 1; 163 163 } 164 void 164 void 165 165 p_error_mixhnh(void) 166 166 { … … 169 169 gl->error_flag = 1; 170 170 } 171 void 171 void 172 172 p_error_misscom() 173 173 { … … 176 176 gl->error_flag = 1; 177 177 } 178 void 178 void 179 179 p_error_missco() 180 180 { … … 427 427 } 428 428 break; 429 case 4: 429 case 4: 430 430 case 5: 431 431 item->val = strdup(""); -
trunk/AISC/aisc_commands.c
r2 r655 3 3 #include <string.h> 4 4 #include <unistd.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 #include <memory.h> 7 7 … … 21 21 register const char *s; 22 22 register char *d; 23 23 24 24 i = len; 25 25 s = source; … … 67 67 char *lastbr; 68 68 char c; 69 69 70 70 ld = find_string(&str[2], "$("); 71 71 fi = 0; … … 162 162 163 163 164 int 164 int 165 165 calc_line(char *str, char *buf) 166 166 { … … 181 181 } 182 182 183 int 183 int 184 184 calc_line2(char *str, char *buf) 185 185 { /* erstes $( nicht auswerten ) !!! */ … … 207 207 } 208 208 209 void 209 void 210 210 write_aisc(AD * ad, FILE * out, int deep) 211 211 { … … 235 235 } 236 236 237 void 237 void 238 238 write_prg(CL * cl, FILE * out, int deep) 239 239 { … … 248 248 249 249 250 int 250 int 251 251 do_com_dbg(char *str) 252 252 { … … 255 255 return 0; 256 256 } 257 int 257 int 258 258 do_com_data(char *str) 259 259 { … … 277 277 } 278 278 279 int 279 int 280 280 do_com_write(FILE * out, char *str) 281 281 { … … 345 345 } 346 346 347 int 347 int 348 348 do_com_print(char *str) 349 349 { … … 351 351 return 0; 352 352 } 353 int 353 int 354 354 do_com_print2(char *str) 355 355 { … … 358 358 } 359 359 360 int 360 int 361 361 do_com_tabstop(char *str) 362 362 { … … 373 373 } 374 374 375 int 375 int 376 376 do_com_tab(char *str) 377 377 { … … 394 394 } 395 395 396 int 396 int 397 397 do_com_error(char *str) 398 398 { … … 726 726 } 727 727 gl->pc = fun = (CL *)atol(fn); 728 728 729 729 err = calc_line(gl->pc->str, gl->linebuf); 730 730 if (err) return err; … … 748 748 return 1; 749 749 } 750 write_hash(gl->st->hs, fpara, para); 750 write_hash(gl->st->hs, fpara, para); 751 751 } 752 752 if (*fpara) { … … 785 785 } 786 786 787 int 787 int 788 788 do_com_for(char *str) 789 789 { … … 888 888 &&!strncmp(string,str,len)) { char *s=str+len;\ 889 889 if (func(s)) break; continue;} 890 int 890 int 891 891 run_prg(void) 892 892 { -
trunk/AISC/aisc_mix.c
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 6 6 #include "aisc.h" … … 66 66 co ->next = cod; 67 67 co->str = NULL; 68 co->path = strdup(co->path); 68 co->path = strdup(co->path); 69 69 aif->ELSE=co; 70 70 aelse = co; … … 130 130 default: 131 131 break; 132 132 133 133 } 134 134 co = co->next; … … 246 246 register const char *p; 247 247 register char c; 248 248 249 249 p = key; 250 250 x = 1; … … 315 315 e->val = 0; 316 316 } 317 317 318 318 return str2; 319 319 } -
trunk/AISC/aisc_var_ref.c
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include "aisc.h" 6 6 #include "aisc_proto.h" -
trunk/AISC_COM/C/aisc_server.h
r2 r655 8 8 #endif 9 9 #include <string.h> 10 #include <malloc.h>10 // #include <malloc.h> 11 11 #include <memory.h> 12 12 int aisc_make_sets(long *obj); /* sets in a create request */ -
trunk/AISC_COM/C/client.c
r238 r655 2 2 #include <stdio.h> 3 3 #include <stdlib.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <unistd.h> 6 6 #include <errno.h> -
trunk/AISC_COM/C/debug.c
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <ad_varargs.h> 6 6 #include <aisc_com.h> … … 32 32 static bytestring gbs; 33 33 bptr = &buf[0]; 34 va_start(parg,str); 34 va_start(parg,str); 35 35 sm = sc = strdup(str); 36 36 if (aisc_get(link,AISC_COMMON,object, … … 57 57 sprintf(bptr,"%30s,",sc); 58 58 bptr += strlen(bptr); 59 sc += strlen(sc)+1; 59 sc += strlen(sc)+1; 60 60 type = code & 0xff000000; 61 61 er = (long *)aisc_debug_info(link,key,object,(int)code); … … 107 107 COMMON_CNT, &anz, 108 108 NULL)) return "connection problems"; 109 sprintf(bptr," %s (%li) */\n",keystr,anz); 109 sprintf(bptr," %s (%li) */\n",keystr,anz); 110 110 bptr += strlen(bptr); 111 111 }else{ -
trunk/AISC_COM/C/server.c
r555 r655 2 2 #include <stdio.h> 3 3 #include <stdlib.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <unistd.h> 6 6 #include <errno.h> … … 25 25 # endif 26 26 #else 27 # if defined(HP) || defined(LINUX) || defined(DIGITAL) 27 # if defined(HP) || defined(LINUX) || defined(DIGITAL) || defined(DARWIN) 28 28 # define SIG_PF void (*)(int) 29 29 # endif -
trunk/AISC_COM/C/struct_man.c
r33 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <string.h> 5 5 #include "aisc.h" … … 351 351 bs->size = 0; 352 352 if (pb->cnt == 0) return 0; 353 353 354 354 bs->size = sizeof(int) * pb->cnt; 355 355 ptr = (int *)malloc(bs->size); … … 374 374 bs->size = 0; 375 375 if (pb->cnt == 0) return 0; 376 376 377 377 size = sizeof(int) * (pb->cnt+1); 378 378 stringlenghts = 0; -
trunk/ALIV3/BI_helix.cxx
r65 r655 3 3 #include <string.h> 4 4 #include <ctype.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <arbdb.h> 7 7 #include <arbdbt.h> -
trunk/ALIV3/a3_bihelix.cxx
r2 r655 7 7 #include <string.h> 8 8 #include <ctype.h> 9 #include <malloc.h>9 // #include <malloc.h> 10 10 11 11 #include "a3_bihelix.hxx" … … 32 32 long pos; 33 33 BI_PAIR_TYPE type; 34 char c; 34 char c; 35 35 } 36 36 #ifdef LINUX … … 91 91 pairs[HELIX_PAIR] = strdup("AU GU"); 92 92 char_bind[HELIX_PAIR] = strdup("-"); 93 93 94 94 pairs[HELIX_WEAK_PAIR] = strdup("GA GT"); 95 95 char_bind[HELIX_WEAK_PAIR] = strdup("."); … … 164 164 return 0; 165 165 } 166 166 167 167 // ----------------------------------------------------------------------------- 168 168 char *A3_BI_Helix::init ( char *helix_nr, … … 217 217 if (isdigit(c)) continue; 218 218 } 219 219 220 220 break; 221 221 } 222 222 } 223 223 } 224 224 225 225 c = helix[pos]; 226 226 … … 292 292 } 293 293 294 entries[pos].helix_nr = sident+1; 294 entries[pos].helix_nr = sident+1; 295 295 entries[stack->pos].helix_nr = sident; 296 296 } -
trunk/ARBDB/EXAMPLES/write_all_species.c
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include <arbdb.h> 4 4 int main(int argc,char **argv) … … 8 8 GB_ERROR fehler; 9 9 char *species_name; 10 if(argc==1) path=":"; 10 if(argc==1) path=":"; 11 11 else path=argv[1]; 12 12 gb_main=GB_open(path,"r"); … … 17 17 } 18 18 fehler=GB_begin_transaction(gb_main); 19 if(fehler) 19 if(fehler) 20 20 { 21 21 printf("fehler:%s\n",fehler); … … 31 31 gb_speciesname=GB_search(gb_species,"full_name",GB_FIND); 32 32 if(!gb_speciesname) printf("\n"); 33 else 33 else 34 34 { 35 35 species_name=GB_read_string(gb_speciesname); 36 36 printf(" %s\n",species_name); 37 37 free(species_name); 38 } 38 } 39 39 } 40 40 GB_commit_transaction(gb_main); 41 } 42 41 } 43 42 43 -
trunk/ARBDB/ad_core.c
r566 r655 3 3 4 4 #include <string.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 7 7 /*#include "arbdb.h"*/ -
trunk/ARBDB/ad_load.c
r501 r655 3 3 #include <errno.h> 4 4 #include <string.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 #include <ctype.h> 7 7 #include <sys/stat.h> -
trunk/ARBDB/ad_save_load.c
r454 r655 3 3 #include <errno.h> 4 4 #include <string.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 #include <ctype.h> 7 7 #include <sys/stat.h> -
trunk/ARBDB/adcompr.c
r318 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <memory.h> 5 5 #include <string.h> -
trunk/ARBDB/adhash.c
r2 r655 5 5 #include <stdio.h> 6 6 #include <stdlib.h> 7 #include <malloc.h> 7 /* #include <malloc.h> */ 8 8 #include <string.h> 9 9 #include <ctype.h> … … 136 136 } 137 137 val = atoi(dp+1); 138 GBS_write_hash_no_strdup(hash,str,val); 138 GBS_write_hash_no_strdup(hash,str,val); 139 139 } 140 140 … … 200 200 return i2; 201 201 } 202 202 203 203 if (val == 0) return 0; 204 204 … … 236 236 return i2; 237 237 } 238 238 239 239 e = (struct gbs_hash_entry *)gbm_get_mem(sizeof(struct gbs_hash_entry),GBM_HASH_INDEX); 240 240 e->next = hs->entries[i]; … … 283 283 for (i = 0; i < e2; i++) { 284 284 for (e = hs->entries[i]; e; e = ee) { 285 free(e->key); 285 free(e->key); 286 286 ee = e->next; 287 287 gbm_free_mem((char *)e,sizeof(struct gbs_hash_entry),GBM_HASH_INDEX); … … 377 377 hs->loop_entry = 0; 378 378 } 379 379 380 380 void GBS_hash_first_element(GB_HASH *hs,const char **key, long *val){ 381 381 struct gbs_hash_entry *e; … … 402 402 extern "C" { 403 403 #endif 404 404 405 405 long g_bs_compare_two_items(void *v0, void *v1, char *unused) { 406 406 struct gbs_hash_entry *e0 = (struct gbs_hash_entry*)v0; 407 407 struct gbs_hash_entry *e1 = (struct gbs_hash_entry*)v1; 408 408 GBUSE(unused); 409 409 410 410 return gbh_sort_func(e0->key, e0->val, e1->key, e1->val); 411 411 } … … 619 619 register long i; 620 620 char *data = 0; 621 621 622 622 while ( ( (!cs->firstfree_entry) || ( needed_size + cs->sum_data_size >= max_data_size)) 623 623 && cs->oldest_entry) { … … 660 660 register long i; 661 661 char *data = 0; 662 662 663 663 data = delete_old_cache_entries(cs, size, cs->max_data_size); /* delete enough old memory */ 664 664 … … 685 685 cs->entries[i].gbd = gbd; 686 686 gbd->cache_index = (short)i; 687 687 688 688 return data; 689 689 } -
trunk/ARBDB/adlang1.c
r641 r655 3 3 #include <unistd.h> 4 4 #include <string.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 #include <ctype.h> 7 7 -
trunk/ARBDB/adlmacros.h
r566 r655 19 19 #define GB_DELETE(a) if (a) GB_FREE(a); a = 0 20 20 21 #if defined(HP) || defined(DIGITAL) 21 #if defined(HP) || defined(DIGITAL) || defined(DARWIN) 22 22 # undef GB_MEMALIGN 23 23 # define GB_MEMALIGN(a,b) malloc(b) -
trunk/ARBDB/admalloc.c
r2 r655 2 2 #include <stdlib.h> 3 3 #include <unistd.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <string.h> 6 6 #include <limits.h> … … 57 57 58 58 59 #define GBB_INCR 11 /* memsize increment in percent between 59 #define GBB_INCR 11 /* memsize increment in percent between 60 60 adjacent clusters */ 61 61 #define GBB_CLUSTERS 64 /* # of different clusters */ 62 62 #define GBB_ALIGN GBM_LD_ALIGNED /* align memsize of clusters (# of bits) */ 63 63 #define GBB_MINSIZE GBM_MAX_SIZE /* minimal size of allocated big block */ 64 #define GBB_MAX_TRIALS 4 /* maximal number of clusters to search 64 #define GBB_MAX_TRIALS 4 /* maximal number of clusters to search 65 65 for an unused block */ 66 66 #define GBB_MAGIC 0x67823747 … … 76 76 struct gbb_data 77 77 { 78 size_t size; /* real size of memblock 78 size_t size; /* real size of memblock 79 79 (from `content` to end of block) */ 80 80 long allocFromSystem; /* ==0 -> it`s a block imported by gbm_put_mem */ 81 81 82 struct gbb_freedata content; /* startposition of block returned to user 82 struct gbb_freedata content; /* startposition of block returned to user 83 83 or chain info for free blocks */ 84 84 }; … … 89 89 { 90 90 size_t size; /* minimum size of memblocks in this cluster */ 91 struct gbb_data *first; /* first free block */ 92 91 struct gbb_data *first; /* first free block */ 92 93 93 } gbb_cluster[GBB_CLUSTERS+1]; 94 94 … … 98 98 size_t size = nelem*elsize; 99 99 void *mem = malloc(size); 100 100 101 101 if (mem) { 102 102 memset(mem,0,size); … … 118 118 size_t nsize = nelem*elsize; 119 119 void *mem = malloc(nsize); 120 120 121 121 if (mem) { 122 122 size_t osize = oelem*elsize; 123 123 124 124 if (nsize>=osize) { 125 125 memmove(mem, ptr, osize); … … 133 133 } 134 134 else { 135 fprintf(stderr,"Panic Error: Unsufficient memory: tried to get %i*%i bytes : Increase Swap space\n",nelem,elsize); 136 } 137 135 fprintf(stderr,"Panic Error: Unsufficient memory: tried to get %i*%i bytes : Increase Swap space\n",nelem,elsize); 136 } 137 138 138 return mem; 139 139 } … … 148 148 149 149 flag = 1; 150 for (i=0;i<GBM_MAX_INDEX;i++) 150 for (i=0;i<GBM_MAX_INDEX;i++) 151 151 { 152 152 memset((char *)&gbm_global[i],0,sizeof(struct gbm_struct)); … … 155 155 gbm_global2.old_sbrk = (char *)sbrk(0); 156 156 157 /* init GBB: 157 /* init GBB: 158 158 * --------- */ 159 159 … … 162 162 163 163 for (i=1; i<GBB_CLUSTERS; i++) 164 { 164 { 165 165 long nextSize = gbb_cluster[i-1].size * (100+GBB_INCR); 166 166 167 167 nextSize /= 100; 168 168 nextSize >>= GBB_ALIGN; … … 178 178 /* last cluster contains ALL bigger blocks */ 179 179 180 gbb_cluster[GBB_CLUSTERS].size = INT_MAX; 180 gbb_cluster[GBB_CLUSTERS].size = INT_MAX; 181 181 gbb_cluster[GBB_CLUSTERS].first = NULL; 182 182 … … 184 184 185 185 #if (defined(DEBUG) && 0) 186 { 187 188 int i; 186 { 187 188 int i; 189 189 190 190 for (i=200; i<3000; i+=1) 191 191 { 192 192 char *someMem = (char*)calloc(1,(size_t)i); 193 193 194 194 if (someMem) gbb_put_memblk(someMem,i); 195 195 } 196 196 } 197 #endif 197 #endif 198 198 } 199 199 200 200 void GB_memerr(void) 201 { 201 { 202 202 GB_internal_error("memory allocation error - maybe you're out of swap space?"); 203 203 } … … 215 215 struct gbb_Cluster *cl = &(gbb_cluster[idx]); 216 216 struct gbb_data *blk = cl->first; 217 217 218 218 while (blk) 219 219 { … … 241 241 } 242 242 243 static int getClusterIndex(size_t size) /* searches the index of the 244 lowest cluster for that: 245 size <= cluster->size */ 243 static int getClusterIndex(size_t size) /* searches the index of the 244 lowest cluster for that: 245 size <= cluster->size */ 246 246 { 247 247 int l,m,h; … … 251 251 l = 1; 252 252 h = GBB_CLUSTERS; 253 253 254 254 while (l!=h) 255 255 { … … 257 257 if (gbb_cluster[m].size < size) l = m+1; 258 258 else h = m; 259 } 259 } 260 260 261 261 ad_assert(l<=GBB_CLUSTERS); … … 264 264 } 265 265 266 void gbb_put_memblk(char *memblk, size_t size) /* gives any memory block (allocated or not) 266 void gbb_put_memblk(char *memblk, size_t size) /* gives any memory block (allocated or not) 267 267 into the responsibility of this module; 268 268 the block has to be aligned!!! */ 269 269 { 270 struct gbb_data *block; 270 struct gbb_data *block; 271 271 int idx; 272 272 … … 277 277 #endif 278 278 279 if (size<(GBB_HEADER_SIZE+GBB_MINSIZE)) 280 { 281 GB_internal_error("gmb_put_memblk() called with size below %i bytes", 279 if (size<(GBB_HEADER_SIZE+GBB_MINSIZE)) 280 { 281 GB_internal_error("gmb_put_memblk() called with size below %i bytes", 282 282 GBB_HEADER_SIZE+GBB_MINSIZE); 283 283 return; … … 286 286 block = (struct gbb_data *)memblk; 287 287 block->size = size-GBB_HEADER_SIZE; 288 block->allocFromSystem = 0; 289 290 idx = getClusterIndex(block->size)-1; 288 block->allocFromSystem = 0; 289 290 idx = getClusterIndex(block->size)-1; 291 291 ad_assert(idx>=0); 292 292 293 293 block->content.next = gbb_cluster[idx].first; 294 294 block->content.magic = GBB_MAGIC; 295 gbb_cluster[idx].first = block; 295 gbb_cluster[idx].first = block; 296 296 297 297 ad_assert(idx==GBB_CLUSTERS || block->size>=gbb_cluster[idx].size); … … 303 303 struct gbb_data *block = NULL; 304 304 int trials = GBB_MAX_TRIALS, 305 idx; 305 idx; 306 306 307 307 TEST(); … … 309 309 idx = getClusterIndex(size); 310 310 ad_assert(gbb_cluster[idx].size>=size); 311 311 312 312 while (trials--) /* search a cluster containing a block */ 313 313 { … … 318 318 319 319 if (!block) /* if no unused block -> allocate from system */ 320 { 320 { 321 321 int allocationSize; 322 322 … … 331 331 332 332 block->size = allocationSize-GBB_HEADER_SIZE; 333 block->allocFromSystem = 1; 333 block->allocFromSystem = 1; 334 334 335 335 ad_assert(block->size>=size); … … 347 347 while ((block=*blockPtr)!=NULL && block->size<size) 348 348 blockPtr = &(block->content.next); 349 349 350 350 if (!block) goto allocFromSys; 351 351 ad_assert(block->size>=size); … … 384 384 nsize = (size + (GBM_ALIGNED - 1)) & (-GBM_ALIGNED); 385 385 386 if (nsize > GBM_MAX_SIZE) 386 if (nsize > GBM_MAX_SIZE) 387 387 { 388 388 ggi->extern_data_size += nsize; 389 389 ggi->extern_data_items++; 390 390 391 391 erg = gbb_get_memblk((size_t)nsize); 392 392 return erg; … … 394 394 395 395 pos = nsize >> GBM_LD_ALIGNED; 396 if ( (gds = ggi->tables[pos]) ) 396 if ( (gds = ggi->tables[pos]) ) 397 397 { 398 398 ggi->tablecnt[pos]--; 399 399 erg = (char *)gds; 400 if (gds->magic != GBM_MAGIC) 400 if (gds->magic != GBM_MAGIC) 401 401 { 402 402 printf("%lX!= %lX\n",gds->magic,(long)GBM_MAGIC); … … 405 405 } 406 406 ggi->tables[pos] = ggi->tables[pos]->next; 407 } 408 else 409 { 410 if (ggi->size < nsize) 407 } 408 else 409 { 410 if (ggi->size < nsize) 411 411 { 412 412 struct gbm_table_struct *gts = (struct gbm_table_struct *)GB_MEMALIGN(gbm_system_page_size, GBM_TABLE_SIZE); … … 428 428 ggi->useditems[pos]++; 429 429 GB_MEMSET(erg,0,nsize); 430 430 431 431 return erg; 432 432 } … … 443 443 nsize = (size + (GBM_ALIGNED - 1)) & (-GBM_ALIGNED); 444 444 445 if (nsize > GBM_MAX_SIZE) 445 if (nsize > GBM_MAX_SIZE) 446 446 { 447 447 struct gbb_data *block; … … 453 453 block->size = size-GBB_HEADER_SIZE; 454 454 block->allocFromSystem = 0; 455 455 456 456 /* printf("put mapped Block (size=%li)\n", size); */ 457 457 458 458 if (size>=(GBB_HEADER_SIZE+GBB_MINSIZE)) 459 459 gbb_put_memblk((char*)block, size); 460 460 461 461 } 462 462 else 463 463 { 464 block = (struct gbb_data *)(data-GBB_HEADER_SIZE); 465 464 block = (struct gbb_data *)(data-GBB_HEADER_SIZE); 465 466 466 ggi->extern_data_size -= (size_t)nsize; 467 467 ggi->extern_data_items--; … … 469 469 if (block->size<size) { imemerr("block size does not mach"); return; } 470 470 471 if (block->allocFromSystem) 471 if (block->allocFromSystem) 472 472 { 473 473 /* printf("free %li bytes\n", size); */ 474 474 free((char *)block); 475 475 } 476 else 476 else 477 477 { 478 478 /* printf("put unused block (size=%li block->size=%li)\n", … … 481 481 } 482 482 } 483 } 484 else 483 } 484 else 485 485 { 486 486 if (gb_isMappedMemory(data)) return; /* @@@ reason: size may be shorter */ 487 if ( ((struct gbm_data_struct *)data)->magic == GBM_MAGIC) 487 if ( ((struct gbm_data_struct *)data)->magic == GBM_MAGIC) 488 488 /* double free */ 489 { 489 { 490 490 imemerr("double free"); 491 491 return; … … 510 510 long index_total; 511 511 struct gbm_struct *ggi; 512 512 513 513 printf("Memory Debug Information:\n"); 514 514 for (index = 0; index < GBM_MAX_INDEX; index++) … … 555 555 } 556 556 } 557 557 558 558 { 559 559 char *topofmem = (char *)sbrk(0); -
trunk/ARBDB/admath.c
r2 r655 1 1 #include <stdlib.h> 2 2 #include <stdio.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <string.h> 5 5 #include <math.h> … … 13 13 static double *res = 0; 14 14 if (n<=1) return 0.0; /* log 1 = 0 */ 15 15 16 16 if (n >= max_n){ 17 17 double sum = 0; -
trunk/ARBDB/adquery.c
r500 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <ctype.h> 6 6 -
trunk/ARBDB/adseqcompr.c
r518 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 6 6 #include <adlocal.h> … … 18 18 unsigned char *data = (unsigned char *)GB_calloc(sizeof(char)*256,len); 19 19 gcon->len = len; 20 20 21 21 for (i=0;i<256;i++){ 22 22 gcon->con[i] = data + len*i; … … 86 86 87 87 memset(seq,'@',gcon->len); 88 88 89 89 for (c = 1; c<256;c++){ /* Find maximum frequency of non run */ 90 90 if (!gcon->used[c]) continue; … … 258 258 long len = seq_len; 259 259 d = buffer = (unsigned char *)GB_give_other_buffer(seq,seq_len); 260 260 261 261 if (seq_len > master_len){ 262 262 rest = seq_len - master_len; 263 263 len = master_len; 264 264 } 265 265 266 266 last = -1000; /* Convert Sequence relative to Master */ 267 267 for( i = len; i>0; i--){ … … 288 288 g_b_put_number2(master_index,&dest2); /* Tags */ 289 289 g_b_put_number2(q,&dest2); 290 290 291 291 gb_compress_equal_bytes_2((char *)buffer,seq_len,memsize,(char *)dest2); /* append runlength compressed sequences to tags */ 292 292 293 293 *memsize = *memsize + (dest2-buffer2); 294 294 return (char *)buffer2; … … 320 320 GB_MAIN_TYPE *Main = GB_MAIN(gb_main); 321 321 q = gb_key_2_quark(Main,ali_name); 322 322 323 323 do { 324 324 long seq_len = GBT_get_alignment_len(gb_main,(char *)ali_name); … … 330 330 leafcount = g_b_count_leafs(tree); 331 331 if (!leafcount) return 0; 332 332 333 333 g_b_number_of_sequences_to_compress = (1 + leafcount) * (2.0 + 1.0 / MAX_SEQUENCE_PER_MASTER); 334 334 g_b_counter_of_sequences_to_compress = 0; … … 353 353 g_b_create_master(tree,seqs,masters,-1,ali_name,seq_len); 354 354 } while(0); 355 355 356 356 /* Now compress everything !!! */ 357 357 { … … 371 371 GB_Master *master = masters[mi]; 372 372 GBDATA *gbd = seqs[si].gbd; 373 373 374 374 char *seqm = GB_read_string(master->gbd); 375 375 int master_len = GB_read_string_count(master->gbd); … … 385 385 ss = gb_compress_sequence_by_master(gbd,seqm,master_len,mi,q,seq,seq_len,&sizes); 386 386 gb_write_compressed_pntr(gbd,ss,sizes,seq_len); 387 387 388 388 GB_status( (++g_b_counter_of_sequences_to_compress) / g_b_number_of_sequences_to_compress); 389 389 … … 438 438 ss = gb_compress_sequence_by_master(gbd,seqm,master_len,mi,q,seq,seq_len,&sizes); 439 439 gb_write_compressed_pntr(gbd,ss,sizes,seq_len); 440 440 441 441 g_b_counter_of_sequences_to_compress++; 442 442 GB_status(g_b_counter_of_sequences_to_compress / g_b_number_of_sequences_to_compress); 443 443 444 444 sumnew+= sizes; 445 445 free(seqm); … … 471 471 if (Main->transaction>0){ 472 472 GB_internal_error("Internal Error: Compress Sequences called during a running transacton"); 473 return GB_export_error("Internal Error: Compress Sequences called during a running transacton"); 473 return GB_export_error("Internal Error: Compress Sequences called during a running transacton"); 474 474 } 475 475 GB_request_undo_type(gb_main,GB_UNDO_KILL); … … 604 604 605 605 char *gb_uncompress_by_sequence(GBDATA *gbd, const char *s,long size, GB_ERROR *error){ 606 register char *dest; 606 register char *dest; 607 607 GB_MAIN_TYPE *Main; 608 608 GBDATA *gb_main; … … 613 613 long master_size; 614 614 char *to_free; 615 615 616 616 *error = 0; 617 617 618 618 if (!GB_FATHER(gbd)) { 619 619 *error = "Cannot uncompress this sequence: Sequence has no father"; 620 620 return 0; 621 621 } 622 622 623 623 Main = GB_MAIN(gbd); 624 624 gb_main = (GBDATA *)Main->data; 625 625 626 626 to_free = gb_check_out_buffer(s); /* Get our own buffer, maybe load_single_key_data will destroy it */ 627 627 628 628 index = g_b_read_number2((unsigned char **)&s); 629 629 quark = g_b_read_number2((unsigned char **)&s); 630 630 631 631 if (!Main->keys[quark].gb_master_ali){ 632 632 gb_load_single_key_data(gb_main,quark); … … 636 636 return 0; 637 637 } 638 638 639 639 gb_master = gb_find_by_nr(Main->keys[quark].gb_master_ali,index); 640 640 if (!gb_master){ -
trunk/ARBDB/adsocket.c
r569 r655 6 6 #include <sys/time.h> 7 7 #include <errno.h> 8 #include <malloc.h> 8 /* #include <malloc.h> */ 9 9 #include <string.h> 10 10 #include <memory.h> -
trunk/ARBDB/adsort.c
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <memory.h> 5 5 … … 12 12 compare(2,3) should be <0; 13 13 compare(x,x) = 0; 14 compare(4,3) >0; 14 compare(4,3) >0; 15 15 16 16 */ … … 79 79 while(i<mid) buffer[dest++] = array[i++]; 80 80 while(j<end) buffer[dest++] = array[j++]; 81 81 82 82 memcpy( (char *)(array+start),(char *)buffer,(int)size * sizeof(void *)); 83 83 84 84 if (size>=256) free((char *)buffer); 85 85 86 86 return error; 87 87 } -
trunk/ARBDB/adstring.c
r569 r655 3 3 #include <string.h> 4 4 #include <ctype.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 7 7 #include "adlocal.h" -
trunk/ARBDB/adsystem.c
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 6 6 #include <sys/types.h> … … 24 24 size = GB_read_bytes_count(gb_dict); 25 25 GB_write_security_write(gb_dict,7); 26 26 27 27 idata = (GB_NINT *)data; 28 dict->words = ntohl(*idata++); 28 dict->words = ntohl(*idata++); 29 29 dict->textlen = (int)(size - sizeof(GB_NINT)*(1+dict->words*2)); 30 31 dict->offsets = idata; 30 31 dict->offsets = idata; 32 32 dict->resort = idata+dict->words; 33 dict->text = (unsigned char*)(idata+2*dict->words); 33 dict->text = (unsigned char*)(idata+2*dict->words); 34 34 35 35 return dict; … … 48 48 Main->keys[q].dictionary = 0; 49 49 Main->keys[q].gb_key = 0; 50 }else{ 50 }else{ 51 51 gb_load_single_key_data(gbd,q); 52 52 } … … 71 71 return; 72 72 } 73 73 74 74 gb_main = (GBDATA *)Main->data; 75 75 if (key[0] == '@'){ … … 85 85 if (gb_name){ 86 86 gb_key= GB_get_father(gb_name); 87 }else{ 87 }else{ 88 88 gb_key = gb_create_container(gb_key_data,"@key"); 89 89 gb_name = gb_create(gb_key,"@name",GB_STRING); 90 90 GB_write_string(gb_name,key); 91 91 } 92 92 93 93 GB_ensure_callback(gb_key,(GB_CB_TYPE)(GB_CB_CHANGED|GB_CB_DELETE),gb_system_key_changed_cb,(int *)q); 94 94 95 95 ks->compression_mask = (int)GBT_read_int2(gb_key,"compression_mask",-1); 96 96 gb_dict = GB_find(gb_key,"@dictionary",0,down_level); … … 134 134 if (gb_name){ 135 135 gb_key= GB_get_father(gb_name); 136 }else{ 136 }else{ 137 137 gb_key = gb_create_container(gb_key_data,"@key"); 138 138 gb_name = gb_create(gb_key,"@name",GB_STRING); 139 139 GB_write_string(gb_name,key); 140 140 } 141 gb_dict = gb_search(gb_key,"@dictionary",GB_BYTES,1); 141 gb_dict = gb_search(gb_key,"@dictionary",GB_BYTES,1); 142 142 error = GB_write_bytes(gb_dict,dict,size); 143 143 GB_pop_my_security(gb_main); … … 155 155 GBDATA *gb_key,*gb_next_key=0; 156 156 int key; 157 157 158 158 Main->gb_key_data = gb_key_data; 159 159 if (!Main->local_mode) return 0; /* do not create anything at the client side */ … … 181 181 gb_key_2_quark(Main,"@dictionary"); 182 182 gb_key_2_quark(Main,"compression_mask"); 183 183 184 184 for (key=1;key<Main->sizeofkeys;key++){ 185 185 char *k = Main->keys[key].key; … … 187 187 gb_load_single_key_data(gb_main,key); 188 188 } 189 189 190 190 191 191 GB_pop_my_security(gb_main); -
trunk/ARBDB/adtools.c
r651 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <memory.h> 6 6 #include <math.h> -
trunk/ARBDB/arbdb.c
r297 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <sys/types.h> 6 6 #include <netinet/in.h> … … 22 22 { 23 23 if (!rel_adress) return NULL; 24 return (char*)struct_adress+rel_adress; 24 return (char*)struct_adress+rel_adress; 25 25 } 26 26 /******************************************************************************************** … … 61 61 62 62 /******************************************************************************************** 63 compression tables 63 compression tables 64 64 ********************************************************************************************/ 65 65 int gb_convert_type_2_compression_flags[] = { … … 269 269 return 0; 270 270 } 271 271 272 272 do { 273 273 if (index_pos<0 ) break; … … 368 368 data = GB_GETDATA(gbd); 369 369 if (!data) return 0; 370 if (gbd->flags.compressed_data) { /* uncompressed data return pntr to 370 if (gbd->flags.compressed_data) { /* uncompressed data return pntr to 371 371 database entry */ 372 372 char *ca = gb_read_cache(gbd); … … 446 446 size = GB_GETSIZE(gbd); 447 447 if (!size) return 0; 448 { 448 { 449 449 char *ca = gb_read_cache(gbd); 450 450 char *da; … … 661 661 } 662 662 663 int gb_get_compression_mask(GB_MAIN_TYPE *Main, GBQUARK key, int gb_type) 663 int gb_get_compression_mask(GB_MAIN_TYPE *Main, GBQUARK key, int gb_type) 664 664 { 665 665 struct gb_key_struct *ks = &Main->keys[key]; … … 676 676 } 677 677 678 GB_ERROR GB_write_pntr(GBDATA *gbd,const char *s, long bytes_size, long stored_size) 678 GB_ERROR GB_write_pntr(GBDATA *gbd,const char *s, long bytes_size, long stored_size) 679 679 { 680 680 GB_MAIN_TYPE *Main = GB_MAIN(gbd); … … 683 683 int compression_mask; 684 684 long memsize; 685 685 686 686 gb_free_cache(Main,gbd); 687 687 gb_save_extern_data_in_ts(gbd); 688 688 689 689 compression_mask = gb_get_compression_mask(Main, key, GB_TYPE(gbd)); 690 690 691 691 if (compression_mask){ 692 692 d = gb_compress_data(gbd, key, s, bytes_size, &memsize, compression_mask, GB_FALSE); … … 705 705 gb_touch_entry(gbd,gb_changed); 706 706 GB_DO_CALLBACKS(gbd); 707 707 708 708 return 0; 709 709 } … … 711 711 GB_ERROR GB_write_string(GBDATA *gbd,const char *s) 712 712 { 713 long size; 713 long size; 714 714 /*fprintf(stderr, "GB_write_string(%p, %s);\n", gbd, s);*/ 715 715 GB_TEST_WRITE(gbd,GB_STRING,"GB_write_string"); … … 773 773 GB_TEST_WRITE(gbd,GB_INTS,"GB_write_ints"); 774 774 GB_TEST_NON_BUFFER((char *)i,"GB_write_ints"); /* compress will destroy the other buffer */ 775 775 776 776 if ( 0x01020304 != htonl((GB_UINT4)0x01020304) ) { 777 777 register long j; … … 857 857 GB_MAIN_TYPE *Main = GB_MAIN(gbd); 858 858 GB_TEST_TRANSACTION(gbd); 859 859 860 860 if (GB_GET_SECURITY_WRITE(gbd)>Main->security_level) 861 861 return gb_security_error(gbd); … … 870 870 GB_MAIN_TYPE *Main = GB_MAIN(gbd); 871 871 GB_TEST_TRANSACTION(gbd); 872 if (GB_GET_SECURITY_WRITE(gbd)>Main->security_level) 872 if (GB_GET_SECURITY_WRITE(gbd)>Main->security_level) 873 873 return gb_security_error(gbd); 874 874 if (GB_GET_SECURITY_READ(gbd) == level) return 0; … … 883 883 GB_MAIN_TYPE *Main = GB_MAIN(gbd); 884 884 GB_TEST_TRANSACTION(gbd); 885 if (GB_GET_SECURITY_WRITE(gbd)>Main->security_level) 885 if (GB_GET_SECURITY_WRITE(gbd)>Main->security_level) 886 886 return gb_security_error(gbd); 887 887 if (GB_GET_SECURITY_DELETE(gbd) == level) return 0; … … 895 895 GB_MAIN_TYPE *Main = GB_MAIN(gbd); 896 896 GB_TEST_TRANSACTION(gbd); 897 if (GB_GET_SECURITY_WRITE(gbd)>Main->security_level) 897 if (GB_GET_SECURITY_WRITE(gbd)>Main->security_level) 898 898 return gb_security_error(gbd); 899 899 GB_PUT_SECURITY_WRITE(gbd,writelevel); … … 924 924 return 0; 925 925 } 926 926 927 927 Main->old_security_level = Main->security_level; 928 928 Main->security_level = 7; … … 1006 1006 1007 1007 GBDATA *GB_get_father(GBDATA *gbd) /* Get the father of an entry */ 1008 { 1008 { 1009 1009 GBDATA *father; 1010 1010 … … 1107 1107 { 1108 1108 GBDATA *gb_main; 1109 1109 1110 1110 GB_TEST_TRANSACTION(source); 1111 1111 if (GB_GET_SECURITY_DELETE(source)>GB_MAIN(source)->security_level) { 1112 1112 return GB_export_error("Security error in GB_delete: %s",GB_read_key_pntr(source)); 1113 1113 } 1114 1115 gb_main = GB_get_root(source); 1116 1114 1115 gb_main = GB_get_root(source); 1116 1117 1117 if (source->flags.compressed_data) { 1118 1118 GB_set_compression(gb_main, 0); /* disable compression */ 1119 gb_set_compression(source); /* write data w/o compression (otherwise GB_read_old_value... won't work) */ 1119 gb_set_compression(source); /* write data w/o compression (otherwise GB_read_old_value... won't work) */ 1120 1120 GB_set_compression(gb_main, -1); /* allow all types of compressions */ 1121 1121 } 1122 1122 1123 1123 if (GB_MAIN(source)->transaction<0){ 1124 1124 gb_delete_entry(source); 1125 gb_do_callback_list(gb_main); 1125 gb_do_callback_list(gb_main); 1126 1126 }else{ 1127 1127 gb_touch_entry(source,gb_deleted); … … 1173 1173 case GB_LINK: /* No local compression */ 1174 1174 error = GB_write_link(dest,GB_read_link_pntr(source)); 1175 break; 1175 break; 1176 1176 case GB_BITS: /* only local compressions for the following types */ 1177 1177 case GB_BYTES: … … 1183 1183 GB_GETDATA(source)); 1184 1184 dest->flags.compressed_data = source->flags.compressed_data; 1185 1185 1186 1186 break; 1187 1187 case GB_DB: 1188 1188 1189 1189 destc = (GBCONTAINER *)dest; 1190 1190 sourcec = (GBCONTAINER *)source; 1191 1191 1192 1192 if (GB_TYPE(destc) != GB_DB) 1193 1193 { … … 1197 1197 return err; 1198 1198 } 1199 1199 1200 1200 if (source->flags2.folded_container) gb_unfold((GBCONTAINER *)source,-1,-1); 1201 1201 if (dest->flags2.folded_container) gb_unfold((GBCONTAINER *)dest,0,-1); … … 1206 1206 { 1207 1207 GB_TYPES type2 = (GB_TYPES)GB_TYPE(gb_p); 1208 1208 1209 1209 key = GB_read_key_pntr(gb_p); 1210 1210 if (type2 == GB_DB) 1211 1211 { 1212 1212 gb_d = GB_create_container(dest,key); 1213 gb_create_header_array((GBCONTAINER *)gb_d, ((GBCONTAINER *)gb_p)->d.size); 1213 gb_create_header_array((GBCONTAINER *)gb_d, ((GBCONTAINER *)gb_p)->d.size); 1214 1214 } 1215 1215 else … … 1217 1217 gb_d = GB_create(dest,key,type2); 1218 1218 } 1219 1219 1220 1220 if (!gb_d) return GB_get_error(); 1221 1221 error = GB_copy(gb_d, gb_p); … … 1225 1225 destc->flags3 = sourcec->flags3; 1226 1226 break; 1227 1227 1228 1228 default: 1229 error = GB_export_error("GB_copy error unknown type"); 1229 error = GB_export_error("GB_copy error unknown type"); 1230 1230 } 1231 1231 if (error) return error; … … 1250 1250 long type; 1251 1251 char *result = 0; 1252 1252 1253 1253 GB_TEST_TRANSACTION(gbd); 1254 1254 type = GB_TYPE(gbd); 1255 1255 1256 1256 if (type==GB_DB) { /* we are a container */ 1257 1257 GBCONTAINER *gbc = (GBCONTAINER*)gbd; 1258 1258 GBDATA *gbp; 1259 1259 int result_length = 0; 1260 1260 1261 1261 if (gbc->flags2.folded_container) { 1262 1262 gb_unfold(gbc, -1, -1); 1263 1263 } 1264 1264 1265 1265 for (gbp = GB_find(gbd, 0, 0, down_level); 1266 1266 gbp; … … 1269 1269 const char *key = GB_read_key_pntr(gbp); 1270 1270 int keylen = strlen(key); 1271 1271 1272 1272 if (result) { 1273 1273 char *neu_result = (char*)malloc(result_length+keylen+1+1); 1274 1274 1275 1275 if (neu_result) { 1276 1276 char *p = stpcpy(neu_result, result); … … 1278 1278 *p++ = ';'; 1279 1279 p[0] = 0; 1280 1280 1281 1281 free(result); 1282 1282 result = neu_result; … … 1296 1296 } 1297 1297 } 1298 } 1298 } 1299 1299 else { 1300 1300 result = GB_strdup(";"); 1301 1301 } 1302 1302 1303 1303 return result; 1304 1304 } … … 1395 1395 1396 1396 GB_ERROR GB_push_local_transaction(GBDATA *gbd){ /* Starts a read only transaction !!; 1397 be shure that all data is cached 1397 be shure that all data is cached 1398 1398 be extremely carefull !!!!! */ 1399 1399 GB_MAIN_TYPE *Main = GB_MAIN(gbd); … … 1468 1468 if (error) return error; 1469 1469 } 1470 gb_do_callback_list(gbd); /* do all callbacks 1471 cb that change the db are no problem 1470 gb_do_callback_list(gbd); /* do all callbacks 1471 cb that change the db are no problem 1472 1472 'cause it's the beginning of a ta */ 1473 1473 Main->clock ++; … … 1635 1635 gb_add_ref_gb_transaction_save(old); 1636 1636 cbl->old = old; 1637 1637 1638 1638 return 0; 1639 1639 } … … 1702 1702 data = GB_GETDATA_TS(ts); 1703 1703 if (!data) return 0; 1704 if (ts->flags.compressed_data) { /* uncompressed data return pntr to 1704 if (ts->flags.compressed_data) { /* uncompressed data return pntr to 1705 1705 database entry */ 1706 1706 size = GB_GETSIZE_TS(ts) * gb_convert_type_2_sizeof[type] + gb_convert_type_2_appendix_size[type]; … … 1713 1713 void *GB_read_old_value(){ 1714 1714 char *data; 1715 1715 1716 1716 if (!g_b_old_callback_list) { 1717 1717 GB_export_error("You cannot call GB_read_old_value outside a ARBDB callback"); … … 1724 1724 data = GB_GETDATA_TS(g_b_old_callback_list->old); 1725 1725 if (!data) return 0; 1726 1726 1727 1727 return gb_read_pntr_ts(g_b_old_callback_list->gbd, g_b_old_callback_list->old); 1728 1728 } … … 1795 1795 } 1796 1796 } 1797 return GB_add_callback(gbd,type,func,clientdata); 1797 return GB_add_callback(gbd,type,func,clientdata); 1798 1798 } 1799 1799 /******************************************************************************************** … … 1870 1870 GBCONTAINER *father; 1871 1871 struct gb_header_list_struct *hl, h; 1872 1872 1873 1873 if (GB_read_clients(gb_main)<0) 1874 1874 return GB_export_error("Sorry: this program is not the arbdb server, you cannot resort your data"); … … 1877 1877 return GB_export_error("There are %i clients (editors, tree programms) connected to this server,\n" 1878 1878 "please close clients and rerun operation", 1879 GB_read_clients(gb_main)); 1879 GB_read_clients(gb_main)); 1880 1880 1881 1881 if (listsize <=0) return 0; 1882 1882 1883 1883 father = GB_FATHER(new_order_list[0]); 1884 1884 GB_disable_quicksave(gb_main,"some entries in the database got a new order"); 1885 1885 hl = GB_DATA_LIST_HEADER(father->d); 1886 1886 1887 for (new_index= 0 ; new_index< listsize; new_index++ ) 1887 for (new_index= 0 ; new_index< listsize; new_index++ ) 1888 1888 { 1889 1889 long old_index = new_order_list[new_index]->index; … … 1898 1898 ogb = GB_HEADER_LIST_GBD(hl[old_index]); 1899 1899 ngb = GB_HEADER_LIST_GBD(hl[new_index]); 1900 1900 1901 1901 h = hl[new_index]; 1902 1902 hl[new_index] = hl[old_index]; … … 1905 1905 SET_GB_HEADER_LIST_GBD(hl[old_index], ngb ); 1906 1906 SET_GB_HEADER_LIST_GBD(hl[new_index], ogb ); 1907 1907 1908 1908 if ( ngb ) ngb->index = old_index; 1909 1909 if ( ogb ) ogb->index = new_index; … … 1999 1999 prev = GB_ARRAY_FLAGS(gbc).flags; 2000 2000 gbd->flags.saved_flags = prev; 2001 2001 2002 2002 if (flag){ 2003 2003 GB_ARRAY_FLAGS(gbc).flags |= ubit; … … 2043 2043 printf("\nDump %p (%i Byte):\n", data, size); 2044 2044 2045 while (size--) 2045 while (size--) 2046 2046 { 2047 2047 const char *hex = "0123456789abcdef"; 2048 2048 char c = *data++; 2049 2049 2050 2050 printf("%c%c ", hex[(c&0xf0)>>4], hex[c&0x0f]); 2051 2051 … … 2086 2086 int size ; 2087 2087 GB_MAIN_TYPE *Main; 2088 2088 2089 2089 if (gbd==NULL) { printf("NULL\n"); return -1; } 2090 2090 GB_push_transaction(gbd); … … 2094 2094 printf(" "); 2095 2095 } 2096 2096 2097 2097 printf("(GBDATA*)0x%lx (GBCONTAINER*)0x%lx ",(long)gbd,(long)gbd); 2098 2098 2099 2099 if (gbd->rel_father==0) { printf("father=NULL\n"); return -1; } 2100 2100 … … 2113 2113 size = gbc->d.size; 2114 2114 printf("Size %i nheader %i hmemsize %i", gbc->d.size, gbc->d.nheader, gbc->d.headermemsize); 2115 printf(" father=(GBDATA*)0x%lx\n", (long)GB_FATHER(gbd)); 2115 printf(" father=(GBDATA*)0x%lx\n", (long)GB_FATHER(gbd)); 2116 2116 if (size < GB_info_deep){ 2117 2117 int index; … … 2128 2128 data = GB_read_as_string(gbd); 2129 2129 if (data) {printf("%s",data); free(data);} 2130 printf(" father=(GBDATA*)0x%lx\n", (long)GB_FATHER(gbd)); 2130 printf(" father=(GBDATA*)0x%lx\n", (long)GB_FATHER(gbd)); 2131 2131 } 2132 2132 2133 2133 2134 2134 GB_pop_transaction(gbd); 2135 2136 return 0; 2137 } 2138 2139 2140 int GB_info(GBDATA *gbd) 2135 2136 return 0; 2137 } 2138 2139 2140 int GB_info(GBDATA *gbd) 2141 2141 { 2142 2142 return gb_info(gbd,0); … … 2147 2147 GBCONTAINER *gbc; 2148 2148 GB_TYPES type = (GB_TYPES)GB_TYPE(gbd); 2149 2149 2150 2150 switch(type) 2151 2151 { 2152 case GB_DB: /* @@@ client size < actual size!!! => use GB_rescan_number_of_subentries() from client */ 2152 case GB_DB: /* @@@ client size < actual size!!! => use GB_rescan_number_of_subentries() from client */ 2153 2153 gbc = (GBCONTAINER *)gbd; 2154 2154 return gbc->d.size; … … 2160 2160 long GB_rescan_number_of_subentries(GBDATA *gbd) { 2161 2161 /* this is just a workaround for the above function, cause GB_number_of_subentries does not work in clients; it's used in ARB_EDIT4 */ 2162 2162 2163 2163 GBCONTAINER *gbc = (GBCONTAINER *)gbd; 2164 2164 /* int userbit = GBCONTAINER_MAIN(gbc)->users[0]->userbit; */ -
trunk/ARBDBPP/adseq.cxx
r2 r655 8 8 #include <stdlib.h> 9 9 #include <memory.h> 10 #include <malloc.h>10 // #include <malloc.h> 11 11 #include <string.h> 12 12 #include <ctype.h> … … 98 98 gb_markdata = 0; 99 99 inited_object = 0; 100 return 0; 101 } 102 100 return 0; 101 } 102 103 103 AD_ERR * AD_STAT::initpntr() { 104 104 if (gb_markdata == 0) { … … 152 152 } 153 153 return 0; 154 } 154 } 155 155 156 156 AD_ERR * AD_STAT::first() { … … 242 242 // behandelt ein update der Markierung in der Datenbank 243 243 // problem -> wenn editiert wird ni 244 // 244 // 245 245 // 246 246 { … … 251 251 ad_mark->gb_markdata = gb_char_mark; 252 252 ad_mark->initpntr(); 253 253 254 254 } 255 255 if (gb_char_mark == ad_mark->GB_FLOAT_mark) { … … 261 261 ad_mark->initpntr(); 262 262 } 263 263 264 264 ad_mark->updated = 1; // flag setzen 265 265 return 0; 266 266 } 267 267 268 268 269 269 char * AD_STAT::getbits() { 270 270 if (marktype != ad_bits) { … … 294 294 AD_ERR *AD_STAT::put() { 295 295 char *error; 296 if (gb_char_mark == 0 && GB_FLOAT_mark == 0 && GB_INT_mark == 0) 297 return new AD_ERR("AD_SEQ::write not possible!"); 296 if (gb_char_mark == 0 && GB_FLOAT_mark == 0 && GB_INT_mark == 0) 297 return new AD_ERR("AD_SEQ::write not possible!"); 298 298 if (GB_FLOAT_mark != 0) { 299 299 error = (char *)GB_write_floats(GB_FLOAT_mark,markdatafloat,nmark); … … 306 306 if (error != 0) { 307 307 return new AD_ERR(error); 308 } 308 } 309 309 } 310 310 if (GB_INT_mark != 0) { … … 312 312 if (error != 0) { 313 313 return new AD_ERR(error); 314 } 315 } 314 } 315 } 316 316 return 0; 317 317 } … … 346 346 return 0; 347 347 } 348 348 349 349 AD_ERR *AD_STAT::put(GB_UINT4 *markings, int len) { 350 350 if (marktype != ad_ints) { 351 351 return new AD_ERR("*AD_STAT::put(int * ... WRONG TYPE",CORE); 352 } 352 } 353 353 markdataint = markings; 354 354 nmark = len; … … 359 359 AD_TYPES AD_STAT::type() { 360 360 return marktype; 361 } 362 363 364 361 } 362 363 364 365 365 366 366 /********************* … … 377 377 // behandelt ein update der sequenz in der Datenbank 378 378 // problem -> wenn editiert wird ni 379 //380 379 // 380 // 381 381 { 382 382 long new_time_stamp; 383 if (gb_seq != ad_seq->gb_seq) 383 if (gb_seq != ad_seq->gb_seq) 384 384 new AD_ERR("AD_SEQ: WRONG update callback",CORE); 385 385 new_time_stamp = GB_read_clock(gb_seq); … … 401 401 AD_SEQ::AD_SEQ() 402 402 { 403 memset(this,0,sizeof(AD_SEQ)); // no virtual members !!! 403 memset(this,0,sizeof(AD_SEQ)); // no virtual members !!! 404 404 } 405 405 … … 411 411 delete seq; 412 412 seq = 0; 413 } 413 } 414 414 } 415 415 … … 447 447 gbdataptr = gb_seq; 448 448 return 0; 449 } else 450 return new AD_ERR("AD_SEQ: exit() without init()"); 449 } else 450 return new AD_ERR("AD_SEQ: exit() without init()"); 451 451 } 452 452 … … 469 469 else gb_seq = 0; 470 470 } 471 471 472 472 if (gb_seq) { 473 473 if (!nseq_but_filter) { … … 512 512 delete seq; 513 513 seq = (char *)malloc((size_t)seq_len + 1); 514 strncpy(seq,sequenz,(int)seq_len); 514 strncpy(seq,sequenz,(int)seq_len); 515 515 for ( i = laenge; i < seq_len; i++) { 516 516 seq[i] = SEQ_POINT; … … 521 521 return 0; 522 522 } 523 523 524 524 char * AD_SEQ::get() 525 525 { … … 535 535 { 536 536 char *error; 537 if (gb_seq == 0) 537 if (gb_seq == 0) 538 538 return new AD_ERR("AD_SEQ::write not possible!"); 539 539 if (nseq_but_filter) { … … 580 580 } 581 581 for (i = seq_len - text_len; i<seq_len; i++) { 582 if (!ADPP_IS_ALIGN_CHARACTER(seq[i])) { 582 if (!ADPP_IS_ALIGN_CHARACTER(seq[i])) { 583 583 return new AD_ERR("AD_SEQ::insert: end of alignment reached !"); 584 584 } … … 587 587 seq[i+text_len] = seq[i]; 588 588 } 589 589 590 590 for (i = 0 ;i<text_len;i++) { 591 591 seq[position + i] = text[i]; … … 596 596 } 597 597 for (i = 0; i<text_len; i++) { 598 if (!ADPP_IS_ALIGN_CHARACTER(seq[i])) { 598 if (!ADPP_IS_ALIGN_CHARACTER(seq[i])) { 599 599 return new AD_ERR("AD_SEQ::insert: start of alignment reached !"); 600 600 } … … 603 603 seq[i] = seq[i+text_len]; 604 604 } 605 605 606 606 for (i = 0 ;i<text_len;i++) { 607 607 seq[position - i -1] = text[i]; … … 609 609 } 610 610 return 0; 611 } 612 611 } 612 613 613 AD_ERR * AD_SEQ::remove(int len,long position, int direction) { 614 614 long new_len; … … 640 640 return 0; 641 641 } 642 642 643 643 644 644 AD_ERR * AD_SEQ::replace(char *text,long position, int direction) { … … 933 933 changed_flag = 1; 934 934 cursorpos += direction; 935 } 935 } 936 936 }else{ 937 937 if (ADPP_IS_ALIGN_CHARACTER(seq[cursorpos+offset])){ … … 944 944 default: 945 945 break; 946 946 947 947 } 948 948 if (ad_err) cursorpos = oldcursorpos; … … 963 963 return this->get_ad_main()->mode; 964 964 } 965 965 966 966 967 967 … … 969 969 970 970 /*************************** 971 AD_CONT 971 AD_CONT 972 972 container wird mit spezies,alignment initialisiert 973 973 entspricht ungefaehr dem ali_xxx container der ARB DB … … 993 993 { 994 994 if (!con_insert(adptr1,adptr2)) // test ob container schoneinmal initialisiert 995 return new AD_ERR("AD_CONT::init ONLY ONE AD_CONT PER SPECIES/ALIGN"); 995 return new AD_ERR("AD_CONT::init ONLY ONE AD_CONT PER SPECIES/ALIGN"); 996 996 ad_species = adptr1; 997 997 ad_ali = adptr2; -
trunk/ARBDBPP/adt_edit.cxx
r2 r655 3 3 #include <stdlib.h> 4 4 #include <string.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <memory.h> 7 7 #include <arbdb.h> … … 54 54 local_char_array[i] = (char) i; 55 55 } 56 return local_char_array; 56 return local_char_array; 57 57 } 58 58 … … 60 60 AD_ERR * ADT_COMPLEMENT::complement_compile(void) { //Veraendert Zeichensatz 61 61 62 delete char_array; 62 delete char_array; 63 63 char_array = make_char_array(); 64 64 … … 127 127 128 128 seq_buff = (char *)calloc( ((int)buffer_len + 1), sizeof(char) ); 129 memset(seq_buff, (int)'.', ((int)buffer_len)); 129 memset(seq_buff, (int)'.', ((int)buffer_len)); 130 130 sequence_buffer = seq_buff; 131 131 132 132 133 133 ind_buff = (long *) calloc( ((int)buffer_len + 1), sizeof(long) ); 134 134 ind_buff[buffer_len] = -1; … … 175 175 mistakes_allowed = 0; 176 176 gaps = -1; //gaps werden nicht ignoriert 177 upper_eq_lower = 0; //gross/KLEIN-Schreibung, 178 t_equal_u = 0; //t und u gleichbehandeln, 177 upper_eq_lower = 0; //gross/KLEIN-Schreibung, 178 t_equal_u = 0; //t und u gleichbehandeln, 179 179 search_start_cursor_pos = 0; 180 180 replace_start_cursor_pos= 0; … … 200 200 search_array[i] = (char) i; 201 201 } 202 return search_array; 202 return search_array; 203 203 } 204 204 205 205 //*********************************** 206 206 //Veraendert Zeichensatz, Liefert Matchpattern ohne Gaps 207 AD_ERR * ADT_SEARCH::compile(void) { 208 delete search_array; 207 AD_ERR * ADT_SEARCH::compile(void) { 208 delete search_array; 209 209 search_array = show_search_array(); 210 210 … … 230 230 char *matchp_buffer_start, *matchp_buffer_loop; 231 231 232 matchp_buffer_start = matchp_buffer_loop = 232 matchp_buffer_start = matchp_buffer_loop = 233 233 matchpattern_buffer; 234 234 235 for( matchp_copy_loop = matchpattern ; 236 *matchp_copy_loop != '\0' ; 235 for( matchp_copy_loop = matchpattern ; 236 *matchp_copy_loop != '\0' ; 237 237 matchp_copy_loop++ ) { 238 238 if(*matchp_copy_loop != '-') { … … 255 255 // 256 256 //************************************************************************** 257 AD_ERR * ADT_SEQUENCE::make_sequence_buffer(ADT_SEARCH 257 AD_ERR * ADT_SEQUENCE::make_sequence_buffer(ADT_SEARCH 258 258 *ptr_adt_search, ADT_EDIT *ptr_adt_edit) { 259 259 … … 270 270 seq_buffer_start = (char *)calloc(strlen(seq_anfang)+1,sizeof(char)); 271 271 272 if (!seq_buffer_start) { 272 if (!seq_buffer_start) { 273 273 // printf("\n**** ERROR sequence-buffer no memory allocated"); 274 274 } … … 279 279 seq_index_start = (long *) calloc(strlen(seq_anfang)+1,sizeof(long)); 280 280 281 if (!seq_index_start) { 281 if (!seq_index_start) { 282 282 // printf("\n**** ERROR index-buffer no memory allocated"); 283 283 } … … 290 290 if(*seq_copy_loop != '-') { 291 291 *(seq_buffer_loop++) = source; //kopiert Zeichen 292 *(seq_index_loop++) = seq_copy_loop - seq_anfang; 292 *(seq_index_loop++) = seq_copy_loop - seq_anfang; 293 293 //Index des Zeichens 294 294 } … … 296 296 *seq_buffer_loop = '\0'; 297 297 *seq_index_loop = -1; 298 ptr_adt_search->seq_anfang = seq_buffer_start; //SEQUENCE START 298 ptr_adt_search->seq_anfang = seq_buffer_start; //SEQUENCE START 299 299 //--------------------------------------------------end sequencebuffer 300 300 … … 305 305 long buffer_index = 0; //zaehlvariable fuer 306 306 //Cursorberechnung 307 for( buffer_index = 0 ; 308 (seq_index_start[buffer_index] < 309 var_cursorpos_editor) && 307 for( buffer_index = 0 ; 308 (seq_index_start[buffer_index] < 309 var_cursorpos_editor) && 310 310 (seq_index_start[buffer_index] != -1 ) ; 311 311 buffer_index++ ) { … … 321 321 if( (seq_index_start[buffer_index] == var_cursorpos_editor) && 322 322 (var_cursorpos_editor > 0) ) { 323 ptr_adt_search->search_start_cursor_pos = 323 ptr_adt_search->search_start_cursor_pos = 324 324 buffer_index + 1; 325 325 } 326 326 else { 327 ptr_adt_search->search_start_cursor_pos = 327 ptr_adt_search->search_start_cursor_pos = 328 328 buffer_index; 329 } 329 } 330 330 } // end if 331 331 else { … … 346 346 // 347 347 //************************************************************************** 348 AD_ERR * ADT_SEQUENCE::rewrite_from_sequence_buffer(ADT_SEARCH 348 AD_ERR * ADT_SEQUENCE::rewrite_from_sequence_buffer(ADT_SEARCH 349 349 *ptr_adt_search, ADT_EDIT *ptr_adt_edit) { 350 350 … … 355 355 356 356 //--------------------------------found_cursor_pos nach Suche ohne Gaps 357 if (( ptr_adt_edit->found_matchp == 1 ) && 357 if (( ptr_adt_edit->found_matchp == 1 ) && 358 358 ( ptr_adt_search->replace_option == ADT_NO_REPLACE )) { 359 ptr_adt_search->found_cursor_pos = 359 ptr_adt_search->found_cursor_pos = 360 360 ptr_adt_search->seq_index_start[found_cursor_pos_buffer]; 361 361 } … … 364 364 //---------------------------------------rewrite Seq-Puffer auf Sequenz 365 365 if( ptr_adt_search->replace_option != ADT_NO_REPLACE ) { 366 seq_buffer_start = ptr_adt_search->seq_anfang; 366 seq_buffer_start = ptr_adt_search->seq_anfang; 367 367 seq_index_start = ptr_adt_search->seq_index_start; 368 368 seq_anfang = get(); 369 369 370 long buffer_index = 0; //zaehlvariable 370 long buffer_index = 0; //zaehlvariable 371 371 register char source; 372 372 373 for( ; (source = seq_buffer_start[buffer_index]) ; 373 for( ; (source = seq_buffer_start[buffer_index]) ; 374 374 buffer_index++ ) { 375 375 *(seq_anfang + seq_index_start[buffer_index]) = source; … … 379 379 380 380 char *replace_anfang = ptr_adt_search->replace_string; 381 long var_start_cursor_pos = 381 long var_start_cursor_pos = 382 382 ptr_adt_search->replace_start_cursor_pos; 383 383 384 384 //--------------------------------------------cursorpos_editor 385 long buffer_end_replace = 385 long buffer_end_replace = 386 386 var_start_cursor_pos + strlen(replace_anfang); 387 388 ptr_adt_edit->actual_cursorpos_editor = 387 388 ptr_adt_edit->actual_cursorpos_editor = 389 389 ptr_adt_search->seq_index_start[buffer_end_replace-1]; 390 // nur bei Suchrichtung 390 // nur bei Suchrichtung 391 391 // "Vorwaerts" !!! 392 392 //----------------------------------------end cursorpos_editor … … 411 411 // 412 412 //************************************************************************** 413 AD_ERR * ADT_SEQUENCE::show_edit_seq_search(ADT_SEARCH *ptr_adt_search, 413 AD_ERR * ADT_SEQUENCE::show_edit_seq_search(ADT_SEARCH *ptr_adt_search, 414 414 ADT_EDIT *ptr_adt_edit) { 415 415 AD_ERR *ad_err; … … 421 421 422 422 423 // Sicherheitsabfrage fuer die 423 // Sicherheitsabfrage fuer die 424 424 // Rueckwaertssuche !! 425 if(ptr_adt_search->search_start_cursor_pos > len()) { 425 if(ptr_adt_search->search_start_cursor_pos > len()) { 426 426 //Cursorpos > Sequenzlaenge? 427 427 ptr_adt_search->search_start_cursor_pos = len() - 1; … … 430 430 //-----------------------------------------------------Sequenz puffern 431 431 if( (ptr_adt_search->gaps == 0) || (ptr_adt_search->gaps == 1) ) { 432 make_sequence_buffer(ptr_adt_search, ptr_adt_edit); 432 make_sequence_buffer(ptr_adt_search, ptr_adt_edit); 433 433 /////////////////////////////////////////////////// 434 434 } //end if, >>Sequenz<< OHNE Gaps. 435 //---------------------------------------------------- end seq puffern 435 //---------------------------------------------------- end seq puffern 436 436 437 437 //---------------------------------Sicherungskopie der Seq fuer REPLACE … … 442 442 443 443 //---------------------------------------korrigiert die Start Cursorpos 444 // bis Ende.., da erst search(), dann replace() 444 // bis Ende.., da erst search(), dann replace() 445 445 if( ( (ptr_adt_search->replace_option == ADT_REPLACE_ONLY) || 446 446 (ptr_adt_search->replace_option == ADT_REPLACE_AND_SEARCH_NEXT)|| … … 454 454 455 455 //==================================================================== 456 //=================================================while(replace_loop) 456 //=================================================while(replace_loop) 457 457 long max_loop = this->seq_len; 458 458 do { // END Sequenz/Editor 459 459 460 //------------------------------------------------------SEARCH 460 //------------------------------------------------------SEARCH 461 461 ptr_adt_edit->found_matchp = 0; 462 462 463 463 show_edit_search(ptr_adt_search, ptr_adt_edit); 464 464 ////////////////////////////////////////////// 465 //------------------------------------------------- END SEARCH 465 //------------------------------------------------- END SEARCH 466 466 467 467 if( ((ptr_adt_search->replace_option == ADT_REPLACE_ONLY) || … … 474 474 475 475 else { 476 ptr_adt_search->replace_start_cursor_pos = 476 ptr_adt_search->replace_start_cursor_pos = 477 477 ptr_adt_search->found_cursor_pos; 478 478 } 479 479 480 //---------------------------------------------------- REPLACE 481 if( (ptr_adt_edit->found_matchp == 1) && 480 //---------------------------------------------------- REPLACE 481 if( (ptr_adt_edit->found_matchp == 1) && 482 482 (ptr_adt_search->replace_option != ADT_NO_REPLACE) ) { 483 483 484 484 ad_err = show_edit_replace(ptr_adt_search,ptr_adt_edit); 485 ////////////////////////////////////////////// 485 ////////////////////////////////////////////// 486 486 if(ad_err) return ad_err; 487 487 } … … 492 492 (ptr_adt_search->string_replace == 1) ) { 493 493 ptr_adt_search->string_replace = 0; 494 ptr_adt_search->search_start_cursor_pos = 494 ptr_adt_search->search_start_cursor_pos = 495 495 ptr_adt_edit->actual_cursorpos_editor + 1; 496 496 ptr_adt_search->replace_option = ADT_NO_REPLACE; 497 497 } 498 498 //---------end repl/find next 499 else { 499 else { 500 500 if( (ptr_adt_search->replace_option == ADT_REPLACE_REST_SEQUENCE) || 501 501 (ptr_adt_search->replace_option == ADT_REPLACE_REST_EDITOR) ) { 502 502 503 503 replace_loop = ptr_adt_search->replace_loop_sequence; 504 ptr_adt_search->search_start_cursor_pos = 504 ptr_adt_search->search_start_cursor_pos = 505 505 ( ptr_adt_edit->actual_cursorpos_editor + 1 ); 506 506 … … 508 508 if( replace_loop == ADT_STOPP_REPLACE ) { 509 509 ptr_adt_edit->found_matchp = 1; 510 } 510 } 511 511 if (max_loop-- <0) replace_loop = ADT_STOPP_REPLACE; 512 512 } else { … … 536 536 return ad_err; 537 537 } 538 538 539 539 show_update(); 540 540 } 541 541 //---------------------------------------------------end write into DB 542 542 543 if( (ptr_adt_edit->found_matchp == 1) && 544 (ptr_adt_search->string_replace == 0) ) { 545 ptr_adt_edit->actual_cursorpos_editor = 543 if( (ptr_adt_edit->found_matchp == 1) && 544 (ptr_adt_search->string_replace == 0) ) { 545 ptr_adt_edit->actual_cursorpos_editor = 546 546 ptr_adt_search->found_cursor_pos; 547 547 } … … 549 549 // nichts gefunden, 550 550 //---------------------------------- cursorpos in next sequence 551 if( (ptr_adt_edit->found_matchp == 0) || 551 if( (ptr_adt_edit->found_matchp == 0) || 552 552 (ptr_adt_search->replace_option == ADT_REPLACE_REST_EDITOR) ) { 553 553 if( ptr_adt_search->search_direction == ADT_SEARCH_FORWARD ) { … … 574 574 // 575 575 //************************************************************************** 576 AD_ERR * ADT_SEQUENCE::show_edit_search(ADT_SEARCH *ptr_adt_search, 576 AD_ERR * ADT_SEQUENCE::show_edit_search(ADT_SEARCH *ptr_adt_search, 577 577 ADT_EDIT *ptr_adt_edit) { 578 578 579 579 char *seq_anfang, *seq_loop_start, *seq_loop_ptr; // Suche Sequenz 580 char *matchp_anfang, *matchp_loop_ptr; // Suche 580 char *matchp_anfang, *matchp_loop_ptr; // Suche 581 581 // Matchpattern 582 582 … … 584 584 long vorgabefehler, realfehler=0, equal_chars; 585 585 long seq_empty_var; 586 long search_var; 586 long search_var; 587 587 588 588 search_var = ptr_adt_search->search_direction; … … 600 600 601 601 //---------------------------------------------------------start search 602 for( ; (*seq_loop_start != '\0') && 602 for( ; (*seq_loop_start != '\0') && 603 603 (seq_loop_start >= seq_anfang) ; 604 604 seq_loop_start+=search_var ) { … … 609 609 for( matchp_loop_ptr=matchp_anfang ; *matchp_loop_ptr != '\0' ; 610 610 matchp_loop_ptr++ ) { 611 611 612 612 unsigned char index_seq = *(unsigned char *)seq_loop_ptr; 613 613 unsigned char index_mat=*(unsigned char*)matchp_loop_ptr; 614 614 char i_s = ptr_adt_search->search_array[(int)index_seq]; 615 char i_m = ptr_adt_search->search_array[(int)index_mat]; 615 char i_m = ptr_adt_search->search_array[(int)index_mat]; 616 616 if( i_m == '?' ) { // Wilde Karten 617 617 equal_chars++; … … 624 624 equal_chars++; 625 625 } 626 // mehr Fehler als erlaubt? 626 // mehr Fehler als erlaubt? 627 627 if(realfehler > vorgabefehler) { 628 628 ptr_adt_edit->found_matchp = 0; 629 629 break; 630 630 } 631 //gefunden? (noetig, da Restsequenz 632 //kuerzer 633 //als Suchstringlaenge sein kann.) 634 //Fehler + Uebereinstimmungen = Laenge 631 //gefunden? (noetig, da Restsequenz 632 //kuerzer 633 //als Suchstringlaenge sein kann.) 634 //Fehler + Uebereinstimmungen = Laenge 635 635 //des Matchpatterns 636 636 if(realfehler+equal_chars == matchp_len) { … … 641 641 642 642 seq_loop_ptr++; // Ende der Sequenz erreicht? 643 if( *seq_loop_ptr == '\0') { // 643 if( *seq_loop_ptr == '\0') { // 644 644 seq_empty_var = 1; 645 645 break; … … 648 648 } // end for() 649 649 650 if( *(seq_loop_ptr+1) == '\0') { 651 ptr_adt_search->replace_loop_sequence = 650 if( *(seq_loop_ptr+1) == '\0') { 651 ptr_adt_search->replace_loop_sequence = 652 652 ADT_STOPP_REPLACE; 653 653 } … … 656 656 //---------------------------------found cursorpos in sequence 657 657 if( ptr_adt_edit->found_matchp == 1) { 658 ptr_adt_search->found_cursor_pos = 658 ptr_adt_search->found_cursor_pos = 659 659 seq_loop_start - seq_anfang; 660 660 break; … … 663 663 664 664 if( (ptr_adt_search->replace_option == ADT_REPLACE_ONLY) || 665 (ptr_adt_search->replace_option == 665 (ptr_adt_search->replace_option == 666 666 ADT_REPLACE_AND_SEARCH_NEXT)) { 667 667 break; //for schleife nur einmal ausfuehren. … … 679 679 //************************************************************************** 680 680 // 681 // Ueberprueft zuerst, ob die Sequenz ab der Cursorposition mit dem 681 // Ueberprueft zuerst, ob die Sequenz ab der Cursorposition mit dem 682 682 // Matchpattern uebereinstimmt. Wenn ja, dann erfolgt die Ersetzung. 683 683 // Mit GAPS: durch remove(), und insert() der AD_SEQ-Klasse; 684 // Ohne Gaps: direktes ueberschreiben im Sequenzpuffer, danach 684 // Ohne Gaps: direktes ueberschreiben im Sequenzpuffer, danach 685 685 // ueberschreiben der Sequenzkopie im Cache. 686 // Beide Varianten schreiben die geaenderte Sequenz mittels put() in 686 // Beide Varianten schreiben die geaenderte Sequenz mittels put() in 687 687 // die Datenbank zurueck. (Security-Level nicht vergessen!!) 688 // 689 //************************************************************************** 690 AD_ERR * ADT_SEQUENCE::show_edit_replace(ADT_SEARCH *ptr_adt_search, 691 ADT_EDIT *ptr_adt_edit) 688 // 689 //************************************************************************** 690 AD_ERR * ADT_SEQUENCE::show_edit_replace(ADT_SEARCH *ptr_adt_search, 691 ADT_EDIT *ptr_adt_edit) 692 692 693 693 { … … 701 701 seq_anfang = ptr_adt_search->seq_anfang; 702 702 703 ptr_adt_search->string_replace = 0; 704 long var_start_cursor_pos = 703 ptr_adt_search->string_replace = 0; 704 long var_start_cursor_pos = 705 705 ptr_adt_search->replace_start_cursor_pos; 706 706 … … 718 718 //----------------------------------------------------replace 719 719 seq_loop_ptr = seq_loop_start; 720 for( replace_loop_ptr = replace_anfang ; 720 for( replace_loop_ptr = replace_anfang ; 721 721 *replace_loop_ptr != '\0' ; replace_loop_ptr++ ) { 722 722 *seq_loop_ptr = *replace_loop_ptr; … … 724 724 } // end for() 725 725 } // end if(match_len == replace_len) 726 726 727 727 else { 728 728 //-----------------------------------------------------remove … … 737 737 738 738 //-----------------------------------------------------insert 739 else if( strlen(replace_anfang) != 0 ){ 740 ad_err = insert( replace_anfang, 739 else if( strlen(replace_anfang) != 0 ){ 740 ad_err = insert( replace_anfang, 741 741 (int)var_start_cursor_pos ,1 ); 742 742 … … 750 750 } 751 751 } 752 //========================================================END REPLACE 752 //========================================================END REPLACE 753 753 //-------------------------------------------------- Cursorpos Editor 754 ptr_adt_edit->actual_cursorpos_editor = 755 ptr_adt_search->replace_start_cursor_pos + 754 ptr_adt_edit->actual_cursorpos_editor = 755 ptr_adt_search->replace_start_cursor_pos + 756 756 strlen(replace_anfang) - 1; 757 757 //-----------------------------------------------------END Cursorpos … … 781 781 //-------------------------------------------------------- border check 782 782 if( ptr_adt_complement->take_borders == YES ) { 783 if( (ptr_adt_complement->sequence_length - 1) < 783 if( (ptr_adt_complement->sequence_length - 1) < 784 784 ptr_adt_complement->right_border ) { 785 ptr_adt_complement->right_border = 785 ptr_adt_complement->right_border = 786 786 ptr_adt_complement->sequence_length - 1; 787 787 } 788 if( (ptr_adt_complement->sequence_length - 1) < 788 if( (ptr_adt_complement->sequence_length - 1) < 789 789 ptr_adt_complement->left_border ) { 790 790 return 0; … … 819 819 return ad_err; 820 820 } 821 821 822 822 show_update(); 823 823 } … … 836 836 //printf("SEQUENCE: (ab Cursorpos 200)\n"); 837 837 //seq_loop+=200; 838 for(int k=0; (k<100) && (*seq_loop); k++) { 838 for(int k=0; (k<100) && (*seq_loop); k++) { 839 839 printf("%c", *seq_loop); 840 840 seq_loop++; … … 842 842 printf("\n"); 843 843 printf("alignment_length: %d\n", ptr_adt_complement->alignment_length ); 844 printf("Borders [left..right]: [%d .. %d]\n", 844 printf("Borders [left..right]: [%d .. %d]\n", 845 845 ptr_adt_complement->left_border, ptr_adt_complement->right_border ); 846 846 printf("seq_is_complemented: %d\n", ptr_adt_complement->seq_is_complemented ); … … 885 885 886 886 //-------------------------------------------------erledigt complement 887 for( compl_loop = compl_start; 887 for( compl_loop = compl_start; 888 888 (*compl_loop) && (compl_loop <= right_border) ; compl_loop++ ) { 889 889 *compl_loop = ptr_adt_complement->char_array[(int)*compl_loop]; … … 949 949 950 950 //========================================== kopieren der Seq in Puffer 951 for( sequence_loop = sequence_loop_start; 951 for( sequence_loop = sequence_loop_start; 952 952 ( source = *sequence_loop) && (sequence_loop <= right_border) ; 953 953 sequence_loop++ ) { 954 if( !((source == '-') || (source == '.')) ) 954 if( !((source == '-') || (source == '.')) ) 955 955 { *( seq_buffer_loop++ ) = source; 956 956 *( index_buffer_loop++ ) = sequence_loop - sequence; … … 993 993 994 994 if(ptr_adt_complement->remove_gaps_points == YES) { 995 for( seq_buffer_loop = seq_buffer_loop_start ; 995 for( seq_buffer_loop = seq_buffer_loop_start ; 996 996 (source = *seq_buffer_loop) && (seq_buffer_loop <= right_border); 997 seq_buffer_loop++ ) { 997 seq_buffer_loop++ ) { 998 998 *(sequence_loop++) = source; 999 999 } 1000 1000 } 1001 1001 else { //////////// ptr_adt_complement->remove_gaps_points == NO 1002 for( ; (source = seq_buffer[buffer_index]) && 1002 for( ; (source = seq_buffer[buffer_index]) && 1003 1003 (seq_buffer[buffer_index] != '.'); 1004 1004 buffer_index++) { 1005 1005 *(sequence + index_buffer[buffer_index]) = source; 1006 1007 } 1008 } 1006 1007 } 1008 } 1009 1009 //=========================================== end ueberschreiben der Seq 1010 1010 ptr_adt_complement->seq_is_inverted = YES; -
trunk/ARBDBPP/adtali.cxx
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <arbdb.h> 5 5 #include "adtools.hxx" … … 26 26 // testversion leerer gap 27 27 for (int i = 0; i < len; i++) { 28 gapsequence[i] = NOGAP_SYMBOL; 28 gapsequence[i] = NOGAP_SYMBOL; 29 29 gapshowoffset[i] = 0; 30 30 gaprealoffset[i] = 0; 31 31 } 32 32 gapshowoffset_len = len; 33 inited = 1; 33 inited = 1; 34 34 } 35 35 … … 41 41 int offset_sum = 1; 42 42 int i,counter = 0; 43 if (!((position+length > AD_ALI::len()) || gap_inside(position,position + length))) { 44 for (i = position;i<position +length;i++) { // gapsequence 43 if (!((position+length > AD_ALI::len()) || gap_inside(position,position + length))) { 44 for (i = position;i<position +length;i++) { // gapsequence 45 45 gapsequence[i] = GAP_SYMBOL; 46 46 } … … 48 48 offset_sum = -length-1; 49 49 } 50 for (i = 0; i<AD_ALI::len(); i++) { // gaprealoffset 50 for (i = 0; i<AD_ALI::len(); i++) { // gaprealoffset 51 51 if (gapsequence[i] == GAP_SYMBOL) { 52 offset_sum ++; } 53 gaprealoffset[i] = offset_sum; 52 offset_sum ++; } 53 gaprealoffset[i] = offset_sum; 54 54 } 55 55 … … 61 61 } else { 62 62 offset_sum ++; 63 } 63 } 64 64 } 65 65 gapshowoffset_len = counter-1; … … 67 67 return 0; 68 68 } else { 69 return new AD_ERR("ADT_ALI::gap_make(int position,int length) ungueltige parameter"); 70 } 69 return new AD_ERR("ADT_ALI::gap_make(int position,int length) ungueltige parameter"); 70 } 71 71 } 72 73 72 73 74 74 AD_ERR * ADT_ALI::gap_delete(int showposition) { 75 75 // showposition zeigt auf die position vor dem gap … … 81 81 gapsequence[i] = NOGAP_SYMBOL; 82 82 } 83 for (i = 0; i<AD_ALI::len(); i++) { // gaprealoffset 83 for (i = 0; i<AD_ALI::len(); i++) { // gaprealoffset 84 84 if (gapsequence[i] == GAP_SYMBOL) { 85 offset_sum ++; } 86 gaprealoffset[i] = offset_sum; 85 offset_sum ++; } 86 gaprealoffset[i] = offset_sum; 87 87 } 88 88 … … 94 94 } else { 95 95 offset_sum ++; 96 } 96 } 97 97 } 98 98 99 99 gapshowoffset_len = gapshowoffset_len + endpos-startpos; 100 return 0; 100 return 0; 101 101 } 102 102 … … 106 106 return 0; 107 107 } 108 108 109 109 char * ADT_ALI::gap_make_real_sequence(char *realseq,const char *showseq) { 110 110 realseq=realseq;showseq=showseq; 111 return 0; 111 return 0; 112 112 } 113 113 … … 126 126 127 127 int ADT_ALI::gap_inside(int showposition1,int showposition2) { 128 // if (gapshowoffset[showposition1] != gapshowoffset[showposition2]) 128 // if (gapshowoffset[showposition1] != gapshowoffset[showposition2]) 129 129 // return 1; 130 130 GBUSE(showposition1);GBUSE(showposition2); … … 139 139 GBUSE(showposition); 140 140 return 0; 141 } 141 } 142 142 143 143 int ADT_ALI::gap_realpos(int showposition) { … … 150 150 // return (realposition - gaprealoffset[realposition]); 151 151 } 152 152 153 153 #if 0 154 154 void ADT_ALI::operator = (ADT_ALI &adtali) -
trunk/ARBDBPP/adtsequence.cxx
r2 r655 1 #include <malloc.h>1 // #include <malloc.h> 2 2 #include <memory.h> 3 3 #include <string.h> 4 #include <stdio.h>4 // #include <stdio.h> 5 5 6 6 #include <arbdb.h> … … 22 22 AD_SEQ::init(adcont); 23 23 show_timestamp = timestamp; 24 24 25 25 } 26 26 … … 39 39 ; 40 40 } 41 41 42 42 int ADT_SEQUENCE::show_len() { 43 43 return seq_len; -
trunk/ARBDB_COMPRESS/AC_main.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 42 42 AC_SEQUENCE_INFO *new_ac_seq_info; 43 43 int count = 0; 44 44 45 45 #ifdef COMMENT 46 46 printf("\nStart reading DB : \n\n"); … … 63 63 ac_sequence = new AC_SEQUENCE_UNALIGNED(gb_data);// gbdata !!!!!!! 64 64 } 65 new_ac_seq_info = (AC_SEQUENCE_INFO *) 65 new_ac_seq_info = (AC_SEQUENCE_INFO *) 66 66 calloc(sizeof(AC_SEQUENCE_INFO),1); 67 67 new_ac_seq_info->gb_species = gb_species; … … 71 71 //-------------------------------------------------------- 72 72 sequence_work = new_ac_seq_info->seq; // Pointer auf Class AC_SEQUENCE 73 sequence_work->quality = sequence_work->get_quality(); 73 sequence_work->quality = sequence_work->get_quality(); 74 74 //-------------------------------------------------------- 75 75 this->insert(new_ac_seq_info); 76 76 //-------------------------------------------------------- 77 77 78 78 #ifdef COMMENT 79 79 if (count % 100 == 0) { … … 112 112 printf("\f"); 113 113 #endif 114 114 115 115 AC_DBDATA_STATE ac_dbdata_state = ALIGNED_SEQUENCES; 116 116 … … 141 141 #ifdef PRINT_TREE 142 142 printf("\n"); 143 root->print_tree(); 143 root->print_tree(); 144 144 printf("\n"); 145 145 #endif 146 146 #ifdef PRINT_FORMATED_DBTREE 147 147 printf("\n"); 148 root->print_formated_dbtree(); 148 root->print_formated_dbtree(); 149 149 printf("\n"); 150 150 #endif 151 151 152 152 153 153 -
trunk/ARBDB_COMPRESS/AC_sequence.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <ctype.h> … … 77 77 // class AC_SEQUENCE_ALIGNED::get_distance() 78 78 // 79 // liefert die Distanz zwischen der aktuellen Sequenz und 79 // liefert die Distanz zwischen der aktuellen Sequenz und 80 80 // der Referenzsequenz. 81 81 // Es muessen zwei vergleichbare Zeichen (= Buchstaben) … … 85 85 //********************************************************************* 86 86 double AC_SEQUENCE_ALIGNED::get_distance(AC_SEQUENCE *that) { 87 87 88 88 register long distance, equals; 89 89 register char *revptr, *seqptr; … … 105 105 } // endif 106 106 } // endfor 107 107 108 108 return distance/(distance + equals + 1.0); 109 109 -
trunk/ARBDB_COMPRESS/AC_toys_n_tools.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <math.h> … … 15 15 16 16 17 18 //********************************************************************* 19 // 20 // zur Festlegung der Sortierrichtung des ARRAYS bei dem 17 18 //********************************************************************* 19 // 20 // zur Festlegung der Sortierrichtung des ARRAYS bei dem 21 21 // Funktionsaufruf von: 22 22 // … … 44 44 //********************************************************************* 45 45 // 46 // get_intersection_expglaettg 47 // 46 // get_intersection_expglaettg 47 // 48 48 // diese Funktion bestimmt den Schnittpunkt folgendermassen: 49 49 // 50 50 // 51 51 //********************************************************************* 52 52 53 53 double get_intersection_expglaettg(AC_SEQUENCE_INFO **sort_array, double number_of) 54 54 { 55 55 56 56 AC_SEQUENCE_INFO **array_ptr = sort_array; 57 57 … … 64 64 double nenner = 0; 65 65 double zaehler = 0; 66 double potenz_nenner = 0; 67 double potenz_zaehler = 0; 66 double potenz_nenner = 0; 67 double potenz_zaehler = 0; 68 68 double intersection_value = 0; // Schnittpunkt 69 long anzahl_aller_seq = 0; 69 long anzahl_aller_seq = 0; 70 70 long anzahl_seq_links = 0; 71 71 long anzahl_seq_rechts = 0; … … 74 74 double min_x = 0; // Min Relationship -> Schnittpunkt 75 75 double min_zpar = 0; // Minimum 76 double min_max_anzahl_lire_product = 0; // maximales Produkt aus 77 // AnzahlLinkerSeqs x AnzahlRechterSeqs 76 double min_max_anzahl_lire_product = 0; // maximales Produkt aus 77 // AnzahlLinkerSeqs x AnzahlRechterSeqs 78 78 // eines Minimums !!! 79 79 long min_sequenznumber = 0; // Nummer der Sequenz 80 80 81 81 dekrement = number_of; 82 anzahl_aller_seq = number_of; 82 anzahl_aller_seq = number_of; 83 83 anzahl_seq_links = 0; 84 84 anzahl_seq_rechts = anzahl_aller_seq; // schnittpkt wird die erste seq des re knotens … … 91 91 //-------------------------------- f(x[i]) = f(x[i-1]) * ( 1/32^[f(x[i])-f(x[i-1])] +1 ) 92 92 for( array_ptr,dekrement; 0 < dekrement; ) { 93 93 94 94 //------------------------------------------ Zuweisung Relationship 95 95 x = (*array_ptr)->relationship; … … 99 99 y = x - prev_x; 100 100 //----------------------------------- Ende Bestimmung der Abstaende 101 101 102 102 //------------------------------------------------ Glaettungsfunktion 103 103 if( dekrement == number_of ) { // NUR BEI erster Sequenz "LEFTEND" !! … … 135 135 136 136 //------------------------------------- Bestimmung des Schnittpunktes 137 if( (zpar < min_zpar) || 137 if( (zpar < min_zpar) || 138 138 ((zpar == min_zpar) && (anzahl_lire_product > min_max_anzahl_lire_product)) ) { 139 139 min_x = x; … … 161 161 162 162 prev_y = y; 163 prev_x = x; 163 prev_x = x; 164 164 prev_z = z; 165 165 -
trunk/ARBDB_COMPRESS/AC_tree.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <math.h> … … 43 43 // class AC_SEQUENCE_LIST:: remove_sequence() 44 44 // 45 // gibt den Speicher der Liste wieder frei 45 // gibt den Speicher der Liste wieder frei 46 46 // 47 47 //********************************************************************* … … 62 62 // class AC_SEQUENCE_LIST:: remove_sequence_list() 63 63 // 64 // gibt den Speicher der Liste wieder frei 64 // gibt den Speicher der Liste wieder frei 65 65 // 66 66 //********************************************************************* … … 97 97 this->sequences = new_seq; 98 98 new_seq->previous = NULL; 99 99 100 100 this->nsequences = ++this->nsequences; 101 101 … … 129 129 130 130 for( ptr = ac_sequence_info ; ptr ; ptr = ptr->next ) 131 { 131 { 132 132 if( maximum < ptr->seq->quality ) { 133 133 maximum = ptr->seq->quality; … … 143 143 144 144 } // endfor 145 145 146 146 //printf("\n\nMaxQuality : %d\n\n", maximum); 147 147 … … 159 159 // class AC_SEQUENCE_LIST::determine_distances_to() 160 160 // 161 // bestimmt die reale_Distanz und 161 // bestimmt die reale_Distanz und 162 162 // bestimmt die relative Distanz 163 163 // zwischen zwei Sequenzen. … … 206 206 // class AC_SEQUENCE_LIST::get_seq_with_max_dist_to() 207 207 // 208 // liefert die erste Sequence mit 208 // liefert die erste Sequence mit 209 209 // dem groessten Abstand 210 210 // bei … … 225 225 226 226 for( ptr = ac_sequence_info ; ptr ; ptr = ptr->next ) 227 { 227 { 228 228 product = ptr->relative_leftdistance * ptr->seq->quality; 229 229 if( maxvalue <= product ) { … … 232 232 } // endif 233 233 } // endfor 234 234 235 235 if( 0 == maxvalue ) seq_with_max_dist = NULL; 236 236 … … 245 245 // class AC_SEQUENCE_LIST::determine_basepoints() 246 246 // 247 // 247 // 248 248 // betrachte die Kanten vom Leftend zum Rightend, 249 249 // der Abstand relative_leftdistance vom Rightend 250 250 // ist die Summe der Kanten. 251 251 // 252 // berechne ueber ein Gleichungssystem den Schnittpunkt 252 // berechne ueber ein Gleichungssystem den Schnittpunkt 253 253 // der aktuellen Sequenz mit obiger Gerade. 254 // 255 // 254 // 255 // 256 256 // 257 257 //********************************************************************* 258 258 void AC_SEQUENCE_LIST::determine_basepoints() { 259 259 260 260 261 261 AC_SEQUENCE_INFO *ac_sequence_info; 262 262 AC_SEQUENCE_INFO *ptr; … … 265 265 266 266 ac_sequence_info = this->sequences; 267 267 268 268 baseline = this->rightend->relative_leftdistance; // baseline = Abstand zwischen 269 269 // Leftend und Rightend … … 275 275 276 276 for( ptr = ac_sequence_info ; ptr ; ptr = ptr->next ) 277 { 277 { 278 278 li = ptr->relative_leftdistance; 279 279 re = ptr->relative_rightdistance; … … 300 300 // class AC_SEQUENCE_LIST::reset_AC_SEQUENCE_INFO_struct_values() 301 301 // 302 // Setzt folgende Werte im Struct AC_SEQUENCE_INFO auf die 302 // Setzt folgende Werte im Struct AC_SEQUENCE_INFO auf die 303 303 // Default-Werte zurueck: 304 304 // AC_SEQUENCE_INFO_STATE state, 305 // long real_leftdistance; 306 // double relative_leftdistance; 305 // long real_leftdistance; 306 // double relative_leftdistance; 307 307 // long real_rightdistance; 308 // double relative_rightdistance; 309 // double relationship; 308 // double relative_rightdistance; 309 // double relationship; 310 310 // 311 311 //********************************************************************* … … 318 318 319 319 for(ptr = ac_sequence_info; ptr; ptr = ptr->next ) { 320 ptr->state = ORDINARY; 320 ptr->state = ORDINARY; 321 321 ptr->real_leftdistance = 0; 322 322 ptr->relative_leftdistance = 0.0; 323 323 ptr->real_rightdistance = 0; 324 324 ptr->relative_rightdistance = 0.0; 325 ptr->relationship = 0; 325 ptr->relationship = 0; 326 326 } // endfor 327 327 … … 369 369 // class AC_TREE:: remove_tree() 370 370 // 371 // hier wird rekursiv der Clusterbaum geloescht 371 // hier wird rekursiv der Clusterbaum geloescht 372 372 // 373 373 //********************************************************************* … … 377 377 378 378 if(this) { 379 379 380 380 sequence_list = this->sequences; 381 if(sequence_list) { 381 if(sequence_list) { 382 382 remove_sequence_list(sequence_list); 383 383 } 384 385 386 if(this->left) this->left->remove_tree(); 384 385 386 if(this->left) this->left->remove_tree(); 387 387 if(this->right) this->right->remove_tree(); 388 388 free (this); … … 400 400 // class AC_TREE::print_tree() 401 401 // 402 // hier wird rekursiv der Clusterbaum rausgeschrieben 402 // hier wird rekursiv der Clusterbaum rausgeschrieben 403 403 // 404 404 //********************************************************************* … … 420 420 } 421 421 } 422 if(this->left) this->left->print_tree(); 422 if(this->left) this->left->print_tree(); 423 423 if(this->right) this->right->print_tree(); 424 424 … … 434 434 // class AC_TREE::print_formated_dbtree() 435 435 // 436 // hier wird rekursiv der Clusterbaum rausgeschrieben 436 // hier wird rekursiv der Clusterbaum rausgeschrieben 437 437 // und das in dem wunderbaren ARB-Format 438 438 // (Knoten,Knoten) oder so ?? … … 445 445 if(this->node_state == I_NODE) { 446 446 printf("\n("); 447 this->left->print_formated_dbtree(); 448 449 if( (this->right->node_state == I_NODE) || 450 ( (this->right->node_state == LEAF) && 447 this->left->print_formated_dbtree(); 448 449 if( (this->right->node_state == I_NODE) || 450 ( (this->right->node_state == LEAF) && 451 451 (this->right->sequences != NULL) ) ) { 452 452 printf(","); … … 485 485 // 486 486 // hier wird rekursiv der Clusterbaum aufgebaut. 487 // Die Sequenzliste am root Knoten ist nicht leer. 487 // Die Sequenzliste am root Knoten ist nicht leer. 488 488 // 489 489 //********************************************************************* … … 496 496 497 497 if ( (this->node_state == I_NODE) ) { 498 this->left->make_clustertree(); 498 this->left->make_clustertree(); 499 499 this->right->make_clustertree(); 500 500 } … … 510 510 // class AC_TREE::split() 511 511 // 512 // bestimme LEFTEND 512 // bestimme LEFTEND 513 513 // bestimme Distanzen zum LEFTEND (real/relativ) 514 514 // bestimme RIGHTEND … … 519 519 // legen den Schnittpunkt fest 520 520 // generiere zwei neue Knoten 521 // teile die Sequenzliste auf die Knoten auf 521 // teile die Sequenzliste auf die Knoten auf 522 522 // 523 523 //********************************************************************* … … 532 532 this->rightend = get_seq_with_max_dist_to(); 533 533 534 if( this->rightend != NULL ) { 534 if( this->rightend != NULL ) { 535 535 this->rightend->state = RIGHTEND; 536 536 this->determine_distances_to(rightend, RIGHTEND); // real,relative … … 548 548 //---------------------------------------------- zwei neue Soehne = I_Nodes 549 549 AC_TREE *inode_left = new AC_TREE; 550 this->left = inode_left; 550 this->left = inode_left; 551 551 AC_TREE *inode_right = new AC_TREE; 552 552 this->right = inode_right; … … 556 556 557 557 //========================== Abbruchsbedingung fuer Seqenz-Listenaufteilung 558 if( (this->left->max_relationship <= breakcondition_relationship_distance) || 558 if( (this->left->max_relationship <= breakcondition_relationship_distance) || 559 559 (this->left->nsequences <= breakcondition_min_sequencenumber) ) { 560 560 this->left->node_state = LEAF; … … 567 567 568 568 } //endif 569 569 570 570 else { this->node_state = LEAF; // kein rightend gefunden 571 571 } … … 573 573 } // end AC_TREE::split() 574 574 //********************************************************************* 575 575 576 576 577 577 … … 583 583 // allokiert Speicher fuer das Sortier-Array 584 584 // liest die Werte in das Array ein 585 // 586 // 587 //********************************************************************* 588 void AC_TREE::divide_sequence_list(AC_TREE *that, AC_TREE *inode_left, 585 // 586 // 587 //********************************************************************* 588 void AC_TREE::divide_sequence_list(AC_TREE *that, AC_TREE *inode_left, 589 589 AC_TREE *inode_right) { 590 590 … … 595 595 sort_array = (AC_SEQUENCE_INFO **)calloc(sizeof(void *),number_of); 596 596 597 #ifdef DEBUG_print_unsorted_array 598 printf("\n\nunsorted array: \n\n"); 597 #ifdef DEBUG_print_unsorted_array 598 printf("\n\nunsorted array: \n\n"); 599 599 #endif 600 600 //------------------------------------------------------ einlesen der seqenptr in array … … 630 630 // zum GNUPLOT Ausdruck 631 631 long dekrement; 632 #ifdef GNUPLOT_print_sorted_array 632 #ifdef GNUPLOT_print_sorted_array 633 633 // long dekrement; 634 634 dekrement = number_of; … … 638 638 // printf("%f 10\n", (*array_ptr)->relationship); 639 639 // printf("%f ", (*array_ptr)->relationship); 640 } 641 printf("\n\n"); 642 #endif 643 644 #ifdef GNUPLOT_print_sorted_left_right_reldist 645 // long dekrement; 646 dekrement = number_of; 640 } 641 printf("\n\n"); 642 #endif 643 644 #ifdef GNUPLOT_print_sorted_left_right_reldist 645 // long dekrement; 646 dekrement = number_of; 647 647 printf("\n\nsorted array relative left/right distances : \n\n"); 648 648 for(array_ptr = sort_array; 0 < dekrement; array_ptr++, dekrement--) { 649 649 printf("%f ", 650 650 (*array_ptr)->relative_leftdistance); 651 printf("%f\n", 651 printf("%f\n", 652 652 (*array_ptr)->relative_rightdistance); 653 } 653 } 654 654 printf("\n\n"); 655 655 #endif … … 677 677 // class AC_TREE::separate_sequencelist() 678 678 // 679 // geht das sortierte array durch und haengt den ersten Teil an 680 // den linken Knoten, 681 // den zweiten Knoten, d.h. das Element das den intersection_value 679 // geht das sortierte array durch und haengt den ersten Teil an 680 // den linken Knoten, 681 // den zweiten Knoten, d.h. das Element das den intersection_value 682 682 // liefert sammt Rest an den zweiten Knoten. 683 683 // Zu merken ist der Verwandtschaftsgrad der beiden Seqs zu den 684 684 // aktuellen Referenz-Sequenzen. 685 685 // 686 // 687 // 688 //********************************************************************* 689 void AC_TREE::separate_sequencelist(AC_SEQUENCE_INFO **sort_array, 686 // 687 // 688 //********************************************************************* 689 void AC_TREE::separate_sequencelist(AC_SEQUENCE_INFO **sort_array, 690 690 double intersection_value ) 691 691 { … … 696 696 697 697 for( array_ptr,dekrement; 0 < dekrement; array_ptr++, dekrement--) { 698 basepoint = (*array_ptr)->relationship; 699 700 if( (*array_ptr)->state != ORDINARY ) { 698 basepoint = (*array_ptr)->relationship; 699 700 if( (*array_ptr)->state != ORDINARY ) { 701 701 if( (*array_ptr)->state == LEFTEND ) { // LEFTEND nach links 702 702 inode = this->left; 703 } 703 } 704 704 else if( (*array_ptr)->state == RIGHTEND ) { // RIGHTEND nach rechts 705 705 inode = this->right; 706 } 706 } 707 707 } 708 708 … … 711 711 if( (basepoint < intersection_value) || (0 == basepoint) ) { 712 712 inode = this->left; 713 } 713 } 714 714 else if( intersection_value == basepoint ) { 715 715 inode = this->right; … … 717 717 else if( basepoint >= intersection_value) { 718 718 inode = this->right; 719 } 720 } 719 } 720 } 721 721 722 722 inode->insert(*array_ptr); // einfuegen des listenelements nach left oder right 723 723 // inode->nsequences++; // wird bereits von insert() erledigt ! 724 724 725 if( basepoint < intersection_value ) { // Abbruchsbedingung groesster Abstand zu 725 if( basepoint < intersection_value ) { // Abbruchsbedingung groesster Abstand zu 726 726 this->left->max_relationship = basepoint; // LEFTEND/RIGHTEND 727 727 } … … 729 729 this->right->max_relationship = abs(100 - intersection_value); 730 730 } 731 } 731 } 732 732 this->sequences = NULL; // sicher ist sicher !!! 733 // d.h. am aktuellen Knoten haengt 733 // d.h. am aktuellen Knoten haengt 734 734 // keine !! Sequenzenliste mehr 735 735 … … 746 746 printf("Anzahl Seqs LEFT/RIGHT: %d ", this->left->nsequences); 747 747 printf("%d", this->right->nsequences); 748 748 749 749 printf("\n\n"); 750 750 printf("Relationship zu LEFT/RIGHT: %f ", this->left->max_relationship); … … 766 766 printf("left_side : %f\n", subnode_list->relationship); 767 767 subnode_list = subnode_list->next; 768 } 768 } 769 769 printf("\n\n"); 770 770 subnode_list = this->right->sequences; 771 for( subnode_list; subnode_list; ) { 771 for( subnode_list; subnode_list; ) { 772 772 printf("Seq_Nr : %d ", subnode_list->number); 773 773 printf("right_side : %f\n", subnode_list->relationship); -
trunk/ARBDB_COMPRESS/DEBUG_tools.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 35 35 AC_SEQUENCE_INFO *run_ptr = NULL; 36 36 for( run_ptr = root->sequences; run_ptr ; 37 run_ptr = run_ptr->next ) 37 run_ptr = run_ptr->next ) 38 38 { 39 39 printf("Nr: %5i ", run_ptr->number); … … 71 71 AC_SEQUENCE_INFO *run_ptr = NULL; 72 72 for( run_ptr = root->sequences; run_ptr ; 73 run_ptr = run_ptr->next ) 73 run_ptr = run_ptr->next ) 74 74 { 75 75 printf("Nr: %5i ", run_ptr->number); … … 101 101 AC_SEQUENCE_INFO *run_ptr = NULL; 102 102 for( run_ptr = root->sequences; run_ptr ; 103 run_ptr = run_ptr->next ) 103 run_ptr = run_ptr->next ) 104 104 { 105 105 if(run_ptr->state == LEFTEND) printf("LEFTEND "); -
trunk/ARB_GDE/GDE.cxx
r550 r655 5 5 #include <arbdb.h> 6 6 #include <arbdbt.h> 7 #include <malloc.h>7 // #include <malloc.h> 8 8 #include <aw_root.hxx> 9 9 #include <aw_device.hxx> -
trunk/ARB_GDE/GDE_FileIO.cxx
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <string.h> 5 5 … … 39 39 alignment->element[j].groupb = NULL; 40 40 } 41 41 42 42 for (group = 1;group <= alignment->numgroups;group++) 43 43 { … … 48 48 if(last != -1) 49 49 { 50 alignment->element[j].groupb = 50 alignment->element[j].groupb = 51 51 &(alignment->element[last]); 52 alignment->element[last].groupf = 52 alignment->element[last].groupf = 53 53 &(alignment->element[j]); 54 54 } … … 135 135 136 136 /* 137 LoadData(): 137 LoadData(): 138 138 Load a data set from the command line argument. 139 139 … … 269 269 FILE *file; 270 270 char in_line[GBUFSIZ]; 271 271 272 272 file = fopen(name,"r"); 273 273 *dtype=0; … … 396 396 { 397 397 for(j=0;j<aln->numelements;j++) 398 if(seqs[j].elementtype == MASK && 398 if(seqs[j].elementtype == MASK && 399 399 seqs[j].selected) 400 400 mask = j; … … 420 420 else 421 421 offset_str[0] = '\0'; 422 423 if((((int)j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 422 423 if((((int)j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 424 424 || (method == SELECT_REGION && seqs[j].subselected) 425 425 || method == ALL) … … 713 713 if(IGNORE_DASH && (indx != -1)) 714 714 { 715 for(jj=0,j=0;(j<curlen) && 715 for(jj=0,j=0;(j<curlen) && 716 716 (jj<aln->element[indx].seqlen);j++,jj++) 717 717 { … … 729 729 * 730 730 * The allocated space is equal the seqlen of the matched sequence. 731 * 731 * 732 732 */ 733 733 if(aln->element[indx].tmatrix) … … 883 883 return(1); 884 884 885 /* 885 /* 886 886 NAdd = (NA_DisplayData*)((NA_Alignment*)DataSet)->na_ddata; 887 887 if(NAdd == NULL) 888 888 return(1); 889 */ 889 */ 890 890 891 891 file = fopen(filename,"w"); … … 945 945 FILE *file; 946 946 filename=0; 947 947 948 948 char in_line[GBUFSIZ],head[GBUFSIZ]; 949 949 file = fopen(filename,"r"); … … 966 966 } 967 967 } 968 968 969 969 */ 970 970 } … … 1021 1021 { 1022 1022 for(j=0;j<aln->numelements;j++) 1023 if(seqs[j].elementtype == MASK && 1023 if(seqs[j].elementtype == MASK && 1024 1024 seqs[j].selected) 1025 1025 mask = j; … … 1043 1043 else 1044 1044 offset_str[0] = '\0'; 1045 1046 if((((int)j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 1045 1046 if((((int)j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 1047 1047 || (method == SELECT_REGION && seqs[j].subselected) 1048 1048 || method == ALL) -
trunk/ARB_GDE/GDE_Genbank.cxx
r344 r655 1 1 #include <sys/time.h> 2 2 #include <stdio.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <string.h> 5 5 #include <time.h> -
trunk/ARB_GDE/GDE_HGLfile.cxx
r344 r655 2 2 #include <stdio.h> 3 3 #include <stdlib.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <time.h> -
trunk/ARB_GDE/GDE_ParseMenu.cxx
r335 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <ctype.h> 6 6 #include <assert.h> -
trunk/ARB_GDE/GDE_arbdb_io.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <memory.h> 6 6 … … 54 54 int InsertDatainGDE(NA_Alignment *dataset,GBDATA **the_species,unsigned char **the_names,unsigned char **the_sequences, 55 55 unsigned long numberspecies,unsigned long maxalignlen,AP_filter *filter, long compress) 56 { 56 { 57 57 GBDATA *gb_name; 58 58 GBDATA *gb_species; … … 60 60 int newfiltercreated=0; 61 61 NA_Sequence *this_elem; 62 62 63 63 gde_assert((the_species==0) != (the_names==0)); 64 65 if(filter==0) 64 65 if(filter==0) 66 66 { 67 67 filter = new AP_filter; … … 75 75 } 76 76 } 77 77 78 78 size_t *seqlen=(size_t *)calloc((unsigned int)numberspecies,sizeof(size_t)); 79 79 // sequences may have different length … … 82 82 for(i=0;i<numberspecies;i++){ 83 83 seqlen[i] = strlen((char *)the_sequences[i]); 84 } 85 } 86 87 84 } 85 } 86 87 88 88 uchar **sequfilt=(uchar**)calloc((unsigned int)numberspecies+1,sizeof(uchar*)); 89 89 if(compress==2) // compress all gaps and filter positions … … 133 133 sequfilt[i][len] = 0; 134 134 memset(sequfilt[i],'.',len); // Generate empty sequences 135 135 136 136 size_t col; 137 137 for(col=0;(col<maxalignlen)&&(c=the_sequences[i][col]);col++){ … … 150 150 delete string; 151 151 } 152 152 153 153 delete seqlen; 154 154 155 155 long number=0; 156 156 int curelem; 157 157 158 158 if (the_species) { 159 159 for (gb_species = the_species[number]; gb_species; gb_species = the_species[++number] ) { … … 172 172 173 173 strncpy(this_elem->short_name,GB_read_char_pntr(gb_name),31); 174 174 175 175 gbd = GB_find(gb_species,"author",0,down_level); 176 176 if (gbd) strncpy(this_elem->authority,GB_read_char_pntr(gbd),79); … … 185 185 delete sequfilt[number]; sequfilt[number] = 0; 186 186 } 187 187 188 188 this_elem->comments = strdup("no comments"); 189 189 this_elem->comments_maxlen = 1 + (this_elem->comments_len = strlen(this_elem->comments)); … … 210 210 else { // use the_names 211 211 unsigned char *species_name; 212 212 213 213 for (species_name=the_names[number]; species_name; species_name=the_names[++number]) { 214 214 if ((number/10)*10==number) { … … 217 217 } 218 218 } 219 219 220 220 curelem = Arbdb_get_curelem(dataset); 221 221 this_elem = &(dataset->element[curelem]); … … 223 223 this_elem->attr = DEFAULT_X_ATTR; 224 224 this_elem->gb_species = 0; 225 225 226 226 strncpy((char*)this_elem->short_name, (char*)species_name, 31); 227 227 this_elem->authority[0] = 0; 228 228 this_elem->seq_name[0] = 0; 229 229 this_elem->id[0] = 0; 230 230 231 231 { 232 232 AppendNA((NA_Base *)sequfilt[number],strlen((const char *)sequfilt[number]),this_elem); 233 233 delete sequfilt[number]; sequfilt[number] = 0; 234 234 } 235 235 236 236 this_elem->comments = strdup("no comments"); 237 237 this_elem->comments_maxlen = 1 + (this_elem->comments_len = strlen(this_elem->comments)); … … 245 245 } 246 246 } 247 247 248 248 { 249 249 unsigned long i; … … 273 273 { 274 274 dataset->gb_main = gb_main; 275 GBDATA **the_species; 275 GBDATA **the_species; 276 276 long maxalignlen; 277 277 long numberspecies=0; … … 281 281 the_species, the_names, the_sequences, 282 282 numberspecies, maxalignlen); 283 283 284 284 gde_assert((the_species==0) != (the_names==0)); 285 285 286 286 if (error) { 287 287 aw_message(error); -
trunk/ARB_GDE/GDE_event.cxx
r551 r655 11 11 #include <arbdb.h> 12 12 #include <arbdbt.h> 13 #include <malloc.h>13 // #include <malloc.h> 14 14 #include <aw_root.hxx> 15 15 #include <aw_device.hxx> -
trunk/AWDEMO/demo.cxx
r2 r655 7 7 #include <demo.hxx> 8 8 #include <memory.h> 9 #include <malloc.h>9 // #include <malloc.h> 10 10 #include <string.h> 11 11 -
trunk/AWT/AWT_codon_table.cxx
r2 r655 1 #include <malloc.h>1 // #include <malloc.h> 2 2 #include <string.h> 3 3 #include <ctype.h> … … 11 11 // "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG", base2 12 12 // "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG" base3 13 { 13 { 14 14 "Standard Code", 15 15 "FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 16 16 "---M---------------M---------------M----------------------------" 17 }, 18 { 19 "Bacterial Code", 20 "FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 21 "---M---------------M------------MMMM---------------M------------" 22 }, 23 { 24 "Vertebrate Mitochondrial Code", 25 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSS**VVVVAAAADDEEGGGG", 17 }, 18 { 19 "Bacterial Code", 20 "FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 21 "---M---------------M------------MMMM---------------M------------" 22 }, 23 { 24 "Vertebrate Mitochondrial Code", 25 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSS**VVVVAAAADDEEGGGG", 26 26 "--------------------------------MMMM---------------M------------" 27 }, 28 { 29 "Invertebrate Mitochondrial Code", 30 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSSSVVVVAAAADDEEGGGG", 31 "---M----------------------------MMMM---------------M------------" 32 }, 33 { 34 "Yeast Mitochondrial Code", 35 "FFLLSSSSYY**CCWWTTTTPPPPHHQQRRRRIIMMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 36 "-----------------------------------M----------------------------" 37 }, 38 { 27 }, 28 { 29 "Invertebrate Mitochondrial Code", 30 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSSSVVVVAAAADDEEGGGG", 31 "---M----------------------------MMMM---------------M------------" 32 }, 33 { 34 "Yeast Mitochondrial Code", 35 "FFLLSSSSYY**CCWWTTTTPPPPHHQQRRRRIIMMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 36 "-----------------------------------M----------------------------" 37 }, 38 { 39 39 "Mold/Protozoan/Coelenterate Mitochondrial Code", // identical with "Mycoplasma/Spiroplasma Code" (split because of name-length) 40 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 41 "--MM---------------M------------MMMM---------------M------------" 42 }, 43 { 44 "Echinoderm Mitochondrial Code", 45 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG", 46 "-----------------------------------M----------------------------" 47 }, 48 { 49 "Ascidian Mitochondrial Code", 50 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSGGVVVVAAAADDEEGGGG", 51 "-----------------------------------M----------------------------" 52 }, 53 { 54 "Flatworm Mitochondrial Code", 55 "FFLLSSSSYYY*CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG", 56 "-----------------------------------M----------------------------" 57 }, 58 { 40 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 41 "--MM---------------M------------MMMM---------------M------------" 42 }, 43 { 44 "Echinoderm Mitochondrial Code", 45 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG", 46 "-----------------------------------M----------------------------" 47 }, 48 { 49 "Ascidian Mitochondrial Code", 50 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSGGVVVVAAAADDEEGGGG", 51 "-----------------------------------M----------------------------" 52 }, 53 { 54 "Flatworm Mitochondrial Code", 55 "FFLLSSSSYYY*CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG", 56 "-----------------------------------M----------------------------" 57 }, 58 { 59 59 "Mycoplasma/Spiroplasma Code", // identical with "Mold/Protozoan/Coelenterate Mitochondrial Code" (split because of name-length) 60 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 61 "--MM---------------M------------MMMM---------------M------------" 62 }, 63 { 64 "Ciliate, Dasycladacean and Hexamita Nuclear Code", 65 "FFLLSSSSYYQQCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 66 "-----------------------------------M----------------------------" 67 }, 68 { 69 "Euplotid Nuclear Code", 70 "FFLLSSSSYY**CCCWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 71 "-----------------------------------M----------------------------" 72 }, 73 { 74 "Alternative Yeast Nuclear Code", 75 "FFLLSSSSYY**CC*WLLLSPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 76 "-------------------M---------------M----------------------------" 77 }, 78 { 79 "Blepharisma Nuclear Code", 80 "FFLLSSSSYY*QCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 81 "-----------------------------------M----------------------------" 82 }, 83 60 "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 61 "--MM---------------M------------MMMM---------------M------------" 62 }, 63 { 64 "Ciliate, Dasycladacean and Hexamita Nuclear Code", 65 "FFLLSSSSYYQQCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 66 "-----------------------------------M----------------------------" 67 }, 68 { 69 "Euplotid Nuclear Code", 70 "FFLLSSSSYY**CCCWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 71 "-----------------------------------M----------------------------" 72 }, 73 { 74 "Alternative Yeast Nuclear Code", 75 "FFLLSSSSYY**CC*WLLLSPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 76 "-------------------M---------------M----------------------------" 77 }, 78 { 79 "Blepharisma Nuclear Code", 80 "FFLLSSSSYY*QCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG", 81 "-----------------------------------M----------------------------" 82 }, 83 84 84 { 0, 0, 0 } // end of table-marker 85 85 }; … … 91 91 void AWT_initialize_codon_tables() { 92 92 if (codon_tables_initialized) return; 93 94 int codon_nr; 93 94 int codon_nr; 95 95 int code_nr; 96 96 97 97 for (codon_nr=0; codon_nr<AWT_MAX_CODONS; codon_nr++) { 98 98 ambiguous_codons[codon_nr] = 0; 99 99 } 100 100 101 101 awt_assert(AWT_CODON_CODES>=1); 102 102 memcpy(definite_translation, AWT_codon_def[0].aa, AWT_MAX_CODONS); // only one translation is really definite 103 103 104 104 awt_assert(AWT_codon_def[AWT_CODON_CODES].aa==NULL); // Error in AWT_codon_def or AWT_CODON_CODES 105 105 106 106 for (code_nr=1; code_nr<AWT_CODON_CODES; code_nr++) { 107 107 const char *translation = AWT_codon_def[code_nr].aa; 108 108 109 109 for (codon_nr=0; codon_nr<AWT_MAX_CODONS; codon_nr++) { 110 110 if (definite_translation[codon_nr]!='?') { // is definite till now … … 114 114 amb[0] = definite_translation[0]; 115 115 amb[1] = translation[codon_nr]; 116 116 117 117 ambiguous_codons[codon_nr] = amb; 118 118 definite_translation[codon_nr] = '?'; … … 134 134 } 135 135 } 136 136 137 137 codon_tables_initialized = 1; 138 138 } … … 142 142 switch (c) { 143 143 case 'T': case 't': 144 case 'U': case 'u': return 0; 144 case 'U': case 'u': return 0; 145 145 case 'C': case 'c': return 1; 146 146 case 'A': case 'a': return 2; … … 159 159 int i2 = dna2idx(dna[1]); 160 160 int i3 = dna2idx(dna[2]); 161 161 162 162 if (i1==4||i2==4||i3==4) return AWT_MAX_CODONS; // is not a codon 163 163 164 164 int codon_nr = i1*16 + i2*4 + i3; 165 165 awt_assert(codon_nr>=0 && codon_nr<=AWT_MAX_CODONS); … … 169 169 inline void build_codon(int codon_nr, char *to_buffer) { 170 170 awt_assert(codon_nr>=0 && codon_nr<AWT_MAX_CODONS); 171 171 172 172 to_buffer[0] = idx2dna((codon_nr>>4)&3); 173 173 to_buffer[1] = idx2dna((codon_nr>>2)&3); 174 to_buffer[2] = idx2dna(codon_nr&3); 174 to_buffer[2] = idx2dna(codon_nr&3); 175 175 } 176 176 … … 182 182 static const char *protein_name[26+1] = { 183 183 "Ala", // A 184 "Asx", // B 184 "Asx", // B 185 185 "Cys", // C 186 186 "Asp", // D … … 213 213 if (protein=='*') return "End"; 214 214 if (protein=='-') return "---"; 215 215 216 216 awt_assert(protein>='A' && protein<='Z'); 217 217 awt_assert(protein_name[protein-'A']!=0); … … 234 234 void AWT_dump_codons() { 235 235 AWT_allowedCode allowed_code; 236 236 237 237 for (char c='*'; c<='Z'; c++) { 238 printf("Codes for '%c': ", c); 238 printf("Codes for '%c': ", c); 239 239 int first_line = 1; 240 240 int found = 0; … … 245 245 dna[0]=b1; 246 246 dna[1]=b2; 247 dna[2]=b3; 247 dna[2]=b3; 248 248 dna[3]=0; 249 249 250 250 AWT_allowedCode allowed_code_left; 251 251 if (AWT_is_codon(c, dna, allowed_code, allowed_code_left)) { 252 if (!first_line) printf("\n "); 252 if (!first_line) printf("\n "); 253 253 first_line = 0; 254 254 printf("%s (", dna); 255 255 256 256 int first=1; 257 257 for (int code=0; code<AWT_CODON_CODES; code++) { … … 262 262 } 263 263 } 264 printf(") "); 265 264 printf(") "); 265 266 266 found = 1; 267 267 } … … 281 281 282 282 int AWT_is_codon(char protein, const char *dna, const AWT_allowedCode& allowed_code, AWT_allowedCode& allowed_code_left) { 283 awt_assert(codon_tables_initialized); 284 283 awt_assert(codon_tables_initialized); 284 285 285 protein = toupper(protein); 286 286 if (protein=='B') { // B is a shortcut for Asp(=D) or Asn(=N) 287 287 return 288 AWT_is_codon('D', dna, allowed_code, allowed_code_left) || 289 AWT_is_codon('N', dna, allowed_code, allowed_code_left); 290 } 291 else if (protein=='Z') { // Z is a shortcut for Glu(=E) or Gln(=Q) 288 AWT_is_codon('D', dna, allowed_code, allowed_code_left) || 289 AWT_is_codon('N', dna, allowed_code, allowed_code_left); 290 } 291 else if (protein=='Z') { // Z is a shortcut for Glu(=E) or Gln(=Q) 292 292 return 293 293 AWT_is_codon('E', dna, allowed_code, allowed_code_left) || 294 AWT_is_codon('Q', dna, allowed_code, allowed_code_left); 295 } 296 294 AWT_is_codon('Q', dna, allowed_code, allowed_code_left); 295 } 296 297 297 int codon_nr = calc_codon_nr(dna); 298 298 if (codon_nr==AWT_MAX_CODONS) { // dna is not a clean codon (it contains iupac-codes) 299 299 int error_positions = 0; 300 int first_error_pos = -1; 300 int first_error_pos = -1; 301 301 { 302 302 int iupac_pos; … … 305 305 if (first_error_pos==-1) first_error_pos = iupac_pos; 306 306 error_positions++; 307 } 308 } 309 } 310 gb_assert(error_positions); 307 } 308 } 309 } 310 gb_assert(error_positions); 311 311 if (error_positions==3) { // don't accept codons with 3 errors 312 312 return 0; 313 313 } 314 315 const char *decoded_iupac = AWT_decode_iupac(dna[first_error_pos], GB_AT_DNA, 0); 316 char dna_copy[4]; 314 315 const char *decoded_iupac = AWT_decode_iupac(dna[first_error_pos], GB_AT_DNA, 0); 316 char dna_copy[4]; 317 317 memcpy(dna_copy, dna, 3); 318 318 dna_copy[3] = 0; 319 319 320 320 #if defined(DEBUG) && 0 321 321 printf("Check if '%s' is a codon for '%c'\n", dna_copy, protein); 322 322 #endif 323 323 324 324 int all_are_codons = 1; 325 325 AWT_allowedCode allowed_code_copy; 326 326 allowed_code_copy = allowed_code; 327 327 328 328 for (int i=0; decoded_iupac[i]; i++) { 329 329 dna_copy[first_error_pos] = decoded_iupac[i]; … … 331 331 all_are_codons = 0; 332 332 break; 333 } 333 } 334 334 allowed_code_copy = allowed_code_left; 335 335 } 336 336 337 337 if (all_are_codons) { 338 338 allowed_code_left = allowed_code_copy; … … 346 346 return all_are_codons; 347 347 } 348 348 349 349 if (definite_translation[codon_nr]!='?') { 350 int ok = definite_translation[codon_nr]==protein; 351 350 int ok = definite_translation[codon_nr]==protein; 351 352 352 if (ok) allowed_code_left = allowed_code; 353 else allowed_code_left.forbidAll(); 354 353 else allowed_code_left.forbidAll(); 354 355 355 return ok; 356 356 } 357 357 358 358 if (strchr(ambiguous_codons[codon_nr], protein)==0) { 359 359 allowed_code_left.forbidAll(); 360 return 0; 361 } 362 360 return 0; 361 } 362 363 363 // search for allowed correct translation possibity: 364 int found = 0; 364 int found = 0; 365 365 for (int code_nr=0; code_nr<AWT_CODON_CODES; code_nr++) { 366 366 if (allowed_code.is_allowed(code_nr) && // is this code allowed? … … 373 373 } 374 374 } 375 375 376 376 return found; 377 377 } … … 382 382 { 383 383 char codon[64]; // index is calculated with calc_codon_nr 384 384 385 385 public: 386 386 Codon_Group(char protein, int code_nr); 387 387 ~Codon_Group() {} 388 388 389 389 // static int idx(int x, int y, int z) const { return (((x<<2)+y)<<2)+z; } 390 390 // static int is_idx(int idx) { return idx>=0 && idx<AWT_MAX_CODONS; } 391 392 // void add_member(int idx) { awt_assert(is_idx(idx)); codon[idx] = 1; } 391 392 // void add_member(int idx) { awt_assert(is_idx(idx)); codon[idx] = 1; } 393 393 Codon_Group& operator+=(const Codon_Group& other); 394 394 int expand(char *to_buffer) const; 395 395 }; 396 396 397 Codon_Group::Codon_Group(char protein, int code_nr) { 398 protein = toupper(protein); 397 Codon_Group::Codon_Group(char protein, int code_nr) { 398 protein = toupper(protein); 399 399 awt_assert(protein=='*' || isalpha(protein)); 400 400 awt_assert(code_nr>=0 && code_nr<AWT_CODON_CODES); 401 401 402 402 const char *amino_table = AWT_codon_def[code_nr].aa; 403 403 for (int i=0; i<AWT_MAX_CODONS; i++) { … … 413 413 } 414 414 415 inline int legal_dna_no(int i) { return i>=0 && i<4; } 415 inline int legal_dna_no(int i) { return i>=0 && i<4; } 416 416 inline void my_memcpy(char *dest, const char *source, size_t length) { for (size_t l=0; l<length; l++) { dest[l] = source[l]; } } 417 417 … … 420 420 int mismatch_index = -1; 421 421 static char buf[4]; 422 422 423 423 for (int i=0; i<3; i++) { 424 424 if (con1[i]!=con2[i]) { 425 425 mismatches++; 426 mismatch_index = i; 427 } 426 mismatch_index = i; 427 } 428 428 else { 429 429 buf[i] = con1[i]; 430 430 } 431 431 } 432 433 if (mismatches==1) { // exactly one position differs between codons 432 433 if (mismatches==1) { // exactly one position differs between codons 434 434 awt_assert(mismatch_index!=-1); 435 435 buf[mismatch_index] = AWT_iupac_add(con1[mismatch_index], con2[mismatch_index], GB_AT_DNA); … … 444 444 const char *con1, *con2; 445 445 int added = 0; 446 446 447 447 for (i=0; i<no_of_condons; i++) { 448 448 con1 = bufferStart+3*i; 449 449 450 450 for (j=i+1; j<no_of_condons; j++) { 451 451 con2 = bufferStart+3*j; 452 452 const char *result = buildMixedCodon(con1, con2); 453 453 if (result) { 454 to_buffer[0] = 0; 454 to_buffer[0] = 0; 455 455 // do we already have this codon? 456 456 const char *found; … … 464 464 } 465 465 466 if (!found) { 466 if (!found) { 467 467 my_memcpy(to_buffer, result, 3); to_buffer+=3; 468 468 added++; … … 478 478 int i; 479 479 char *org_to_buffer = to_buffer; 480 480 481 481 for (i=0; i<AWT_MAX_CODONS; i++) { 482 482 if (codon[i]) { … … 486 486 } 487 487 } 488 488 489 489 #if defined(DEBUG) && 0 490 490 to_buffer[0] = 0; 491 491 printf("codons = '%s'\n", org_to_buffer); 492 492 #endif 493 493 494 494 for (;;) { 495 495 int new_count = expandMore(org_to_buffer, count, to_buffer); … … 499 499 to_buffer[0] = 0; 500 500 printf("codons (expandedMore) = '%s'\n", org_to_buffer); 501 #endif 502 } 503 504 awt_assert(count==(int(to_buffer-org_to_buffer)/3)); 505 501 #endif 502 } 503 504 awt_assert(count==(int(to_buffer-org_to_buffer)/3)); 505 506 506 return count; 507 507 } 508 508 509 509 510 510 // -------------------------------------------------------------------------------- … … 517 517 awt_assert(code_nr>=0 && code_nr<AWT_CODON_CODES); 518 518 protein = toupper(protein); 519 awt_assert(isalpha(protein) || protein=='*'); 520 awt_assert(codon_tables_initialized); 521 519 awt_assert(isalpha(protein) || protein=='*'); 520 awt_assert(codon_tables_initialized); 521 522 522 Codon_Group *cgroup = 0; 523 523 524 524 if (protein=='B') { 525 525 cgroup = new Codon_Group('D', code_nr); … … 530 530 cgroup = new Codon_Group('E', code_nr); 531 531 Codon_Group Q('Q', code_nr); 532 *cgroup += Q; 532 *cgroup += Q; 533 533 } 534 534 else { 535 535 cgroup = new Codon_Group(protein, code_nr); 536 536 } 537 538 awt_assert(cgroup); 539 540 static char buffer[MAX_CODON_LIST_LENGTH]; 537 538 awt_assert(cgroup); 539 540 static char buffer[MAX_CODON_LIST_LENGTH]; 541 541 int offset = 3*cgroup->expand(buffer); 542 awt_assert(offset<MAX_CODON_LIST_LENGTH); 543 buffer[offset] = 0; 544 545 delete cgroup; 546 542 awt_assert(offset<MAX_CODON_LIST_LENGTH); 543 buffer[offset] = 0; 544 545 delete cgroup; 546 547 547 return buffer; 548 548 } -
trunk/AWT/AWT_file_selection.cxx
r528 r655 4 4 #include <time.h> 5 5 #include <string.h> 6 #include <malloc.h>6 // #include <malloc.h> 7 7 #include <memory.h> 8 8 -
trunk/AWT/AWT_nds.cxx
r466 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 -
trunk/AWT/AWT_nei.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <memory.h> 6 6 #include <arbdb.h> … … 226 226 // lower triangular matrix 227 227 // size: size of matrix 228 228 229 229 230 230 PH_NEIGHBOURJOINING *nj = new PH_NEIGHBOURJOINING(m,size); -
trunk/AWT/AWT_pro_a_nucs.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <ctype.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 10 10 #include <awt_codon_table.hxx> 11 11 12 struct arb_r2a_struct *awt_pro_a_nucs = 0; 12 struct arb_r2a_struct *awt_pro_a_nucs = 0; 13 13 14 14 char *AP_create_dna_to_ap_bases(void){ … … 144 144 if ( nucs->nucbits[1] != n1 ) c++; 145 145 if ( nucs->nucbits[2] != n2 ) c++; 146 if (c <= 1) break; 146 if (c <= 1) break; 147 147 } 148 148 if (!nucs) { … … 150 150 nucs->next = str->nucs; 151 151 str->nucs = nucs; 152 } 152 } 153 153 nucs->nucbits[0] |= n0; 154 154 nucs->nucbits[1] |= n1; … … 207 207 awt_pro_a_nucs->nuc_2_bitset = AP_create_dna_to_ap_bases(); 208 208 awt_pro_a_nucs->t2i_hash = GBS_create_hash(1024,1); // case insensitive 209 209 210 210 AWT_initialize_codon_tables(); 211 211 212 int code_nr = GBT_read_int(gb_main,AP_PRO_TYPE_AWAR); 213 212 int code_nr = GBT_read_int(gb_main,AP_PRO_TYPE_AWAR); 213 214 214 { 215 215 char *D_codons = GB_strdup(AWT_get_codons('D', code_nr)); … … 217 217 char *E_codons = GB_strdup(AWT_get_codons('E', code_nr)); 218 218 char *Q_codons = GB_strdup(AWT_get_codons('Q', code_nr)); 219 219 220 220 char protein; 221 221 for (protein='*'; protein<='Z'; protein = (protein=='*' ? 'A' : protein+1)) { 222 222 if (protein!='J' && protein!='O' && protein!='U') { // JOU are no aminos 223 const char *codons; 223 const char *codons; 224 224 if (protein=='D') codons = D_codons; 225 225 else if (protein=='N') codons = N_codons; 226 226 else if (protein=='E') codons = E_codons; 227 227 else if (protein=='Q') codons = Q_codons; 228 else codons = AWT_get_codons(protein, code_nr); 228 else codons = AWT_get_codons(protein, code_nr); 229 229 // codons now contains a 0-terminated-string containing all possible codons for protein 230 230 231 231 const char *protein_name = AWT_get_protein_name(protein); 232 232 233 233 for (int off=0; codons[off]; off+=3) { 234 char codon[4]; 234 char codon[4]; 235 235 memcpy(codon, codons+off, 3); 236 236 codon[3] = 0; 237 237 238 238 if (protein=='B') { 239 239 if (!codon_defined_in(codon, D_codons) && !codon_defined_in(codon, N_codons)) { … … 252 252 } 253 253 } 254 255 254 255 256 256 free(Q_codons); 257 257 free(E_codons); … … 259 259 free(D_codons); 260 260 } 261 262 T('-', "---", "---"); 261 262 T('-', "---", "---"); 263 263 T('.', "...", "..."); 264 264 T('.', "???", "???"); 265 265 T('X', "NNN", "NNN"); 266 266 267 268 /* 267 268 /* 269 269 T("A","Ala","GCT"); 270 270 T("A","Ala","GCC"); … … 276 276 T("R","Arg","CGA"); 277 277 T("R","Arg","CGG"); T("R","Arg","CGX"); 278 278 279 279 T("R","Arg","AGA"); 280 280 T("R","Arg","AGG"); … … 283 283 T("N","Asn","AAT"); 284 284 T("N","Asn","AAC"); T("N","Asn","AAY"); 285 285 286 286 T("D","Asp","GAT"); 287 287 T("D","Asp","GAC"); T("D","Asp","GAY"); 288 288 289 289 T("C","Cys","TGT"); 290 290 T("C","Cys","TGC"); T("C","Cys","TGY"); 291 291 292 292 T("Q","Gln","CAA"); 293 293 if ( code_nr == AP_YEASTMITO ) { … … 295 295 T("Q","Gln","CAG"); T("Q","Gln","CAR"); 296 296 } 297 297 298 298 T("E","Glu","GAA"); 299 299 if (code_nr == AP_MITO || … … 324 324 T("L","Leu","CTG"); T("L","Leu","CTX"); 325 325 T("L","Leu","YTR"); 326 326 327 327 T("K","Lys","AAA"); 328 328 T("K","Lys","AAG"); T("K","Lys","AAR"); … … 335 335 T("M","Met","ATG"); 336 336 } 337 337 338 338 T("F","Phe","TTT"); 339 339 T("F","Phe","TTC"); T("F","Phe","TTY"); 340 340 341 341 T("P","Pro","CCT"); 342 342 T("P","Pro","CCC"); 343 343 T("P","Pro","CCA"); 344 344 T("P","Pro","CCG"); T("P","Pro","CCX"); 345 345 346 346 T("s","Ser","TCT"); // Special insertion, why?? see phylip 347 347 T("s","Ser","TCC"); 348 348 T("s","Ser","TCG"); 349 349 T("s","Ser","TCA"); T("s","Ser","TCX"); 350 350 351 351 T("S","Ser","AGT"); 352 352 T("S","Ser","AGC"); T("S","Ser","AGY"); 353 353 354 354 T("T","Thr","ACT"); 355 355 T("T","Thr","ACC"); 356 356 T("T","Thr","ACA"); 357 357 T("T","Thr","ACG"); T("T","Thr","ACX"); 358 358 359 359 if ( code_nr == AP_YEASTMITO ){ 360 360 T("T","Thr","CAG"); 361 361 } 362 362 363 363 T("W","Trp","TGG"); 364 364 if (code_nr == AP_MITO || … … 372 372 T("Y","Tyr","TAC"); T("Y","Tyr","TAY"); 373 373 374 374 375 375 T("V","Val","GTA"); 376 376 T("V","Val","GTC"); … … 381 381 }else{ 382 382 T("V","Val","GTT"); T("V","Val","GTH"); 383 } 383 } 384 384 }else{ 385 385 T("V","Val","GTT"); 386 386 T("V","Val","GTG"); T("V","Val","GTX"); 387 387 } 388 388 389 389 T("*","End","TAA"); 390 390 T("*","End","TAG"); … … 395 395 T("*","End","GTG"); 396 396 } 397 397 398 398 if ( code_nr == AP_VERTMITO ){ 399 399 T("*","End","GTT"); 400 400 } 401 401 402 402 awt_pro_a_nucs->realmax_aa = awt_pro_a_nucs->max_aa; 403 403 T("-","---","---"); 404 405 404 405 406 406 // T("B","Asx","AAC"); 407 407 // T("B","Asx","AAT"); … … 414 414 T("B","Asx","RAY"); 415 415 T("Z","Glx","SAR"); 416 416 417 417 T(".","...","..."); 418 418 T(".","???","???"); 419 419 T(".","NNN","NNN"); 420 */ 421 420 */ 421 422 422 awt_pro_a_nucs->pro_2_bitset = awt_nuc_create_pro_to_bits(); 423 423 } … … 452 452 // check bits should not be present in distpad 453 453 if (s<awt_pro_a_nucs->realmax_aa) for (i=0;i<2;i++) { 454 if ( awt_pro_a_nucs->dist[s]->patd[i] & 454 if ( awt_pro_a_nucs->dist[s]->patd[i] & 455 455 ~awt_pro_a_nucs->dist[s]->patd[i+1]) GB_CORE; 456 456 } … … 519 519 #ifndef NDEBUG 520 520 awt_pro_a_nucs_debug(); 521 #endif 522 } 521 #endif 522 } -
trunk/AWT/AWT_query_and_functions.cxx
r622 r655 4 4 #include <time.h> 5 5 #include <string.h> 6 #include <malloc.h>6 // #include <malloc.h> 7 7 #include <memory.h> 8 8 #include <ctype.h> -
trunk/AWT/AWT_sel_boxes.cxx
r463 r655 4 4 #include <time.h> 5 5 #include <string.h> 6 #include <malloc.h>6 // #include <malloc.h> 7 7 #include <memory.h> 8 8 -
trunk/AWT/AWT_seq_colors.cxx
r169 r655 3 3 #include <string.h> 4 4 #include <ctype.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <arbdb.h> 7 7 #include <arbdbt.h> -
trunk/AWT/AWT_species_sel_box.cxx
r540 r655 4 4 #include <time.h> 5 5 #include <string.h> 6 #include <malloc.h>6 // #include <malloc.h> 7 7 #include <memory.h> 8 8 -
trunk/AWT/AWT_tables.cxx
r210 r655 4 4 #include <time.h> 5 5 #include <string.h> 6 #include <malloc.h>6 // #include <malloc.h> 7 7 #include <memory.h> 8 8 -
trunk/AWT/AWT_tree.cxx
r377 r655 3 3 #include <stdlib.h> 4 4 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <math.h> 7 7 #include <string.h> -
trunk/AWT/AWT_tree_cmp.cxx
r608 r655 1 1 #include <stdio.h> 2 #include <malloc.h>2 // #include <malloc.h> 3 3 #include <memory.h> 4 4 #include <string.h> -
trunk/AWT/AWT_www.cxx
r566 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 -
trunk/AWT/BI_helix.cxx
r2 r655 3 3 #include <string.h> 4 4 #include <ctype.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <arbdb.h> 7 7 #include <arbdbt.h> … … 26 26 long pos; 27 27 BI_PAIR_TYPE type; 28 char c; 28 char c; 29 29 }; 30 30 … … 64 64 entries = 0; 65 65 size = 0; 66 66 67 67 pairs[HELIX_NONE]=strdup(""); 68 68 char_bind[HELIX_NONE] = strdup(" "); … … 175 175 char *sident; 176 176 struct helix_stack *laststack = 0,*stack; 177 177 178 178 size = sizei; 179 179 … … 220 220 } 221 221 c = helix[pos]; 222 if (strchr(LEFT_HELIX,c) || strchr(LEFT_NONS,c) ){ // push 222 if (strchr(LEFT_HELIX,c) || strchr(LEFT_NONS,c) ){ // push 223 223 laststack = (struct helix_stack *)GBS_read_hash(hash,ident); 224 224 stack = new helix_stack; … … 228 228 GBS_write_hash(hash,ident,(long)stack); 229 229 } 230 else if (strchr(RIGHT_HELIX,c) || strchr(RIGHT_NONS,c) ){ // pop 230 else if (strchr(RIGHT_HELIX,c) || strchr(RIGHT_NONS,c) ){ // pop 231 231 stack = (struct helix_stack *)GBS_read_hash(hash,ident); 232 232 if (!stack) { … … 310 310 GBDATA *gb_helix = 0; 311 311 GBDATA *gb_helix_nr = 0; 312 312 313 313 if (gb_helix_nr_con) gb_helix_nr = GBT_read_sequence(gb_helix_nr_con,alignment_name); 314 314 if (gb_helix_con) gb_helix = GBT_read_sequence(gb_helix_con,alignment_name); 315 315 316 316 err = init(gb_helix_nr, gb_helix, size2); 317 317 } … … 423 423 char *buffer = GB_give_buffer(size+1); 424 424 register unsigned long i,j,k; 425 425 426 426 for (k=0; k<size; k++) { 427 427 i = k+start; … … 465 465 aws->at_newline(); 466 466 467 aws->label_length( 18 ); 467 aws->label_length( 18 ); 468 468 int i; 469 469 int j; … … 472 472 for (j=0; helix_awars[j].awar; j++){ 473 473 474 aws->label_length( 25 ); 474 aws->label_length( 25 ); 475 475 i = helix_awars[j].pair_type; 476 476 -
trunk/AWTC/AWTC_ClustalV.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <stdio.h> … … 41 41 #define MAXN_2_assert(xxx) awtc_assert(xxx) 42 42 #else 43 #define MAXN_2(xxx) 43 #define MAXN_2(xxx) 44 44 #define MAXN_2_assert(xxx) 45 45 #endif … … 64 64 static int pos1; 65 65 static int pos2; 66 static int **naa1; // naa1[basetype][position] counts bases for each position of all sequences in group1 66 static int **naa1; // naa1[basetype][position] counts bases for each position of all sequences in group1 67 67 static int **naa2; // naa2[basetype][position] same for group2 68 static int **naas; // 68 static int **naas; // 69 69 static int seqlen_array[MAXN+1];// length of all sequences 70 70 static char *seq_array[MAXN+1]; // the sequences 71 static int group[MAXN+1]; // group of sequence 71 static int group[MAXN+1]; // group of sequence 72 72 static int alist[MAXN+1]; // indices of sequences to be aligned 73 static int fst_list[MAXN+1]; 73 static int fst_list[MAXN+1]; 74 74 static int snd_list[MAXN+1]; 75 75 static int nseqs; // # of sequences … … 102 102 static inline int master_gap_open(int beforePosition) 103 103 { 104 #ifdef DYNAMIC_PENALTIES 104 #ifdef DYNAMIC_PENALTIES 105 105 long gaps = gapsBeforePosition[beforePosition-1]; 106 return (gaps)? MASTER_GAP_OPEN - MAX_GAP_OPEN_DISCOUNT : MASTER_GAP_OPEN; 107 106 return (gaps)? MASTER_GAP_OPEN - MAX_GAP_OPEN_DISCOUNT : MASTER_GAP_OPEN; 107 108 108 /* return 109 109 gaps >= MAX_GAP_OPEN_DISCOUNT … … 112 112 #else 113 113 return DEFAULT_GAP_OPEN; 114 #endif 114 #endif 115 115 } 116 116 static inline int master_gap_extend(int beforePosition) 117 117 { 118 #ifdef DYNAMIC_PENALTIES 118 #ifdef DYNAMIC_PENALTIES 119 119 long gaps = gapsBeforePosition[beforePosition-1]; 120 120 121 121 return (gaps)? MASTER_GAP_EXTEND - MAX_GAP_EXTEND_DISCOUNT : MASTER_GAP_EXTEND; 122 122 /* return … … 126 126 #else 127 127 return DEFAULT_GAP_EXTEND; 128 #endif 128 #endif 129 129 } 130 130 … … 133 133 if (length<=0) 134 134 return 0; 135 135 136 136 int beforePosition = atPosition, 137 137 afterPosition = atPosition-1; … … 140 140 { 141 141 int p1,p2; 142 142 143 143 if ((p1=master_gap_extend(beforePosition)) < (p2=master_gap_extend(afterPosition+1)) && 144 144 beforePosition>1) … … 207 207 { 208 208 #define COMPARABLE_BASES 5 209 209 210 210 if (c1==c2) return 0; 211 211 … … 217 217 c2 = c3; 218 218 } 219 220 if (c2<=COMPARABLE_BASES) 219 220 if (c2<=COMPARABLE_BASES) 221 221 { 222 222 awtc_assert(c1<=COMPARABLE_BASES); … … 237 237 int i; 238 238 int bestMatch = 3; 239 239 240 240 if (c1<=COMPARABLE_BASES) 241 241 { … … 293 293 return 0; 294 294 } 295 295 296 296 static char *result[3]; // result buffers 297 297 … … 372 372 { 373 373 int len = strlen(amino_acid_order); 374 374 375 375 for (int i=1; i<=l && naseq[i]; i++) 376 376 { … … 385 385 { 386 386 int len = strlen(nucleic_acid_order); 387 387 388 388 for (int i=1; i<=l && naseq[i]; i++) 389 389 { … … 414 414 415 415 if (error) return; 416 416 417 417 naa1 = (int **)ckalloc(21 * sizeof (int *) ); 418 418 for(i=0;i<21;i++) naa1[i]=(int *)ckalloc( (max_seq_length+1)*sizeof (int)); 419 419 if (error) return; 420 420 421 421 naa2 = (int **)ckalloc(21 * sizeof (int *) ); 422 422 for(i=0;i<21;i++) naa2[i]=(int *)ckalloc( (max_seq_length+1)*sizeof (int)); 423 423 if (error) return; 424 424 425 425 naas = (int **)ckalloc(21 * sizeof (int *) ); 426 426 for(i=0;i<21;i++) naas[i]=(int *)ckalloc( (max_seq_length+1)*sizeof (int)); … … 431 431 { 432 432 register int i,c; 433 433 434 434 little_pam=big_pam=matptr[0]; 435 435 for(i=0;i<210;++i) { … … 452 452 { 453 453 register int i,j,pos; 454 454 455 455 pos=0; 456 456 457 457 for(i=0;i<20;++i) 458 458 for(j=0;j<=i;++j) 459 459 pam[i][j]=pamo[pos++]; 460 460 461 461 for(i=0;i<20;++i) 462 462 for(j=0;j<=i;++j) 463 463 pam[j][i]=pam[i][j]; 464 464 465 465 if(dnaflag) 466 466 { … … 520 520 displ[print_ptr++] = last_print; 521 521 } 522 else { 522 else { 523 523 last_print = displ[print_ptr++] = v; 524 524 } … … 531 531 int j = seq_array[alist[1]][v2+jat-1]; 532 532 return j>0 ? naas[j][v1+iat-1] : 0; 533 #else 533 #else 534 534 int sum,i,j,lookn,ret; 535 535 int ipos,jpos; 536 536 537 537 ipos = v1 + iat -1; 538 538 jpos = v2 + jat -1; 539 539 540 540 ret = 0; 541 541 sum = lookn = 0; … … 551 551 ++lookn; 552 552 } 553 } 553 } 554 554 } 555 555 else … … 567 567 if (sum>0) ret = sum/lookn; 568 568 return ret; 569 #endif 569 #endif 570 570 } 571 571 … … 631 631 632 632 #ifdef DEBUG 633 # ifdef MATRIX_DUMP 633 # ifdef MATRIX_DUMP 634 634 int display_matrix = 0; 635 635 636 636 awtc_assert(v3<=(DISPLAY_MATRIX_SIZE+2)); // width 637 637 awtc_assert(v4<=(DISPLAY_MATRIX_SIZE)); // height 638 638 639 639 # define DISPLAY_MATRIX_ELEMENTS ((DISPLAY_MATRIX_SIZE+2)*(DISPLAY_MATRIX_SIZE+2)) 640 640 641 641 memset(vertical, -1, DISPLAY_MATRIX_ELEMENTS*sizeof(int)); 642 642 memset(verticalOpen, -1, DISPLAY_MATRIX_ELEMENTS*sizeof(int)); … … 644 644 memset(horizontal, -1, DISPLAY_MATRIX_ELEMENTS*sizeof(int)); 645 645 memset(horizontalOpen, -1, DISPLAY_MATRIX_ELEMENTS*sizeof(int)); 646 646 647 647 # endif 648 #endif 648 #endif 649 649 static int deep; 650 650 deep++; … … 665 665 printf("slave = '%s'\n", d); 666 666 } 667 #endif 667 #endif 668 668 669 669 // q = gap_open + gap_extend; // q is replaced for local positions 670 670 671 671 if(v4<=0) { // if slave sequence is empty 672 672 if(v3>0) { … … 675 675 } 676 676 else { 677 last_print = displ[print_ptr++] = -(v3); // .. or insert gap of length 'v3' into slave 677 last_print = displ[print_ptr++] = -(v3); // .. or insert gap of length 'v3' into slave 678 678 } 679 679 } 680 680 681 681 deep--; 682 return master_gapAt(v1,v3); 683 } 684 685 if(v3<=1) { 682 return master_gapAt(v1,v3); 683 } 684 685 if(v3<=1) { 686 686 if(v3<=0) { // if master sequence is empty 687 687 add(v4); // ??? insert gap length 'v4' into master ??? … … 702 702 ctrc = slave_gapAtWithOpenPenalty(v2,v4,st); 703 703 ctrj = 0; 704 704 705 705 for(j=1;j<=v4;++j) 706 706 { … … 732 732 733 733 awtc_assert(v3>=1 && v4>=1); 734 734 735 735 // slave length >= 1 736 736 // master length >= 1 … … 742 742 zza[0] = 0; 743 743 p = master_gap_open(v1); 744 for(j=1; j<=v4; j++) 744 for(j=1; j<=v4; j++) 745 745 { 746 746 p += master_gap_extend(v1); … … 750 750 zzb[j] = p + master_gap_open(v1); 751 751 } 752 752 753 753 // left half of the matrix 754 754 p = st; 755 ctri = v3 / 2; 756 for(i=1; i<=ctri; i++) 755 ctri = v3 / 2; 756 for(i=1; i<=ctri; i++) 757 757 { 758 758 n = zza[0]; … … 762 762 zza[0] = k; 763 763 l = p + master_gap_open(v1+i+AF); 764 764 765 765 for(j=1; j<=v4; j++) 766 766 { … … 777 777 // diagonal (no gaps) 778 778 IF_MATRIX_DUMP(diagonal[i][j]=) k = n + calc_weight(i,j,v1,v2); // (5) 779 if(l<k) k = l; 779 if(l<k) k = l; 780 780 if(m<k) k = m; // k = minimum of all paths 781 781 782 782 n = zza[j]; // minimum of same row; one column to the left 783 783 zza[j] = k; // minimum of all paths to this matrix position … … 788 788 # define MHO 1 // X-Offset for second half of matrix-arrays (only used to insert MID-column into dumpMatrix()) 789 789 # define BO 1 // Offset for second half of matrix (cause now the indices i and j are smaller as above) 790 790 791 791 // last column of matrix: 792 792 793 793 zzb[0]=zza[0]; 794 794 IF_MATRIX_DUMP(vertical[v3+1+MHO][v4+1]=) … … 803 803 zzd[j] = p+master_gap_open(v1+v3); 804 804 } 805 805 806 806 // right half of matrix (backwards): 807 807 p = en; 808 for(i=v3-1;i>=ctri;i--) 808 for(i=v3-1;i>=ctri;i--) 809 809 { 810 810 n = zzc[v4]; … … 814 814 zzc[v4] = k; 815 815 l = p+master_gap_open(v1+i); 816 816 817 817 for(j=v4-1; j>=0; j--) 818 818 { … … 831 831 if(l<k) k = l; 832 832 if(m<k) k = m; // k = minimum of all paths 833 833 834 834 n = zzc[j]; // minimum of same row; one column to the right 835 835 zzc[j] = k; // minimum of all paths to this matrix position … … 839 839 840 840 #undef BO 841 841 842 842 // connect rightmost column of first half (column ctri) 843 843 // with leftmost column of second half (column ctri+1) 844 844 845 845 zzd[v4] = zzc[v4]; 846 846 847 847 ctrc = INT_MAX; 848 848 flag = 0; 849 849 850 850 for(j=(ctri?0:1);j<=v4;j++) // was j=0;... (this was erroneous cause it splitted zero-length subsequences) 851 851 { 852 852 IF_MATRIX_DUMP(vertical[ctri+MHO][j]=) 853 853 k = zza[j] + zzc[j]; // sum up both calculations (=diagonal=no gaps) 854 854 855 855 if (k<ctrc || ((k==ctrc) && (zza[j]!=zzb[j]) && (zzc[j]==zzd[j]))) 856 856 { … … 861 861 } 862 862 863 for(j=v4;j>=(ctri?0:1);j--) 863 for(j=v4;j>=(ctri?0:1);j--) 864 864 { 865 865 IF_MATRIX_DUMP(verticalOpen[ctri+MHO][j]=) 866 866 k = zzb[j] + zzd[j] // paths where gaps were inserted into slave (left and right side!) 867 867 - slave_gap_open(j); // subtract gap_open-penalty which was added twice (at left and right end of gap) 868 868 869 869 if(k<ctrc) 870 870 { … … 877 877 awtc_assert(flag>=1 && flag<=2); 878 878 879 #undef MHO 880 881 #ifdef MATRIX_DUMP 879 #undef MHO 880 881 #ifdef MATRIX_DUMP 882 882 if (display_matrix) 883 883 dumpMatrix(v1,v2,v3,v4,ctri); 884 884 #endif 885 885 886 886 /* Conquer recursively around midpoint */ 887 887 888 888 if(flag==1) /* Type 1 gaps */ 889 { 889 { 890 890 diff(v1,v2,ctri,ctrj,st,master_gap_open(v1+ctri)); // includes midpoint ctri and ctrj 891 891 diff(v1+ctri,v2+ctrj,v3-ctri,v4-ctrj,master_gap_open(v1+ctri),en); … … 894 894 { 895 895 diff(v1,v2,ctri-1,ctrj,st,0); // includes midpoint ctrj 896 896 897 897 if(last_print<0) /* Delete 2 */ 898 898 last_print = displ[print_ptr-1] -= 2; 899 899 else 900 900 last_print = displ[print_ptr++] = -2; 901 902 diff(v1+ctri+1,v2+ctrj,v3-ctri-1,v4-ctrj,0,en); 901 902 diff(v1+ctri+1,v2+ctrj,v3-ctri-1,v4-ctrj,0,en); 903 903 } 904 904 … … 916 916 // clear statistics 917 917 918 for(i=1;i<=act_seq_length;++i) 918 for(i=1;i<=act_seq_length;++i) 919 919 { 920 920 for(j=0;j<21;++j) naa1[j][i]=naa2[j][i]=0; … … 924 924 // create position statistics for each group 925 925 // [here every group contains only one seq] 926 926 927 927 for(i=1;i<=nseqs;++i) 928 928 { … … 933 933 if(seq_array[i][j]>0) 934 934 { 935 ++naa1[seq_array[i][j]][j]; 935 ++naa1[seq_array[i][j]][j]; 936 936 ++naa1[0][j]; 937 937 } … … 984 984 naas[i][n]=t_arr[i]/k; 985 985 } 986 #endif 986 #endif 987 987 } 988 988 … … 994 994 { 995 995 int i,j,k,xtra; 996 996 997 997 for(i=1;i<=nseqs;++i) 998 998 if(group[i] == sclass) … … 1016 1016 { 1017 1017 int i,j,k,pos,to_do; 1018 1018 1019 1019 pos=1; 1020 1020 to_do=print_ptr; 1021 1022 for(i=0;i<to_do;++i) // was: 1 .. <=to_do 1021 1022 for(i=0;i<to_do;++i) // was: 1 .. <=to_do 1023 1023 { 1024 1024 if(displ[i]==0) … … 1051 1051 } 1052 1052 1053 #ifdef DEBUG 1053 #ifdef DEBUG 1054 1054 result[1][pos] = 0; 1055 1055 result[2][pos] = 0; 1056 #endif 1057 1056 #endif 1057 1058 1058 return pos-1; 1059 1059 } … … 1078 1078 { 1079 1079 int c = res_index(amino_acid_order,seq[i]); 1080 1080 1081 1081 if (!c) 1082 1082 { 1083 1083 if (seq[i]!='?') { // consensus contains ??? 1084 1084 char buf[100]; 1085 sprintf(buf, "Illegal character '%c' in sequence data", seq[i]); 1085 sprintf(buf, "Illegal character '%c' in sequence data", seq[i]); 1086 1086 aw_message(buf); 1087 1087 } 1088 1089 c = res_index(amino_acid_order, 'X'); 1090 } 1091 1088 1089 c = res_index(amino_acid_order, 'X'); 1090 } 1091 1092 1092 awtc_assert(c>0); 1093 1093 naseq[i] = c; … … 1097 1097 } 1098 1098 1099 static GB_ERROR n_encode(const char *seq,char *naseq,int l) 1099 static GB_ERROR n_encode(const char *seq,char *naseq,int l) 1100 1100 { /* code seq as ints .. use -2 for gap */ 1101 1101 int i; 1102 1102 /* static char *nucs="ACGTU"; */ 1103 1103 int warned = 0; 1104 1104 1105 1105 for(i=1; i<=l; i++) 1106 1106 { … … 1112 1112 if (!warned) { 1113 1113 char buf[100]; 1114 sprintf(buf, "Illegal character '%c' in sequence data", seq[i]); 1114 sprintf(buf, "Illegal character '%c' in sequence data", seq[i]); 1115 1115 aw_message(buf); 1116 1116 warned = 1; … … 1119 1119 c = res_index(nucleic_acid_order, 'N'); 1120 1120 } 1121 1121 1122 1122 awtc_assert(c>0); 1123 1123 naseq[i] = c; … … 1132 1132 const int *gapsBefore1, 1133 1133 int max_seq_length, 1134 char **resultPtr1, 1134 char **resultPtr1, 1135 1135 char **resultPtr2, 1136 1136 int *resLengthPtr, … … 1139 1139 error = 0; 1140 1140 gapsBeforePosition = gapsBefore1; 1141 1141 1142 1142 if (!module_initialized) // initialize only once 1143 1143 { 1144 1144 dnaflag = is_dna; 1145 1145 is_weight = weighted; 1146 1146 1147 1147 init_myers(max_seq_length); 1148 1148 init_show_pair(max_seq_length); 1149 1149 make_pamo(0); 1150 1150 fill_pam(); 1151 1151 1152 1152 for (int i=1; i<=2; i++) 1153 1153 { … … 1158 1158 1159 1159 if (error) goto ende; 1160 1160 1161 1161 module_initialized = 1; 1162 1162 } … … 1178 1178 memset(&seq_array[2][1], 0, max_seq_length*sizeof(seq_array[2][1])); 1179 1179 memset(&displ[1], 0xff, max_seq_length*sizeof(displ[1])); 1180 seq_array[1][0] = '_'; 1180 seq_array[1][0] = '_'; 1181 1181 seq_array[2][0] = '_'; 1182 #endif 1182 #endif 1183 1183 1184 1184 { … … 1188 1188 if (error) goto ende; 1189 1189 seqlen_array[1] = length1; 1190 1190 1191 1191 error = encode(seq2-1, seq_array[2], length2); 1192 1192 if (error) goto ende; … … 1202 1202 } 1203 1203 1204 ende: 1204 ende: 1205 1205 1206 1206 return error; -
trunk/AWTC/AWTC_rename.cxx
r205 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <arbdb.h> 6 6 #include <arbdbt.h> -
trunk/AWTI/AWTI_export.cxx
r640 r655 3 3 #include <unistd.h> 4 4 #include <string.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <arbdb.h> 7 7 #include <arbdbt.h> -
trunk/AWTI/AWTI_import.cxx
r636 r655 3 3 #include <unistd.h> 4 4 #include <string.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <memory.h> 7 7 #include <limits.h> -
trunk/CAT/CAT_tree.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <memory.h> 6 6 … … 13 13 const char *CAT_field_names[CAT_FIELD_MAX]; // Fields which are extracted from the arb database 14 14 // syntax: field[:word/(range of words] 15 // ex full_name 15 // ex full_name 16 16 17 17 double CATL_tree_max_deep(GBT_TREE *tree){ … … 85 85 return GB_export_error("Disk Full"); 86 86 } 87 } 87 } 88 88 return 0; 89 89 } … … 107 107 cat_tree->nodes[node->leftson].father = nodec; 108 108 cat_tree->nodes[node->rightson].father = nodec; 109 109 110 110 double l = tree->leftlen; 111 111 double r = tree->rightlen; 112 112 113 113 if (l<0) l = 0.0; 114 114 if (r<0) r = 0.0; 115 115 116 116 cat_tree->nodes[node->leftson].branch_length_float = l; 117 117 cat_tree->nodes[node->rightson].branch_length_float = r; … … 119 119 l *= scale; 120 120 r *= scale; 121 if (l>0 && l<1) l = 1; 121 if (l>0 && l<1) l = 1; 122 122 if (r>0 && r<1) r = 1; 123 123 124 124 if (l> 255) l = 255; 125 125 if (r > 255) l = 255; 126 126 127 127 cat_tree->nodes[node->leftson].branch_length_byte = (unsigned char)l; 128 128 cat_tree->nodes[node->rightson].branch_length_byte = (unsigned char)r; … … 164 164 fullname = name; 165 165 } 166 166 167 167 node->field_offsets[CAT_FIELD_NAME] = GBS_memoffset(cat_mem_files[CAT_FIELD_NAME]); 168 168 GBS_strcat(cat_mem_files[CAT_FIELD_NAME],name); 169 169 GBS_chrcat(cat_mem_files[CAT_FIELD_NAME],1); // seperated by '^A' 170 170 171 171 node->field_offsets[CAT_FIELD_FULL_NAME] = GBS_memoffset(cat_mem_files[CAT_FIELD_FULL_NAME]); 172 172 GBS_strcat(cat_mem_files[CAT_FIELD_FULL_NAME],fullname); … … 207 207 208 208 double scale = 255/CATL_tree_max_deep(tree); 209 cat_convert_tree_2_cat_rek(tree, cat_tree, 0,scale, 209 cat_convert_tree_2_cat_rek(tree, cat_tree, 0,scale, 210 210 level_counter, leaf_counter, node_counter); 211 211 int i; … … 228 228 CAT_node *node = & cat_tree->nodes[i]; 229 229 printf("%4i f%4li l%4li r%4li lfn%4li lvl%4li d%4li bl%4i ", 230 i, 230 i, 231 231 node->father, 232 232 node->leftson, … … 240 240 if (node->field_offsets[j]) { 241 241 printf("%15s ",cat_tree->data+node->field_offsets[j]); 242 } 242 } 243 243 } 244 244 printf("\n"); -
trunk/DIST/PH_matr.cxx
r102 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 -
trunk/DIST/PH_mldist.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 170 170 d2p = 0.0; 171 171 predict(tt, b1, b2); 172 172 173 173 if (p > 0.0){ 174 174 double ip = 1.0/p; -
trunk/DIST/PH_protdist.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 791 791 code(); 792 792 pameigen(); 793 break; 793 break; 794 794 default: 795 795 code(); -
trunk/DIST/PH_save_matr.cxx
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <memory.h> 5 5 #include <string.h> … … 59 59 double max = min; 60 60 double sum = 0.0; 61 61 62 62 make_node_text_init(gb_main); 63 63 for (row = 0; row<nentries;row++){ -
trunk/DIST/distanalyse.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 103 103 104 104 } 105 106 107 105 106 107 -
trunk/EDIT/edit.cxx
r435 r655 2 2 #include <stdlib.h> // wegen exit(); 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 -
trunk/EDIT4/ED4_base.cxx
r584 r655 3 3 #include <string.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <assert.h> 7 7 -
trunk/EDIT4/ED4_edit_string.cxx
r535 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <memory.h> 5 5 #include <string.h> -
trunk/EDIT4/ED4_main.cxx
r583 r655 3 3 #include <string.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 7 7 #include <arbdb.h> -
trunk/EDIT4/ED4_manager.cxx
r629 r655 3 3 #include <string.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <math.h> 7 7 -
trunk/EDIT4/ED4_members.cxx
r584 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 6 6 #include <arbdb.h> -
trunk/EDIT4/ED4_terminal.cxx
r68 r655 3 3 #include <string.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <assert.h> 7 7 -
trunk/EDIT4/ED4_text_terminals.cxx
r581 r655 3 3 #include <string.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 7 7 #include <arbdb.h> -
trunk/GDE/CLUSTALW/clustalw.h
r176 r655 1 /*#include "/us1/user/julie/dmalloc/malloc.h"*/2 1 /*********************CLUSTALW.H*********************************************/ 3 2 /****************************************************************************/ … … 14 13 /*#define MSDOS 1 Turbo C for PC's */ 15 14 16 #define UNIX 1 /*Ultrix/Decstation, Gnu C for 15 #define UNIX 1 /*Ultrix/Decstation, Gnu C for 17 16 Sun, IRIX/SGI, OSF1/ALPHA */ 18 17 … … 26 25 #define MAXTITLES 60 /* Title length */ 27 26 #define FILENAMELEN 256 /* Max. file name length */ 28 27 29 28 #define UNKNOWN 0 30 29 #define EMBLSWISS 1 … … 57 56 #ifdef VMS /* Defaults for VAX VMS */ 58 57 #define COMMANDSEP '/' 59 #define DIRDELIM ']' /* Last character before file name in full file 58 #define DIRDELIM ']' /* Last character before file name in full file 60 59 specs */ 61 60 #define INT_SCALE_FACTOR 1000 /* Scaling factor to convert float to integer for profile scores */ … … 114 113 115 114 typedef struct { 116 int llimit; 115 int llimit; 117 116 int ulimit; 118 117 short *matptr; … … 124 123 SeriesMat mat[MAXMAT]; 125 124 } UserMatSeries; 126 125 127 126 128 127 /* … … 166 165 sint prf_length, sint gapcoef, sint lencoef); 167 166 /* calcprf1.c */ 168 void calc_prf1(sint **profile, char **alignment, sint *gaps, sint matrix[NUMRES ][NUMRES ], 167 void calc_prf1(sint **profile, char **alignment, sint *gaps, sint matrix[NUMRES ][NUMRES ], 169 168 sint *seq_weight, sint prf_length, sint first_seq, sint last_seq); 170 169 /* calcprf2.c */ -
trunk/GDE/CORE/BasicDisplay.c
r2 r655 1 #include <malloc.h> 1 /* #include <malloc.h> */ 2 2 #include <X11/X.h> 3 3 #include <X11/Xlib.h> … … 69 69 /* 70 70 * For all menus defined in the .GDEmenu file, create a corresponding 71 * menu on the menu bar, and tie its XView object to the internal 71 * menu on the menu bar, and tie its XView object to the internal 72 72 * menu structure. 73 73 */ … … 378 378 OPENWIN_SPLIT_INIT_PROC,InitEditSplit, 379 379 OPENWIN_SPLIT_DESTROY_PROC,DestroySplit, 380 NULL, 380 NULL, 381 381 WIN_INHERIT_COLORS,FALSE, 382 382 WIN_BELOW,menubar, … … 588 588 CANVAS_RETAINED,FALSE, 589 589 0); 590 590 591 591 xv_set(NamCan, 592 592 WIN_HEIGHT,MIN(MAX_STARTUP_CANVAS_HEIGHT, -
trunk/GDE/CORE/BuiltIn.c
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include <string.h> 4 4 #include <xview/xview.h> … … 127 127 popup = xv_get(pframe,FRAME_CMD_PANEL); 128 128 (void)xv_create (popup,PANEL_BUTTON, 129 PANEL_LABEL_STRING,"OK", 130 PANEL_NOTIFY_PROC,SaveAsFileName, 129 PANEL_LABEL_STRING,"OK", 130 PANEL_NOTIFY_PROC,SaveAsFileName, 131 131 0); 132 132 133 133 (void)xv_create (popup,PANEL_BUTTON, 134 PANEL_LABEL_STRING,"Cancel", 135 PANEL_NOTIFY_PROC,DONT, 134 PANEL_LABEL_STRING,"Cancel", 135 PANEL_NOTIFY_PROC,DONT, 136 136 0); 137 137 … … 404 404 (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL,0); 405 405 406 (void)xv_create(popup,PANEL_CHOICE_STACK, 406 (void)xv_create(popup,PANEL_CHOICE_STACK, 407 407 PANEL_LAYOUT,PANEL_VERTICAL, 408 408 PANEL_LABEL_STRING,"Color type", … … 441 441 } 442 442 443 (void)xv_create(popup,PANEL_CHOICE_STACK, 443 (void)xv_create(popup,PANEL_CHOICE_STACK, 444 444 PANEL_LAYOUT,PANEL_VERTICAL, 445 445 PANEL_NOTIFY_PROC,ChFontSize, … … 469 469 "Inverted","Lock vertical scroll","Key clicks","Message panel", 470 470 0, 471 PANEL_NOTIFY_PROC,ChDisAttr, 472 PANEL_VALUE,DisplayAttr, 471 PANEL_NOTIFY_PROC,ChDisAttr, 472 PANEL_VALUE,DisplayAttr, 473 473 0); 474 474 … … 830 830 DrawNANames(dpy,xv_get(canvas_paint_window(EditNameCan),XV_XID)); 831 831 view = (Xv_window)xv_get(EditCan,OPENWIN_NTH_VIEW,0); 832 832 833 833 OPENWIN_EACH_VIEW(EditCan,view) 834 834 JumpTo(view, 0,lastselected); … … 1156 1156 PANEL_CHOICE_STRINGS, 1157 1157 "RNA", 1158 "DNA", 1158 "DNA", 1159 1159 "TEXT", 1160 1160 "MASK", … … 1174 1174 (void)xv_create(popup,PANEL_CHOICE_STACK, 1175 1175 PANEL_NOTIFY_PROC,ChAttrType, 1176 PANEL_LABEL_STRING,"Strand", 1176 PANEL_LABEL_STRING,"Strand", 1177 1177 PANEL_CHOICE_STRINGS, 1178 1178 "Primary", … … 1195 1195 PANEL_LAYOUT,PANEL_HORIZONTAL, 1196 1196 PANEL_NOTIFY_PROC,ChAttrType, 1197 PANEL_LABEL_STRING,"Direction", 1197 PANEL_LABEL_STRING,"Direction", 1198 1198 PANEL_CHOICE_STRINGS, 1199 1199 "5' to 3'", … … 1245 1245 #ifdef HGL 1246 1246 if(sel_count == 1) 1247 (void)xv_create(popup,PANEL_TEXT, 1248 PANEL_VALUE_DISPLAY_LENGTH,40, 1247 (void)xv_create(popup,PANEL_TEXT, 1248 PANEL_VALUE_DISPLAY_LENGTH,40, 1249 1249 PANEL_LABEL_STRING,"Membrane ", 1250 1250 PANEL_VALUE,this_elem->membrane, … … 1257 1257 1258 1258 if(sel_count == 1) 1259 (void)xv_create(popup,PANEL_TEXT, 1260 PANEL_VALUE_DISPLAY_LENGTH,40, 1259 (void)xv_create(popup,PANEL_TEXT, 1260 PANEL_VALUE_DISPLAY_LENGTH,40, 1261 1261 PANEL_LABEL_STRING,"Author ", 1262 1262 PANEL_VALUE,this_elem->authority, … … 1269 1269 #ifdef HGL 1270 1270 if(sel_count == 1) 1271 (void)xv_create(popup,PANEL_TEXT, 1272 PANEL_VALUE_DISPLAY_LENGTH,40, 1271 (void)xv_create(popup,PANEL_TEXT, 1272 PANEL_VALUE_DISPLAY_LENGTH,40, 1273 1273 PANEL_LABEL_STRING,"Barcode ", 1274 1274 PANEL_VALUE,this_elem->barcode, … … 1348 1348 WIN_INHERIT_COLORS,TRUE, 1349 1349 WIN_BELOW,comments_tsw, 1350 XV_X,0, XV_HEIGHT,90, 1350 XV_X,0, XV_HEIGHT,90, 1351 1351 TEXTSW_CONTENTS,this_elem->baggage? 1352 1352 this_elem->baggage:"", … … 1385 1385 Cfree(DataSet->element[lastselected].comments); 1386 1386 1387 DataSet->element[lastselected].comments = 1387 DataSet->element[lastselected].comments = 1388 1388 Calloc(xv_get(client,TEXTSW_LENGTH)+1,sizeof(char)); 1389 1389 … … 1391 1391 strlen(DataSet->element[lastselected].comments); 1392 1392 1393 DataSet->element[lastselected].comments_maxlen = 1393 DataSet->element[lastselected].comments_maxlen = 1394 1394 xv_get(client,TEXTSW_LENGTH); 1395 1395 … … 1982 1982 for(i=0;i<slen;i++) 1983 1983 { 1984 rev_seq[i] = 1984 rev_seq[i] = 1985 1985 (NA_Base)getelem(&(element[j]), 1986 1986 slen+offset - i - 1); -
trunk/GDE/CORE/CutCopyPaste.c
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include <string.h> 4 4 #include <xview/xview.h> … … 11 11 #include "defines.h" 12 12 extern Canvas EditCan,EditNameCan; 13 extern Panel_item left_foot,right_foot; 13 extern Panel_item left_foot,right_foot; 14 14 extern Frame frame; 15 15 extern NA_Alignment *DataSet,*Clipboard; … … 48 48 Clipboard->maxnumelements*sizeof(NA_Sequence)); 49 49 } 50 Clipboard->element[(Clipboard->numelements)] = 50 Clipboard->element[(Clipboard->numelements)] = 51 51 DataSet->element[j]; 52 52 /* … … 127 127 strdup(DataSet->element[j].comments); 128 128 Clipboard->element[this].comments_maxlen = 129 Clipboard->element[this].comments_len; 129 Clipboard->element[this].comments_len; 130 130 } 131 131 /* … … 134 134 if(DataSet->element[j].baggage) 135 135 { 136 Clipboard->element[this].baggage = (char*) 136 Clipboard->element[this].baggage = (char*) 137 137 strdup(DataSet->element[j].baggage); 138 138 Clipboard->element[this].baggage_maxlen = 139 Clipboard->element[this].baggage_len; 139 Clipboard->element[this].baggage_len; 140 140 } 141 141 … … 174 174 Event *event; 175 175 { 176 176 177 177 extern Frame frame; 178 178 extern Canvas EditCan,EditNameCan; … … 209 209 210 210 for(j=DataSet->numelements-1;j>=last+1;j--) 211 DataSet->element[j+Clipboard->numelements] = 211 DataSet->element[j+Clipboard->numelements] = 212 212 DataSet->element[j]; 213 213 214 214 for(j=0;j<Clipboard->numelements;j++) 215 215 { 216 DataSet->element[last+1+j] = Clipboard->element[j]; 216 DataSet->element[last+1+j] = Clipboard->element[j]; 217 217 /* 218 218 * be sure to bring them back into alignment with the rest … … 255 255 alignment->element[j].groupb = NULL; 256 256 } 257 257 258 258 for(group = 1;group <= alignment->numgroups;group++) 259 259 { … … 264 264 if(last != -1) 265 265 { 266 alignment->element[j].groupb = 266 alignment->element[j].groupb = 267 267 &(alignment->element[last]); 268 alignment->element[last].groupf = 268 alignment->element[last].groupf = 269 269 &(alignment->element[j]); 270 270 } … … 337 337 * Need to check protections 338 338 */ 339 339 340 340 for(i=0,blank_space = 0;i<this_elem->offset;i++) 341 341 if(DataSet->selection_mask[i] == '1') 342 342 TextClip[numselected][blank_space++] = 343 (char)getelem(this_elem,i); 343 (char)getelem(this_elem,i); 344 344 345 345 … … 362 362 if((k!=0) && (i<this_elem->seqlen-1)) 363 363 { 364 this_elem->sequence[1+i-k] = 364 this_elem->sequence[1+i-k] = 365 365 this_elem->sequence[1+i]; 366 366 if(this_elem->cmask) 367 367 { 368 this_elem->cmask[1+i-k] = 368 this_elem->cmask[1+i-k] = 369 369 this_elem->cmask[1+i]; 370 370 } … … 417 417 if(DataSet->selection_mask[i] == '1') 418 418 { 419 base = (char)getelem(this_elem,i); 419 base = (char)getelem(this_elem,i); 420 420 if(this_elem->tmatrix) 421 421 tbase = (this_elem->tmatrix[base])|32; … … 446 446 GAP = TRUE; 447 447 else 448 UNAMB = TRUE; 448 UNAMB = TRUE; 449 449 break; 450 450 default: … … 496 496 return(XV_OK); 497 497 } 498 498 499 499 for(j=0;j<TextClipSize;j++) 500 500 { … … 511 511 } 512 512 } 513 513 514 514 RepaintAll(TRUE); 515 515 sprintf(buffer,"%d bytes in Text Clipboard",TextClipLength * … … 578 578 * Need to check protections 579 579 */ 580 580 581 581 for(i=0,blank_space = 0;i<this_elem->offset;i++) 582 582 if(DataSet->selection_mask[i] == '1') 583 583 TextClip[numselected][blank_space++] = 584 (char)getelem(this_elem,i); 584 (char)getelem(this_elem,i); 585 585 586 586 -
trunk/GDE/CORE/DrawNA.c
r2 r655 1 #include <malloc.h> 1 /* #include <malloc.h> */ 2 2 #include <X11/X.h> 3 3 #include <X11/Xlib.h> … … 239 239 wid -= j; 240 240 j=0; 241 buffer[j] = tmat? 241 buffer[j] = tmat? 242 242 tmat[base]:base; 243 243 /* -
trunk/GDE/CORE/EventHandler.c
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include <string.h> 4 4 #include <xview/xview.h> … … 125 125 PANEL_LAYOUT,PANEL_HORIZONTAL, 126 126 PANEL_LABEL_STRING,thisitem->arg[j].label, 127 PANEL_NOTIFY_PROC, HandleMenuItem, 127 PANEL_NOTIFY_PROC, HandleMenuItem, 128 128 PANEL_CHOICE_STRING, 129 129 0,thisitem->arg[j].choice[0].label, … … 177 177 178 178 179 default: 179 default: 180 180 break; 181 181 }; … … 213 213 values returned from the dialog box so that they can be used for calling 214 214 the external function. 215 215 216 216 Copyright (c) 1989-1990, University of Illinois board of trustees. All 217 217 rights reserved. Written by Steven Smith at the Center for Prokaryote Genome … … 312 312 select_mode = TestSelection(); 313 313 314 /* 314 /* 315 315 Make sure that we are still in a writeable directory 316 316 */ … … 519 519 * The basic idea is to replace all of the symbols in the method 520 520 * string with the values picked in the dialog box. The method 521 * is the general command line structure. All arguements have three 521 * is the general command line structure. All arguements have three 522 522 * parts, a label, a method, and a value. The method never changes, and 523 * is used to represent '-flag's for a given function. Values are the 524 * associated arguements that some flags require. All symbols that 523 * is used to represent '-flag's for a given function. Values are the 524 * associated arguements that some flags require. All symbols that 525 525 * require argvalue replacement should have a '$' infront of the symbol 526 526 * name in the itemmethod definition. All symbols without the '$' will … … 551 551 * argchoice:Argument_label:Argument_method 552 552 * 553 * 553 * 554 554 */ 555 555 char *symbol,*method,*textvalue,buf1[GBUFSIZ],buf2[GBUFSIZ],*temp; … … 872 872 PANEL_LAYOUT,PANEL_HORIZONTAL, 873 873 PANEL_LABEL_STRING,thisitem->arg[j].label, 874 PANEL_NOTIFY_PROC, HandleMenuItem, 874 PANEL_NOTIFY_PROC, HandleMenuItem, 875 875 PANEL_CHOICE_STRING, 876 876 0,thisitem->arg[j].choice[0].label, … … 905 905 906 906 907 default: 907 default: 908 908 break; 909 909 }; -
trunk/GDE/CORE/FileIO.c
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include <xview/xview.h> 4 4 #include <xview/notice.h> … … 373 373 { 374 374 for(j=0;j<aln->numelements;j++) 375 if(seqs[j].elementtype == MASK && 375 if(seqs[j].elementtype == MASK && 376 376 seqs[j].selected) 377 377 mask = j; … … 395 395 else 396 396 offset_str[0] = '\0'; 397 398 if(((j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 397 398 if(((j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 399 399 || (method == SELECT_REGION && seqs[j].subselected) 400 400 || method == ALL) … … 688 688 if(IGNORE_DASH && (indx != -1)) 689 689 { 690 for(jj=0,j=0;(j<curlen) && 690 for(jj=0,j=0;(j<curlen) && 691 691 (jj<aln->element[indx].seqlen);j++,jj++) 692 692 { … … 704 704 * 705 705 * The allocated space is equal the seqlen of the matched sequence. 706 * 706 * 707 707 */ 708 708 if(aln->element[indx].tmatrix) … … 946 946 } 947 947 } 948 948 949 949 */ 950 950 } … … 1000 1000 { 1001 1001 for(j=0;j<aln->numelements;j++) 1002 if(seqs[j].elementtype == MASK && 1002 if(seqs[j].elementtype == MASK && 1003 1003 seqs[j].selected) 1004 1004 mask = j; … … 1022 1022 else 1023 1023 offset_str[0] = '\0'; 1024 1025 if(((j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 1024 1025 if(((j!=mask) && (seqs[j].selected) && method != SELECT_REGION) 1026 1026 || (method == SELECT_REGION && seqs[j].subselected) 1027 1027 || method == ALL) -
trunk/GDE/CORE/Free.c
r2 r655 2 2 #include <xview/defaults.h> 3 3 #include <xview/xview.h> 4 #include <xview/panel.h> 5 #include <xview/window.h> 6 #include <xview/icon.h> 7 #include <pixrect/pixrect.h> 8 #include <malloc.h> 4 #include <xview/panel.h> 5 #include <xview/window.h> 6 #include <xview/icon.h> 7 #include <pixrect/pixrect.h> 8 /* #include <malloc.h> */ 9 9 #include "menudefs.h" 10 10 #include "defines.h" -
trunk/GDE/CORE/Genbank.c
r344 r655 1 1 #include <sys/time.h> 2 2 #include <stdio.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <time.h> 5 5 #include <xview/xview.h> -
trunk/GDE/CORE/HGLfile.c
r2 r655 1 1 #include <sys/time.h> 2 2 #include <stdio.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <xview/xview.h> 5 5 #include <xview/panel.h> … … 234 234 if(line[j] == '"') done = TRUE; 235 235 236 else 236 else 237 237 buffer[len++] = line[j]; 238 238 } … … 464 464 * non-'0' space in the mask. 465 465 */ 466 for(k=this_elem->offset;k<aln->selection_mask_len && 466 for(k=this_elem->offset;k<aln->selection_mask_len && 467 467 aln->selection_mask[k] == '0';k++); 468 468 fprintf(file,"offset %d\n", aln->rel_offset+k); … … 536 536 if(k%60 == 0) 537 537 putc('\n',file); 538 if(method == SELECT_REGION) 538 if(method == SELECT_REGION) 539 539 { 540 if(aln->selection_mask[k] == '1') 540 if(aln->selection_mask[k] == '1') 541 541 putc(this_elem->tmatrix[getelem(this_elem,k)], 542 542 file); … … 571 571 if(k%60 == 0) 572 572 putc('\n',file); 573 if(method == SELECT_REGION) 573 if(method == SELECT_REGION) 574 574 { 575 if(aln->selection_mask[k] == '1') 575 if(aln->selection_mask[k] == '1') 576 576 putc(getelem(this_elem,k),file); 577 577 } … … 754 754 that->baggage_maxlen += this->baggage_maxlen; 755 755 if(that->baggage) 756 that->baggage = 756 that->baggage = 757 757 Realloc(that->baggage,that->baggage_maxlen*sizeof(char)); 758 758 else … … 765 765 that->comments_maxlen += this->comments_maxlen; 766 766 if(that->comments) 767 that->comments = 767 that->comments = 768 768 Realloc(that->comments,that->comments_maxlen*sizeof(char)); 769 769 else -
trunk/GDE/CORE/ParseMenu.c
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include <xview/xview.h> 4 4 #include <xview/panel.h> … … 96 96 curmenu = num_menus++; 97 97 thismenu = &menu[curmenu]; 98 thismenu->label = 98 thismenu->label = 99 99 (char*)calloc(strlen(temp)+1,sizeof(char)); 100 100 … … 153 153 { 154 154 crop(Inline,head,temp); 155 thisitem->method = 155 thisitem->method = 156 156 (char*)calloc(strlen(temp)+1,sizeof(char)); 157 157 if(thisitem->method == NULL) … … 177 177 { 178 178 crop(Inline,head,temp); 179 thisitem->meta = temp[0]; 179 thisitem->meta = temp[0]; 180 180 } 181 181 /* … … 194 194 resize = realloc(thisitem->arg, 195 195 thisitem->numargs*sizeof(GmenuItemArg) ); 196 196 197 197 198 198 if(resize == NULL) … … 392 392 thisitem->output = (GfileFormat*)resize; 393 393 thisoutput = &(thisitem->output)[curoutput]; 394 thisoutput->save = FALSE; 394 thisoutput->save = FALSE; 395 395 thisoutput->overwrite = FALSE; 396 396 thisoutput->format = 0; … … 446 446 if(thisoutput == NULL) 447 447 Error("Problem with GDEmenus"); 448 crop(Inline,head,tail); 449 if(Find(tail,"genbank")) 450 thisoutput->format = GENBANK; 448 crop(Inline,head,tail); 449 if(Find(tail,"genbank")) 450 thisoutput->format = GENBANK; 451 451 else if(Find(tail,"gde")) 452 452 thisoutput->format = GDE; … … 547 547 Crop(): 548 548 Split "this:that[:the_other]" 549 into: "this" and "that[:the_other]" 549 into: "this" and "that[:the_other]" 550 550 */ 551 551 -
trunk/GDE/CORE/Scroll.c
r2 r655 1 #include <malloc.h> 1 /* #include <malloc.h> */ 2 2 #include <X11/X.h> 3 3 #include <X11/Xlib.h> … … 138 138 deltax=(int)xv_get(hsc,SCROLLBAR_VIEW_LENGTH); 139 139 140 lasty=(int)xv_get(vsc, 140 lasty=(int)xv_get(vsc, 141 141 SCROLLBAR_LAST_VIEW_START); 142 142 … … 181 181 return(XV_OK); 182 182 } 183 183 184 184 /* 185 185 test for hsc && vsc attempts to fix warnings at split 186 186 */ 187 187 else if ((event_action(event) == ACTION_SPLIT_HORIZONTAL || 188 event_action(event) == ACTION_SPLIT_VERTICAL ) && 188 event_action(event) == ACTION_SPLIT_VERTICAL ) && 189 189 hsc && vsc) 190 190 { … … 209 209 Xv_xrectlist area; 210 210 Xv_window win; 211 211 212 212 hsc = (Scrollbar)xv_get(EditCan,OPENWIN_HORIZONTAL_SCROLLBAR,view); 213 213 vsc = (Scrollbar)xv_get(EditCan,OPENWIN_VERTICAL_SCROLLBAR,view); -
trunk/GDE/CORE/main.c
r2 r655 2 2 #include <xview/defaults.h> 3 3 #include <xview/xview.h> 4 #include <xview/panel.h> 5 #include <xview/window.h> 6 #include <xview/icon.h> 7 #include <pixrect/pixrect.h> 8 #include <malloc.h> 4 #include <xview/panel.h> 5 #include <xview/window.h> 6 #include <xview/icon.h> 7 #include <pixrect/pixrect.h> 8 /* #include <malloc.h> */ 9 9 #include "menudefs.h" 10 10 #include "defines.h" … … 169 169 170 170 xv_set(frame, 171 FRAME_ICON,tool_icon, 171 FRAME_ICON,tool_icon, 172 172 0); 173 173 -
trunk/GDE/HGL_SRC/Alloc.c
r2 r655 1 1 #include <stdio.h> 2 2 #include "global_defs.h" 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 5 5 /* … … 67 67 #ifdef SUN4 68 68 if(free(block) == 0) 69 Warning("Error in Cfree..."); 69 Warning("Error in Cfree..."); 70 70 #endif 71 71 } … … 104 104 105 105 /* 106 * Replace the array element at seq[indx] with elem. The index 107 * is relative to the alignment. 106 * Replace the array element at seq[indx] with elem. The index 107 * is relative to the alignment. 108 108 */ 109 109 … … 190 190 c[0]=ch; 191 191 c[1] = '\0'; 192 192 193 193 return (InsertElems(a,b,c)); 194 194 } … … 274 274 275 275 seq->direction *= -1; 276 276 277 277 SeqNormal(seq); 278 278 return; 279 } 279 } 280 280 281 281 … … 289 289 static int tmatr[16] = {'-','a','c','m','g','r','s','v', 290 290 't','w','y','h','k','d','b','n'}; 291 291 292 292 static int matr[128] = { 293 293 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x00, … … 298 298 0,0,0,0,0x00,0 299 299 }; 300 300 301 301 c = seq->c_elem; 302 302 for(j=0;j<seq->seqlen;j++) … … 328 328 0; 329 329 return; 330 331 } 330 331 } -
trunk/GDE/HGL_SRC/MakeCons.c
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include "global_defs.h" 4 4 … … 17 17 { 18 18 fprintf(stderr, "Usage:\n"); 19 fprintf(stderr, 19 fprintf(stderr, 20 20 "%s %s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n", 21 21 av[0], 22 "sequence-file", 22 "sequence-file", 23 23 "[-iupac] IUPAC consensus. Default", 24 24 "[-majority percent] Majority consensus (default percent: 75)", … … 32 32 33 33 InitRecord(&cons); 34 34 35 35 if((file = fopen(av[1],"r")) == NULL) 36 36 { … … 39 39 } 40 40 41 41 42 42 master = (Sequence*)Calloc(maxsize,sizeof(Sequence)); 43 43 … … 128 128 fprintf(maskout_fp, "start:\n"); 129 129 } 130 130 131 131 if((cons_type == 'i' && 132 132 MakeConsensus(master,cursize,&cons,0,cons_type)==FALSE) || … … 147 147 } 148 148 149 /*WriteRecord(stdout, &cons, NULL, 0); 149 /*WriteRecord(stdout, &cons, NULL, 0); 150 150 printf("\n\n");*/ 151 151 152 152 if(maskout_fp == NULL) 153 153 { -
trunk/GDE/HGL_SRC/Translate.c
r256 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 /* #include <malloc.h> */ 3 3 #include <string.h> 4 4 #include "global_defs.h" … … 227 227 228 228 /* save_name = malloc(80); */ 229 229 230 230 strncpy(save_name, seq->name, 80); 231 231 temp=(char*)Calloc(seq->seqlen+1,sizeof(char)); … … 250 250 } 251 251 252 /* 253 * Skip over r_frame valid characters (skip ' ','-','~') 252 /* 253 * Skip over r_frame valid characters (skip ' ','-','~') 254 254 */ 255 255 for(true_start=0,i=0; i<r_frame&&true_start< … … 299 299 fptr = 0; 300 300 /* 301 * Check to see if it is a valid ORF 301 * Check to see if it is a valid ORF 302 302 */ 303 303 if((strncmp("Ter",&(temp[start]),3) == 0) || … … 318 318 * If reading from stop to stop, leave the elading stop codon 319 319 */ 320 if(temp[last_start]=='*' || 320 if(temp[last_start]=='*' || 321 321 strncmp("Ter",&(temp[last_start]),3) == 0) 322 322 for(i=last_start+3;i<start+3;i++) … … 343 343 save_c_elem = seq->c_elem; 344 344 seq->c_elem = temp; 345 WriteRecord(stdout,seq,NULL,0); 345 WriteRecord(stdout,seq,NULL,0); 346 346 strncpy(seq->name, save_name, 80); 347 347 seq->c_elem = save_c_elem; … … 368 368 { 369 369 seq->c_elem = temp; 370 WriteRecord(stdout,seq,NULL,0); 370 WriteRecord(stdout,seq,NULL,0); 371 371 } 372 372 Cfree(temp); -
trunk/GDE/HGL_SRC/global_defs.h
r2 r655 3 3 #include <limits.h> 4 4 #include <string.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <time.h> 7 7 … … 72 72 73 73 /*** 74 *** Elements in at[] and e_tags should be IN THE SAME ORDER. 74 *** Elements in at[] and e_tags should be IN THE SAME ORDER. 75 75 ***/ 76 76 … … 94 94 "baggage", 95 95 "group-number", 96 "barcode", 96 "barcode", 97 97 "orig_direction", 98 98 "orig_strand", -
trunk/GDE/LOOPTOOL/Draw.c
r2 r655 5 5 #include <xview/panel.h> 6 6 #include <string.h> 7 #include <malloc.h> 7 /* #include <malloc.h> */ 8 8 #include "loop.h" 9 9 #include "globals.h" … … 205 205 SetPos(nuc_sel1,nuc_sel2,x,y); 206 206 break; 207 207 208 208 case ANGULAR: 209 209 SetAng(nuc_sel1,nuc_sel2,x,y); 210 210 break; 211 211 212 212 case DISTANCE: 213 213 SetDist(nuc_sel1,nuc_sel2,x,y); … … 223 223 UnHiLite(nuc_sel2); 224 224 select_state=0; 225 nuc_sel1= -1; 225 nuc_sel1= -1; 226 226 nuc_sel2= -1; 227 227 select_state=0; … … 246 246 } 247 247 248 UnHiLite(nuc) 249 int nuc; 250 { 248 UnHiLite(nuc) 249 int nuc; 250 { 251 251 if(nuc == -1) return; 252 252 baselist[nuc].attr &= ~HILITE; … … 308 308 309 309 SetPos(nuc1,nuc2,x,y) 310 int nuc1,nuc2; 311 double x,y; 312 { 310 int nuc1,nuc2; 311 double x,y; 312 { 313 313 int i,nuc,pair; 314 314 double dx,dy,sqrt(); … … 344 344 345 345 SetAng(nuc1,nuc2,x,y) 346 int nuc1,nuc2; 347 double x,y; 348 { 346 int nuc1,nuc2; 347 double x,y; 348 { 349 349 int i,j; 350 350 double dist,theta; … … 543 543 int nucnum; 544 544 Pixwin *pw; 545 { 545 { 546 546 Base *b; 547 547 int j; … … 577 577 578 578 x = b->x+label->dist*cos(theta)-xc; 579 y = b->y+label->dist*sin(theta)-yc; 579 y = b->y+label->dist*sin(theta)-yc; 580 580 } 581 581 label -> x=x; … … 594 594 return; 595 595 } 596 596 597 597 598 598 IsLoop(n1,n2) -
trunk/GDE/LOOPTOOL/ReadData.c
r2 r655 3 3 #include <stdio.h> 4 4 #include <string.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 #include "loop.h" 7 7 #include "globals.h" … … 130 130 (*blist)[pos-1].y=0.0; 131 131 (*blist)[pos-1].known=TRUE; 132 132 133 133 *seqlen=pos; 134 134 for(j=19;j<pos;j+=20) -
trunk/GDE/LOOPTOOL/Window.c
r2 r655 7 7 #include <xview/panel.h> 8 8 #include <string.h> 9 #include <malloc.h> 9 /* #include <malloc.h> */ 10 10 #include <math.h> 11 11 #include "loop.h" … … 61 61 * Open font for screen operations. 62 62 */ 63 page=xv_create(NULL,FRAME, 63 page=xv_create(NULL,FRAME, 64 64 FRAME_LABEL, "LoopTool", 65 65 WIN_INHERIT_COLORS,TRUE, … … 87 87 PANEL_LABEL_STRING,"Data File:", 88 88 PANEL_VALUE,"", 89 PANEL_NOTIFY_PROC,SetFile, 89 PANEL_NOTIFY_PROC,SetFile, 90 90 0); 91 91 … … 150 150 /* 151 151 * Pagecan is the canvas used for the primary display. 152 */ 152 */ 153 153 pagecan=xv_create(page,CANVAS, 154 154 WIN_INHERIT_COLORS,TRUE, … … 201 201 XV_AUTO_CREATE,FALSE, 202 202 0); 203 203 204 204 205 205 if(colmap == NULL) … … 213 213 WIN_CMS_NAME,"GDE Palette", 214 214 WIN_CMS, colmap, 215 WIN_FOREGROUND_COLOR,8, 215 WIN_FOREGROUND_COLOR,8, 216 216 WIN_BACKGROUND_COLOR,15, 217 217 WIN_INHERIT_COLORS,FALSE, … … 224 224 window_fit_width(page); 225 225 226 fdlg=xv_create(file_dialog,PANEL, 226 fdlg=xv_create(file_dialog,PANEL, 227 227 XV_WIDTH,300, 228 228 XV_HEIGHT,200, … … 230 230 0); 231 231 232 pdlg=xv_create(print_dialog,PANEL, 233 XV_WIDTH,300, 232 pdlg=xv_create(print_dialog,PANEL, 233 XV_WIDTH,300, 234 234 XV_HEIGHT,200, 235 PANEL_LAYOUT,PANEL_HORIZONTAL, 235 PANEL_LAYOUT,PANEL_HORIZONTAL, 236 236 0); 237 237 … … 337 337 xmin = 99999.99; 338 338 ymin = 99999.99; 339 339 340 340 for(nucpos=0;nucpos<seqlen;nucpos++) 341 341 { … … 392 392 PlaceLabel(baselist[nucpos].label,nucpos,pw); 393 393 } 394 394 395 395 } 396 396 if(sho_con) … … 409 409 410 410 411 /* 411 /* 412 412 * BuildLoopStack: Build a stack of bases that make a subloop of 413 413 * the structure. Unknown bases are pushed on the stack until a known … … 430 430 stk[stkp=0].nucnum=nuc; 431 431 stk[stkp++].dist=0.0; 432 432 433 433 434 434 current=NextBase(nuc,blist,&dist); … … 507 507 else 508 508 { 509 if(pair<=forw) 510 { 511 next = pair; 512 *dist=Spacing(here.nuc,blist[next].nuc); 513 } 514 else 515 { 509 if(pair<=forw) 510 { 511 next = pair; 512 *dist=Spacing(here.nuc,blist[next].nuc); 513 } 514 else 515 { 516 516 next = forw; 517 *dist = here.dforw.dist; 518 } 519 } 517 *dist = here.dforw.dist; 518 } 519 } 520 520 } 521 521 … … 689 689 if(blist[stk[i].nucnum].posnum != -1) 690 690 PosConFix(blist[stk[i].nucnum]); 691 } 691 } 692 692 } 693 693 } -
trunk/GDE/LOOPTOOL/WriteData.c
r2 r655 4 4 #include <stdio.h> 5 5 #include <string.h> 6 #include <malloc.h> 6 /* #include <malloc.h> */ 7 7 #include "loop.h" 8 8 #include "globals.h" … … 13 13 FILE *outfile; 14 14 Base base; 15 15 16 16 outfile = fopen("loop.temp","w"); 17 17 if(outfile == NULL) -
trunk/GDE/MOLPHY/Nucml.c
r2 r655 623 623 getfreqepm(Seqchar, Freqemp, Maxspc, Maxsite); 624 624 alias = new_ivector(Maxsite); 625 radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn);625 a_radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn); 626 626 Seqconint = new_imatrix(Maxspc, Numptrn); 627 627 Weight = new_ivector(Numptrn); … … 1201 1201 for (Cnotree = 0; Cnotree < Numqltree; Cnotree++) { 1202 1202 Alklptrn = Lklptrn[Cnotree]; 1203 if (Cnotree == 0) 1203 if (Cnotree == 0) 1204 1204 initturn(Ctree); 1205 1205 else -
trunk/GDE/MOLPHY/Nucst.c
r2 r655 203 203 getfreqepm(Seqchar, Freqemp, Maxspc, Maxsite); 204 204 alias = new_ivector(Maxsite); 205 radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn);205 a_radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn); 206 206 Seqconint = new_imatrix(Maxspc, Numptrn); 207 207 Weight = new_ivector(Numptrn); -
trunk/GDE/MOLPHY/Nuctpm.c
r2 r655 624 624 getfreqepm(Seqchar, Freqemp, Maxspc, Maxsite); 625 625 alias = new_ivector(Maxsite); 626 radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn);626 a_radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn); 627 627 Seqconint = new_imatrix(Maxspc, Numptrn); 628 628 Weight = new_ivector(Numptrn); … … 1203 1203 for (Cnotree = 0; Cnotree < Numqltree; Cnotree++) { 1204 1204 Alklptrn = Lklptrn[Cnotree]; 1205 if (Cnotree == 0) 1205 if (Cnotree == 0) 1206 1206 initturn(Ctree); 1207 1207 else -
trunk/GDE/MOLPHY/Prottpm.c
r2 r655 624 624 getfreqepm(Seqchar, Freqemp, Maxspc, Maxsite); 625 625 alias = new_ivector(Maxsite); 626 radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn);626 a_radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn); 627 627 Seqconint = new_imatrix(Maxspc, Numptrn); 628 628 Weight = new_ivector(Numptrn); … … 1203 1203 for (Cnotree = 0; Cnotree < Numqltree; Cnotree++) { 1204 1204 Alklptrn = Lklptrn[Cnotree]; 1205 if (Cnotree == 0) 1205 if (Cnotree == 0) 1206 1206 initturn(Ctree); 1207 1207 else -
trunk/GDE/MOLPHY/prot_tml.h
r2 r655 25 25 void getfreqepm P_((cmatrix seqchar, double *freqemp, int maxspc, int maxsite)); 26 26 void convfreq P_((double *freqemp)); 27 void radixsort P_((cmatrix seqchar, ivector alias, int maxspc, int maxsite, int *numptrn));27 void a_radixsort P_((cmatrix seqchar, ivector alias, int maxspc, int maxsite, int *numptrn)); 28 28 void condenceseq P_((cmatrix seqchar, ivector alias, imatrix seqconint, ivector weight, int maxspc, int maxsite, int numptrn)); 29 29 void getnumsites P_((imatrix seqconint, ivector numsites, ivector weight, int numspc, int numptrn)); -
trunk/GDE/MOLPHY/protml.c
r2 r655 624 624 getfreqepm(Seqchar, Freqemp, Maxspc, Maxsite); 625 625 alias = new_ivector(Maxsite); 626 radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn);626 a_radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn); 627 627 Seqconint = new_imatrix(Maxspc, Numptrn); 628 628 Weight = new_ivector(Numptrn); … … 1203 1203 for (Cnotree = 0; Cnotree < Numqltree; Cnotree++) { 1204 1204 Alklptrn = Lklptrn[Cnotree]; 1205 if (Cnotree == 0) 1205 if (Cnotree == 0) 1206 1206 initturn(Ctree); 1207 1207 else -
trunk/GDE/MOLPHY/protst.c
r2 r655 203 203 getfreqepm(Seqchar, Freqemp, Maxspc, Maxsite); 204 204 alias = new_ivector(Maxsite); 205 radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn);205 a_radixsort(Seqchar, alias, Maxspc, Maxsite, &Numptrn); 206 206 Seqconint = new_imatrix(Maxspc, Numptrn); 207 207 Weight = new_ivector(Numptrn); -
trunk/GDE/MOLPHY/seqproc.c
r2 r655 30 30 } putchar('\n'); 31 31 } 32 #endif 32 #endif 33 33 } /*_ convseq */ 34 34 … … 94 94 95 95 96 void 97 radixsort(seqchar, alias, maxspc, maxsite, numptrn) 96 void a_radixsort(seqchar, alias, maxspc, maxsite, numptrn) 98 97 cmatrix seqchar; 99 98 ivector alias; … … 148 147 } 149 148 #endif 150 } /*_ radixsort */149 } /*_ a_radixsort */ 151 150 152 151 … … 213 212 numsites[i] = n; 214 213 /* printf("numsites %3d %5d\n", i ,n); */ 215 } 214 } 216 215 } /* getnumsites */ 217 216 … … 234 233 putchar('\n'); 235 234 for (i = 0; i < numspc; i++) { 236 fputid(stdout, identif[i], 10); 235 fputid(stdout, identif[i], 10); 237 236 putchar(' '); 238 237 for (j = k; j < maxj; j++) { -
trunk/GDE/SUPPORT/Flatio.c
r2 r655 1 #include <malloc.h> 1 /* #include <malloc.h> */ 2 2 #include <stdio.h> 3 3 #define TRUE 1 -
trunk/GDE/SUPPORT/lsadt.c
r2 r655 1 1 /* 2 PROGRAM LSADT3 Fortran->C conversion by Mike Maciukenas, CPGA, Microbiology at University2 PROGRAM LSADT 3 Fortran->C conversion by Mike Maciukenas, CPGA, Microbiology at University 4 4 of Illinois. 5 C-----------------------------------------------------------------------6 C7 C LEAST SQUARES ALGORITHM FOR FITTING ADDITIVE TREES TO8 C PROXIMITY DATA9 C10 C GEERT DE SOETE -- VERSION 1.01 - FEB. 198311 C VERSION 1.02 - JUNE 198312 C VERSION 1.03 - JULY 198313 C14 C REFERENCE: DE SOETE, G. A LEAST SQUARES ALGORITHM FOR FITTING15 C ADDITIVE TREES TO PROXIMITY DATA. PSYCHOMETRIKA, 1983, 48,16 C 621-626.17 C DE SOETE, G. ADDITIVE TREE REPRESENTATIONS OF INCOMPLETE18 C DISSIMILARITY DATA. QUALITY AND QUANTITY, 1984, 18,19 C 387-393.20 C REMARKS21 C -------22 C 2) UNIFORMLY DISTRIBUTED RANDOM NUMBERS ARE GENERATED BY A23 C PROCEDURE DUE TO SCHRAGE. CF.24 C SCHRAGE, L. A MORE PORTABLE FORTRAN RANDOM NUMBER GENERATOR.25 C ACM TRANS. ON MATH. SOFTW., 1979, 5, 132-138.26 C 3) SUBROUTINES VA14AD AND VA14AC (translated into minfungra) ARE27 C ADAPTED FROM THE HARWELL SUBROUTINE LIBRARY (1979 EDITION).28 C 4) ALTHOUGH THIS PROGRAM HAS BEEN CAREFULLY TESTED, THE29 C AUTHOR DISCLAIMS ANY RESPONSABILITY FOR POSSIBLE30 C ERRORS.31 C32 C-----------------------------------------------------------------------5 C----------------------------------------------------------------------- 6 C 7 C LEAST SQUARES ALGORITHM FOR FITTING ADDITIVE TREES TO 8 C PROXIMITY DATA 9 C 10 C GEERT DE SOETE -- VERSION 1.01 - FEB. 1983 11 C VERSION 1.02 - JUNE 1983 12 C VERSION 1.03 - JULY 1983 13 C 14 C REFERENCE: DE SOETE, G. A LEAST SQUARES ALGORITHM FOR FITTING 15 C ADDITIVE TREES TO PROXIMITY DATA. PSYCHOMETRIKA, 1983, 48, 16 C 621-626. 17 C DE SOETE, G. ADDITIVE TREE REPRESENTATIONS OF INCOMPLETE 18 C DISSIMILARITY DATA. QUALITY AND QUANTITY, 1984, 18, 19 C 387-393. 20 C REMARKS 21 C ------- 22 C 2) UNIFORMLY DISTRIBUTED RANDOM NUMBERS ARE GENERATED BY A 23 C PROCEDURE DUE TO SCHRAGE. CF. 24 C SCHRAGE, L. A MORE PORTABLE FORTRAN RANDOM NUMBER GENERATOR. 25 C ACM TRANS. ON MATH. SOFTW., 1979, 5, 132-138. 26 C 3) SUBROUTINES VA14AD AND VA14AC (translated into minfungra) ARE 27 C ADAPTED FROM THE HARWELL SUBROUTINE LIBRARY (1979 EDITION). 28 C 4) ALTHOUGH THIS PROGRAM HAS BEEN CAREFULLY TESTED, THE 29 C AUTHOR DISCLAIMS ANY RESPONSABILITY FOR POSSIBLE 30 C ERRORS. 31 C 32 C----------------------------------------------------------------------- 33 33 */ 34 34 #include <stdio.h> 35 35 #include <math.h> 36 37 #ifdef DARWIN 38 #include <float.h> 39 #define MAXDOUBLE DBL_MAX 40 #define MINDOUBLE DBL_MIN 41 #else 36 42 #include <values.h> 43 #endif 44 37 45 #include <ctype.h> 38 46 #include <fcntl.h> … … 59 67 60 68 double dabs(a) 61 double a;69 double a; 62 70 { 63 71 return((a<0.0) ? -a : a); … … 65 73 66 74 double sqr(a) 67 double a;75 double a; 68 76 { 69 77 return(a*a); … … 71 79 72 80 double max(a, b) 73 double a;74 double b;81 double a; 82 double b; 75 83 { 76 84 return((a>b)?a:b); … … 78 86 79 87 int imin(a, b) 80 int a;81 int b;88 int a; 89 int b; 82 90 { 83 91 return((a<b)?a:b); … … 85 93 86 94 double min(a, b) 87 double a;88 double b;95 double a; 96 double b; 89 97 { 90 98 return((a<b)?a:b); … … 100 108 int xhi, xalo, leftlo, fhi, k; 101 109 float t1, t2; 102 110 103 111 xhi = seed/B16; 104 112 xalo = (seed - (xhi * B16)) * A; … … 140 148 } 141 149 } 142 #define gd(i,j) ( (j<i)? d[i][j] : d[j][i] ) 150 #define gd(i,j) ( (j<i)? d[i][j] : d[j][i] ) 143 151 144 152 #if 0 145 153 double gd(i, j) 146 int i, j;154 int i, j; 147 155 { 148 156 if(j<i) … … 153 161 show_error("gd: i=j -- programmer screwed up!"); 154 162 } 155 #endif 163 #endif 156 164 157 165 char *repeatch(string, ch, num) 158 char *string;159 int ch;160 int num;166 char *string; 167 int ch; 168 int num; 161 169 { 162 170 for(string[num--] = '\0'; num >= 0; string[num--] = ch); … … 165 173 166 174 int getachar() 167 /* skips comments! */175 /* skips comments! */ 168 176 { 169 177 static int oldchar = '\0'; … … 197 205 198 206 int getaword(string, len) 199 /* 0 if failed, 1 if data was read, -1 if data read to end of file */200 char *string;201 int len;207 /* 0 if failed, 1 if data was read, -1 if data read to end of file */ 208 char *string; 209 int len; 202 210 { 203 211 int i; … … 222 230 223 231 int readtobar(string, len) 224 /* 0 if failed, 1 if data was read */225 char *string;226 int len;232 /* 0 if failed, 1 if data was read */ 233 char *string; 234 int len; 227 235 { 228 236 int i; … … 253 261 254 262 int readtobarorcolon(string, len) 255 /* 0 if failed, 1 if data was read */256 char *string;257 int len;263 /* 0 if failed, 1 if data was read */ 264 char *string; 265 int len; 258 266 { 259 267 int i; … … 284 292 285 293 char *getmem(nelem, elsize) 286 unsigned nelem, elsize;294 unsigned nelem, elsize; 287 295 { 288 296 char *temp; … … 294 302 295 303 int get_parms(argc, argv) 296 int argc;297 char **argv;304 int argc; 305 char **argv; 298 306 { 299 307 int i; … … 322 330 for(i=1; i<argc; i++) 323 331 switch(cur_arg) { 324 case 0:325 if(strcmp(argv[i],"-d")==0)326 dissim = 0;327 else if(strcmp(argv[i],"-s")==0)328 dissim = 1;329 else if(strcmp(argv[i],"-print")==0)330 cur_arg = 1;331 else if(strcmp(argv[i],"-init")==0)332 cur_arg = 2;333 else if(strcmp(argv[i],"-save")==0)334 save = 1;335 else if(strcmp(argv[i],"-seed")==0)336 cur_arg = 3;337 else if(strcmp(argv[i],"-ps1")==0)338 cur_arg = 4;339 else if(strcmp(argv[i],"-ps2")==0)340 cur_arg = 5;341 else if(strcmp(argv[i],"-empty")==0)342 cur_arg = 6;343 else if(strcmp(argv[i],"-f")==0)344 cur_arg = 7;345 else if(strcmp(argv[i],"-help")==0)346 show_help();347 else348 {349 printf("\nlsadt: bad option\n");350 show_help();351 }352 break;353 case 1:354 pr = atoi(argv[i]);355 cur_arg = 0;356 break;357 case 2:358 start = atoi(argv[i]);359 cur_arg = 0;360 break;361 case 3:362 seed = atoi(argv[i]);363 cur_arg = 0;364 break;365 case 4:366 ps1 = atof(argv[i]);367 cur_arg = 0;368 break;369 case 5:370 ps2 = atof(argv[i]);371 cur_arg = 0;372 break;373 case 6:374 empty = atof(argv[i]);375 cur_arg = 0;376 break;377 case 7:378 strcpy(fname, argv[i]);379 cur_arg = 0;380 break;381 default:382 printf("\nlsadt: bad option\n");383 show_help();384 break;385 } 386 387 388 /* check validity of parameters */332 case 0: 333 if(strcmp(argv[i],"-d")==0) 334 dissim = 0; 335 else if(strcmp(argv[i],"-s")==0) 336 dissim = 1; 337 else if(strcmp(argv[i],"-print")==0) 338 cur_arg = 1; 339 else if(strcmp(argv[i],"-init")==0) 340 cur_arg = 2; 341 else if(strcmp(argv[i],"-save")==0) 342 save = 1; 343 else if(strcmp(argv[i],"-seed")==0) 344 cur_arg = 3; 345 else if(strcmp(argv[i],"-ps1")==0) 346 cur_arg = 4; 347 else if(strcmp(argv[i],"-ps2")==0) 348 cur_arg = 5; 349 else if(strcmp(argv[i],"-empty")==0) 350 cur_arg = 6; 351 else if(strcmp(argv[i],"-f")==0) 352 cur_arg = 7; 353 else if(strcmp(argv[i],"-help")==0) 354 show_help(); 355 else 356 { 357 printf("\nlsadt: bad option\n"); 358 show_help(); 359 } 360 break; 361 case 1: 362 pr = atoi(argv[i]); 363 cur_arg = 0; 364 break; 365 case 2: 366 start = atoi(argv[i]); 367 cur_arg = 0; 368 break; 369 case 3: 370 seed = atoi(argv[i]); 371 cur_arg = 0; 372 break; 373 case 4: 374 ps1 = atof(argv[i]); 375 cur_arg = 0; 376 break; 377 case 5: 378 ps2 = atof(argv[i]); 379 cur_arg = 0; 380 break; 381 case 6: 382 empty = atof(argv[i]); 383 cur_arg = 0; 384 break; 385 case 7: 386 strcpy(fname, argv[i]); 387 cur_arg = 0; 388 break; 389 default: 390 printf("\nlsadt: bad option\n"); 391 show_help(); 392 break; 393 } 394 395 396 /* check validity of parameters */ 389 397 if(ps1<0.0) ps1 = 0.0001; 390 398 if(ps2<0.0) ps2 = 0.0001; … … 394 402 if(seed < 0) seed = 12345; 395 403 396 /*printf("dissim=%d\n", dissim);*/397 /*printf("pr=%d\n", pr);*/398 /*printf("start=%d\n", start);*/399 /*printf("save=%d\n", save);*/400 /*printf("seed=%d\n", seed);*/401 /*printf("ps1=%f\n", ps1);*/402 /*printf("ps2=%f\n", ps2);*/403 /*printf("empty=%f\n", empty);*/404 /*printf("dissim=%d\n", dissim);*/ 405 /*printf("pr=%d\n", pr);*/ 406 /*printf("start=%d\n", start);*/ 407 /*printf("save=%d\n", save);*/ 408 /*printf("seed=%d\n", seed);*/ 409 /*printf("ps1=%f\n", ps1);*/ 410 /*printf("ps2=%f\n", ps2);*/ 411 /*printf("empty=%f\n", empty);*/ 404 412 } 405 413 … … 412 420 int result; 413 421 double temp, nfactor, datmin, datmax; 414 422 415 423 416 424 nempty = n = 0; … … 542 550 t2 = gd(j,k); 543 551 if(t1!=empty && t2!=empty) 544 dmax = min(dmax, max(t1,t2));552 dmax = min(dmax, max(t1,t2)); 545 553 } 546 554 if(dmax!=MAXDOUBLE) … … 617 625 } 618 626 else 619 if((djilk>=dkilj)&&620 (dlikj>=dkilj))621 {622 wijkl=djilk-dlikj;623 fitp+=wijkl*wijkl;624 fw = fac*wijkl;625 gji+=fw;626 g[l][k]+=fw;627 gkj-=fw;628 g[l][i]-=fw;629 }else{630 wijkl=dkilj-dlikj;631 fitp+=wijkl*wijkl;632 fw = fac*wijkl;633 gki+=fw;634 g[l][j]+=fw;635 g[l][i]-=fw;636 gkj-=fw;637 }627 if((djilk>=dkilj)&& 628 (dlikj>=dkilj)) 629 { 630 wijkl=djilk-dlikj; 631 fitp+=wijkl*wijkl; 632 fw = fac*wijkl; 633 gji+=fw; 634 g[l][k]+=fw; 635 gkj-=fw; 636 g[l][i]-=fw; 637 }else{ 638 wijkl=dkilj-dlikj; 639 fitp+=wijkl*wijkl; 640 fw = fac*wijkl; 641 gki+=fw; 642 g[l][j]+=fw; 643 g[l][i]-=fw; 644 gkj-=fw; 645 } 638 646 } /* l */ 639 647 g[k][i] += gki; … … 649 657 static int iterc, prc; 650 658 print_iter(maxfnc, f) 651 int maxfnc;652 double f;659 int maxfnc; 660 double f; 653 661 { 654 662 int i, j; … … 693 701 694 702 minfungra(dfn, acc, maxfn) 695 double dfn, acc;696 int maxfn;703 double dfn, acc; 704 int maxfn; 697 705 { 698 706 double beta, c, clt, dginit, dgstep, dtest, finit; … … 709 717 goto L190; 710 718 711 L10:719 L10: 712 720 xnew = dabs(dfn+dfn)/gsumsq; 713 721 dgstep = -gsumsq; 714 722 itcrs = m+1; 715 L30:723 L30: 716 724 if(maxfnk<maxfnc) 717 725 { … … 735 743 for(j=1;j<i;j++) 736 744 d1[i][j] = -g[i][j]; 737 }745 } 738 746 print_iter(maxfnc, f); 739 747 dginit = 0.0; … … 766 774 xnew = xnew * min(1.0, dgstep/dginit); 767 775 dgstep = dginit; 768 L170:776 L170: 769 777 c = xnew-xmin; 770 778 dtest = 0.0; … … 781 789 } 782 790 if(max(xbound, xmin-c) < 0.0) { 783 clt = 0.1;791 clt = 0.1; 784 792 } 785 793 maxfnc++; 786 L190:794 L190: 787 795 fungra(); 788 796 … … 792 800 for(j=1;j<i;j++) 793 801 gnew += d1[i][j]*g[i][j]; 794 }802 } 795 803 if(maxfnc<=1 || 796 804 (maxfnc>1 && f<fmin) || … … 831 839 ggstar += gs[i][j]*g[i][j]; 832 840 beta = (gsumsq-ggstar)/(gm-dginit); 833 L300:841 L300: 834 842 if(dabs(gm)>clt*dabs(dginit) || 835 843 (dabs(gm)<=clt*dabs(dginit) && dabs(gm*beta) >= clt*gsumsq)) 836 844 { 837 L310:845 L310: 838 846 clt += 0.3; 839 847 if(clt>0.8) … … 856 864 xnew = 10.0*xold; 857 865 if(xbound>=0.0) { 858 xnew = 0.5*(xold+xbound);866 xnew = 0.5*(xold+xbound); 859 867 } 860 868 } 861 869 c = gnew-(3.0*gnew + gmin-4.0*(f-fmin)/(xold-xmin))* 862 (xold-xnew)/(xold-xmin);870 (xold-xnew)/(xold-xmin); 863 871 if(maxfnk>=maxfnc) 864 872 { 865 873 if(gmin*gnew<=0.0) { 866 xbound = xmin;874 xbound = xmin; 867 875 } 868 876 xmin = xold; … … 895 903 for(j=1;j<i;j++) 896 904 d1[i][j] = -gg[i][j] + 897 beta*d1[i][j] +898 gamma*dr[i][j];905 beta*d1[i][j] + 906 gamma*dr[i][j]; 899 907 itcrs++; 900 908 } … … 926 934 goto L30; 927 935 } 928 else 936 else 929 937 { 930 938 retry = -retry; … … 1034 1042 for(i=1;i<=nm3;i++) 1035 1043 for(j=i+1;j<=nm2;j++) 1036 for(k=j+1;k<=nm1;k++)1037 for(l=k+1;l<=nm0;l++)1038 if((d[j][i]+d[l][k]>=d[l][i]+d[k][j])&&1039 (d[k][i]+d[l][j]>=d[l][i]+d[k][j]))1040 result=max(result,1041 dabs(d[j][i]+d[l][k]-d[k][i]-d[l][j]));1042 else1043 if((d[j][i]+d[l][k]>=d[k][i]+d[l][j])&&1044 (d[l][i]+d[k][j]>=d[k][i]+d[l][j]))1045 result=max(result,1046 dabs(d[j][i]+d[l][k]-d[l][i]-d[k][j]));1047 else1048 if((d[k][i]+d[l][j]>=d[j][i]+d[l][k])&&1049 (d[l][i]+d[k][j]>=d[j][i]+d[l][k]))1050 result=max(result,1051 dabs(d[k][i]+d[l][j]-d[l][i]-d[k][j]));1044 for(k=j+1;k<=nm1;k++) 1045 for(l=k+1;l<=nm0;l++) 1046 if((d[j][i]+d[l][k]>=d[l][i]+d[k][j])&& 1047 (d[k][i]+d[l][j]>=d[l][i]+d[k][j])) 1048 result=max(result, 1049 dabs(d[j][i]+d[l][k]-d[k][i]-d[l][j])); 1050 else 1051 if((d[j][i]+d[l][k]>=d[k][i]+d[l][j])&& 1052 (d[l][i]+d[k][j]>=d[k][i]+d[l][j])) 1053 result=max(result, 1054 dabs(d[j][i]+d[l][k]-d[l][i]-d[k][j])); 1055 else 1056 if((d[k][i]+d[l][j]>=d[j][i]+d[l][k])&& 1057 (d[l][i]+d[k][j]>=d[j][i]+d[l][k])) 1058 result=max(result, 1059 dabs(d[k][i]+d[l][j]-d[l][i]-d[k][j])); 1052 1060 return(result); 1053 1061 } … … 1074 1082 else 1075 1083 return((fn*scp-sumx*sumy)/ 1076 sqrt((fn*ssqx-sqr(sumx))*(fn*ssqy-sqr(sumy))));1084 sqrt((fn*ssqx-sqr(sumx))*(fn*ssqy-sqr(sumy)))); 1077 1085 } 1078 1086 … … 1096 1104 if(k!=i && k!=j) 1097 1105 c=max(c,gd( i, j)- 1098 gd( i, k)-1099 gd( j, k));1106 gd( i, k)- 1107 gd( j, k)); 1100 1108 if(report) 1101 1109 fprintf(reportf, "Additive Constant: %15.10f\n", c); … … 1130 1138 maxcnt=-1; 1131 1139 for(i=1;i<=nnode;i++) if(!act[i]) 1132 for(j=1;j<i;j++) if(!act[j])1133 {1134 count=0;1135 arci=0.0;1136 arcj=0.0;1137 for(k=2;k<=nnode;k++) if(!act[k] && k!=i && k!=j)1138 for(l=1;l<k;l++) if(!act[l] && l!= i && l!= j)1139 if(gd(i,j)+gd(k,l)<=gd(i,k)+gd(j,l) &&1140 gd(i,j)+gd(k,l)<=gd(i,l)+gd(j,k))1141 {1142 count++;1143 arci+=(gd(i,j)+gd(i,k)-gd(j,k))/2.0;1144 arcj+=(gd(i,j)+gd(j,l)-gd(i,l))/2.0;1145 }1146 if(count>maxcnt)1147 {1148 maxcnt = count;1149 arcim=max(0.0, arci/count);1150 arcjm=max(0.0, arcj/count);1151 im=i;1152 jm=j;1153 }1154 }1155 1140 for(j=1;j<i;j++) if(!act[j]) 1141 { 1142 count=0; 1143 arci=0.0; 1144 arcj=0.0; 1145 for(k=2;k<=nnode;k++) if(!act[k] && k!=i && k!=j) 1146 for(l=1;l<k;l++) if(!act[l] && l!= i && l!= j) 1147 if(gd(i,j)+gd(k,l)<=gd(i,k)+gd(j,l) && 1148 gd(i,j)+gd(k,l)<=gd(i,l)+gd(j,k)) 1149 { 1150 count++; 1151 arci+=(gd(i,j)+gd(i,k)-gd(j,k))/2.0; 1152 arcj+=(gd(i,j)+gd(j,l)-gd(i,l))/2.0; 1153 } 1154 if(count>maxcnt) 1155 { 1156 maxcnt = count; 1157 arcim=max(0.0, arci/count); 1158 arcjm=max(0.0, arcj/count); 1159 im=i; 1160 jm=j; 1161 } 1162 } 1163 1156 1164 nnode++; 1157 1165 if(nnode+2>maxnode) … … 1173 1181 for(i=1;act[i];i++) 1174 1182 if(i>nnode) 1175 show_error("get_tree: can't find last two invisible nodes");1183 show_error("get_tree: can't find last two invisible nodes"); 1176 1184 im=i; 1177 1185 for(i=im+1;act[i];i++) 1178 1186 if(i>nnode) 1179 show_error("get_tree: can't find last two invisible nodes");1187 show_error("get_tree: can't find last two invisible nodes"); 1180 1188 jm=i; 1181 1189 for(i=jm+1;act[i];i++) 1182 1190 if(i>nnode) 1183 show_error("get_tree: can't find last two invisible nodes");1191 show_error("get_tree: can't find last two invisible nodes"); 1184 1192 km=i; 1185 1193 for(i=km+1;act[i];i++) 1186 1194 if(i>nnode) 1187 show_error("get_tree: can't find last two invisible nodes");1195 show_error("get_tree: can't find last two invisible nodes"); 1188 1196 lm=i; 1189 1197 if(gd(im,jm)+gd(km,lm)<=gd(im,km)+gd(jm,lm)+tol && … … 1231 1239 1232 1240 print_node(node, dist, indent) 1233 int node;1234 double dist;1235 int indent;1241 int node; 1242 double dist; 1243 int indent; 1236 1244 { 1237 1245 static char buf[BUFLEN]; … … 1239 1247 if(node<=n) 1240 1248 printf("%s%s:%6.4f", 1241 repeatch(buf, '\t', indent),1242 names[node],1243 dist/nfac);1249 repeatch(buf, '\t', indent), 1250 names[node], 1251 dist/nfac); 1244 1252 else 1245 1253 { 1246 1254 printf("%s(\n", 1247 repeatch(buf, '\t', indent));1255 repeatch(buf, '\t', indent)); 1248 1256 print_node(mergei[node-n], gd(node, mergei[node-n]), indent+1); 1249 1257 printf(",\n"); 1250 1258 print_node(mergej[node-n], gd(node, mergej[node-n]), indent+1); 1251 1259 printf("\n%s):%6.4f", repeatch(buf, '\t', indent), 1252 dist/nfac);1260 dist/nfac); 1253 1261 } 1254 1262 } … … 1297 1305 1298 1306 show_error(message) 1299 char *message;1307 char *message; 1300 1308 { 1301 1309 printf("\n>>>>ERROR:\n>>>>%s\n", message); … … 1304 1312 1305 1313 main(argc, argv) 1306 int argc;1307 char **argv;1314 int argc; 1315 char **argv; 1308 1316 { 1309 1317 int i; -
trunk/GDE/TREEPUZZLE/src/ml.h
r191 r655 30 30 #define MAXCAT 16 31 31 32 #define RMHROOT 5.0 /* upper relative bound for height of root */ 32 #define RMHROOT 5.0 /* upper relative bound for height of root */ 33 33 #define MAXARC 900.0 /* upper limit on branch length (PAM) = 6.0 */ 34 34 #define MINARC 0.001 /* lower limit on branch length (PAM) = 0.00001 */ … … 133 133 EXTERN int Converg; /* flag for ML convergence (no clock) */ 134 134 EXTERN int Convergc; /* flag for ML convergence (clock) */ 135 EXTERN int data_optn; /* type of sequence input data */ 135 EXTERN int data_optn; /* type of sequence input data */ 136 136 EXTERN int Dayhf_optn; /* Dayhoff model */ 137 137 EXTERN int HKY_optn; /* use HKY model */ … … 174 174 175 175 void convfreq(dvector); 176 void radixsort(cmatrix, ivector, int, int, int *);176 void a_radixsort(cmatrix, ivector, int, int, int *); 177 177 void condenceseq(cmatrix, ivector, cmatrix, ivector, int, int, int); 178 178 void countconstantsites(cmatrix, ivector, int, int, int *, int*); -
trunk/GDE/TREEPUZZLE/src/ml1.c
r191 r655 67 67 } 68 68 freqemp[maxi] += 1.0 - sum; 69 69 70 70 for (i = 0; i < tpmradix - 1; i++) { 71 71 for (j = i + 1; j < tpmradix; j++) { … … 79 79 80 80 /* sort site patters of original input data */ 81 void radixsort(cmatrix seqchar, ivector ali, int maxspc, int maxsite,81 void a_radixsort(cmatrix seqchar, ivector ali, int maxspc, int maxsite, 82 82 int *numptrn) 83 83 { … … 192 192 193 193 void evaluateseqs() 194 { 194 { 195 195 ivector ali; 196 196 197 197 convfreq(Freqtpm); /* make all frequencies slightly different */ 198 198 ali = new_ivector(Maxsite); 199 radixsort(Seqchar, ali, Maxspc, Maxsite, &Numptrn);199 a_radixsort(Seqchar, ali, Maxspc, Maxsite, &Numptrn); 200 200 Seqpat = new_cmatrix(Maxspc, Numptrn); 201 201 constpat = new_ivector(Numptrn); … … 204 204 free_ivector(ali); 205 205 countconstantsites(Seqpat, Weight, Maxspc, Numptrn, &Numconst, &Numconstpat); 206 fracconstpat = (double) Numconstpat / (double) Numptrn; 207 fracconst = (double) Numconst / (double) Maxsite; 206 fracconstpat = (double) Numconstpat / (double) Numptrn; 207 fracconst = (double) Numconst / (double) Maxsite; 208 208 } 209 209 … … 617 617 y = h[i + 1][i]; 618 618 vr = (wr[i] - p) * (wr[i] - p); 619 vr = vr + wi[i] * wi[i] - q * q; 619 vr = vr + wi[i] * wi[i] - q * q; 620 620 vi = (wr[i] - p) * 2.0 * q; 621 621 if (vr == 0.0 && vi == 0.0) { … … 735 735 736 736 rtfdata(a, forg); /* get relative transition matrix and frequencies */ 737 737 738 738 onepamratematrix(a); /* make 1 PAM rate matrix */ 739 739 740 740 /* copy a to b */ 741 741 for (i = 0; i < tpmradix; i++) … … 746 746 eltran(a, evec, ordr, tpmradix); 747 747 hqr2(tpmradix, 1, tpmradix, a, evec, eval, evali); 748 748 749 749 /* check eigenvalue equation */ 750 750 error = FALSE; … … 754 754 zero -= eval[j] * evec[i][j]; 755 755 if (fabs(zero) > 1.0e-5) 756 error = TRUE; 756 error = TRUE; 757 757 } 758 758 } … … 777 777 dmatrix omtrx; 778 778 779 779 780 780 index = new_ivector(tpmradix); 781 781 omtrx = new_dmatrix(tpmradix,tpmradix); 782 782 783 783 /* copy inmat to omtrx */ 784 784 for (i = 0; i < tpmradix; i++) 785 785 for (j = 0; j < tpmradix; j++) 786 786 omtrx[i][j] = inmat[i][j]; 787 787 788 788 wk = (double *) malloc((unsigned)size * sizeof(double)); 789 789 aw = 1.0; … … 956 956 fv = 1.0-fracinv; 957 957 fv2 = (1.0-fracinv)/(double) numcats; 958 958 959 959 if (numcats == 1) { 960 960 961 for (k = 0; k < Numptrn; k++) { 962 961 for (k = 0; k < Numptrn; k++) { 962 963 963 /* compute likelihood for pattern k */ 964 964 sitelkl = cdl[0][k]*fv; 965 965 if (constpat[k] == TRUE) 966 966 sitelkl += fracinv*Freqtpm[(int) Seqpat[0][k]]; 967 967 968 968 /* total log-likelihood */ 969 969 loglkl += log(sitelkl)*Weight[k]; 970 970 971 971 } 972 972 973 973 } else { 974 974 975 975 for (k = 0; k < Numptrn; k++) { 976 977 /* this general routine works always but it's better 976 977 /* this general routine works always but it's better 978 978 to run it only when it's really necessary */ 979 979 980 980 /* compute likelihood for pattern k */ 981 981 sitelkl = 0.0; … … 985 985 if (constpat[k] == TRUE) 986 986 sitelkl += fracinv*Freqtpm[(int) Seqpat[0][k]]; 987 987 988 988 /* total log-likelihood */ 989 989 loglkl += log(sitelkl)*Weight[k]; 990 991 } 992 993 } 994 990 991 } 992 993 } 994 995 995 return loglkl; 996 996 } 997 997 998 998 999 /* computes the site log-likelihoods 999 /* computes the site log-likelihoods 1000 1000 input: likelihoods for each site and non-zero rate 1001 1001 output: log-likelihood for each site */ … … 1007 1007 fv = 1.0-fracinv; 1008 1008 fv2 = (1.0-fracinv)/(double) numcats; 1009 1009 1010 1010 if (numcats == 1) { 1011 1011 1012 for (k = 0; k < Numptrn; k++) { 1013 1012 for (k = 0; k < Numptrn; k++) { 1013 1014 1014 /* compute likelihood for pattern k */ 1015 1015 sitelkl = cdl[0][k]*fv; 1016 1016 if (constpat[k] == TRUE) 1017 1017 sitelkl += fracinv*Freqtpm[(int) Seqpat[0][k]]; 1018 1018 1019 1019 /* site log-likelihood */ 1020 1020 aslkl[k] = log(sitelkl); … … 1022 1022 1023 1023 } else { 1024 1024 1025 1025 for (k = 0; k < Numptrn; k++) { 1026 1027 /* this general routine works always but it's better 1026 1027 /* this general routine works always but it's better 1028 1028 to run it only when it's really necessary */ 1029 1029 1030 1030 /* compute likelihood for pattern k */ 1031 1031 sitelkl = 0.0; … … 1035 1035 if (constpat[k] == TRUE) 1036 1036 sitelkl += fracinv*Freqtpm[(int) Seqpat[0][k]]; 1037 1037 1038 1038 /* total log-likelihood */ 1039 1039 aslkl[k] = log(sitelkl); 1040 1040 1041 1041 } 1042 1042 } … … 1052 1052 double loglkl, fv, sitelkl; 1053 1053 1054 1054 1055 1055 /* compute tpms */ 1056 1056 for (r = 0; r < numcats; r++) … … 1060 1060 loglkl = 0.0; 1061 1061 fv = 1.0-fracinv; 1062 1062 1063 1063 if (numcats == 1) { 1064 1064 1065 for (k = 0; k < Numptrn; k++) { 1066 1065 for (k = 0; k < Numptrn; k++) { 1066 1067 1067 /* compute likelihood for site k */ 1068 1068 ci = seqchi[k]; … … 1074 1074 if (ci == cj && ci != tpmradix) 1075 1075 sitelkl += fracinv*Freqtpm[ci]; 1076 1076 1077 1077 /* total log-likelihood */ 1078 1078 loglkl += log(sitelkl)*Weight[k]; 1079 1079 1080 1080 } 1081 1081 1082 1082 } else { 1083 1083 1084 1084 for (k = 0; k < Numptrn; k++) { 1085 1086 /* this general routine works always but it's better 1085 1086 /* this general routine works always but it's better 1087 1087 to run it only when it's really necessary */ 1088 1088 1089 1089 /* compute likelihood for site k */ 1090 1090 ci = seqchi[k]; … … 1094 1094 for (r = 0; r < numcats; r++) 1095 1095 sitelkl += ltprobr[r][ci][cj]; 1096 sitelkl = fv*sitelkl/(double) numcats; 1096 sitelkl = fv*sitelkl/(double) numcats; 1097 1097 } else 1098 1098 sitelkl = fv; 1099 1099 if (ci == cj && ci != tpmradix) 1100 1100 sitelkl += fracinv*Freqtpm[ci]; 1101 1101 1102 1102 /* total log-likelihood */ 1103 1103 loglkl += log(sitelkl)*Weight[k]; 1104 1105 } 1106 1107 } 1108 1104 1105 } 1106 1107 } 1108 1109 1109 /* return negative log-likelihood as we use a minimizing procedure */ 1110 1110 return -loglkl; … … 1119 1119 { 1120 1120 double dist, fx, f2x; 1121 1121 1122 1122 if (i == j) return 0.0; 1123 1124 /* use old distance as start value */ 1123 1124 /* use old distance as start value */ 1125 1125 dist = Distanmat[i][j]; 1126 1126 … … 1132 1132 if (dist <= MINARC) dist = MINARC+1.0; 1133 1133 if (dist >= MAXARC) dist = MAXARC-1.0; 1134 1134 1135 1135 dist = onedimenmin(MINARC, dist, MAXARC, pairlkl, EPSILON, &fx, &f2x); 1136 1136 1137 1137 return dist; 1138 1138 } … … 1144 1144 int i, j, k, diff, x, y; 1145 1145 double obs, temp; 1146 1146 1147 1147 for (i = 0; i < Maxspc; i++) { 1148 1148 Distanmat[i][i] = 0.0; … … 1150 1150 seqchi = Seqpat[i]; 1151 1151 seqchj = Seqpat[j]; 1152 1152 1153 1153 /* count observed differences */ 1154 1154 diff = 0; … … 1240 1240 } 1241 1241 } 1242 1242 1243 1243 oprob = op->partials; 1244 1244 cprob = op->kinp->isop->partials; … … 1297 1297 do { 1298 1298 cp = cp->isop->kinp; 1299 if (cp->isop == NULL) { /* external node */ 1299 if (cp->isop == NULL) { /* external node */ 1300 1300 cp = cp->kinp; /* not descen */ 1301 1301 partialsexternal(cp); 1302 } else { /* internal node */ 1302 } else { /* internal node */ 1303 1303 if (!cp->descen) { 1304 1304 productpartials(cp->kinp->isop); … … 1325 1325 for (s = 0; s < Numptrn; s++) { 1326 1326 sumlk = 0.0; 1327 for (i = 0; i < tpmradix; i++) { 1327 for (i = 0; i < tpmradix; i++) { 1328 1328 slk = 0.0; 1329 for (j = 0; j < tpmradix; j++) 1330 slk += partialj[r][s][j] * ltprobr[r][i][j]; 1331 sumlk += Freqtpm[i] * partiali[r][s][i] * slk; 1329 for (j = 0; j < tpmradix; j++) 1330 slk += partialj[r][s][j] * ltprobr[r][i][j]; 1331 sumlk += Freqtpm[i] * partiali[r][s][i] * slk; 1332 1332 } 1333 1333 cdl[r][s] = sumlk; … … 1355 1355 op->kinp->length = arc; 1356 1356 op->length = arc; 1357 1357 1358 1358 /* variance of branch length */ 1359 1359 f2x = fabs(f2x); … … 1373 1373 dvector opb; 1374 1374 dmatrix cdl; 1375 1375 1376 1376 cdl = Ctree->condlkl; 1377 1377 for (r = 0; r < numcats; r++) { … … 1392 1392 } 1393 1393 } 1394 1394 1395 1395 /* compute total log-likelihood for current tree */ 1396 1396 Ctree->lklhd = comptotloglkl(cdl); … … 1412 1412 op->kinp->length = arc; 1413 1413 op->length = arc; 1414 1414 1415 1415 /* variance of branch length */ 1416 1416 f2x = fabs(f2x); … … 1444 1444 slk += partialj[r][k][j] * ltprobr[r][i][j]; 1445 1445 sumlk += Freqtpm[i] * partiali[r][k][i] * slk; 1446 } 1446 } 1447 1447 cdl[r][k] = sumlk; 1448 1448 } … … 1460 1460 int nconv; 1461 1461 double lendiff; 1462 1462 1463 1463 clockmode = 0; /* nonclocklike branch lengths */ 1464 1464 nconv = 0; … … 1466 1466 initpartials(tr); 1467 1467 for (Numit = 1; (Numit <= MAXIT) && (!Converg); Numit++) { 1468 1468 1469 1469 cp = rp = tr->rootp; 1470 1470 do { 1471 1471 cp = cp->isop->kinp; 1472 1472 productpartials(cp->kinp->isop); 1473 if (cp->isop == NULL) { /* external node */ 1473 if (cp->isop == NULL) { /* external node */ 1474 1474 cp = cp->kinp; /* not descen */ 1475 1475 1476 1476 lendiff = cp->length; 1477 1477 optexternalbranch(cp); 1478 1478 lendiff = fabs(lendiff - cp->length); 1479 1479 if (lendiff < EPSILON) nconv++; 1480 else nconv = 0; 1481 1480 else nconv = 0; 1481 1482 1482 partialsexternal(cp); 1483 1483 } else { /* internal node */ … … 1485 1485 partialsinternal(cp); 1486 1486 } else { 1487 1487 1488 1488 lendiff = cp->length; 1489 1489 optinternalbranch(cp); … … 1491 1491 if (lendiff < EPSILON) nconv++; 1492 1492 else nconv = 0; 1493 1493 1494 1494 /* eventually compute likelihoods for each site */ 1495 1495 if ((cp->number == Numibrnch-1 && lendiff < EPSILON) || … … 1498 1498 partialsinternal(cp); 1499 1499 } 1500 } 1500 } 1501 1501 if (nconv >= Numbrnch) { /* convergence */ 1502 1502 Converg = TRUE; … … 1534 1534 cdl[r][k] = sumlk; 1535 1535 } 1536 } 1537 1536 } 1537 1538 1538 /* return total log-likelihood for current tree */ 1539 1539 return comptotloglkl(cdl); … … 1635 1635 1636 1636 /* least square estimation of branch lengths 1637 used for the approximate ML and as starting point 1637 used for the approximate ML and as starting point 1638 1638 in the calculation of the exact value of the ML */ 1639 1639 void lslength(Tree *tr, dvector distanvec, int numspc, int numibrnch, dvector Brnlength) … … 1713 1713 ebp[i]->length = leng; 1714 1714 ebp[i]->kinp->length = leng; 1715 } 1715 } 1716 1716 Brnlength[i] = leng; 1717 1717 } -
trunk/GENOM/GEN_db.cxx
r474 r655 1 #include <malloc.h>1 // #include <malloc.h> 2 2 3 3 #include <arbdb.h> -
trunk/Makefile
r649 r655 54 54 endif 55 55 56 PREFIX = 57 LIBDIR = /usr/lib 56 58 XHOME = /usr/X11 57 59 … … 79 81 endif 80 82 83 #********************* Darwin gcc enviroments ***************** 84 ifdef DARWIN 85 86 XHOME = /usr/X11R6 87 havebool = -DHAVE_BOOL 88 lflags = $(LDFLAGS) -force_flat_namespace 89 DARWIN_SPECIALS = -DNO_REGEXPR -no-cpp-precomp -DHAVE_BOOL 90 CPP = cc -D$(MACH) $(DARWIN_SPECIALS) 91 ACC = cc -D$(MACH) $(DARWIN_SPECIALS) 92 CCLIB = cc -fno-common -D$(MACH) $(DARWIN_SPECIALS) 93 CCPLIB = cc -fno-common -D$(MACH) $(DARWIN_SPECIALS) 94 AR = ld -r $(lflags) -o# # Archive Linker 95 ARLIB = ld -r $(lflags) -o# # Archive Linker shared libs. 96 # ARLIB = cc -bundle -flat_namespace -undefined suppress -o 97 SHARED_LIB_SUFFIX = a# 98 # .. Just building shared libraries static, i was having problems otherwise 99 100 GMAKE = make -j 3 -r 101 SYSLIBS = -lstdc++ 102 103 MOTIF_LIBNAME = libXm.3.dylib 104 MOTIF_LIBPATH = $(LIBDIR)/$(MOTIF_LIBNAME) 105 XINCLUDES = -I/usr/X11R6/include 106 XLIBS = -L$(XHOME)/lib $(SYSLIBS) -lXm -lXt -lX11 -lXext -lXp -lc 107 108 PERLBIN = /usr/bin 109 PERLLIB = /usr/lib 110 CRYPTLIB = -L/usr/lib -lcrypt 111 112 endif 113 81 114 #********************* Linux and gcc enviroments ***************** 82 115 ifdef LINUX … … 95 128 GMAKE = make -j 3 -r 96 129 SYSLIBS = -lm 97 98 130 ifndef DEBIAN 99 131 XINCLUDES = -I/usr/X11/include -I/usr/X11/include/Xm -I/usr/openwin/include … … 711 743 # (cd LIBLINK; for i in *.s*; do if test -r $$i; then cp $$i ../lib; fi; done ) 712 744 745 # the following lib is not provided with the source 746 # you need to install Motif (NOT lesstif) and correct 747 # MOTIF_LIBPATH 748 749 ifndef MOTIF_LIBNAME 750 MOTIF_LIBNAME=libXm.so.2 751 endif 752 ifndef MOTIF_LIBPATH 753 MOTIF_LIBPATH=Motif/$(MOTIF_LIBNAME) 754 endif 755 713 756 ifndef DEBIAN 714 757 libs: lib/libARBDB.$(SHARED_LIB_SUFFIX) \ … … 717 760 lib/libAW.$(SHARED_LIB_SUFFIX) \ 718 761 lib/libAWT.$(SHARED_LIB_SUFFIX) \ 719 lib/ libXm.so.2762 lib/$(MOTIF_LIBNAME) 720 763 else 721 764 libs: lib/libARBDB.$(SHARED_LIB_SUFFIX) \ … … 729 772 cp $< $@ 730 773 731 # the following lib is not provided with the source 732 # you need to install Motif (NOT lesstif) and correct 733 # MOTIF_LIBPATH 734 735 MOTIF_LIBPATH=LIBLINK/libXm.so.2 736 #MOTIF_LIBPATH=/usr/X11R6/lib/libXm.so.2 737 738 lib/libXm.so.2: $(MOTIF_LIBPATH) 774 lib/$(MOTIF_LIBNAME): $(MOTIF_LIBPATH) 739 775 cp $< $@ 740 776 -
trunk/NALIGNER/ali_aligner.hxx
r2 r655 4 4 #define _ALI_ALIGNER_INC_ 5 5 6 #include <malloc.h>6 // #include <malloc.h> 7 7 8 8 #include "ali_solution.hxx" … … 28 28 float d1, d2, d3; 29 29 ALI_TARRAY<ali_pathmap_up_pointer> *starts; 30 30 31 31 ali_aligner_cell(void) { 32 32 d1 = d2 = d3 = 0.0; … … 78 78 unsigned char operation; 79 79 80 ali_aligner_dellist_elem(unsigned long s = 0, float c = 0.0, 80 ali_aligner_dellist_elem(unsigned long s = 0, float c = 0.0, 81 81 unsigned char op = 0) { 82 82 start = s; … … 158 158 } 159 159 float update(unsigned long position); 160 ALI_TARRAY<ali_pathmap_up_pointer> *starts(float costs, 160 ALI_TARRAY<ali_pathmap_up_pointer> *starts(float costs, 161 161 unsigned long y_offset); 162 void optimize(unsigned long position); 162 void optimize(unsigned long position); 163 163 }; 164 164 … … 213 213 insert_up(0, ALI_LEFT, cost); 214 214 } 215 void update_left(ali_aligner_cell *akt_cell, unsigned long akt_pos, 215 void update_left(ali_aligner_cell *akt_cell, unsigned long akt_pos, 216 216 unsigned long start_x, unsigned long end_x) { 217 217 float min; … … 227 227 min + profile->w_ins_multi_cheap(start_x + akt_pos, end_x)); 228 228 } 229 void update_up(ali_aligner_cell *akt_cell, unsigned long akt_pos, 229 void update_up(ali_aligner_cell *akt_cell, unsigned long akt_pos, 230 230 unsigned long start_y, unsigned long end_y) { 231 231 float min; … … 400 400 401 401 public: 402 ALI_ALIGNER(ALI_ALIGNER_CONTEXT *context, ALI_PROFILE *profile, 402 ALI_ALIGNER(ALI_ALIGNER_CONTEXT *context, ALI_PROFILE *profile, 403 403 unsigned long start_x, unsigned long end_x, 404 404 unsigned long start_y, unsigned long end_y); … … 409 409 } 410 410 }; 411 411 412 412 413 413 -
trunk/NALIGNER/ali_pathmap.cxx
r2 r655 1 1 2 #include <malloc.h>2 // #include <malloc.h> 3 3 #include <stdlib.h> 4 4 -
trunk/NALIGNER/ali_postree.cxx
r2 r655 1 1 2 #include <malloc.h>2 // #include <malloc.h> 3 3 4 4 #include "ali_misc.hxx" … … 15 15 16 16 17 ALI_POSTREE_NODE::ALI_POSTREE_NODE(ALI_POSTREE_NODE_TYPE t, 18 unsigned long nochild_position) 17 ALI_POSTREE_NODE::ALI_POSTREE_NODE(ALI_POSTREE_NODE_TYPE t, 18 unsigned long nochild_position) 19 19 { 20 20 typ = t; 21 21 if (typ == Node) { 22 22 node.number_of_children = nochild_position; 23 node.children = (ALI_POSTREE_NODE *(*) []) 23 node.children = (ALI_POSTREE_NODE *(*) []) 24 24 CALLOC((unsigned int) nochild_position, 25 25 sizeof(ALI_POSTREE_NODE *)); … … 33 33 } 34 34 35 ALI_POSTREE_NODE::~ALI_POSTREE_NODE(void) 35 ALI_POSTREE_NODE::~ALI_POSTREE_NODE(void) 36 36 { 37 37 if (typ == Node) { … … 44 44 } 45 45 46 ALI_POSTREE_NODE *ALI_POSTREE_NODE::leftmost_leaf(void) 46 ALI_POSTREE_NODE *ALI_POSTREE_NODE::leftmost_leaf(void) 47 47 { 48 48 ALI_POSTREE_NODE *n = this; … … 50 50 51 51 while (n->typ == Node) { 52 for (i = 0; 52 for (i = 0; 53 53 i < n->node.number_of_children && !(*n->node.children)[i]; i++); 54 54 if (i < n->node.number_of_children) … … 61 61 } 62 62 63 ALI_POSTREE_NODE *ALI_POSTREE_NODE::rightmost_leaf(void) 63 ALI_POSTREE_NODE *ALI_POSTREE_NODE::rightmost_leaf(void) 64 64 { 65 65 ALI_POSTREE_NODE *n = this; … … 67 67 68 68 while (n->typ == Node) { 69 for (i = (long) n->node.number_of_children - 1; 69 for (i = (long) n->node.number_of_children - 1; 70 70 i >= 0 && !(*n->node.children)[i]; i--); 71 71 if (i >= 0) … … 78 78 } 79 79 80 ALI_POSTREE_NODE *ALI_POSTREE_NODE::link_leafs(ALI_POSTREE_NODE *last) 80 ALI_POSTREE_NODE *ALI_POSTREE_NODE::link_leafs(ALI_POSTREE_NODE *last) 81 81 { 82 82 long i; … … 149 149 unsigned long position; 150 150 151 for (position = 0; *pos != terminal && *pos < number_of_branches; 151 for (position = 0; *pos != terminal && *pos < number_of_branches; 152 152 position++, pos++) { 153 153 akt = pos; … … 161 161 * Make a unique leaf for the new prefix 162 162 */ 163 if (!(*v->node.children)[*akt]) 163 if (!(*v->node.children)[*akt]) 164 164 (*v->node.children)[*akt] = new ALI_POSTREE_NODE(Leaf,position); 165 165 else { 166 166 ALI_POSTREE_NODE *old_leaf = (*v->node.children)[*akt]; 167 unsigned char *akt2 = (unsigned char *) 168 ((int) seq + (int) old_leaf->leaf.position + 167 unsigned char *akt2 = (unsigned char *) 168 ((int) seq + (int) old_leaf->leaf.position + 169 169 (int) akt - (int) pos); 170 170 /* … … 179 179 } 180 180 (*v->node.children)[*akt2] = old_leaf; 181 (*v->node.children)[*akt] = new ALI_POSTREE_NODE(Leaf,position); 181 (*v->node.children)[*akt] = new ALI_POSTREE_NODE(Leaf,position); 182 182 } 183 183 } … … 246 246 247 247 248 unsigned long ALI_POSTREE::maximal_position(ALI_POSTREE_NODE *first, 248 unsigned long ALI_POSTREE::maximal_position(ALI_POSTREE_NODE *first, 249 249 ALI_POSTREE_NODE *last) 250 250 { … … 385 385 stack->push(ALI_POSTREE_STACK_SUB); 386 386 finder((*n->node.children)[i],seq,seq_len,seq_pos + 1, 387 im_seq_len + 1, min_pos, max_pos, errors - 1, 387 im_seq_len + 1, min_pos, max_pos, errors - 1, 388 388 stack, sol_list); 389 389 stack->pop(); … … 395 395 } 396 396 } 397 398 399 400 397 398 399 400 401 401 402 402 /***************************************************************************** … … 410 410 ALI_POSTREE::ALI_POSTREE(unsigned long branches, 411 411 unsigned char *seq, unsigned long seq_len, 412 unsigned char terminal) 412 unsigned char terminal) 413 413 { 414 414 unsigned char *seq_buffer; … … 504 504 printf(", %d",pos_list->next()); 505 505 } 506 else 506 else 507 507 printf("%2d : empty",i); 508 508 printf("\n"); -
trunk/NALIGNER/ali_postree.hxx
r2 r655 5 5 6 6 #include <string.h> 7 #include <malloc.h>7 // #include <malloc.h> 8 8 9 9 #include "ali_misc.hxx" … … 32 32 }; 33 33 34 ALI_POSTREE_NODE(ALI_POSTREE_NODE_TYPE t, 34 ALI_POSTREE_NODE(ALI_POSTREE_NODE_TYPE t, 35 35 unsigned long nochild_position = 0); 36 36 ~ALI_POSTREE_NODE(void); … … 118 118 ALI_POSTREE_NODE *last); 119 119 void handle_remaining_sequence( 120 unsigned char *seq, unsigned long seq_len, 120 unsigned char *seq, unsigned long seq_len, 121 121 unsigned long seq_pos, unsigned long im_seq_len, 122 122 unsigned long min_pos, unsigned long max_pos, … … 125 125 ALI_TLIST<ali_postree_sol *> *sol_list); 126 126 void finder(ALI_POSTREE_NODE *n, 127 unsigned char *seq, unsigned long seq_len, 127 unsigned char *seq, unsigned long seq_len, 128 128 unsigned long seq_pos, unsigned long im_seq_len, 129 129 unsigned long min_pos, unsigned long max_pos, 130 unsigned long errors, 130 unsigned long errors, 131 131 ALI_TSTACK<char> *stack, 132 132 ALI_TLIST<ali_postree_sol *> *sol_list); 133 133 134 134 public: 135 ALI_POSTREE(unsigned long branches, 135 ALI_POSTREE(unsigned long branches, 136 136 unsigned char *seq, unsigned long seq_len, 137 137 unsigned char terminal = 4); -
trunk/NALIGNER/ali_profile.cxx
r2 r655 1 1 2 2 #include <ctype.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <stdlib.h> 5 5 … … 82 82 83 83 /* 84 * calculate the extension of the family 84 * calculate the extension of the family 85 85 */ 86 86 number = 0; … … 181 181 * allocate memory for costs 182 182 */ 183 183 184 184 base_weights = (float (**) [4]) CALLOC((unsigned int) prof_len, sizeof(float [4])); 185 185 //base_weights = (float (*) [1][4]) CALLOC((unsigned int) prof_len, sizeof(float [4])); … … 193 193 gap_percents = (float***) CALLOC((unsigned int) prof_len, sizeof(float *)); 194 194 //gap_percents = (float*(*)[1]) CALLOC((unsigned int) prof_len, sizeof(float *)); 195 if (binding_costs == 0 || sub_costs == 0 || lmin == 0 || lmax == 0 || 195 if (binding_costs == 0 || sub_costs == 0 || lmin == 0 || lmax == 0 || 196 196 gap_costs == 0 || gap_percents == 0 || base_weights == 0) { 197 197 ali_fatal_error("Out of memory"); … … 219 219 for (i = 0; i < 7; i++) 220 220 a[i] = w[i] = sm[5][i] = sm[i][5] = sm[6][i] = sm[i][6] = 0.0; 221 for (i = 0; i < 6; i++) 221 for (i = 0; i < 6; i++) 222 222 (*sub_costs)[p][i] = 0.0; 223 223 w_sum = 0.0; … … 245 245 * Relative weight of bases 246 246 */ 247 if (w_sum != 0) 247 if (w_sum != 0) 248 248 for (i = 0; i < 4; i++) 249 249 (*base_weights)[p][i] = w[i] / w_sum; … … 392 392 * find the next helix 393 393 */ 394 int ALI_PROFILE::find_next_helix(char h[], unsigned long h_len, 394 int ALI_PROFILE::find_next_helix(char h[], unsigned long h_len, 395 395 unsigned long pos, 396 396 unsigned long *helix_nr, … … 400 400 401 401 for (i = pos; i < h_len && !isdigit(h[i]); i++); 402 if (i >= h_len) 402 if (i >= h_len) 403 403 return -1; 404 404 … … 424 424 do { 425 425 for (; i < h_len && !isdigit(h[i]); i++); 426 if (i >= h_len) 426 if (i >= h_len) 427 427 return -1; 428 428 *start = i; … … 457 457 unsigned long last1, last2; 458 458 459 if (end1 >= h_len || end2 >= h_len || start1 > end1 || start2 > end2) 459 if (end1 >= h_len || end2 >= h_len || start1 > end1 || start2 > end2) 460 460 ali_fatal_error("Inconsistent parameters","ALI_PROFILE::map_helix()"); 461 461 … … 509 509 helix_borders = (char **) CALLOC((unsigned int) helix_len, sizeof(long)); 510 510 //helix_borders = (char (*) [1]) CALLOC((unsigned int) helix_len, sizeof(long)); 511 if (helix == 0 || helix_borders == 0) 511 if (helix == 0 || helix_borders == 0) 512 512 ali_fatal_error("Out of memory"); 513 513 … … 523 523 524 524 525 ALI_PROFILE::ALI_PROFILE(ALI_SEQUENCE *sequence, ALI_PROFILE_CONTEXT *context) 526 { 525 ALI_PROFILE::ALI_PROFILE(ALI_SEQUENCE *sequence, ALI_PROFILE_CONTEXT *context) 526 { 527 527 char message_buffer[100]; 528 528 ali_family_member *family_member; … … 604 604 * test whether a position is inside a helix 605 605 */ 606 int ALI_PROFILE::is_in_helix(unsigned long pos, 606 int ALI_PROFILE::is_in_helix(unsigned long pos, 607 607 unsigned long *first, unsigned long *last) { 608 608 long i; … … 655 655 * test, whether a position is outside a helix 656 656 */ 657 int ALI_PROFILE::is_outside_helix(unsigned long pos, 657 int ALI_PROFILE::is_outside_helix(unsigned long pos, 658 658 unsigned long *first, unsigned long *last) { 659 659 long i; … … 704 704 char *ALI_PROFILE::cheapest_sequence(void) 705 705 { 706 706 707 707 char *seq; 708 708 size_t p; … … 745 745 * calculate the costs of a binding 746 746 */ 747 float ALI_PROFILE::w_binding(unsigned long first_seq_pos, 748 ALI_SEQUENCE *sequence) 747 float ALI_PROFILE::w_binding(unsigned long first_seq_pos, 748 ALI_SEQUENCE *sequence) 749 749 { 750 750 unsigned long pos_1_seq, pos_2_seq, last_seq_pos; … … 768 768 return costs; 769 769 } 770 771 770 771 -
trunk/NALIGNER/ali_sequence.cxx
r2 r655 3 3 #include <string.h> 4 4 #include <stdlib.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 7 7 #include "ali_misc.hxx" … … 95 95 } 96 96 97 ALI_NORM_SEQUENCE::ALI_NORM_SEQUENCE(ALI_SEQUENCE *sequence) 97 ALI_NORM_SEQUENCE::ALI_NORM_SEQUENCE(ALI_SEQUENCE *sequence) 98 98 { 99 99 unsigned long counter, pos; … … 102 102 unsigned char *str; 103 103 104 for (counter = pos = 0, str = sequence->sequence(); 104 for (counter = pos = 0, str = sequence->sequence(); 105 105 pos < sequence->length(); pos++, str++) 106 106 if (ali_is_base(*str)) … … 118 118 dot_flag = 0; 119 119 (*dots)[0] |= (unsigned char) (1<<7); 120 for (counter = pos = 0, str = sequence->sequence(), s = seq; 120 for (counter = pos = 0, str = sequence->sequence(), s = seq; 121 121 pos < sequence->length(); str++, pos++) { 122 122 if (ali_is_base(*str)) { -
trunk/NALIGNER/ali_sequence.hxx
r2 r655 4 4 5 5 #include <string.h> 6 #include <malloc.h>6 // #include <malloc.h> 7 7 8 8 #include "ali_misc.hxx" … … 39 39 } 40 40 int check(void); 41 char *string(void); 41 char *string(void); 42 42 char *name(void) { 43 43 return seq_name; -
trunk/NALIGNER/ali_solution.cxx
r2 r655 1 1 2 2 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <stdlib.h> 5 5 #include "ali_misc.hxx" … … 73 73 if ((*mapping)[i-1] >= (*mapping)[i]) 74 74 return 0; 75 75 76 76 return 1; 77 77 } … … 85 85 unsigned char *seq, *seq_buffer; 86 86 87 seq_buffer = (unsigned char *) CALLOC((unsigned int) 88 (last_ref_base - first_ref_base + insert_counter + 1), 87 seq_buffer = (unsigned char *) CALLOC((unsigned int) 88 (last_ref_base - first_ref_base + insert_counter + 1), 89 89 sizeof(unsigned char)); 90 90 … … 138 138 unsigned char *seq, *seq_buffer; 139 139 140 seq_buffer = (unsigned char *) CALLOC((unsigned int) 140 seq_buffer = (unsigned char *) CALLOC((unsigned int) 141 141 (last_ref_base - first_ref_base + 1), sizeof(unsigned char)); 142 142 if (seq_buffer == 0) … … 183 183 unsigned long map_pos; 184 184 ALI_MAP *inv_map; 185 186 inv_map = new ALI_MAP(first_ref_base, last_ref_base, 185 186 inv_map = new ALI_MAP(first_ref_base, last_ref_base, 187 187 first_seq_base, last_seq_base); 188 188 … … 194 194 } 195 195 } 196 196 197 197 return inv_map; 198 198 } … … 204 204 char *seq, *seq_buffer; 205 205 206 seq_buffer = (char *) CALLOC( (last_ref_base - first_ref_base + insert_counter + 2), 206 seq_buffer = (char *) CALLOC( (last_ref_base - first_ref_base + insert_counter + 2), 207 207 sizeof(char)); 208 208 … … 336 336 } 337 337 338 unsigned long ALI_SUB_SOLUTION::number_of_free_areas(void) 338 unsigned long ALI_SUB_SOLUTION::number_of_free_areas(void) 339 339 { 340 340 ALI_MAP *map; … … 347 347 counter = 0; 348 348 map = map_list.first(); 349 if (map->first_base() > 0 && map->first_reference_base() > 0) 349 if (map->first_base() > 0 && map->first_reference_base() > 0) 350 350 counter++; 351 351 … … 365 365 366 366 367 int ALI_SUB_SOLUTION::is_konsistent(ALI_MAP *in_map) 367 int ALI_SUB_SOLUTION::is_konsistent(ALI_MAP *in_map) 368 368 { 369 369 ALI_MAP *map; … … 387 387 while (map_list.is_next()) { 388 388 map = map_list.next(); 389 if (last_of_prev < in_map->first_base() && 389 if (last_of_prev < in_map->first_base() && 390 390 in_map->last_base() < map->first_base() && 391 391 last_of_prev_ref < in_map->first_reference_base() && … … 510 510 new_map = new ALI_MAP(first_base_of_first,last_base_of_last, 511 511 first_reference_of_first,last_reference_of_last); 512 512 513 513 map = map_list.first(); 514 514 do { … … 524 524 525 525 if (map->is_inserted(i)) 526 new_map->set(i,map->first_reference_base() + 526 new_map->set(i,map->first_reference_base() + 527 527 map->position(i) - first_reference_of_first,1); 528 528 else 529 new_map->set(i,map->first_reference_base() + 529 new_map->set(i,map->first_reference_base() + 530 530 map->position(i) - first_reference_of_first,0); 531 531 } … … 560 560 561 561 562 563 564 565 566 567 562 563 564 565 566 567 -
trunk/NALIGNER/ali_solution.hxx
r2 r655 6 6 7 7 8 #include <malloc.h>8 // #include <malloc.h> 9 9 10 10 #include "ali_profile.hxx" … … 129 129 int is_equal(ALI_MAP *map) { 130 130 unsigned long i; 131 if (first_seq_base != map->first_seq_base || 131 if (first_seq_base != map->first_seq_base || 132 132 last_seq_base != map->last_seq_base || 133 133 first_ref_base != map->first_ref_base || 134 last_ref_base != map->last_ref_base) 134 last_ref_base != map->last_ref_base) 135 135 return 0; 136 136 for (i = 0; i < last_seq_base - first_seq_base + 1; i++) … … 187 187 void print(void); 188 188 }; 189 189 190 190 191 191 #endif -
trunk/NALIGNER/ali_tarray.hxx
r2 r655 4 4 #define _ALI_TARRAY_INC_ 5 5 6 #include <malloc.h>6 // #include <malloc.h> 7 7 8 8 #include "ali_misc.hxx" -
trunk/NALIGNER/ali_tstack.hxx
r2 r655 4 4 #define _ALI_TSTACK_INC_ 5 5 6 #include <malloc.h>6 // #include <malloc.h> 7 7 #include "ali_misc.hxx" 8 8 -
trunk/NAMES/names_client.c
r36 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h> 4 /* #include <malloc.h> */ 5 5 #include <names_client.h> 6 6 #include <arbdb.h> … … 78 78 if (err) return err; 79 79 80 80 81 81 gb_species_data = GB_search(gb_main,"species_data",GB_CREATE_CONTAINER); 82 82 -
trunk/NTREE/AP_consensus.cxx
r572 r655 51 51 #include <arbdb.h> 52 52 #include <arbdbt.h> 53 #include <malloc.h>53 // #include <malloc.h> 54 54 #include <aw_root.hxx> 55 55 #include <aw_device.hxx> -
trunk/NTREE/AP_cprofile.cxx
r2 r655 8 8 * Global Functions: x 9 9 * 10 * Global Variables: 10 * Global Variables: 11 11 * AWARS 12 12 * AW_STRING, "cpro/alignment" : name of alignment 13 13 * AW_STRING, "cpro/which_species" : all/marked 14 14 * AW_STRING, "cpro/countgaps" : if off, drop gaps 15 * AW_FLOAT, "cpro/rateofgroup" : how to rate, when two 15 * AW_FLOAT, "cpro/rateofgroup" : how to rate, when two 16 16 * characters belong to the same group [ 0.0 means don't rate ] 17 * AW_INT, AWAR_CURSOR_POSITION: 17 * AW_INT, AWAR_CURSOR_POSITION: 18 18 * column shown in func. CPRO_drawstatistic_cb 19 19 * … … 30 30 * 31 31 * Description: x 32 * 32 * 33 33 * Integration Notes: The main function using this module must have a 34 34 * callback to the function … … 44 44 #include <string.h> 45 45 #include <memory.h> 46 #include <malloc.h>46 // #include <malloc.h> 47 47 #include <math.h> 48 48 #include <arbdb.h> … … 79 79 long memneeded; // memory required for this statistic 80 80 char which_species[20]; // "marked vs all" , ... 81 char drawmode; // smoothing 81 char drawmode; // smoothing 82 82 char alignname[80]; // name of alignment 83 83 char statisticexists; // was there yet a statistic calculated/loaded ? … … 88 88 89 89 struct CPRO_struct { 90 long numspecies; // number of species 90 long numspecies; // number of species 91 91 long maxresneeded; // not yet used (max distance of calculation) 92 92 long partition; // size of partition in matrix of compares … … 94 94 char *agonist; // list of species that contribute to statistic 95 95 char *antagonist; // -^- 96 char convtable[256]; // converts character to a token 96 char convtable[256]; // converts character to a token 97 97 char grouptable[MAX_AMINOS]; // gives number of group, in which token is 98 // member 98 // member 99 99 float grouprate; // ratio between transitions and transversions 100 100 float distancecorrection; // results out of grouprate … … 110 110 111 111 /* ----------------------------------------------------------------- 112 * Function: CPRO_readandallocate 112 * Function: CPRO_readandallocate 113 113 * 114 114 * Arguments: char versus,char *align (name of alignment) 115 115 * 116 * Returns: modifies: 116 * Returns: modifies: 117 117 * char **&speciesdata,GBDATA **&speciesdatabase 118 118 * … … 120 120 * 'agonist' and 'antagonist' is allocated. 121 121 * Pointers to the sequences in the database are 122 * read into array 'speciesdatabase'. 123 * 122 * read into array 'speciesdatabase'. 123 * 124 124 * 125 125 * NOTE: . … … 132 132 * 133 133 * AWARs modified: x 134 * 135 * Dependencies: . 134 * 135 * Dependencies: . 136 136 * ----------------------------------------------------------------- 137 137 */ … … 147 147 gb_species = GBT_first_species_rel_species_data(gb_species_data); 148 148 while(gb_species) 149 { 149 { 150 150 if(GBT_read_sequence(gb_species,align)){ 151 151 nrofspecies++; } 152 gb_species = GBT_next_species(gb_species); 152 gb_species = GBT_next_species(gb_species); 153 153 } 154 154 CPRO.numspecies=nrofspecies; … … 164 164 gb_species = GBT_first_species_rel_species_data(gb_species_data); 165 165 while(gb_species) 166 { 167 if( (alidata=GBT_read_sequence(gb_species,align)) ) 166 { 167 if( (alidata=GBT_read_sequence(gb_species,align)) ) 168 168 { 169 speciesdatabase[countspecies++]=alidata; 169 speciesdatabase[countspecies++]=alidata; 170 170 } 171 gb_species = GBT_next_species(gb_species); 171 gb_species = GBT_next_species(gb_species); 172 172 } 173 173 … … 183 183 { 184 184 CPRO.antagonist[j]=0; 185 if(GB_read_flag(GB_get_father(GB_get_father(speciesdatabase[j])))) 185 if(GB_read_flag(GB_get_father(GB_get_father(speciesdatabase[j])))) 186 186 CPRO.antagonist[j]=(char)1; 187 187 } … … 214 214 (size_t)CPRO.result[which_statistic].resolution*3+3, 215 215 sizeof(STATTYPE *)); 216 for(long i=0;i<CPRO.result[which_statistic].resolution*3;i++) 216 for(long i=0;i<CPRO.result[which_statistic].resolution*3;i++) 217 217 { 218 218 CPRO.result[which_statistic].statistic[i]=(STATTYPE *)calloc( 219 219 (size_t)CPRO.result[which_statistic].maxalignlen, 220 sizeof(STATTYPE)); 220 sizeof(STATTYPE)); 221 221 } 222 222 } … … 263 263 CPRO.result[which_statistic].maxaccu=sum; 264 264 colmax=column; 265 } 265 } 266 266 } 267 267 if(hits) memneeded+=CPRO.result[which_statistic].maxalignlen; … … 283 283 284 284 /* ----------------------------------------------------------------- 285 * Function: CPRO_maketables 285 * Function: CPRO_maketables 286 286 * 287 287 * Arguments: char isamino 288 288 * 289 * Returns: modifies: char *CPRO.convtable, 289 * Returns: modifies: char *CPRO.convtable, 290 290 * char *CPRO.grouptable 291 291 * 292 * Description: Fills tables CPRO.convtable and CPRO.grouptable, that are 292 * Description: Fills tables CPRO.convtable and CPRO.grouptable, that are 293 293 * used later, when making the statistic. Meaning of tables: 294 * E.g. CPRO.convtable['a']=BAS_A means that char. 'a' is 294 * E.g. CPRO.convtable['a']=BAS_A means that char. 'a' is 295 295 * converted into number BAS_A. Then CPRO.grouptable[BAS_A]=1 296 296 * and CPRO.grouptable[BAS_G]=1 means, that characters 'a' 297 * and 'g' are both members of group 1. 297 * and 'g' are both members of group 1. 298 298 * 299 299 * NOTE: . … … 301 301 * Global Variables referenced: . 302 302 * 303 * Global Variables modified: char *CPRO.convtable, char *CPRO.grouptable 303 * Global Variables modified: char *CPRO.convtable, char *CPRO.grouptable 304 304 * 305 305 * AWARs referenced: . 306 306 * 307 307 * AWARs modified: x 308 * 309 * Dependencies: . 308 * 309 * Dependencies: . 310 310 * ----------------------------------------------------------------- 311 311 */ … … 313 313 { 314 314 long i; 315 for(i=0;i<256;i++) { 315 for(i=0;i<256;i++) { 316 316 CPRO.convtable[i]=0; } 317 317 if(!isamino) … … 324 324 CPRO.convtable['u']=BAS_T; CPRO.convtable['U']=BAS_T; 325 325 326 for(i=0;i<MAX_AMINOS;i++) { 326 for(i=0;i<MAX_AMINOS;i++) { 327 327 CPRO.grouptable[i]=0; } 328 328 CPRO.grouptable[BAS_A]=1; CPRO.grouptable[BAS_G]=1; 329 CPRO.grouptable[BAS_C]=2; CPRO.grouptable[BAS_T]=2; 329 CPRO.grouptable[BAS_C]=2; CPRO.grouptable[BAS_T]=2; 330 330 } 331 331 else … … 351 351 SC(5,'F');SC(5,'Y');SC(5,'W'); 352 352 /* FYW */ 353 #undef SC 353 #undef SC 354 354 } 355 355 } … … 366 366 float distance=0.0; 367 367 368 368 369 369 if(elemx==elemy) return; 370 370 if(!(CPRO.agonist[elemx])) return; 371 371 if(!(CPRO.antagonist[elemy])) return; 372 if((CPRO.agonist[elemy])&&(CPRO.antagonist[elemx])&&(elemy<elemx)) return; 372 if((CPRO.agonist[elemy])&&(CPRO.antagonist[elemx])&&(elemy<elemx)) return; 373 373 374 374 //add similarities (added 1.0 means equal, 0.0 means different) … … 379 379 { 380 380 numofcolumns++; 381 if(value1==value2) { 381 if(value1==value2) { 382 382 rate=rate+1.0; } 383 383 else if(CPRO.grouptable[value1]==CPRO.grouptable[value2]) { 384 rate=rate+CPRO.grouprate; } // add transition weighted 384 rate=rate+CPRO.grouprate; } // add transition weighted 385 385 // between 1.0 and 0.0 386 386 } … … 396 396 397 397 if (column < 0 || column>= CPRO.result[which_statistic].resolution) return; 398 398 399 399 register STATTYPE *equalentry= 400 400 CPRO.result[which_statistic].statistic[3*column]; … … 408 408 for(counter=0;counter<CPRO.result[which_statistic].maxalignlen;counter++) 409 409 { 410 if((value1=*firstseq)&&(value2=*secondseq)) 410 if((value1=*firstseq)&&(value2=*secondseq)) 411 411 // when gap or unaligned base goto next position 412 412 { … … 421 421 samegroupentry++; 422 422 differententry++; 423 } 424 423 } 424 425 425 426 426 … … 428 428 429 429 // is used by function CPRO_makestatistic 430 // reads sequences of a segment into memory, converts them 430 // reads sequences of a segment into memory, converts them 431 431 // and frees older sequences 432 432 void CPRO_readneededdata(char **speciesdata,GBDATA **speciesdatabase, … … 437 437 for(i=0;i<CPRO.numspecies;i++) 438 438 { 439 if((speciesdata[i])&&(i<elemy1)&&(i>elemy2)&&(i<elemx1)&&(i>elemx2)) 440 { 441 delete(speciesdata[i]); speciesdata[i]=0; 442 } 443 } 439 if((speciesdata[i])&&(i<elemy1)&&(i>elemy2)&&(i<elemx1)&&(i>elemx2)) 440 { 441 delete(speciesdata[i]); speciesdata[i]=0; 442 } 443 } 444 444 445 445 if(elemx1<CPRO.numspecies) 446 446 { 447 for(i=elemx1;(i<=elemx2 && i<CPRO.numspecies);i++) 447 for(i=elemx1;(i<=elemx2 && i<CPRO.numspecies);i++) 448 448 { 449 449 if( (CPRO.agonist[i])&&(!(speciesdata[i])) ) … … 457 457 } 458 458 } 459 if(elemy1<CPRO.numspecies) 460 { 461 for(i=elemy1;(i<=elemy2 && i<CPRO.numspecies);i++) 459 if(elemy1<CPRO.numspecies) 460 { 461 for(i=elemy1;(i<=elemy2 && i<CPRO.numspecies);i++) 462 462 { 463 463 if( (CPRO.antagonist[i])&&(!(speciesdata[i])) ) … … 465 465 tempdata=GB_read_char_pntr(speciesdatabase[i]); 466 466 speciesdata[i]=(char*)calloc((unsigned int) 467 CPRO.result[which_statistic].maxalignlen,1); 467 CPRO.result[which_statistic].maxalignlen,1); 468 468 for(j=0;j<CPRO.result[which_statistic].maxalignlen;j++) { 469 469 speciesdata[i][j]=CPRO.convtable[tempdata[j]]; } … … 475 475 476 476 /* ----------------------------------------------------------------- 477 * Function: CPRO_makestatistic 477 * Function: CPRO_makestatistic 478 478 * 479 479 * Arguments: char **speciesdata, 480 * GBDATA **speciesdatabase 481 * 482 * Returns: 1 if successful, 0 if user abort 483 * (without consequences) 480 * GBDATA **speciesdatabase 481 * 482 * Returns: 1 if successful, 0 if user abort 483 * (without consequences) 484 484 * 485 485 * Description: This function compares every sequence with every sequence. … … 489 489 * When a new segment is entered, the corresponding 490 490 * sequences are loaded into array 'speciesdata' by the function 491 * CPRO_readneededdata. 'speciesdatabase' contains pointers of 491 * CPRO_readneededdata. 'speciesdatabase' contains pointers of 492 492 * sequences to the database. Comparison and evaluation of two 493 493 * sequences is done by function CPRO_entryinstatistic. … … 495 495 * NOTE: . 496 496 * 497 * Global Variables referenced: 498 * CPRO.numspecies,CPRO.result[which_statistic].maxalignlen 499 * 500 * Global Variables modified: x 497 * Global Variables referenced: 498 * CPRO.numspecies,CPRO.result[which_statistic].maxalignlen 499 * 500 * Global Variables modified: x 501 501 * 502 502 * AWARs referenced: . 503 503 * 504 504 * AWARs modified: CPRO.result[which_statistic].statistic is modified 505 * 506 * Dependencies: CPRO_entryinstatistic , CPRO_readneededdata 505 * 506 * Dependencies: CPRO_entryinstatistic , CPRO_readneededdata 507 507 * ----------------------------------------------------------------- 508 508 */ 509 509 char CPRO_makestatistic(char **speciesdata,GBDATA **speciesdatabase, 510 char which_statistic) 510 char which_statistic) 511 511 { 512 512 long widthmatrix=CPRO.partition; … … 548 548 elemx,elemy,which_statistic); 549 549 compares++; 550 if(((compares/30)*30)==compares) 550 if(((compares/30)*30)==compares) 551 551 { 552 552 if(aw_status((double)compares … … 581 581 * Global Variables referenced: . 582 582 * 583 * Global Variables modified: x 583 * Global Variables modified: x 584 584 * 585 585 * AWARs referenced: cpro/alignment , cpro/which_species … … 587 587 * 588 588 * AWARs modified: x 589 * 590 * Dependencies: CPRO_readandallocate , CPRO_makestatistic , CPRO_deallocate 589 * 590 * Dependencies: CPRO_readandallocate , CPRO_makestatistic , CPRO_deallocate 591 591 * ----------------------------------------------------------------- 592 592 */ … … 621 621 else strcpy(CPRO.result[which_statistic].which_species,"all vs all\0"); 622 622 623 if( (faultmessage=GB_push_transaction(gb_main)) ) 623 if( (faultmessage=GB_push_transaction(gb_main)) ) 624 624 { 625 625 aw_message(faultmessage,"OK,EXIT"); … … 640 640 aw_openstatus("calculating");aw_status((double)0); 641 641 642 GBDATA **speciesdatabase; // array of GBDATA-pointers to the species 643 char **speciesdata;//array of pointers to strings that hold data of species 644 645 // allocate memory for 'CPRO.statistic','speciesdata' and fill 642 GBDATA **speciesdatabase; // array of GBDATA-pointers to the species 643 char **speciesdata;//array of pointers to strings that hold data of species 644 645 // allocate memory for 'CPRO.statistic','speciesdata' and fill 646 646 // 'speciesdatabase','agonist' and 'antagonist' 647 647 CPRO_readandallocate(speciesdata,speciesdatabase,versus,align); … … 668 668 CPRO_deallocate(speciesdata,speciesdatabase); 669 669 delete align; 670 if( (faultmessage=GB_pop_transaction(gb_main)) ) 670 if( (faultmessage=GB_pop_transaction(gb_main)) ) 671 671 { 672 672 aw_message(faultmessage,"OK,EXIT"); 673 673 return; 674 } 674 } 675 675 676 676 CPRO_memrequirement_cb(awr,0,0); … … 696 696 aw_root->awar("tmp/cpro/which1")->write_string(CPRO.result[0].which_species); 697 697 aw_root->awar("tmp/cpro/which2")->write_string(CPRO.result[1].which_species); 698 698 699 699 sprintf(buf,"%5ld",CPRO.result[0].resolution); 700 700 aw_root->awar("tmp/cpro/nowres1")->write_string(buf); … … 704 704 if(!(CPRO.result[0].statisticexists)) 705 705 aw_root->awar("tmp/cpro/memfor1")->write_string("0KB\0"); 706 else 706 else 707 707 { 708 708 sprintf(buf,"%ldKB",CPRO.result[0].memneeded/1024); … … 712 712 if(!(CPRO.result[1].statisticexists)) 713 713 aw_root->awar("tmp/cpro/memfor2")->write_string("0KB\0"); 714 else 714 else 715 715 { 716 716 sprintf(buf,"%ldKB",CPRO.result[1].memneeded/1024); … … 718 718 } 719 719 720 if( (faultmessage=GB_push_transaction(gb_main)) ) 720 if( (faultmessage=GB_push_transaction(gb_main)) ) 721 721 { 722 722 aw_message(faultmessage,"OK,EXIT"); … … 744 744 } 745 745 while(gb_species) 746 { 746 { 747 747 if(GBT_read_sequence(gb_species,align)){ 748 nrofspecies++; 748 nrofspecies++; 749 749 } 750 750 if (versus==1) { … … 752 752 }else{ 753 753 gb_species = GBT_next_species(gb_species); 754 } 754 } 755 755 } 756 756 CPRO.numspecies=nrofspecies; */ … … 759 759 /*if(CPRO.numspecies<=2*CPRO.partition) mem=CPRO.numspecies*len; 760 760 else mem=CPRO.partition*2*len; */ 761 mem=CPRO.partition*len*2; // *2, because of row and column in matrix 761 mem=CPRO.partition*len*2; // *2, because of row and column in matrix 762 762 sprintf(buf,"%ldKB",mem/1024); 763 763 aw_root->awar("tmp/cpro/mempartition")->write_string(buf); 764 764 765 765 mem+=resolution*3*sizeof(STATTYPE)*len; 766 766 sprintf(buf,"%ldKB",mem/1024); 767 767 aw_root->awar("tmp/cpro/memstatistic")->write_string(buf); 768 768 769 769 delete align; 770 770 if( (faultmessage=GB_pop_transaction(gb_main)) ) … … 794 794 aw_root->awar_int( "cpro/firstreachedstep",4,aw_def); 795 795 aw_root->awar_int( "cpro/leastcompares",300,aw_def); 796 aw_root->awar_string("tmp/cpro/mempartition","",aw_def); 796 aw_root->awar_string("tmp/cpro/mempartition","",aw_def); 797 797 aw_root->awar_int( "cpro/gridhorizontal",20,aw_def); 798 798 aw_root->awar_int( "cpro/gridvertical",20,aw_def); … … 852 852 853 853 sum=hits+group+different; 854 854 855 855 if(!(mode)) 856 856 { 857 if(sum) 857 if(sum) 858 858 { 859 859 equal=(float)hits/(float)sum; 860 ingroup=((float)hits+(float)group)/(float)sum; 861 } 862 else 860 ingroup=((float)hits+(float)group)/(float)sum; 861 } 862 else 863 863 { 864 864 equal=1.0; 865 ingroup=1.0; 865 ingroup=1.0; 866 866 } 867 867 return; … … 871 871 float accu=pow(sum/(float)CPRO.result[which_statistic].maxaccu,0.0675); 872 872 float distance=(float)CPRO.result[which_statistic].drawmode*.01* 873 CPRO.result[which_statistic].resolution; 873 CPRO.result[which_statistic].resolution; 874 874 float alpha=0.0; // alpha=0.0 no smoothing; alpha=0.99 high smoothing 875 if(distance>0.0000001) 875 if(distance>0.0000001) 876 876 { 877 877 alpha=1.0-accu/distance; … … 879 879 } 880 880 881 if(res==0) 881 if(res==0) 882 882 { 883 883 CPRO.Z_it_group=1.0; … … 904 904 void CPRO_box(AW_device *device,int gc,float l,float t,float width,float high) 905 905 { 906 device->line(gc,l,t,l+width,t,1,(AW_CL)0,(AW_CL)0); 907 device->line(gc,l+width,t,l+width,t+high,1,(AW_CL)0,(AW_CL)0); 908 device->line(gc,l,t+high,l+width,t+high,1,(AW_CL)0,(AW_CL)0); 909 device->line(gc,l,t,l,t+high,1,(AW_CL)0,(AW_CL)0); 906 device->line(gc,l,t,l+width,t,1,(AW_CL)0,(AW_CL)0); 907 device->line(gc,l+width,t,l+width,t+high,1,(AW_CL)0,(AW_CL)0); 908 device->line(gc,l,t+high,l+width,t+high,1,(AW_CL)0,(AW_CL)0); 909 device->line(gc,l,t,l,t+high,1,(AW_CL)0,(AW_CL)0); 910 910 } 911 911 … … 935 935 float betweendistance=30.0; 936 936 float firstavailable=.65; 937 float secondavailable=.35; 937 float secondavailable=.35; 938 938 /* points are in the areas and without the frame */ 939 939 float topfirst, leftfirst, widthfirst, highfirst; … … 952 952 widthfirst=(rect.r-rect.l)-leftdistance-1-rightdistance; 953 953 widthsecond=(rect.r-rect.l)-leftdistance-1-rightdistance; 954 highboth=(rect.b-rect.t)-topdistance-bottomdistance-betweendistance-4; 954 highboth=(rect.b-rect.t)-topdistance-bottomdistance-betweendistance-4; 955 955 if((highboth<12.0)||(widthfirst<10.0)) return; 956 956 … … 967 967 CPRO_box(device,GC_black,leftsecond-1,topsecond-1, 968 968 widthsecond+2,highsecond+2); 969 969 970 970 device->text(GC_black,"column",leftdistance+82,14,0,1,0,0); 971 971 … … 985 985 sprintf(buf,"%3ld%%",gridy); 986 986 device->text(GC_black,buf,xpos-27,ypos+4,0,1,0,0); 987 } 987 } 988 988 device->text(GC_black,"100%",leftdistance-26,topdistance+5,0,1,0,0); 989 989 … … 998 998 { 999 999 xpos=leftdistance+1+(float)gridx*0.01/CPRO.maxdistance*widthfirst; 1000 if((float)gridx*0.01<1.0*CPRO.maxdistance) 1000 if((float)gridx*0.01<1.0*CPRO.maxdistance) 1001 1001 device->line(GC_grid,xpos,ypos,xpos,ypos+highfirst,1,0,0); 1002 1002 sprintf(buf,"%3ld%%",gridx); … … 1030 1030 // do not draw outside canvas-box 1031 1031 if(xpos+linelength > leftfirst+widthfirst+1) continue; 1032 1032 1033 1033 confidinterval=highfirst* 1034 1034 CPRO_confidinterval(firstx,CPRO.column-1,which_statistic,mode); 1035 1035 1036 1036 ytop=ypos-confidinterval; 1037 if(ytop>=topfirst) { 1037 if(ytop>=topfirst) { 1038 1038 device->line(GC_blue,xpos,ytop,xpos+linelength,ytop,1,0,0); } 1039 1039 else { ytop=topfirst; } … … 1041 1041 1042 1042 ybottom=ypos+confidinterval; 1043 if(ybottom<topfirst+highfirst) { 1043 if(ybottom<topfirst+highfirst) { 1044 1044 device->line(GC_blue,xpos,ybottom,xpos+linelength,ybottom,1,0,0);} 1045 1045 else { ybottom=topfirst+highfirst-1; } … … 1048 1048 ypos=topfirst+ingroup*highfirst; 1049 1049 ytop=ypos-confidinterval; 1050 if(ytop>=topfirst) { 1050 if(ytop>=topfirst) { 1051 1051 device->line(GC_green,xpos,ytop,xpos+linelength,ytop,1,0,0); } 1052 1052 else { ytop=topfirst; } 1053 1053 device->line(GC_green,xpos+linelength/2,ytop,xpos+linelength/2,ypos,1,0,0); 1054 1054 1055 1055 ybottom=ypos+confidinterval; 1056 if(ybottom<topfirst+highfirst){ 1056 if(ybottom<topfirst+highfirst){ 1057 1057 device->line(GC_green,xpos,ybottom,xpos+linelength,ybottom,1,0,0);} 1058 1058 else { ybottom=topfirst+highfirst-1; } 1059 1059 device->line(GC_green,xpos+linelength/2,ybottom,xpos+linelength/2,ypos,1,0,0); 1060 1060 1061 1061 } 1062 1062 } 1063 1063 1064 1064 float resaccu; 1065 float rate; 1065 float rate; 1066 1066 sprintf(buf," %5ld",CPRO.result[which_statistic].maxaccu); 1067 1067 device->text(GC_black," max",leftsecond-50,topsecond,0,1,0,0); … … 1093 1093 AW_device *device=aws->get_device(AW_INFO_AREA); 1094 1094 device->reset(); 1095 CPRO_drawstatistic(device,(char)which_statistic); 1096 } 1097 1095 CPRO_drawstatistic(device,(char)which_statistic); 1096 } 1097 1098 1098 void CPRO_expose_cb( AW_window *aws,AW_CL which_statistic, AW_CL cd2) 1099 1099 { … … 1113 1113 1114 1114 AW_device *device=aws->get_device (AW_INFO_AREA); 1115 CPRO_drawstatistic(device,(char)which_statistic); 1116 } 1115 CPRO_drawstatistic(device,(char)which_statistic); 1116 } 1117 1117 1118 1118 void CPRO_column_cb(AW_root *awr,AW_window *aws,AW_CL which_statistic) … … 1167 1167 GB_write_int(gb_param,CPRO.result[which_statistic].resolution); 1168 1168 gb_param=GB_create(newbase,"cpro_maxalignlen",GB_INT); 1169 GB_write_int(gb_param,CPRO.result[which_statistic].maxalignlen); 1169 GB_write_int(gb_param,CPRO.result[which_statistic].maxalignlen); 1170 1170 gb_param=GB_create(newbase,"cpro_maxaccu",GB_INT); 1171 1171 GB_write_int(gb_param,CPRO.result[which_statistic].maxaccu); … … 1175 1175 GB_write_string(gb_param,CPRO.result[which_statistic].alignname); 1176 1176 gb_param=GB_create(newbase,"cpro_which_species",GB_STRING); 1177 GB_write_string(gb_param,CPRO.result[which_statistic].which_species); 1177 GB_write_string(gb_param,CPRO.result[which_statistic].which_species); 1178 1178 gb_param=GB_create(newbase,"cpro_ratio",GB_FLOAT); 1179 1179 GB_write_float(gb_param,CPRO.result[which_statistic].ratio); … … 1181 1181 GB_write_int(gb_param,CPRO.result[which_statistic].countgaps); 1182 1182 1183 1184 long maxalignlen=CPRO.result[which_statistic].maxalignlen; 1183 1184 long maxalignlen=CPRO.result[which_statistic].maxalignlen; 1185 1185 1186 1186 GBDATA *gb_colrescontainer; … … 1206 1206 } 1207 1207 } 1208 1208 1209 1209 if( (error=GB_commit_transaction(newbase)) ) 1210 1210 { … … 1278 1278 gb_param=GB_search(oldbase,"cpro_which_species",GB_FIND); 1279 1279 if(gb_param) strcpy(CPRO.result[which_statistic].which_species, 1280 GB_read_char_pntr(gb_param)); 1280 GB_read_char_pntr(gb_param)); 1281 1281 1282 1282 CPRO.result[which_statistic].statistic=(STATTYPE **)calloc( … … 1328 1328 1329 1329 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 1330 aws->create_button("CLOSE","CLOSE","C"); 1330 aws->create_button("CLOSE","CLOSE","C"); 1331 1331 1332 1332 aws->at("save");aws->callback(CPRO_savestatistic_cb,which_statistic); 1333 aws->create_button("SAVE","SAVE","S"); 1333 aws->create_button("SAVE","SAVE","S"); 1334 1334 1335 1335 aws->callback( (AW_CB0)AW_POPDOWN); 1336 1336 aws->at("cancel"); 1337 aws->create_button("CANCEL","CANCEL","C"); 1337 aws->create_button("CANCEL","CANCEL","C"); 1338 1338 1339 1339 awt_create_selection_box((AW_window *)aws,"cpro/save"); … … 1349 1349 1350 1350 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 1351 aws->create_button("CLOSE","CLOSE","C"); 1351 aws->create_button("CLOSE","CLOSE","C"); 1352 1352 1353 1353 aws->at("save");aws->callback(CPRO_loadstatistic_cb,which_statistic); 1354 aws->create_button("LOAD","LOAD","S"); 1354 aws->create_button("LOAD","LOAD","S"); 1355 1355 1356 1356 awt_create_selection_box((AW_window *)aws,"cpro/load"); … … 1361 1361 // search point of resolution when half maximum if reached (for condense) 1362 1362 float CPRO_gethalfmaximum(long column,float maximum,float firsttoreach, 1363 char transversion,char which_statistic,char mode) 1363 char transversion,char which_statistic,char mode) 1364 1364 { 1365 1365 float equal,ingroup,interest; … … 1385 1385 } 1386 1386 halfmax=(float)res/(float)CPRO.result[which_statistic].resolution; 1387 return(halfmax-(float)CPRO.result[which_statistic].drawmode*0.01); 1387 return(halfmax-(float)CPRO.result[which_statistic].drawmode*0.01); 1388 1388 // delay depending on drawmode 1389 1389 } … … 1415 1415 AW_root *aw_root = aw->get_root(); 1416 1416 char mode=CPRO.result[which_statistic].drawmode; 1417 if(!(CPRO.result[which_statistic].statisticexists)) 1417 if(!(CPRO.result[which_statistic].statisticexists)) 1418 1418 { 1419 1419 aw_message("statistic doesn't exist !"); … … 1432 1432 1433 1433 char *savename=aw_root->awar("cpro/condensename")->read_string(); 1434 if(savename[0]==0) 1434 if(savename[0]==0) 1435 1435 { 1436 1436 delete savename; … … 1444 1444 float maximum; 1445 1445 float reachedhalf; 1446 char steps; 1446 char steps; 1447 1447 for(long column=0;column<maxcol;column++) 1448 1448 { … … 1451 1451 if(maximum<-100.0) result[column]='.'; 1452 1452 else if(maximum<=0.0) result[column]='-'; 1453 else 1453 else 1454 1454 { 1455 1455 if(maximum>=leastmax) result[column]='A'; … … 1458 1458 transversion,(char)which_statistic,mode); 1459 1459 for(steps=0;(reachedhalf>firstreachedstep)&&(steps<'Y'-'A');steps++) 1460 reachedhalf-=firstreachedstep; 1460 reachedhalf-=firstreachedstep; 1461 1461 result[column]+=steps; 1462 1462 } … … 1509 1509 1510 1510 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 1511 aws->create_button("CLOSE","CLOSE","C"); 1511 aws->create_button("CLOSE","CLOSE","C"); 1512 1512 1513 1513 aws->at( "which_result" ); … … 1519 1519 aws->button_length(11); 1520 1520 aws->at("begin");aws->callback(CPRO_condense_cb,which_statistic); 1521 aws->create_button("CONDENSE_AND_EXPORT", "CONDENSE\nAND EXPORT","E"); 1521 aws->create_button("CONDENSE_AND_EXPORT", "CONDENSE\nAND EXPORT","E"); 1522 1522 1523 1523 aws->at("name");aws->create_input_field("cpro/condensename",11); … … 1540 1540 1541 1541 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 1542 aws->create_button("CLOSE","CLOSE","C"); 1543 1542 aws->create_button("CLOSE","CLOSE","C"); 1543 1544 1544 aws->at("partition"); 1545 1545 aws->create_input_field("cpro/partition",6); … … 1583 1583 1584 1584 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 1585 aws->create_button("CLOSE","CLOSE","C"); 1585 aws->create_button("CLOSE","CLOSE","C"); 1586 1586 1587 1587 //aws->at("xpert");aws->callback(AW_POPUP,(AW_CL)CPRO_xpert_cb,0); … … 1590 1590 aws->at("column"); 1591 1591 aws->create_input_field(AWAR_CURSOR_POSITION,4); 1592 1592 1593 1593 aws->button_length(3); 1594 1594 aws->at("d");aws->callback((AW_CB0)CPRO_columnminus_cb); … … 1596 1596 aws->at("u");aws->callback((AW_CB2)CPRO_columnplus_cb,which_statistic,0); 1597 1597 aws->create_button(0,"+","2"); 1598 1598 1599 1599 sprintf(buf,"cpro/drawmode%d",(int)which_statistic); 1600 1600 aws->at("drawmode");aws->create_option_menu(buf); 1601 aws->insert_option( "no smoothing", "n",0); 1602 aws->insert_option( "smoothing 1", "1",1); 1603 aws->insert_option( "smoothing 2", "2",2); 1604 aws->insert_option( "smoothing 3", "3",3); 1605 aws->insert_option( "smoothing 5", "5",5); 1606 aws->insert_option( "smoothing 10", "6",10); 1601 aws->insert_option( "no smoothing", "n",0); 1602 aws->insert_option( "smoothing 1", "1",1); 1603 aws->insert_option( "smoothing 2", "2",2); 1604 aws->insert_option( "smoothing 3", "3",3); 1605 aws->insert_option( "smoothing 5", "5",5); 1606 aws->insert_option( "smoothing 10", "6",10); 1607 1607 aws->insert_option( "smoothing 15", "7",15); 1608 aws->update_option_menu(); 1608 aws->update_option_menu(); 1609 1609 1610 1610 aw_root->awar(buf)->add_callback( 1611 (AW_RCB)CPRO_column_cb,(AW_CL)aws,which_statistic); 1611 (AW_RCB)CPRO_column_cb,(AW_CL)aws,which_statistic); 1612 1612 aw_root->awar("cpro/gridhorizontal")->add_callback( 1613 (AW_RCB)CPRO_column_cb,(AW_CL)aws,which_statistic); 1613 (AW_RCB)CPRO_column_cb,(AW_CL)aws,which_statistic); 1614 1614 aw_root->awar("cpro/gridvertical")->add_callback( 1615 (AW_RCB)CPRO_column_cb,(AW_CL)aws,which_statistic); 1615 (AW_RCB)CPRO_column_cb,(AW_CL)aws,which_statistic); 1616 1616 1617 1617 aws->at("maxdistance"); … … 1628 1628 (AW_CL)aws,which_statistic); 1629 1629 aw_root->awar("cpro/maxdistance")->add_callback((AW_RCB)CPRO_column_cb, 1630 (AW_CL)aws,which_statistic); 1630 (AW_CL)aws,which_statistic); 1631 1631 aws->button_length( 6); 1632 1632 … … 1640 1640 device->new_gc( GC_blue ); 1641 1641 device->set_line_attributes(GC_blue,0.3,AW_SOLID); 1642 device->set_foreground_color(GC_blue,AW_WINDOW_C1); 1642 device->set_foreground_color(GC_blue,AW_WINDOW_C1); 1643 1643 device->new_gc( GC_green ); 1644 1644 device->set_line_attributes(GC_green,0.3,AW_SOLID); … … 1647 1647 device->set_line_attributes(GC_grid,0.3,AW_DOTTED); 1648 1648 device->set_foreground_color(GC_grid,AW_WINDOW_C3); 1649 1649 1650 1650 return (AW_window *)aws; 1651 1651 } … … 1661 1661 1662 1662 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 1663 aws->create_button("CLOSE","CLOSE","C"); 1663 aws->create_button("CLOSE","CLOSE","C"); 1664 1664 1665 1665 aws->at("resolution"); … … 1679 1679 aws->at("calculate"); 1680 1680 aws->callback(CPRO_calculate_cb,(AW_CL)which_statistic); 1681 aws->create_button("CALCULATE","CALCULATE","A"); 1681 aws->create_button("CALCULATE","CALCULATE","A"); 1682 1682 1683 1683 aws->at( "which_species" ); … … 1715 1715 * Global Variables referenced: . 1716 1716 * 1717 * Global Variables modified: x 1717 * Global Variables modified: x 1718 1718 * 1719 1719 * AWARs referenced: . 1720 1720 * 1721 1721 * AWARs modified: x 1722 * 1723 * Dependencies: Needs xfig file cprofile.fig 1722 * 1723 * Dependencies: Needs xfig file cprofile.fig 1724 1724 * ----------------------------------------------------------------- 1725 1725 */ … … 1735 1735 1736 1736 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 1737 aws->create_button("CLOSE","CLOSE","C"); 1738 1737 aws->create_button("CLOSE","CLOSE","C"); 1738 1739 1739 aws->at("help");aws->callback(AW_POPUP_HELP,(AW_CL)"pos_variability.ps"); 1740 aws->create_button("HELP","HELP","H"); 1741 1740 aws->create_button("HELP","HELP","H"); 1741 1742 1742 aws->button_length(10); 1743 1743 aws->at("xpert");aws->callback(AW_POPUP,(AW_CL)CPRO_xpert_cb,0); … … 1749 1749 aws->create_button("GO_STAT_1", "calculate as\nstatistic 1 ...","c"); 1750 1750 aws->at("calculate2");aws->callback(AW_POPUP,(AW_CL)CPRO_calculatewin_cb,1); 1751 aws->create_button("GO_STAT_2", "calculate as\nstatistic 2 ...","a"); 1751 aws->create_button("GO_STAT_2", "calculate as\nstatistic 2 ...","a"); 1752 1752 1753 1753 aws->button_length(17); … … 1788 1788 (AW_RCB)CPRO_memrequirement_cb,0,0); 1789 1789 aw_root->awar("cpro/which_species")->add_callback( 1790 (AW_RCB)CPRO_memrequirement_cb,0,0); 1790 (AW_RCB)CPRO_memrequirement_cb,0,0); 1791 1791 1792 1792 GB_pop_transaction(gb_main); -
trunk/NTREE/AP_pos_var_pars.cxx
r2 r655 3 3 #include <ctype.h> 4 4 #include <string.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <memory.h> 7 7 #include <math.h> … … 56 56 GBDATA *gb_data = GBT_read_sequence(tree->gb_node,ali_name); 57 57 if (!gb_data) return 0; // no sequence 58 if (GB_read_string_count(gb_data) < seq_len) 58 if (GB_read_string_count(gb_data) < seq_len) 59 59 seq_len = GB_read_string_count(gb_data); 60 60 sequence = GB_read_char_pntr(gb_data); … … 114 114 // Calculate the positional variability: control procedure 115 115 GB_ERROR AP_pos_var::retrieve( GBT_TREE *tree){ 116 GB_ERROR error = 0; 116 GB_ERROR error = 0; 117 117 int i; 118 118 … … 190 190 GBDATA *gb_extended = GBT_create_SAI(gb_main,sai_name); 191 191 192 192 193 193 { sprintf(buffer,"%s/_TYPE",ali_name); 194 194 GBDATA *gb_description = GB_search( gb_extended, buffer, GB_STRING); … … 256 256 sprintf(buffer,"%s/_CATEGORIES",ali_name); 257 257 GBDATA *gb_categories = GB_search( gb_extended, buffer, GB_STRING); 258 GB_write_string(gb_categories, h); 258 GB_write_string(gb_categories, h); 259 259 delete h; 260 260 } … … 281 281 return; 282 282 } 283 GBT_link_tree(tree,gb_main, GB_TRUE); 283 GBT_link_tree(tree,gb_main, GB_TRUE); 284 284 } 285 285 aw_status("Counting Mutations"); 286 286 287 287 char *ali_name = GBT_get_default_alignment(gb_main); 288 288 long ali_len = GBT_get_alignment_len(gb_main,ali_name); … … 301 301 // isdna = 1; 302 302 // delete ali_type; 303 303 304 304 GB_alignment_type at = GBT_get_alignment_type(gb_main, ali_name); 305 305 isdna = at==GB_AT_DNA || at==GB_AT_RNA; … … 337 337 338 338 aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 339 aws->create_button("CLOSE","CLOSE","C"); 340 339 aws->create_button("CLOSE","CLOSE","C"); 340 341 341 aws->at("help");aws->callback(AW_POPUP_HELP,(AW_CL)"pos_var_pars.hlp"); 342 aws->create_button("HELP","HELP","H"); 342 aws->create_button("HELP","HELP","H"); 343 343 344 344 aws->at("name"); … … 354 354 aws->highlight(); 355 355 aws->callback(AP_calc_pos_var_pars); 356 aws->create_button("GO","GO"); 356 aws->create_button("GO","GO"); 357 357 358 358 return (AW_window *)aws; -
trunk/NTREE/ETC_check_gcg.cxx
r247 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <arbdb.h> 6 6 #include <arbdbt.h> -
trunk/NTREE/NT_main.cxx
r566 r655 2 2 #include <stdio.h> 3 3 #include <stdlib.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <arbdb.h> 6 6 #include <arbdbt.h> -
trunk/NTREE/NT_sort.cxx
r421 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <arbdb.h> 6 6 #include <arbdbt.h> -
trunk/NTREE/ad_ali.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 126 126 127 127 error = GBT_rename_alignment(gb_main,source,dest,(int)copy,(int)dele); 128 128 129 129 if (!error){ 130 130 char *nfield = strdup(GBS_global_string("%s/data",dest)); … … 149 149 aws->callback( (AW_CB0)AW_POPDOWN); 150 150 aws->at("close"); 151 aws->create_button("CLOSE","CLOSE","C"); 151 aws->create_button("CLOSE","CLOSE","C"); 152 152 153 153 aws->at("label"); … … 159 159 aws->at("ok"); 160 160 aws->callback(aa_copy_delete_rename,1,0); 161 aws->create_button("GO","GO","G"); 161 aws->create_button("GO","GO","G"); 162 162 163 163 return (AW_window *)aws; … … 171 171 aws->callback( (AW_CB0)AW_POPDOWN); 172 172 aws->at("close"); 173 aws->create_button("CLOSE","CLOSE","C"); 173 aws->create_button("CLOSE","CLOSE","C"); 174 174 175 175 aws->at("label"); … … 181 181 aws->at("ok"); 182 182 aws->callback(aa_copy_delete_rename,1,1); 183 aws->create_button("GO","GO","G"); 183 aws->create_button("GO","GO","G"); 184 184 185 185 return (AW_window *)aws; … … 203 203 }else{ 204 204 GB_abort_transaction(gb_main); 205 } 205 } 206 206 if (error) aw_message(error); 207 207 delete name; … … 216 216 aws->callback( (AW_CB0)AW_POPDOWN); 217 217 aws->at("close"); 218 aws->create_button("CLOSE","CLOSE","C"); 218 aws->create_button("CLOSE","CLOSE","C"); 219 219 220 220 aws->at("label"); … … 226 226 aws->at("ok"); 227 227 aws->callback(aa_create_alignment); 228 aws->create_button("GO","GO","G"); 228 aws->create_button("GO","GO","G"); 229 229 230 230 return (AW_window *)aws; … … 240 240 aws->callback( (AW_CB0)AW_POPDOWN); 241 241 aws->at("close"); 242 aws->create_button("CLOSE","CLOSE","C"); 242 aws->create_button("CLOSE","CLOSE","C"); 243 243 244 244 aws->callback( AW_POPUP_HELP,(AW_CL)"ad_align.hlp"); 245 245 aws->at("help"); 246 aws->create_button("HELP","HELP","H"); 246 aws->create_button("HELP","HELP","H"); 247 247 248 248 aws->button_length(13); … … 250 250 aws->at("delete"); 251 251 aws->callback(ad_al_delete_cb); 252 aws->create_button("DELETE","DELETE","D"); 252 aws->create_button("DELETE","DELETE","D"); 253 253 254 254 aws->at("rename"); 255 255 aws->callback(AW_POPUP,(AW_CL)create_alignment_rename_window,0); 256 aws->create_button("RENAME","RENAME","R"); 256 aws->create_button("RENAME","RENAME","R"); 257 257 258 258 aws->at("create"); 259 259 aws->callback(AW_POPUP,(AW_CL)create_alignment_create_window,0); 260 aws->create_button("CREATE","CREATE","N"); 260 aws->create_button("CREATE","CREATE","N"); 261 261 262 262 aws->at("copy"); 263 263 aws->callback(AW_POPUP,(AW_CL)create_alignment_copy_window,0); 264 aws->create_button("COPY","COPY","C"); 264 aws->create_button("COPY","COPY","C"); 265 265 266 266 aws->at("check_len"); 267 267 aws->callback(ed_al_check_len_cb); 268 aws->create_button("CHECK_LEN","CHECK LEN","L"); 268 aws->create_button("CHECK_LEN","CHECK LEN","L"); 269 269 270 270 aws->at("align"); 271 271 aws->callback(ed_al_align_cb); 272 aws->create_button("FORMAT","FORMAT","F"); 272 aws->create_button("FORMAT","FORMAT","F"); 273 273 274 274 aws->at("list"); -
trunk/NTREE/ad_ext.cxx
r142 r655 1 1 #include <stdio.h> 2 2 #include <memory.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <string.h> 5 5 -
trunk/NTREE/ad_trees.cxx
r635 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <assert.h> -
trunk/ORS_CGI/ORS_C_PT.cxx
r2 r655 1 /* 1 /* 2 2 ################################# 3 3 # # … … 9 9 #include <stdlib.h> 10 10 #include <memory.h> 11 #include <malloc.h>11 // #include <malloc.h> 12 12 #include <string.h> 13 13 #include <arbdb.h> … … 30 30 31 31 // results of probe match 32 struct result_struct { 32 struct result_struct { 33 33 T_PT_MATCHLIST match_list; 34 34 long match_list_cnt; … … 66 66 67 67 /****************************************************************************** 68 PROBE MATCH: 68 PROBE MATCH: 69 69 Send probe request to server and receive probe match results 70 70 *******************************************************************************/ … … 106 106 pt_result.bs.data = 0; 107 107 108 aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 108 aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 109 109 LOCS_MATCH_LIST, &pt_result.match_list, // short names of species 110 110 LOCS_MATCH_LIST_CNT, &pt_result.match_list_cnt, // count of species short names 111 LOCS_MATCH_STRING, &pt_result.bs, // output of pt_Server 111 LOCS_MATCH_STRING, &pt_result.bs, // output of pt_Server 112 112 LOCS_ERROR, &locs_error, 113 113 0); … … 123 123 124 124 /****************************************************************************** 125 PROBE FIND: 125 PROBE FIND: 126 126 Send probe request to server and receive probe match results 127 127 *******************************************************************************/ … … 155 155 pt_result.bs.data = 0; 156 156 157 aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 157 aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 158 158 LOCS_MATCH_LIST, &pt_result.match_list, // short names of species 159 159 LOCS_MATCH_LIST_CNT, &pt_result.match_list_cnt, // count of species short names 160 LOCS_MATCH_STRING, &pt_result.bs, // output of pt_Server 160 LOCS_MATCH_STRING, &pt_result.bs, // output of pt_Server 161 161 LOCS_ERROR, &locs_error, 162 162 0); -
trunk/ORS_CGI/ORS_C_java.cxx
r2 r655 1 /* 1 /* 2 2 ####################################### 3 3 # # … … 10 10 #include <string.h> 11 11 #include <memory.h> 12 #include <malloc.h>12 // #include <malloc.h> 13 13 #include <arbdb.h> 14 14 #include <arbdbt.h> … … 53 53 fputc(o,t2j_out); 54 54 t2j_last_nibble = -1; 55 } 55 } 56 56 } 57 57 … … 308 308 Sideeffects: no !!!! 309 309 ***********************************************************************/ 310 GB_ERROR T2J_transform(char *path_of_tree, char *modifier_string, 311 struct T2J_transfer_struct *data, 310 GB_ERROR T2J_transform(char *path_of_tree, char *modifier_string, 311 struct T2J_transfer_struct *data, 312 312 CAT_node_id focus, FILE *out){ 313 313 if (!cat_tree) cat_tree = load_CAT_tree(path_of_tree); … … 385 385 } 386 386 } 387 387 388 388 GB_ERROR T2J_send_newick_tree(char *path_of_tree, FILE *out){ 389 389 if (!cat_tree) cat_tree = load_CAT_tree(path_of_tree); // 3 lines that should never be deleted … … 396 396 } 397 397 398 399 /*********************************************************************** 400 Send the tree. level numbering !!! branch lengths from 0-15 398 399 /*********************************************************************** 400 Send the tree. level numbering !!! branch lengths from 0-15 401 401 Sideeffects: writes to out 402 402 ***********************************************************************/ … … 571 571 node->user_data = cat_tree->data + node->field_offsets[CAT_FIELD_GROUP_NAME]; 572 572 } 573 573 574 574 } 575 575 return T2J_send_tree(0,0); 576 576 } 577 577 578 long t2j_get_deepest_node_that_contains_all_selected(CAT_node_id nn, 578 long t2j_get_deepest_node_that_contains_all_selected(CAT_node_id nn, 579 579 char *selected_ids,long nselected, CAT_node_id *focusout){ 580 580 CAT_node *node = & cat_tree->nodes[nn]; … … 615 615 if (!cat_tree) return 0; 616 616 CAT_node_id *levelindex = t2j_mcreate_level_indexing(); 617 617 618 618 char *readp = sel; 619 619 int nselected = 0; … … 625 625 GBS_strcat(memfile,varname); 626 626 readp = sel; 627 c = *(readp++); 627 c = *(readp++); 628 628 int last = 0; 629 629 for (; c >='A' && c <='Z'; ){ … … 645 645 if (s >= cat_tree->nnodes) e = cat_tree->nnodes-1; 646 646 last = e; 647 647 648 648 if (all_nodes) { 649 649 for (;s<e;s++) { … … 656 656 } 657 657 }else{ 658 GBS_strcat(memfile,cat_tree->data + 658 GBS_strcat(memfile,cat_tree->data + 659 659 cat_tree->nodes[levelindex[s]].field_offsets[CAT_FIELD_NAME]); 660 660 // thats one of my favourites statements … … 673 673 t2j_get_deepest_node_that_contains_all_selected( 674 674 0,selected_ids,nselected,focusout); 675 if (maxnodeout ) *maxnodeout = cat_tree->data + 675 if (maxnodeout ) *maxnodeout = cat_tree->data + 676 676 cat_tree->nodes[*focusout]. 677 677 field_offsets[CAT_FIELD_NAME]; … … 682 682 CAT_node_id nextuppderlabeldnode = *focusout; 683 683 684 while ( nextuppderlabeldnode > 0 684 while ( nextuppderlabeldnode > 0 685 685 && cat_tree->nodes[nextuppderlabeldnode]. 686 686 field_offsets[CAT_FIELD_GROUP_NAME] == 0 ) { … … 688 688 } 689 689 if (nextuppderlabeldnode) { // get the name of the node 690 if (maxnodeout ) *maxnodeout = cat_tree->data + 690 if (maxnodeout ) *maxnodeout = cat_tree->data + 691 691 cat_tree->nodes[nextuppderlabeldnode]. 692 692 field_offsets[CAT_FIELD_GROUP_NAME]; … … 703 703 TEST TEST TEST ... 704 704 ***********************************************************************/ 705 #if 0 705 #if 0 706 706 int main(int argc, char **argv) { 707 707 if (argc != 3) { -
trunk/ORS_CGI/ORS_C_lib.cxx
r2 r655 9 9 #include <unistd.h> 10 10 #include <memory.h> 11 #include <malloc.h>11 // #include <malloc.h> 12 12 #include <string.h> 13 13 #include <arbdb.h> … … 68 68 if (comment) fprintf(fd,"\t%s",comment); 69 69 fprintf(fd,"\n"); 70 70 71 71 fclose(fd); 72 72 return; … … 117 117 118 118 if( !(servername=(char *)ORS_look_for_server()) ){ 119 quit_with_error(ORS_export_error("Cannot find server")); 119 quit_with_error(ORS_export_error("Cannot find server")); 120 120 } 121 121 … … 126 126 // system("tb/bla -b -d &"); 127 127 // sleep(3); 128 // quit_with_error(ORS_export_error("Link to server failed. Restarting server... try reloading this page.")); 129 quit_with_error(ORS_export_error("Link to server failed. Server will be restarted later.")); 128 // quit_with_error(ORS_export_error("Link to server failed. Restarting server... try reloading this page.")); 129 quit_with_error(ORS_export_error("Link to server failed. Server will be restarted later.")); 130 130 131 131 } 132 132 if (init_local_com_struct() ) { 133 quit_with_error(ORS_export_error("Local comm struct failed")); 133 quit_with_error(ORS_export_error("Local comm struct failed")); 134 134 } 135 135 … … 187 187 while (*pos) { 188 188 if (*pos >= 'a' && *pos <= 'z') *pos = *pos - 'a' + 'A'; 189 if (!strchr(allowed_bases, *pos)) 189 if (!strchr(allowed_bases, *pos)) 190 190 quit_with_error(ORS_export_error("Base '%c' at position %i is not allowed! Allowed are: '%s' (norm)", *pos, (int)(pos-seq)+1, allowed_bases)); 191 191 pos++; … … 194 194 195 195 /****************************************************** 196 CALC SEQ & TARGET: 196 CALC SEQ & TARGET: 197 197 deletes and mallocs target 198 198 quit_with_error on error … … 213 213 if (!*seq1 || !**seq1) { tar = *seq1; seq = *seq2; direction=1; } 214 214 else { tar = *seq2; seq = *seq1; direction=2; } 215 215 216 216 delete tar; 217 217 tar = (char *)calloc(sizeof(char), strlen(seq) + 1); … … 239 239 case 'N': *tpos = 'X'; break; 240 240 case '.': *tpos = '.'; break; 241 default: 241 default: 242 242 quit_with_error(ORS_export_error( 243 243 "Base '%c' at position %i is not allowed! Allowed are: '%s' (calc_seq)", *spos, (int)(spos-seq)+1, allowed_bases)); -
trunk/ORS_CGI/ORS_C_main.cxx
r2 r655 11 11 #include <stdlib.h> 12 12 #include <memory.h> 13 #include <malloc.h>13 // #include <malloc.h> 14 14 #include <string.h> 15 15 #include <arbdb.h> … … 35 35 36 36 ors_gl.remote_host = getenv("REMOTE_HOST"); 37 if (!ors_gl.remote_host) quit_with_error(ORS_export_error("REMOTE_HOST not set")); 37 if (!ors_gl.remote_host) quit_with_error(ORS_export_error("REMOTE_HOST not set")); 38 38 39 39 ors_gl.remote_user = getenv("REMOTE_USER"); 40 if (ors_gl.remote_user == NULL) ors_gl.remote_user = "unknown"; 40 if (ors_gl.remote_user == NULL) ors_gl.remote_user = "unknown"; 41 41 42 42 ors_gl.path_info = getenv("PATH_INFO"); … … 51 51 else if (!strcmp(request_method,"POST")) { 52 52 char *temp; 53 if(!(temp=getenv("CONTENT_LENGTH"))) 54 quit_with_error(ORS_export_error("CONTENT_LENGTH not set")); 53 if(!(temp=getenv("CONTENT_LENGTH"))) 54 quit_with_error(ORS_export_error("CONTENT_LENGTH not set")); 55 55 int len=atoi(temp); 56 56 indata=new char[len+1]; 57 57 indata[len]=0; 58 58 fread(indata,len,1,stdin); 59 } 60 else quit_with_error(ORS_export_error("Unknown REQUEST_METHOD: %s",request_method)); 59 } 60 else quit_with_error(ORS_export_error("Unknown REQUEST_METHOD: %s",request_method)); 61 61 62 62 char *pos1, *pos2; 63 int i; 63 int i; 64 64 65 65 int ands = ORS_str_char_count(indata, '&'); // number of '&' … … 74 74 ors_gl.cgi_vars[i] = pos1; 75 75 } 76 77 // transform path_info into cgi string array (appending) 78 // take only: /taken/taken/dismissed 76 77 // transform path_info into cgi string array (appending) 78 // take only: /taken/taken/dismissed 79 79 for (pos1 = ors_gl.path_info + 1; pos1; pos1=pos2, i++) { 80 80 pos2 = strchr(pos1,'/'); … … 96 96 switch(*pos1) { 97 97 case '+': c=' '; pos1++; break; 98 case '%': hex[2]=*(pos1+1); hex[3]=*(pos1+2); hex[4]=0; 98 case '%': hex[2]=*(pos1+1); hex[3]=*(pos1+2); hex[4]=0; 99 99 pos1+=3; 100 100 sscanf(hex, "%i", &h); … … 126 126 len=strlen(name); 127 127 if (!pos2) pos2 = name + len; 128 128 129 129 for (i=0; ors_gl.cgi_vars[i]; i++) { 130 130 if (!strncasecmp(ors_gl.cgi_vars[i],pos,pos2-pos) && ors_gl.cgi_vars[i][pos2-pos] == '=' … … 154 154 len=strlen(name); 155 155 if (!pos2) pos2 = name + len; 156 156 157 157 for (i=0; ors_gl.cgi_vars[i]; i++) { 158 158 if (!strncasecmp(ors_gl.cgi_vars[i],pos,pos2-pos) && ors_gl.cgi_vars[i][pos2-pos] == '=') { … … 262 262 263 263 int main(int /*argc*/, char **/*argv*/) { 264 264 265 265 char *debug_command; 266 266 char *html_new; … … 287 287 288 288 init_server_communication(); 289 289 290 290 if (!JAVA) { // Debug-Mode: Output Variables 291 291 if (ors_gl.debug) {print_content_lines("ANFANG"); } … … 305 305 else OC_dailypw_2_userpath(); 306 306 307 if (ors_gl.userpath == NULL || *(ors_gl.userpath) == 0 || 307 if (ors_gl.userpath == NULL || *(ors_gl.userpath) == 0 || 308 308 ors_gl.dailypw == NULL || *(ors_gl.dailypw) == 0) { 309 309 ors_gl.userpath=""; // no admin functionality in html output! … … 372 372 ors_gl.password = cgi_var("password"); //! password, entered by user (login, preferences) 373 373 password2 = cgi_var("password2"); //! reentered password (must be equal) 374 if ( (!*(ors_gl.password) || !*(password2) ) 375 && !(!*(ors_gl.password) && !*(password2) ) ) 374 if ( (!*(ors_gl.password) || !*(password2) ) 375 && !(!*(ors_gl.password) && !*(password2) ) ) 376 376 quit_with_error(ORS_export_error("You have to enter password two times!")); 377 if (ORS_strcmp(ors_gl.password,password2)) 377 if (ORS_strcmp(ors_gl.password,password2)) 378 378 quit_with_error(ORS_export_error("Reentered password differs!")); 379 379 work_on_user(); … … 401 401 ors_gl.sel_password = cgi_var("sel_password"); //! password, entered for sel_user (create/modify sel_user) 402 402 password2 = cgi_var("sel_password2"); //! reentered password (must be equal to password) 403 if (*(ors_gl.sel_password) && *(password2) && strcmp(ors_gl.sel_password,password2)) 403 if (*(ors_gl.sel_password) && *(password2) && strcmp(ors_gl.sel_password,password2)) 404 404 quit_with_error(ORS_export_error("Reentered password differs!")); 405 405 … … 440 440 if (*ors_gl.sequence) OC_normalize_seq(ors_gl.sequence, ors_gl.allowed_bases); 441 441 if (*ors_gl.target_seq) OC_normalize_seq(ors_gl.target_seq, ors_gl.allowed_bases); 442 if (*ors_gl.sequence && *ors_gl.target_seq && !ORS_seq_matches_target_seq(ors_gl.sequence, ors_gl.target_seq, 1)) 442 if (*ors_gl.sequence && *ors_gl.target_seq && !ORS_seq_matches_target_seq(ors_gl.sequence, ors_gl.target_seq, 1)) 443 443 quit_with_error("Sequence and target sequence do not match! Just enter one field, the other is being calculated."); 444 444 … … 451 451 OC_send_pdb_fields_to_server("entered"); // send the sequence to probedb server 452 452 ors_gl.list_of_probes = OC_probe_query(100); // and look for equal seqs 453 453 454 454 if (ors_gl.list_of_probes && *ors_gl.list_of_probes) { 455 455 OC_output_html_page("probe_seq_exists"); //! show probes with equal sequence information … … 630 630 subject = cgi_var("subject"); //! subject of mail message 631 631 body = cgi_var("body"); //! body of mail message 632 632 633 633 // TODO: mail verschicken 634 634 -
trunk/ORS_CGI/ORS_C_probe.cxx
r2 r655 1 /* 1 /* 2 2 ################################# 3 3 # # … … 10 10 #include <stdlib.h> 11 11 #include <memory.h> 12 #include <malloc.h>12 // #include <malloc.h> 13 13 #include <string.h> 14 14 #include <arbdb.h> … … 28 28 void OC_save_probedb(void) { 29 29 30 char *locs_error = 0; 31 32 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 33 LOCAL_DAILYPW, ors_gl.dailypw, 30 char *locs_error = 0; 31 32 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 33 LOCAL_DAILYPW, ors_gl.dailypw, 34 34 LOCAL_REMOTE_HOST, ors_gl.remote_host, 35 LOCAL_SAVE_PROBEDB, "", 36 NULL)) { 37 quit_with_error(ORS_export_error("Server communication failed (save_probedb)")); 38 } 39 40 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 35 LOCAL_SAVE_PROBEDB, "", 36 NULL)) { 37 quit_with_error(ORS_export_error("Server communication failed (save_probedb)")); 38 } 39 40 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 41 41 LOCAL_ERROR , &locs_error, 42 42 NULL)) { 43 quit_with_error(ORS_export_error("Server communication failed (save_probedb2)")); 43 quit_with_error(ORS_export_error("Server communication failed (save_probedb2)")); 44 44 } 45 45 OC_server_error_if_not_empty(locs_error); … … 52 52 void OC_put_probe_field(char *field_section, char *field_name, char *field_data) { 53 53 54 char *locs_error = 0; 54 char *locs_error = 0; 55 55 static bytestring bs = {0,0}; 56 56 delete bs.data; … … 66 66 67 67 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 68 LOCAL_PROBE_FIELD_DATA, bs, 69 LOCAL_PROBE_FIELD_SECTION, field_section, 70 LOCAL_PUT_PROBE_FIELD, field_name, 71 NULL)) { 72 quit_with_error(ORS_export_error("Server communication failed (put_probe_field:%s/%s)",field_section,field_name)); 73 } 74 75 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 68 LOCAL_PROBE_FIELD_DATA, bs, 69 LOCAL_PROBE_FIELD_SECTION, field_section, 70 LOCAL_PUT_PROBE_FIELD, field_name, 71 NULL)) { 72 quit_with_error(ORS_export_error("Server communication failed (put_probe_field:%s/%s)",field_section,field_name)); 73 } 74 75 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 76 76 LOCAL_ERROR , &locs_error, 77 77 NULL)) { 78 quit_with_error(ORS_export_error("Server communication failed (put_probe_field2:%s/%s)",field_section,field_name)); 78 quit_with_error(ORS_export_error("Server communication failed (put_probe_field2:%s/%s)",field_section,field_name)); 79 79 } 80 80 OC_server_error_if_not_empty(locs_error); … … 86 86 void OC_put_probe_ta_id(int ta_id) { 87 87 88 char *locs_error = 0; 89 90 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 91 LOCAL_PROBE_TA_ID, ta_id, 92 NULL)) { 93 quit_with_error(ORS_export_error("Server communication failed (put_probe_ta_id)")); 94 } 95 96 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 88 char *locs_error = 0; 89 90 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 91 LOCAL_PROBE_TA_ID, ta_id, 92 NULL)) { 93 quit_with_error(ORS_export_error("Server communication failed (put_probe_ta_id)")); 94 } 95 96 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 97 97 LOCAL_ERROR , &locs_error, 98 98 NULL)) { 99 quit_with_error(ORS_export_error("Server communication failed (put_probe_ta_id2)")); 99 quit_with_error(ORS_export_error("Server communication failed (put_probe_ta_id2)")); 100 100 } 101 101 OC_server_error_if_not_empty(locs_error); … … 108 108 char *OC_get_probe_field(char *field_section, char *field_name) { 109 109 110 char *locs_error = 0; 110 char *locs_error = 0; 111 111 char *field_data; 112 112 static bytestring bs = {0,0}; … … 117 117 118 118 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 119 LOCAL_PROBE_FIELD_SECTION, field_section, 120 LOCAL_PROBE_FIELD_NAME, field_name, 121 NULL)) { 122 quit_with_error(ORS_export_error("Server communication failed (get_probe_field:%s/%s)",field_section,field_name)); 123 } 124 125 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 119 LOCAL_PROBE_FIELD_SECTION, field_section, 120 LOCAL_PROBE_FIELD_NAME, field_name, 121 NULL)) { 122 quit_with_error(ORS_export_error("Server communication failed (get_probe_field:%s/%s)",field_section,field_name)); 123 } 124 125 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 126 126 LOCAL_ERROR, &locs_error, 127 LOCAL_GET_PROBE_FIELD, &bs, 128 NULL)) { 129 quit_with_error(ORS_export_error("Server communication failed (get_probe_field2:%s/%s)",field_section,field_name)); 127 LOCAL_GET_PROBE_FIELD, &bs, 128 NULL)) { 129 quit_with_error(ORS_export_error("Server communication failed (get_probe_field2:%s/%s)",field_section,field_name)); 130 130 } 131 131 OC_server_error_if_not_empty(locs_error); … … 139 139 int OC_get_probe_ta_id(void) { 140 140 141 char *locs_error = 0; 141 char *locs_error = 0; 142 142 int field_data; 143 143 144 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 144 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 145 145 LOCAL_ERROR, &locs_error, 146 LOCAL_PROBE_TA_ID, &field_data, 147 NULL)) { 148 quit_with_error(ORS_export_error("Server communication failed (get_probe_ta_id)")); 146 LOCAL_PROBE_TA_ID, &field_data, 147 NULL)) { 148 quit_with_error(ORS_export_error("Server communication failed (get_probe_ta_id)")); 149 149 } 150 150 OC_server_error_if_not_empty(locs_error); … … 158 158 void OC_work_on_probe(char *action) { 159 159 160 char *locs_error = 0; 161 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 162 LOCAL_DAILYPW, ors_gl.dailypw, 160 char *locs_error = 0; 161 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 162 LOCAL_DAILYPW, ors_gl.dailypw, 163 163 LOCAL_REMOTE_HOST, ors_gl.remote_host, 164 LOCAL_WORK_ON_PROBE, action, 165 NULL)) { 166 quit_with_error(ORS_export_error("Server communication failed (work_on_probe:%s)",action)); 167 } 168 169 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 164 LOCAL_WORK_ON_PROBE, action, 165 NULL)) { 166 quit_with_error(ORS_export_error("Server communication failed (work_on_probe:%s)",action)); 167 } 168 169 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 170 170 LOCAL_ERROR , &locs_error, 171 171 NULL)) { 172 quit_with_error(ORS_export_error("Server communication failed (work_on_probe2:%s)",action)); 172 quit_with_error(ORS_export_error("Server communication failed (work_on_probe2:%s)",action)); 173 173 } 174 174 OC_server_error_if_not_empty(locs_error); … … 188 188 void OC_probe_select(char *probe_id ) { 189 189 190 char *locs_error = 0; 191 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 192 LOCAL_DAILYPW, ors_gl.dailypw, 190 char *locs_error = 0; 191 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 192 LOCAL_DAILYPW, ors_gl.dailypw, 193 193 LOCAL_REMOTE_HOST, ors_gl.remote_host, 194 LOCAL_PROBE_SELECT, probe_id, 195 NULL)) { 196 quit_with_error(ORS_export_error("Server communication failed (select_probe)")); 197 } 198 199 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 194 LOCAL_PROBE_SELECT, probe_id, 195 NULL)) { 196 quit_with_error(ORS_export_error("Server communication failed (select_probe)")); 197 } 198 199 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 200 200 LOCAL_ERROR, &locs_error, 201 201 NULL)) { 202 quit_with_error(ORS_export_error("Server communication failed (select_probe2)")); 202 quit_with_error(ORS_export_error("Server communication failed (select_probe2)")); 203 203 } 204 204 OC_server_error_if_not_empty(locs_error); … … 215 215 delete result.data; 216 216 217 char *locs_error = 0; 218 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 219 LOCAL_DAILYPW, ors_gl.dailypw, 217 char *locs_error = 0; 218 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 219 LOCAL_DAILYPW, ors_gl.dailypw, 220 220 LOCAL_REMOTE_HOST, ors_gl.remote_host, 221 LOCAL_PROBE_LIST_TYPE, 10, 222 LOCAL_PROBE_LIST_MAX_COUNT, max_count, 223 NULL)) { 224 quit_with_error(ORS_export_error("Server communication failed (probe_query)")); 225 } 226 227 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 228 LOCAL_PROBE_QUERY, &result, 221 LOCAL_PROBE_LIST_TYPE, 10, 222 LOCAL_PROBE_LIST_MAX_COUNT, max_count, 223 NULL)) { 224 quit_with_error(ORS_export_error("Server communication failed (probe_query)")); 225 } 226 227 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 228 LOCAL_PROBE_QUERY, &result, 229 229 LOCAL_ERROR, &locs_error, 230 230 NULL)) { 231 quit_with_error(ORS_export_error("Server communication failed (probe_query2)")); 231 quit_with_error(ORS_export_error("Server communication failed (probe_query2)")); 232 232 } 233 233 OC_server_error_if_not_empty(locs_error); … … 241 241 char * OC_get_probe_list(int type, int count) { 242 242 243 char *locs_error = 0; 243 char *locs_error = 0; 244 244 static bytestring result = {0,0}; 245 245 delete result.data; 246 246 247 247 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 248 LOCAL_PROBE_LIST_TYPE, type, 249 LOCAL_PROBE_LIST_MAX_COUNT, count, 250 NULL)) { 251 quit_with_error(ORS_export_error("Server communication failed (get_probe_list)")); 252 } 253 254 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 248 LOCAL_PROBE_LIST_TYPE, type, 249 LOCAL_PROBE_LIST_MAX_COUNT, count, 250 NULL)) { 251 quit_with_error(ORS_export_error("Server communication failed (get_probe_list)")); 252 } 253 254 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 255 255 LOCAL_GET_PROBE_LIST, &result, 256 256 LOCAL_ERROR, &locs_error, 257 257 NULL)) { 258 quit_with_error(ORS_export_error("Server communication failed (get_probe_list2)")); 258 quit_with_error(ORS_export_error("Server communication failed (get_probe_list2)")); 259 259 } 260 260 OC_server_error_if_not_empty(locs_error); … … 267 267 *****************************************************************************/ 268 268 OC_pdb_list *OC_create_pdb_list_elem(void) { 269 269 270 270 OC_pdb_list *THIS = (OC_pdb_list *)calloc(sizeof(OC_pdb_list), 1); 271 271 if(!THIS) quit_with_error(ORS_export_error("Malloc error in OC_create_pdb_list_elem!")); 272 return THIS; 272 return THIS; 273 273 } 274 274 … … 377 377 } 378 378 pdb_list_elem = OC_create_pdb_list_elem(); 379 379 380 380 tmp = strtok(buffer,","); // extract section/name or name 381 381 if (strchr(tmp,'/')) { … … 414 414 415 415 // printf("name=%s, type=%s, width=%i <BR>",pdb_list_elem->name, pdb_list_elem->type, pdb_list_elem->width); 416 416 417 417 OC_pdb_list_insert(&ors_gl.pdb_list, pdb_list_elem); // put element into list 418 418 } … … 425 425 *****************************************************************************/ 426 426 void OC_clear_pdb_fields_in_server(void) { 427 char *locs_error = 0; 427 char *locs_error = 0; 428 428 char *dummy; 429 429 430 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 430 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 431 431 LOCAL_CLEAR_PROBE_FIELDS, &dummy, 432 432 LOCAL_ERROR, &locs_error, 433 433 NULL)) { 434 quit_with_error(ORS_export_error("Server communication failed (clear_pdb_fields)")); 434 quit_with_error(ORS_export_error("Server communication failed (clear_pdb_fields)")); 435 435 } 436 436 OC_server_error_if_not_empty(locs_error); … … 601 601 void OC_probe_user_transfer(char *from_userpath, char *to_userpath, char *probe_id) { 602 602 603 char *locs_error = 0; 604 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 605 LOCAL_DAILYPW, ors_gl.dailypw, 603 char *locs_error = 0; 604 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 605 LOCAL_DAILYPW, ors_gl.dailypw, 606 606 LOCAL_REMOTE_HOST, ors_gl.remote_host, 607 607 LOCAL_SEL_USERPATH, from_userpath, 608 LOCAL_PROBE_USER_TRANSFER, to_userpath, 609 NULL)) { 610 quit_with_error(ORS_export_error("Server communication failed (probe_transfer)")); 611 } 612 613 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 608 LOCAL_PROBE_USER_TRANSFER, to_userpath, 609 NULL)) { 610 quit_with_error(ORS_export_error("Server communication failed (probe_transfer)")); 611 } 612 613 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 614 614 LOCAL_ERROR, &locs_error, 615 615 NULL)) { 616 quit_with_error(ORS_export_error("Server communication failed (probe_transfer2)")); 617 } 618 OC_server_error_if_not_empty(locs_error); 619 } 616 quit_with_error(ORS_export_error("Server communication failed (probe_transfer2)")); 617 } 618 OC_server_error_if_not_empty(locs_error); 619 } -
trunk/ORS_CGI/ORS_C_scripts.cxx
r241 r655 2 2 # include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <ctype.h> … … 34 34 35 35 FILE *ors_tcp_open(char *mach_name, int socket_id) { 36 36 37 37 int so; 38 38 struct in_addr addr; /* union -> u_long */ … … 109 109 int i; 110 110 register int c; 111 while ( (c = getc(fd)) != EOF) GBS_chrcat(memfile,c); 111 while ( (c = getc(fd)) != EOF) GBS_chrcat(memfile,c); 112 112 int size = GBS_memoffset(memfile); // sizeof data 113 113 char *data = GBS_strclose(memfile,0); 114 // ** Now I would like to use perl, instead I have to use this ugly C 114 // ** Now I would like to use perl, instead I have to use this ugly C 115 115 // Lets check the content type first 116 116 char *nl = strchr(data,'\n'); … … 127 127 if ( !ORS_strncasecmp(data,"ascii")){ 128 128 if (!source_is_java) printf("Content-type: text/plain\n\n%s",nl); 129 else printf("A%s",nl); // write ASCII-TAG + DATA 129 else printf("A%s",nl); // write ASCII-TAG + DATA 130 130 return 0; 131 131 }else if ( !ORS_strncasecmp(data,"error")){ 132 132 if (!source_is_java) printf("Content-type: text/plain\n\n%s",nl); 133 else printf("E%s",nl); // write ASCII-TAG + DATA 133 else printf("E%s",nl); // write ASCII-TAG + DATA 134 134 return 0; 135 135 }else if ( !ORS_strncasecmp(data,"form")){ 136 136 return ors_form_2_java(nl); // parse the form that means removing all spaces!! 137 137 }else if ( !ORS_strncasecmp(data,"link")){ 138 printf("l%s",nl); // write ASCII-TAG + DATA 138 printf("l%s",nl); // write ASCII-TAG + DATA 139 139 return 0; 140 140 }else if ( !ORS_strncasecmp(data,"ovp/")){ … … 163 163 } 164 164 ors_ovp_2_java(data+4,nl,tree,out); 165 fclose(out); 165 fclose(out); 166 166 printf("Goto the java window and press 'Get last netscape query'\n"); 167 167 }else{ … … 221 221 } 222 222 223 GB_ERROR 223 GB_ERROR 224 224 ORS_C_exec_script(char *tree, char *command) 225 225 { -
trunk/ORS_CGI/ORS_C_user.cxx
r2 r655 1 /* 1 /* 2 2 ################################# 3 3 # # … … 10 10 #include <stdlib.h> 11 11 #include <memory.h> 12 #include <malloc.h>12 // #include <malloc.h> 13 13 #include <string.h> 14 14 #include <arbdb.h> … … 28 28 void OC_save_userdb(void) { 29 29 30 char *locs_error = 0; 31 32 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 33 LOCAL_DAILYPW, ors_gl.dailypw, 34 LOCAL_REMOTE_HOST, ors_gl.remote_host, 35 LOCAL_SAVE_USERDB, "", 36 NULL)) { 37 quit_with_error(ORS_export_error("Server communication failed (save_userdb)")); 38 } 39 40 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 41 LOCAL_ERROR , &locs_error, 42 NULL)) { 43 quit_with_error(ORS_export_error("Server communication failed (save_userdb2)")); 30 char *locs_error = 0; 31 32 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 33 LOCAL_DAILYPW, ors_gl.dailypw, 34 LOCAL_REMOTE_HOST, ors_gl.remote_host, 35 LOCAL_SAVE_USERDB, "", 36 NULL)) { 37 quit_with_error(ORS_export_error("Server communication failed (save_userdb)")); 38 } 39 40 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 41 LOCAL_ERROR , &locs_error, 42 NULL)) { 43 quit_with_error(ORS_export_error("Server communication failed (save_userdb2)")); 44 44 } 45 45 OC_server_error_if_not_empty(locs_error); … … 52 52 void OC_login_user(char * password) { 53 53 54 char *locs_error = 0; 54 char *locs_error = 0; 55 55 ors_gl.dailypw = 0; // server might free variable 56 56 static char *crypted_pw = 0; … … 60 60 61 61 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 62 LOCAL_USERPATH, ors_gl.userpath, 63 LOCAL_PASSWORD, crypted_pw, 64 LOCAL_REMOTE_HOST, ors_gl.remote_host, 65 LOCAL_REMOTE_USER, ors_gl.remote_user, 62 LOCAL_USERPATH, ors_gl.userpath, 63 LOCAL_PASSWORD, crypted_pw, 64 LOCAL_REMOTE_HOST, ors_gl.remote_host, 65 LOCAL_REMOTE_USER, ors_gl.remote_user, 66 66 LOCAL_DEBUG, ors_gl.debug, NULL)) { 67 quit_with_error(ORS_export_error("Server communication failed (login_user1)")); 68 } 69 70 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 67 quit_with_error(ORS_export_error("Server communication failed (login_user1)")); 68 } 69 70 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 71 71 LOCAL_CALC_DAILYPW, &ors_gl.dailypw, 72 72 LOCAL_USERNAME, &ors_gl.username, … … 84 84 void OC_logout_user(void) { 85 85 86 char *locs_error = 0; 86 char *locs_error = 0; 87 87 88 88 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 89 89 LOCAL_LOGOUT_USER, ors_gl.dailypw, 90 90 NULL)) { 91 quit_with_error(ORS_export_error("Server communication failed (logout1)")); 92 } 93 94 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 91 quit_with_error(ORS_export_error("Server communication failed (logout1)")); 92 } 93 94 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 95 95 LOCAL_ERROR , &locs_error, 96 96 NULL)) { … … 108 108 void OC_dailypw_2_userpath(void) { 109 109 110 char *locs_error = 0; 111 112 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 113 LOCAL_DAILYPW, ors_gl.dailypw, 114 LOCAL_REMOTE_HOST, ors_gl.remote_host, 115 NULL)) { 116 quit_with_error(ORS_export_error("Server communication failed (3)")); 117 } 118 119 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 110 char *locs_error = 0; 111 112 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 113 LOCAL_DAILYPW, ors_gl.dailypw, 114 LOCAL_REMOTE_HOST, ors_gl.remote_host, 115 NULL)) { 116 quit_with_error(ORS_export_error("Server communication failed (3)")); 117 } 118 119 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 120 120 LOCAL_DAILYPW_2_USERPATH, &ors_gl.userpath, 121 121 LOCAL_USERNAME, &ors_gl.username, … … 134 134 } 135 135 // too many fields (>=16) 136 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 136 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 137 137 LOCAL_MAX_USER_DEPTH, &ors_gl.max_user_depth, 138 138 LOCAL_IS_AUTHOR, &ors_gl.is_author, … … 153 153 void OC_get_sel_userdata_from_server(void) { 154 154 155 char *locs_error = 0; 155 char *locs_error = 0; 156 156 157 157 // at creation time there is no sel_userpath 158 158 // --> we only set init values 159 if (!ors_gl.sel_userpath) { 159 if (!ors_gl.sel_userpath) { 160 160 if (ors_gl.sel_user) { 161 if (!ors_gl.sel_par_userpath) 161 if (!ors_gl.sel_par_userpath) 162 162 ors_gl.sel_par_userpath = strdup(ors_gl.userpath); 163 163 ors_gl.sel_pub_exist_max = strdup(ors_gl.sel_user); … … 168 168 169 169 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 170 LOCAL_DAILYPW, ors_gl.dailypw, 171 LOCAL_REMOTE_HOST, ors_gl.remote_host, 172 LOCAL_SEL_USERPATH, ors_gl.sel_userpath, 173 NULL)) { 174 quit_with_error(ORS_export_error("Server communication failed (dpw2sel_ud1)")); 175 } 176 177 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 170 LOCAL_DAILYPW, ors_gl.dailypw, 171 LOCAL_REMOTE_HOST, ors_gl.remote_host, 172 LOCAL_SEL_USERPATH, ors_gl.sel_userpath, 173 NULL)) { 174 quit_with_error(ORS_export_error("Server communication failed (dpw2sel_ud1)")); 175 } 176 177 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 178 178 LOCAL_GET_SEL_USERDATA, &ors_gl.userpath, 179 179 // LOCAL_USERNAME, &ors_gl.username, … … 189 189 quit_with_error(ORS_export_error("Server communication failed (dpw2sel_ud2)")); 190 190 } 191 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 191 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 192 192 LOCAL_SEL_MAX_USERS, &ors_gl.sel_max_users, 193 193 LOCAL_SEL_MAX_USER_DEPTH, &ors_gl.sel_max_user_depth, … … 215 215 //if (!ors_gl.sel_user || !*ors_gl.sel_user) { // only calculate sel_user when not read from cgi_var 216 216 delete ors_gl.sel_user; 217 if (pos < ors_gl.sel_userpath + strlen(ors_gl.sel_userpath) - 1) 217 if (pos < ors_gl.sel_userpath + strlen(ors_gl.sel_userpath) - 1) 218 218 ors_gl.sel_user = strdup(pos + 1); 219 else 219 else 220 220 ors_gl.sel_user = strdup(ors_gl.sel_userpath); 221 221 //} … … 237 237 char * OC_read_user_field(char *sel_userpath, char *fieldname) { 238 238 239 char *locs_error = 0; 239 char *locs_error = 0; 240 240 char *field_data; 241 241 242 if (!sel_userpath) quit_with_error(ORS_export_error("read_user_field: sel_userpath == (null)")); 243 244 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 245 LOCAL_DAILYPW, ors_gl.dailypw, 246 LOCAL_REMOTE_HOST, ors_gl.remote_host, 247 LOCAL_SEL_USERPATH, sel_userpath, 248 LOCAL_FIELDNAME, fieldname, 249 NULL)) { 250 quit_with_error(ORS_export_error("Server communication failed (10)")); 251 } 252 253 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 242 if (!sel_userpath) quit_with_error(ORS_export_error("read_user_field: sel_userpath == (null)")); 243 244 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 245 LOCAL_DAILYPW, ors_gl.dailypw, 246 LOCAL_REMOTE_HOST, ors_gl.remote_host, 247 LOCAL_SEL_USERPATH, sel_userpath, 248 LOCAL_FIELDNAME, fieldname, 249 NULL)) { 250 quit_with_error(ORS_export_error("Server communication failed (10)")); 251 } 252 253 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 254 254 LOCAL_READ_USER_FIELD, &field_data, 255 255 LOCAL_ERROR , &locs_error, … … 264 264 *****************************************************************************/ 265 265 char * list_of_users(char *keyword) { 266 char *locs_error = 0; 266 char *locs_error = 0; 267 267 char *list; 268 268 269 if (!ors_gl.userpath) quit_with_error(ORS_export_error("Userpath not set!!")); 269 if (!ors_gl.userpath) quit_with_error(ORS_export_error("Userpath not set!!")); 270 270 if (!ors_gl.sel_userpath) ors_gl.sel_userpath=""; // not needed 271 if (!keyword) quit_with_error(ORS_export_error("List Type keyword not set!!")); 272 273 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 274 LOCAL_USERPATH, ors_gl.userpath, 275 LOCAL_SEL_USERPATH, ors_gl.sel_userpath, 271 if (!keyword) quit_with_error(ORS_export_error("List Type keyword not set!!")); 272 273 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, 274 LOCAL_USERPATH, ors_gl.userpath, 275 LOCAL_SEL_USERPATH, ors_gl.sel_userpath, 276 276 LOCAL_LIST_TYPE, keyword, 277 277 NULL)) { 278 quit_with_error(ORS_export_error("Server communication failed (l_of_su1)")); 279 } 280 281 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 278 quit_with_error(ORS_export_error("Server communication failed (l_of_su1)")); 279 } 280 281 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 282 282 LOCAL_LIST_OF_USERS, &list, 283 283 LOCAL_ERROR, &locs_error, … … 293 293 void work_on_user(void) { 294 294 char *locs_error = 0, *dummy=0; 295 if (!ors_gl.userpath) quit_with_error(ORS_export_error("Userpath not set!!")); 295 if (!ors_gl.userpath) quit_with_error(ORS_export_error("Userpath not set!!")); 296 296 297 297 static char *crypted_pw = 0; … … 312 312 LOCAL_WORK_ON_USER, "", 313 313 NULL)) { 314 quit_with_error(ORS_export_error("Server communication failed (work_on_user1)")); 315 } 316 317 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 314 quit_with_error(ORS_export_error("Server communication failed (work_on_user1)")); 315 } 316 317 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 318 318 LOCAL_ERROR , &locs_error, 319 319 NULL)) { … … 334 334 char *locs_error = 0, *dummy=0; 335 335 336 if (!ors_gl.userpath) quit_with_error(ORS_export_error("Userpath not set!!")); 336 if (!ors_gl.userpath) quit_with_error(ORS_export_error("Userpath not set!!")); 337 337 338 338 if (!strcasecmp(action,"CREATE") || !strcasecmp(action,"MODIFY")) { 339 339 340 if (!ors_gl.sel_password) ors_gl.sel_password =""; 341 if (!ors_gl.sel_mail_addr) ors_gl.sel_mail_addr=""; 342 if (!ors_gl.sel_user_info) ors_gl.sel_user_info=""; 343 if (!ors_gl.sel_username) ors_gl.sel_username =""; 340 if (!ors_gl.sel_password) ors_gl.sel_password =""; 341 if (!ors_gl.sel_mail_addr) ors_gl.sel_mail_addr=""; 342 if (!ors_gl.sel_user_info) ors_gl.sel_user_info=""; 343 if (!ors_gl.sel_username) ors_gl.sel_username =""; 344 344 345 345 static char *crypted_pw = 0; … … 351 351 *********************************************************************/ 352 352 if (!strcasecmp(action,"CREATE")) { 353 if (!ors_gl.sel_user) quit_with_error(ORS_export_error("Sel_User not set!!")); 354 if (!ors_gl.sel_par_userpath) quit_with_error(ORS_export_error("Sel_Par_Userpath not set!!")); 355 if (!*(ors_gl.sel_username)) quit_with_error(ORS_export_error("You must supply a full name.")); 353 if (!ors_gl.sel_user) quit_with_error(ORS_export_error("Sel_User not set!!")); 354 if (!ors_gl.sel_par_userpath) quit_with_error(ORS_export_error("Sel_Par_Userpath not set!!")); 355 if (!*(ors_gl.sel_username)) quit_with_error(ORS_export_error("You must supply a full name.")); 356 356 if (!*(ors_gl.sel_password)) quit_with_error(ORS_export_error("You must supply a password!")); 357 357 if (strlen(ors_gl.sel_password) < PASSWORD_MIN_LENGTH && !ors_gl.is_superuser) … … 370 370 LOCAL_SEL_PUB_CONTENT_MAX,ors_gl.sel_pub_content_max, 371 371 NULL)) { 372 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user1)")); 372 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user1)")); 373 373 } 374 374 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, … … 380 380 LOCAL_WORK_ON_SEL_USER, action, 381 381 NULL)) { 382 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user1)")); 383 } 384 385 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 382 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user1)")); 383 } 384 385 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 386 386 LOCAL_ERROR , &locs_error, 387 387 NULL)) { … … 395 395 *********************************************************************/ 396 396 else if (!strcasecmp(action,"MODIFY")) { 397 if (!ors_gl.sel_userpath) quit_with_error(ORS_export_error("Sel_Userpath not set!!")); 397 if (!ors_gl.sel_userpath) quit_with_error(ORS_export_error("Sel_Userpath not set!!")); 398 398 399 399 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, … … 410 410 LOCAL_SEL_PUB_CONTENT_MAX,ors_gl.sel_pub_content_max, 411 411 NULL)) { 412 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user5)")); 412 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user5)")); 413 413 } 414 414 if (aisc_nput(ors_gl.link, ORS_LOCAL, ors_gl.locs, … … 420 420 LOCAL_WORK_ON_SEL_USER, action, 421 421 NULL)) { 422 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user3)")); 423 } 424 425 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 422 quit_with_error(ORS_export_error("Server communication failed (work_on_sel_user3)")); 423 } 424 425 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 426 426 LOCAL_ERROR , &locs_error, 427 427 NULL)) { … … 441 441 LOCAL_WORK_ON_SEL_USER, action, 442 442 NULL)) { 443 quit_with_error(ORS_export_error("Server communication failed (work_on_user5)")); 444 } 445 446 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 443 quit_with_error(ORS_export_error("Server communication failed (work_on_user5)")); 444 } 445 446 if (aisc_get(ors_gl.link, ORS_LOCAL, ors_gl.locs, 447 447 LOCAL_ERROR , &locs_error, 448 448 NULL)) { -
trunk/ORS_CGI/ORS_lib.cxx
r2 r655 3 3 #include <unistd.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <string.h> 7 7 #include <arbdb.h> … … 61 61 // sprintf (buffer,"ORS ERROR: "); 62 62 p += strlen(p); 63 va_start(parg,templat); 63 va_start(parg,templat); 64 64 65 65 vsprintf(p,templat,parg); … … 77 77 va_list parg; 78 78 p += strlen(p); 79 va_start(parg,templat); 79 va_start(parg,templat); 80 80 81 81 vsprintf(p,templat,parg); … … 88 88 Time & Date Strings 89 89 type determines output format 90 time = desired time/date value or 0 90 time = desired time/date value or 0 91 91 ********************************************************************************/ 92 92 char *ORS_time_and_date_string(int type, long time) { … … 133 133 *******************************************************/ 134 134 int ORS_strncase_tail_cmp(char *str1, char *str2) { 135 135 136 136 if (!str1 || !str2) return 1; 137 137 … … 143 143 *******************************************************/ 144 144 int ORS_strncasecmp(char *str1, char *str2) { 145 145 146 146 if (!str1 || !str2) return 1; 147 147 … … 177 177 char *pos = buffer; 178 178 int len; 179 179 180 180 if (!word || !buffer) return 0; 181 181 … … 184 184 pos = strstr(pos, word); 185 185 if (!pos) break; 186 if ( (pos == buffer || *(pos-1) == seperator) && (*(pos+len) == seperator || *(pos+len) == 0 ) ) 186 if ( (pos == buffer || *(pos-1) == seperator) && (*(pos+len) == seperator || *(pos+len) == 0 ) ) 187 187 return 1; // found it! 188 188 pos++; … … 276 276 while (*pos) { 277 277 switch(*pos) { 278 case 'G': 279 case 'C': 278 case 'G': 279 case 'C': 280 280 case 'S': min++; break; 281 281 default: break; … … 289 289 while (*pos) { 290 290 switch(*pos) { 291 case 'G': 292 case 'C': 293 case 'M': 294 case 'R': 295 case 'S': 296 case 'Y': 297 case 'K': 298 case 'V': 299 case 'H': 300 case 'D': 301 case 'B': 302 case 'X': 291 case 'G': 292 case 'C': 293 case 'M': 294 case 'R': 295 case 'S': 296 case 'Y': 297 case 'K': 298 case 'V': 299 case 'H': 300 case 'D': 301 case 'B': 302 case 'X': 303 303 case 'N': max++; break; 304 304 default: break; … … 313 313 314 314 /****************************************************** 315 STRCMP: can compare NULL-pointers! 315 STRCMP: can compare NULL-pointers! 316 316 NULL == NULL 317 317 NULL == "" … … 361 361 362 362 if (!user1 || !*user1 || !user2 || !*user2) return 0; 363 363 364 364 if (!strcmp(user1,ROOT_USERPATH)) return 1; // root ist everybody's father 365 365 int len1=strlen(user1); -
trunk/ORS_COM/ORS_lib.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <arbdb.h> … … 59 59 // sprintf (buffer,"ORS ERROR: "); 60 60 p += strlen(p); 61 va_start(parg,templat); 61 va_start(parg,templat); 62 62 63 63 vsprintf(p,templat,parg); … … 75 75 va_list parg; 76 76 p += strlen(p); 77 va_start(parg,templat); 77 va_start(parg,templat); 78 78 79 79 vsprintf(p,templat,parg); … … 86 86 Time & Date Strings 87 87 type determines output format 88 time = desired time/date value or 0 88 time = desired time/date value or 0 89 89 ********************************************************************************/ 90 90 char *ORS_time_and_date_string(int type, long time) { … … 131 131 *******************************************************/ 132 132 int ORS_strncase_tail_cmp(char *str1, char *str2) { 133 133 134 134 if (!str1 || !str2) return 1; 135 135 … … 165 165 char *pos = buffer; 166 166 int len; 167 167 168 168 if (!word || !buffer) return 0; 169 169 … … 172 172 pos = strstr(pos, word); 173 173 if (!pos) break; 174 if ( (pos == buffer || *(pos-1) == seperator) && (*(pos+len) == seperator || *(pos+len) == 0 ) ) 174 if ( (pos == buffer || *(pos-1) == seperator) && (*(pos+len) == seperator || *(pos+len) == 0 ) ) 175 175 return 1; // found it! 176 176 pos++; … … 264 264 while (*pos) { 265 265 switch(*pos) { 266 case 'G': 267 case 'C': 266 case 'G': 267 case 'C': 268 268 case 'S': min++; break; 269 269 default: break; … … 277 277 while (*pos) { 278 278 switch(*pos) { 279 case 'G': 280 case 'C': 281 case 'M': 282 case 'R': 283 case 'S': 284 case 'Y': 285 case 'K': 286 case 'V': 287 case 'H': 288 case 'D': 289 case 'B': 290 case 'X': 279 case 'G': 280 case 'C': 281 case 'M': 282 case 'R': 283 case 'S': 284 case 'Y': 285 case 'K': 286 case 'V': 287 case 'H': 288 case 'D': 289 case 'B': 290 case 'X': 291 291 case 'N': max++; break; 292 292 default: break; … … 301 301 302 302 /****************************************************** 303 STRCMP: can compare NULL-pointers! 303 STRCMP: can compare NULL-pointers! 304 304 NULL == NULL 305 305 NULL == "" … … 349 349 350 350 if (!user1 || !*user1 || !user2 || !*user2) return 0; 351 351 352 352 if (!strcmp(user1,ROOT_USERPATH)) return 1; // root ist everybody's father 353 353 int len1=strlen(user1); -
trunk/ORS_SERVER/ORS_S_probedb.cxx
r2 r655 1 /* 1 /* 2 2 ################################# 3 3 # # … … 12 12 #include <memory.h> 13 13 14 #include <malloc.h>14 // #include <malloc.h> 15 15 #include <math.h> 16 16 … … 112 112 open the probe database 113 113 *************************************************************************************/ 114 GB_ERROR OS_open_probedb(void){ 115 116 char *name = ORS_read_a_line_in_a_file(ORS_LIB_PATH "CONFIG","PROBE_DB"); 114 GB_ERROR OS_open_probedb(void){ 115 116 char *name = ORS_read_a_line_in_a_file(ORS_LIB_PATH "CONFIG","PROBE_DB"); 117 117 if (!name) ORS_export_error("Missing 'PROBE_DB' in '" ORS_LIB_PATH "CONFIG'"); 118 118 … … 273 273 WRITE PROBE FIELD INFORMATION into user database WITH EXISTING GB_PROBE 274 274 a non existing field is being created (if content is not empty) 275 return error message or NULL 275 return error message or NULL 276 276 no authorisation here! 277 277 *************************************************************************************/ … … 290 290 /************************************************************************************* 291 291 READ PROBE FIELD INFORMATION from user database WITH EXISTING GB_PROBE 292 return value or NULL 292 return value or NULL 293 293 no authorisation here! 294 294 *************************************************************************************/ … … 333 333 static char buffer[20]; 334 334 int next_probe_id; 335 335 336 336 GBDATA *gb_id = GB_search(gb_probedb, "next_probe_id", GB_INT); // creates field if not available 337 next_probe_id = GB_read_int(gb_id); 337 next_probe_id = GB_read_int(gb_id); 338 338 GB_write_int(gb_id, ++next_probe_id); 339 339 sprintf(buffer,"%i", next_probe_id); 340 340 341 341 return strdup(buffer); 342 342 } … … 412 412 413 413 gb_probe = GB_get_father(gb_probe_field); 414 414 415 415 // allowed to see existance? 416 416 gb_field = GB_find(gb_probe,"p_pub_exist",0,down_level); … … 418 418 read_data = GB_read_string(gb_field); 419 419 if (!OS_read_access_allowed(locs->userpath, read_data)) continue; 420 420 421 421 struct OS_probe *probe_struct = (struct OS_probe *)calloc(sizeof(struct OS_probe), 1); 422 422 probes[num_probes++] = probe_struct; 423 423 424 424 gb_field = GB_find(gb_probe,"probe_id",0,down_level); 425 425 if (gb_field) probe_struct->probe_id = GB_read_string(gb_field); 426 426 427 427 gb_field = GB_find(gb_probe,"p_author_date",0,down_level); //! creation date of this probe 428 428 if (gb_field) probe_struct->author_date = GB_read_string(gb_field); 429 429 430 430 gb_field = GB_find(gb_probe,"p_probe_name",0,down_level); //! name of this probe 431 431 if (gb_field) probe_struct->probe_name = GB_read_string(gb_field); 432 433 gb_field = GB_find(gb_probe,"p_probe_info",0,down_level); //! short description of probe 432 433 gb_field = GB_find(gb_probe,"p_probe_info",0,down_level); //! short description of probe 434 434 if (gb_field) probe_struct->probe_info = GB_read_string(gb_field); 435 435 … … 470 470 471 471 gb_probe = GB_get_father(gb_probe_field); 472 472 473 473 // allowed to see existance? 474 474 gb_field = GB_find(gb_probe,"p_pub_exist",0,down_level); … … 476 476 read_data = GB_read_string(gb_field); 477 477 if (!OS_read_access_allowed(locs->userpath, read_data)) continue; 478 478 479 479 struct OS_probe *probe_struct = (struct OS_probe *)calloc(sizeof(struct OS_probe), 1); 480 480 probes[num_probes++] = probe_struct; … … 482 482 gb_field = GB_find(gb_probe,"probe_id",0,down_level); 483 483 if (gb_field) probe_struct->probe_id = GB_read_string(gb_field); 484 484 485 485 gb_field = GB_find(gb_probe,"p_author",0,down_level); //! author of this probe 486 486 if (gb_field) probe_struct->author = GB_read_string(gb_field); 487 487 488 488 gb_field = GB_find(gb_probe,"p_probe_name",0,down_level); 489 489 if (gb_field) probe_struct->probe_name = GB_read_string(gb_field); 490 491 gb_field = GB_find(gb_probe,"p_probe_info",0,down_level); 490 491 gb_field = GB_find(gb_probe,"p_probe_info",0,down_level); 492 492 if (gb_field) probe_struct->probe_info = GB_read_string(gb_field); 493 493 … … 544 544 gb_probe; 545 545 gb_probe = GB_find(gb_probe, "probe", 0, this_level | search_next) ) { // search 1 level down but parallel 546 546 547 547 gb_field = GB_find(gb_probe,"p_pub_exist",0,down_level); 548 548 delete read_data; 549 549 read_data = GB_read_string(gb_field); 550 550 if (!OS_read_access_allowed(locs->userpath, read_data)) continue; 551 551 552 552 if (search_any_only) { 553 553 found_any=0; … … 580 580 if (locs->search_any_field && *locs->search_any_field && !found_any) continue; 581 581 } 582 583 582 583 584 584 struct OS_probe *probe_struct = (struct OS_probe *)calloc(sizeof(struct OS_probe), 1); 585 585 probes[num_probes++] = probe_struct; 586 586 587 587 gb_field = GB_find(gb_probe,"probe_id",0,down_level); 588 588 if (gb_field) probe_struct->probe_id = GB_read_string(gb_field); 589 589 590 590 gb_field = GB_find(gb_probe,"p_author",0,down_level); //! author of this probe 591 591 if (gb_field) probe_struct->author = GB_read_string(gb_field); 592 592 593 593 gb_field = GB_find(gb_probe,"p_probe_name",0,down_level); 594 594 if (gb_field) probe_struct->probe_name = GB_read_string(gb_field); 595 596 gb_field = GB_find(gb_probe,"p_probe_info",0,down_level); 595 596 gb_field = GB_find(gb_probe,"p_probe_info",0,down_level); 597 597 if (gb_field) probe_struct->probe_info = GB_read_string(gb_field); 598 598 … … 643 643 *****************************************************************************/ 644 644 //void OS_probe_change_of_userpath(char *old_userpath, char *new_userpath) { 645 // TODO: funktion wird gebraucht! 645 // TODO: funktion wird gebraucht! 646 646 //} 647 647 … … 678 678 gb_probe = GB_get_father(gb_probe_id); 679 679 } 680 680 681 681 for (pdb_elem = ors_main->pdb_list; pdb_elem; pdb_elem = OS_next_pdb_list_elem(ors_main->pdb_list, pdb_elem)) { 682 682 if (!pdb_elem->content) continue; … … 716 716 GBDATA *gb_probe_id = GB_find(gb_probedb,"probe_id",locs->probe_id,down_2_level); 717 717 if (!gb_probe_id) return 0; 718 718 719 719 GBDATA *gb_probe = GB_get_father(gb_probe_id); 720 720 //GBDATA *gb_field; … … 758 758 return total; 759 759 } 760 760 761 761 /************************************************************ 762 762 TRANSFER PROBES of one user to another … … 779 779 gb_probe_field; 780 780 gb_probe_field = GB_find(gb_probe, "p_author", from_userpath, down_level | search_next) ) { // search 1 level down but parallel 781 781 782 782 gb_probe = GB_get_father(gb_probe_field); 783 783 OS_write_gb_probe_info_string(gb_probe, "p_author", to_userpath); -
trunk/ORS_SERVER/ORS_lib.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <arbdb.h> … … 58 58 // sprintf (buffer,"ORS ERROR: "); 59 59 p += strlen(p); 60 va_start(parg,templat); 60 va_start(parg,templat); 61 61 62 62 vsprintf(p,templat,parg); … … 74 74 va_list parg; 75 75 p += strlen(p); 76 va_start(parg,templat); 76 va_start(parg,templat); 77 77 78 78 vsprintf(p,templat,parg); … … 85 85 Time & Date Strings 86 86 type determines output format 87 time = desired time/date value or 0 87 time = desired time/date value or 0 88 88 ********************************************************************************/ 89 89 char *ORS_time_and_date_string(int type, long time) { … … 130 130 *******************************************************/ 131 131 int ORS_strncase_tail_cmp(char *str1, char *str2) { 132 132 133 133 if (!str1 || !str2) return 1; 134 134 … … 164 164 char *pos = buffer; 165 165 int len; 166 166 167 167 if (!word || !buffer) return 0; 168 168 … … 171 171 pos = strstr(pos, word); 172 172 if (!pos) break; 173 if ( (pos == buffer || *(pos-1) == seperator) && (*(pos+len) == seperator || *(pos+len) == 0 ) ) 173 if ( (pos == buffer || *(pos-1) == seperator) && (*(pos+len) == seperator || *(pos+len) == 0 ) ) 174 174 return 1; // found it! 175 175 pos++; … … 263 263 while (*pos) { 264 264 switch(*pos) { 265 case 'G': 266 case 'C': 265 case 'G': 266 case 'C': 267 267 case 'S': min++; break; 268 268 default: break; … … 276 276 while (*pos) { 277 277 switch(*pos) { 278 case 'G': 279 case 'C': 280 case 'M': 281 case 'R': 282 case 'S': 283 case 'Y': 284 case 'K': 285 case 'V': 286 case 'H': 287 case 'D': 288 case 'B': 289 case 'X': 278 case 'G': 279 case 'C': 280 case 'M': 281 case 'R': 282 case 'S': 283 case 'Y': 284 case 'K': 285 case 'V': 286 case 'H': 287 case 'D': 288 case 'B': 289 case 'X': 290 290 case 'N': max++; break; 291 291 default: break; … … 300 300 301 301 /****************************************************** 302 STRCMP: can compare NULL-pointers! 302 STRCMP: can compare NULL-pointers! 303 303 NULL == NULL 304 304 NULL == "" … … 348 348 349 349 if (!user1 || !*user1 || !user2 || !*user2) return 0; 350 350 351 351 if (!strcmp(user1,ROOT_USERPATH)) return 1; // root ist everybody's father 352 352 int len1=strlen(user1); -
trunk/PARSIMONY/AP_main.cxx
r2 r655 1 1 #include <stdio.h> 2 2 #include <iostream.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <memory.h> 5 5 #include <math.h> … … 14 14 15 15 /********************************************* 16 AP_ERR 16 AP_ERR 17 17 *************************/ 18 18 … … 53 53 54 54 AP_ERR::AP_ERR (const char *pntr, const int core) 55 // setzt den Fehlertext 56 // bricht ab 55 // setzt den Fehlertext 56 // bricht ab 57 57 { 58 58 text = pntr; … … 85 85 if (stack) delete stack; 86 86 } 87 87 88 88 char *AP_main::open(char *db_server) 89 89 { … … 93 93 if (!gb_main) return (char *)GB_get_error(); 94 94 if (error) return error; 95 95 96 96 return 0; 97 97 } … … 111 111 return; 112 112 } 113 113 114 114 void AP_main::push(void) { 115 115 // if count > 1 the nodes are buffered more than once … … 129 129 return; 130 130 } 131 while ( (knoten = stack->pop()) ) { 131 while ( (knoten = stack->pop()) ) { 132 132 if (stack_level != knoten->stack_level) { 133 133 GB_internal_error("AP_main::pop","Error in stack_level"); … … 146 146 user_push_counter = 0; 147 147 } 148 return; 149 } 148 return; 149 } 150 150 151 151 void AP_main::clear(void) { 152 152 // removes count elements from the list 153 153 // because the current tree is used 154 // 154 // 155 155 // if stack_counter greater than last user_push then 156 156 // moves all not previous buffered nodes in the … … 190 190 new AP_ERR("AP_main::clear"); 191 191 } 192 } 192 } 193 193 stack_level --; 194 194 if (stack) user_push_counter = stack->last_user_buffer; … … 196 196 197 197 } 198 198 199 199 void AP_main::push_node(AP_tree * node,AP_STACK_MODE mode) { 200 200 // 201 // stores node 202 // 201 // stores node 202 // 203 203 if (!stack) { 204 204 if (mode & SEQUENCE) node->unhash_sequence(); … … 214 214 } 215 215 216 216 217 217 void AP_main::set_tree_root(AP_tree *new_root) { 218 218 // removes old root and sets it -
trunk/PARSIMONY/AP_tree_nlen.cxx
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h> 2 #include <stdlib.h> 3 // #include <malloc.h> 3 4 #include <string.h> 4 5 #include <iostream.h> … … 33 34 kernighan = AP_NONE; 34 35 sequence = NULL; 35 36 36 37 edge[0] = edge[1] = edge[2] = NULL; 37 38 index[0] = index[1] = index[2] = 0; 38 distance = INT_MAX; 39 40 // cout << "AP_tree_nlen-constructor\n"; 39 distance = INT_MAX; 40 41 // cout << "AP_tree_nlen-constructor\n"; 41 42 } 42 43 43 44 AP_tree_nlen::~AP_tree_nlen(void) 44 45 { 45 46 46 47 //cout << "AP_tree_nlen - destructor " << counter++ << '\n'; 47 48 48 49 } 49 50 … … 56 57 { 57 58 AP_UPDATE_FLAGS res = this->AP_tree::check_update(); 58 59 59 60 if (res == AP_UPDATE_RELOADED) 60 61 { … … 62 63 return AP_UPDATE_OK; 63 64 } 64 65 65 66 return res; 66 67 } 67 68 68 void AP_tree_nlen::copy(AP_tree_nlen *tree) 69 void AP_tree_nlen::copy(AP_tree_nlen *tree) 69 70 { 70 71 // like = operator 71 72 // but copies sequence if is leaf 72 73 73 74 this->is_leaf = tree->is_leaf; 74 75 this->leftlen = tree->leftlen; 75 76 this->rightlen = tree->rightlen; 76 77 this->gb_node = tree->gb_node; 77 78 if(tree->name != NULL) 78 79 if(tree->name != NULL) 79 80 { 80 81 this->name = strdup(tree->name); 81 82 } 82 else 83 else 83 84 { 84 85 this->name = NULL; 85 86 } 86 87 if (is_leaf == AP_TRUE) 88 { 89 if (tree->sequence) 87 88 if (is_leaf == AP_TRUE) 89 { 90 if (tree->sequence) 90 91 { 91 92 this->sequence = tree->sequence; 92 } 93 else 93 } 94 else 94 95 { 95 96 cout << "empty sequence at leaf"; … … 102 103 { 103 104 // return out << " (" << (const void*)(&node) << '=' << node.fullname() << ") "; 104 105 105 106 static int notTooDeep; 106 107 out << ' '; 108 107 108 out << ' '; 109 109 110 if (&node==NULL) 110 111 { 111 out << "NULL"; 112 out << "NULL"; 112 113 } 113 114 if (node.is_leaf) … … 115 116 out << ((void *)&node) << '(' << node.name << ')'; 116 117 } 117 else 118 else 118 119 { 119 120 if (notTooDeep) 120 121 { 121 122 out << ((void *)&node); 122 if (!node.father) out << " (ROOT)"; 123 if (!node.father) out << " (ROOT)"; 123 124 } 124 125 else 125 126 { 126 notTooDeep = 1; 127 128 out << "NODE(" << ((void *)&node); 129 127 notTooDeep = 1; 128 129 out << "NODE(" << ((void *)&node); 130 130 131 if (!node.father) 131 132 { 132 out << " (ROOT)"; 133 out << " (ROOT)"; 133 134 } 134 135 else 135 136 { 136 out << ", father=" << node.father; 137 } 138 139 out << ", leftson=" << node.leftson 140 << ", rightson=" << node.rightson 137 out << ", father=" << node.father; 138 } 139 140 out << ", leftson=" << node.leftson 141 << ", rightson=" << node.rightson 141 142 << ", edge[0]=" << *(node.edge[0]) 142 143 << ", edge[1]=" << *(node.edge[1]) … … 147 148 } 148 149 } 149 150 return out << ' '; 150 151 return out << ' '; 151 152 } 152 153 … … 165 166 int AP_tree_nlen::unusedEdge() const 166 167 { 167 int e; 168 169 for (e=0; e<3; e++) if (edge[e]==NULL) return e; 170 168 int e; 169 170 for (e=0; e<3; e++) if (edge[e]==NULL) return e; 171 171 172 cout << "No unused edge found at" << *this << '\n'; 172 return -1; 173 return -1; 173 174 } 174 175 175 176 AP_tree_edge* AP_tree_nlen::edgeTo(const AP_tree_nlen *neighbour) const 176 177 { 177 int e; 178 178 int e; 179 179 180 for (e=0; e<3; e++) 180 181 { 181 if (edge[e]!=NULL && edge[e]->node[1-index[e]]==neighbour) 182 if (edge[e]!=NULL && edge[e]->node[1-index[e]]==neighbour) 182 183 { 183 184 return edge[e]; 184 } 185 } 185 186 } 186 187 GB_CORE; 187 188 cout << "AP_tree_nlen::edgeTo: " << *this << "\nhas no edge to " << *neighbour << '\n'; 188 return NULL; 189 return NULL; 189 190 } 190 191 … … 200 201 void AP_tree_nlen::unlinkAllEdges(AP_tree_edge **edgePtr1, AP_tree_edge **edgePtr2, AP_tree_edge **edgePtr3) 201 202 { 202 assert(edge[0]!=NULL); 203 assert(edge[1]!=NULL); 204 assert(edge[2]!=NULL); 205 206 *edgePtr1 = edge[0]->unlink(); 207 *edgePtr2 = edge[1]->unlink(); 208 *edgePtr3 = edge[2]->unlink(); 203 assert(edge[0]!=NULL); 204 assert(edge[1]!=NULL); 205 assert(edge[2]!=NULL); 206 207 *edgePtr1 = edge[0]->unlink(); 208 *edgePtr2 = edge[1]->unlink(); 209 *edgePtr3 = edge[2]->unlink(); 209 210 } 210 211 211 212 void AP_tree_nlen::linkAllEdges(AP_tree_edge *edge1, AP_tree_edge *edge2, AP_tree_edge *edge3) 212 213 { 213 assert(edge[0]==NULL); 214 assert(edge[1]==NULL); 215 assert(edge[2]==NULL); 216 217 edge1->relink(this,Father()->Father() ? Father() : Brother()); 218 edge2->relink(this,Leftson()); 219 edge3->relink(this,Rightson()); 214 assert(edge[0]==NULL); 215 assert(edge[1]==NULL); 216 assert(edge[2]==NULL); 217 218 edge1->relink(this,Father()->Father() ? Father() : Brother()); 219 edge2->relink(this,Leftson()); 220 edge3->relink(this,Rightson()); 220 221 } 221 222 … … 243 244 // 244 245 // 245 246 246 247 AP_tree *pntr; 247 248 GB_ERROR error = 0; 248 AP_tree_nlen *newBrother = (AP_tree_nlen*)new_brother; 249 AP_tree_nlen *newBrother = (AP_tree_nlen*)new_brother; 249 250 AP_tree_edge *oldEdge; 250 251 // cout << "insert " << *this << "\nto new_brother " << *newBrother << '\n'; 252 251 252 // cout << "insert " << *this << "\nto new_brother " << *newBrother << '\n'; 253 253 254 // for (pntr = new_brother->father; pntr; pntr = pntr->father) 254 255 // { … … 258 259 // if (new_brother->father) ap_main->push_node(new_brother->father, BOTH); 259 260 // ap_main->push_node(new_brother, STRUCTURE); 260 261 ap_main->push_node(new_brother, STRUCTURE); 261 262 ap_main->push_node(new_brother, STRUCTURE); 262 263 263 264 if (new_brother->father) 264 265 { 265 ap_main->push_node(new_brother->father, BOTH); 266 ap_main->push_node(new_brother->father, BOTH); 266 267 for (pntr = new_brother->father->father; pntr; pntr = pntr->father) 267 268 { 268 ap_main->push_node(pntr, SEQUENCE); 269 } 270 269 ap_main->push_node(pntr, SEQUENCE); 270 } 271 271 272 if (new_brother->father->father) 272 273 { 273 274 oldEdge = newBrother->edgeTo(newBrother->Father())->unlink(); 274 275 error = this->AP_tree::insert(new_brother); 275 oldEdge->relink(Father(),Father()->Father()); 276 oldEdge->relink(Father(),Father()->Father()); 276 277 } 277 278 else // insert to son of root … … 281 282 oldEdge->relink(Father(),Father()->Brother()); 282 283 } 283 284 284 285 new AP_tree_edge(this,Father()); 285 286 new AP_tree_edge(Father(),newBrother); … … 288 289 { 289 290 AP_tree_nlen *lson = newBrother->Leftson(), 290 *rson = newBrother->Rightson(); 291 292 ap_main->push_node(lson, STRUCTURE); 291 *rson = newBrother->Rightson(); 292 293 ap_main->push_node(lson, STRUCTURE); 293 294 ap_main->push_node(rson, STRUCTURE); 294 295 oldEdge = lson->edgeTo(rson)->unlink(); 296 cout << "old Edge = " << oldEdge << '\n'; 297 295 296 oldEdge = lson->edgeTo(rson)->unlink(); 297 cout << "old Edge = " << oldEdge << '\n'; 298 298 299 error = this->AP_tree::insert(new_brother); 299 300 300 301 oldEdge->relink(this,newBrother); 301 new AP_tree_edge(newBrother,rson); 302 new AP_tree_edge(newBrother,rson); 302 303 new AP_tree_edge(newBrother,lson); 303 304 } 304 305 305 306 return error; 306 307 } … … 311 312 // 312 313 // Removes the node and its father from the tree: 313 // 314 // 314 315 // grandpa grandpa 315 316 // / / … … 321 322 // 322 323 // One of the edges is relinked between brother and grandpa. 323 // The other two edges are lost. This is not very relevant in respect to 324 // memory usage because very few remove()s are really performed - the majority 324 // The other two edges are lost. This is not very relevant in respect to 325 // memory usage because very few remove()s are really performed - the majority 325 326 // is undone by a pop(). 326 // In the last case the two unlinked edges will be re-used, cause their 327 // In the last case the two unlinked edges will be re-used, cause their 327 328 // memory location was stored in the tree-stack. 328 329 // … … 330 331 GB_ERROR error = 0; 331 332 AP_tree *pntr; 332 AP_tree_edge *oldEdge; 333 AP_tree_nlen *oldBrother = Brother(); 334 335 336 if (father == 0) 333 AP_tree_edge *oldEdge; 334 AP_tree_nlen *oldBrother = Brother(); 335 336 337 if (father == 0) 337 338 { 338 339 return (char *)GB_export_error("AP_tree_nlen::remove(void) Tried to remove ROOT "); 339 340 } 340 341 341 342 ap_main->push_node(this, STRUCTURE); 342 343 ap_main->push_node(brother(), STRUCTURE); 343 344 344 345 for (pntr = father->father; pntr; pntr = pntr->father) 345 346 { 346 347 ap_main->push_node(pntr, SEQUENCE); 347 348 } 348 349 349 350 if (father->father) 350 351 { 351 AP_tree_nlen *grandPa = Father()->Father(); 352 352 AP_tree_nlen *grandPa = Father()->Father(); 353 353 354 ap_main->push_node(father, BOTH); 354 355 ap_main->push_node(grandPa, STRUCTURE); 355 356 edgeTo(Father())->unlink(); 357 Father()->edgeTo(oldBrother)->unlink(); 358 356 357 edgeTo(Father())->unlink(); 358 Father()->edgeTo(oldBrother)->unlink(); 359 359 360 if (grandPa->father) 360 361 { 361 oldEdge = Father()->edgeTo(grandPa)->unlink(); 362 oldEdge = Father()->edgeTo(grandPa)->unlink(); 362 363 error = this->AP_tree::remove(); 363 oldEdge->relink(oldBrother,grandPa); 364 oldEdge->relink(oldBrother,grandPa); 364 365 } 365 366 else // remove grandson of root 366 367 { 367 AP_tree_nlen *uncle = Father()->Brother(); 368 ap_main->push_node(uncle,STRUCTURE); 369 370 oldEdge = Father()->edgeTo(uncle)->unlink(); 368 AP_tree_nlen *uncle = Father()->Brother(); 369 ap_main->push_node(uncle,STRUCTURE); 370 371 oldEdge = Father()->edgeTo(uncle)->unlink(); 371 372 error = this->AP_tree::remove(); 372 oldEdge->relink(oldBrother,uncle); 373 } 374 } 373 oldEdge->relink(oldBrother,uncle); 374 } 375 } 375 376 else // remove son of root 376 377 { 377 AP_tree_nlen *lson = Brother()->Leftson(); 378 AP_tree_nlen *lson = Brother()->Leftson(); 378 379 AP_tree_nlen *rson = Brother()->Rightson(); 379 380 ap_main->push_node(lson,STRUCTURE); 381 ap_main->push_node(rson,STRUCTURE); 380 381 ap_main->push_node(lson,STRUCTURE); 382 ap_main->push_node(rson,STRUCTURE); 382 383 ap_main->push_node(father, ROOT); 383 384 384 385 ap_main->set_tree_root(oldBrother); 385 386 // delete edgeTo(oldBrother); 386 387 // delete edgeTo(oldBrother); 387 388 oldBrother->edgeTo(lson)->unlink(); 388 // delete oldBrother->edgeTo(lson); 389 oldEdge = oldBrother->edgeTo(rson)->unlink(); 389 // delete oldBrother->edgeTo(lson); 390 oldEdge = oldBrother->edgeTo(rson)->unlink(); 390 391 error = this->AP_tree::remove(); 391 oldEdge->relink(lson,rson); 392 } 393 392 oldEdge->relink(lson,rson); 393 } 394 394 395 return error; 395 396 } … … 402 403 // mode AP_LEFT exchanges leftson with brother 403 404 // mode AP_RIGHT exchanges rightson with brother 404 405 405 406 AP_tree *pntr; 406 AP_tree_nlen *oldBrother, *movedSon; 407 GB_ERROR error = 0; 408 AP_tree_edge *edge1, *edge2; 409 407 AP_tree_nlen *oldBrother, *movedSon; 408 GB_ERROR error = 0; 409 AP_tree_edge *edge1, *edge2; 410 410 411 // cout << "swap" << *this << '\n'; 411 412 412 413 if (is_leaf == AP_TRUE) return AP_tree::swap_assymetric(mode); 413 414 if (father == 0) return AP_tree::swap_assymetric(mode); 414 415 415 416 oldBrother = Brother(); 416 417 417 418 switch (mode) 418 { 419 case AP_LEFT: movedSon = Leftson(); break; 419 { 420 case AP_LEFT: movedSon = Leftson(); break; 420 421 case AP_RIGHT: movedSon = Rightson(); break; 421 default: movedSon = NULL; break; 422 } 423 422 default: movedSon = NULL; break; 423 } 424 424 425 if (!father->father) 425 426 { … … 428 429 429 430 if (oldBrother->is_leaf == AP_TRUE) return 0; // no swap needed ! 430 431 AP_tree_nlen *nephew = oldBrother->Leftson(); 432 431 432 AP_tree_nlen *nephew = oldBrother->Leftson(); 433 433 434 ap_main->push_node(this, BOTH); 434 ap_main->push_node(movedSon,STRUCTURE); 435 ap_main->push_node(movedSon,STRUCTURE); 435 436 ap_main->push_node(father, SEQUENCE); 436 437 ap_main->push_node(nephew, STRUCTURE); 437 438 ap_main->push_node(oldBrother, BOTH); 438 439 edge1 = edgeTo(movedSon)->unlink(); 440 edge2 = oldBrother->edgeTo(nephew)->unlink(); 441 439 440 edge1 = edgeTo(movedSon)->unlink(); 441 edge2 = oldBrother->edgeTo(nephew)->unlink(); 442 442 443 error = this->AP_tree::swap_assymetric(mode); 443 444 444 445 edge1->relink(this,nephew); 445 edge2->relink(oldBrother,movedSon); 446 edge2->relink(oldBrother,movedSon); 446 447 } 447 448 else … … 450 451 ap_main->push_node(father, BOTH); 451 452 ap_main->push_node(oldBrother, STRUCTURE); 452 ap_main->push_node(movedSon,STRUCTURE); 453 453 ap_main->push_node(movedSon,STRUCTURE); 454 454 455 // from father to root buffer all sequences 455 456 for (pntr = father->father; pntr ; pntr = pntr->father) 456 457 for (pntr = father->father; pntr ; pntr = pntr->father) 457 458 { 458 459 ap_main->push_node(pntr, SEQUENCE); 459 460 } 460 461 edge1 = edgeTo(movedSon)->unlink(); 462 edge2 = Father()->edgeTo(oldBrother)->unlink(); 463 461 462 edge1 = edgeTo(movedSon)->unlink(); 463 edge2 = Father()->edgeTo(oldBrother)->unlink(); 464 464 465 error = AP_tree::swap_assymetric(mode); 465 466 edge1->relink(this,oldBrother); 467 edge2->relink(Father(),movedSon); 468 } 469 470 return error; 466 467 edge1->relink(this,oldBrother); 468 edge2->relink(Father(),movedSon); 469 } 470 471 return error; 471 472 } 472 473 … … 478 479 { 479 480 AP_tree *pntr; 480 481 481 482 // cout << "set_root" << *this << '\n'; 482 483 483 484 if (!father || !father->father) // already root 484 485 { 485 return 0; 486 } 487 486 return 0; 487 } 488 488 489 // from this to root buffer the nodes 489 490 490 491 ap_main->push_node(this , STRUCTURE); 491 492 AP_tree *old_brother = 0; 492 493 for (pntr = father; pntr->father; pntr = pntr->father) 493 494 for (pntr = father; pntr->father; pntr = pntr->father) 494 495 { 495 496 ap_main->push_node( pntr, BOTH); 496 497 old_brother= pntr; 497 498 } 498 499 499 500 AP_tree *old_root = pntr; 500 501 if (old_brother) 501 502 if (old_brother) 502 503 { 503 504 old_brother = old_brother->brother(); 504 505 ap_main->push_node( old_brother , STRUCTURE); 505 506 } 506 507 507 508 ap_main->push_node(old_root, ROOT); 508 509 509 510 return this->AP_tree::set_root(); 510 511 } … … 517 518 if ((*e1)->Age() > (*e2)->Age()) 518 519 { 519 AP_tree_edge *tmp = *e1; 520 *e1 = *e2; 521 *e2 = tmp; 522 } 523 } 524 520 AP_tree_edge *tmp = *e1; 521 *e1 = *e2; 522 *e2 = tmp; 523 } 524 } 525 525 526 GB_INLINE void sort(AP_tree_edge **e1, AP_tree_edge **e2, AP_tree_edge **e3) 526 527 { 527 sort(e1,e2); 528 sort(e2,e3); 529 sort(e1,e2); 528 sort(e1,e2); 529 sort(e2,e3); 530 sort(e1,e2); 530 531 } 531 532 … … 533 534 { 534 535 AP_tree *pntr; 535 536 536 537 // cout << "move" << *this << "to new_brother" << *((AP_tree_nlen*)new_brother) << rel_pos << '\n'; 537 538 if (!father) 538 539 if (!father) 539 540 { 540 541 AW_ERROR ("AP_tree_nlen::move: You cannot move the root"); 541 542 return "You cannot move the root"; 542 543 } 543 544 if (!new_brother->father) 544 545 if (!new_brother->father) 545 546 { 546 547 AW_ERROR ("AP_tree_nlen::move: You cannot move to the root"); 547 548 return "You cannot move to the root"; 548 549 } 549 550 550 551 ap_main->push_node(this , STRUCTURE); 551 552 ap_main->push_node(brother(), STRUCTURE); 552 553 if (father->father) 554 { 555 AP_tree *grandpa = father->father; 556 553 554 if (father->father) 555 { 556 AP_tree *grandpa = father->father; 557 557 558 ap_main->push_node(father , BOTH); 558 559 559 560 if (grandpa->father) 560 561 { 561 562 ap_main->push_node(grandpa, BOTH); 562 for (pntr = grandpa->father; pntr; pntr = pntr->father) 563 for (pntr = grandpa->father; pntr; pntr = pntr->father) 563 564 { 564 565 ap_main->push_node( pntr, SEQUENCE); … … 574 575 { 575 576 ap_main->push_node(father , ROOT); 576 577 577 578 if (!brother()->is_leaf) 578 579 { … … 581 582 } 582 583 } 583 584 584 585 ap_main->push_node(new_brother , STRUCTURE); 585 if (new_brother->father) 586 if (new_brother->father) 586 587 { 587 588 if (new_brother->father->father) … … 592 593 { 593 594 ap_main->push_node(new_brother->father , BOTH); 594 ap_main->push_node(new_brother->brother(), STRUCTURE); 595 } 596 597 for (pntr = new_brother->father->father; pntr; pntr = pntr->father) 595 ap_main->push_node(new_brother->brother(), STRUCTURE); 596 } 597 598 for (pntr = new_brother->father->father; pntr; pntr = pntr->father) 598 599 { 599 600 ap_main->push_node( pntr, SEQUENCE); 600 601 } 601 602 } 602 603 603 604 const char *res = "Da fehlt wohl was..."; 604 605 AP_tree_nlen *thisFather = Father(), … … 606 607 *grandFather = thisFather->Father(), 607 608 *oldBrother = Brother(), 608 *newBrothersFather = newBrother->Father(); 609 int edgesChange = ! (father==new_brother || 610 new_brother->father==this->father); 611 AP_tree_edge *e1,*e2,*e3,*e4; 612 609 *newBrothersFather = newBrother->Father(); 610 int edgesChange = ! (father==new_brother || 611 new_brother->father==this->father); 612 AP_tree_edge *e1,*e2,*e3,*e4; 613 613 614 if (edgesChange) 614 615 { … … 619 620 if(grandFather->Father()) 620 621 { 621 // cout << "son -> son of brother\n"; 622 623 thisFather->unlinkAllEdges(&e1,&e2,&e3); 624 e4 = newBrother->edgeTo(oldBrother)->unlink(); 625 622 // cout << "son -> son of brother\n"; 623 624 thisFather->unlinkAllEdges(&e1,&e2,&e3); 625 e4 = newBrother->edgeTo(oldBrother)->unlink(); 626 626 627 res = this->AP_tree::move(new_brother,rel_pos); 627 628 628 629 sort(&e1,&e2,&e3); // sort by age (e1==oldest edge) 629 630 e1->relink(oldBrother,grandFather); // use oldest edge at remove position 630 thisFather->linkAllEdges(e2,e3,e4); 631 thisFather->linkAllEdges(e2,e3,e4); 631 632 } 632 633 else // grandson of root -> son of brother 633 634 { 634 // cout << "grandson of root -> son of brother\n"; 635 636 AP_tree_nlen *uncle = thisFather->Brother(); 637 638 thisFather->unlinkAllEdges(&e1,&e2,&e3); 639 e4 = newBrother->edgeTo(oldBrother)->unlink(); 640 635 // cout << "grandson of root -> son of brother\n"; 636 637 AP_tree_nlen *uncle = thisFather->Brother(); 638 639 thisFather->unlinkAllEdges(&e1,&e2,&e3); 640 e4 = newBrother->edgeTo(oldBrother)->unlink(); 641 641 642 res = this->AP_tree::move(new_brother,rel_pos); 642 643 643 644 sort(&e1,&e2,&e3); // sort by age (e1==oldest edge) 644 645 e1->relink(oldBrother,uncle); 645 thisFather->linkAllEdges(e2,e3,e4); 646 thisFather->linkAllEdges(e2,e3,e4); 646 647 } 647 648 } 648 649 else // son of root -> grandson of root 649 650 { 650 // cout << "son of root -> grandson of root\n"; 651 651 // cout << "son of root -> grandson of root\n"; 652 652 653 oldBrother->unlinkAllEdges(&e1,&e2,&e3); 653 654 res = this->AP_tree::move(new_brother,rel_pos); 654 thisFather->linkAllEdges(e1,e2,e3); 655 thisFather->linkAllEdges(e1,e2,e3); 655 656 } 656 657 } 657 658 else if (grandFather==newBrothersFather) // son -> brother of father 658 659 { 659 if (grandFather->father) 660 if (grandFather->father) 660 661 { 661 // cout << "son -> brother of father\n"; 662 663 thisFather->unlinkAllEdges(&e1,&e2,&e3); 664 e4 = grandFather->edgeTo(newBrother)->unlink(); 665 662 // cout << "son -> brother of father\n"; 663 664 thisFather->unlinkAllEdges(&e1,&e2,&e3); 665 e4 = grandFather->edgeTo(newBrother)->unlink(); 666 666 667 res = this->AP_tree::move(new_brother,rel_pos); 667 668 sort(&e1,&e2,&e3); 669 e1->relink(oldBrother,grandFather); 670 thisFather->linkAllEdges(e2,e3,e4); 668 669 sort(&e1,&e2,&e3); 670 e1->relink(oldBrother,grandFather); 671 thisFather->linkAllEdges(e2,e3,e4); 671 672 } 672 673 else 673 674 { 674 675 // no edges change if we move grandson of root -> son of root 675 676 676 677 res = this->AP_tree::move(new_brother,rel_pos); 677 678 } 678 679 } 679 else 680 { 681 // now we are sure, the minimal distance 680 else 681 { 682 // now we are sure, the minimal distance 682 683 // between 'this' and 'newBrother' is 4 edges 683 684 // or if the root-edge is between them, the 684 685 // minimal distance is 3 edges 685 686 686 687 if (!grandFather) // son of root 687 688 { 688 cout << "move son of root\n"; 689 689 cout << "move son of root\n"; 690 690 691 oldBrother->unlinkAllEdges(&e1,&e2,&e3); 691 692 e4 = newBrother->edgeTo(newBrothersFather)->unlink(); 692 693 693 694 res = this->AP_tree::move(new_brother,rel_pos); 694 695 sort(&e1,&e2,&e3); 695 696 sort(&e1,&e2,&e3); 696 697 e1->relink(oldBrother->Leftson(),oldBrother->Rightson()); // new root-edge 697 698 thisFather->linkAllEdges(e2,e3,e4); // old root … … 701 702 if (newBrothersFather->Father()->Father()==NULL) // grandson of root -> grandson of root 702 703 { 703 // cout << "grandson of root -> grandson of root\n"; 704 705 thisFather->unlinkAllEdges(&e1,&e2,&e3); 706 e4 = newBrother->edgeTo(newBrothersFather)->unlink(); 707 704 // cout << "grandson of root -> grandson of root\n"; 705 706 thisFather->unlinkAllEdges(&e1,&e2,&e3); 707 e4 = newBrother->edgeTo(newBrothersFather)->unlink(); 708 708 709 res = this->AP_tree::move(new_brother,rel_pos); 709 710 sort(&e1,&e2,&e3); 710 711 sort(&e1,&e2,&e3); 711 712 e1->relink(oldBrother,newBrothersFather); // new root-edge 712 thisFather->linkAllEdges(e2,e3,e4); 713 thisFather->linkAllEdges(e2,e3,e4); 713 714 } 714 715 else 715 716 { 716 // cout << "move grandson of root\n"; 717 718 AP_tree_nlen *uncle = thisFather->Brother(); 719 720 thisFather->unlinkAllEdges(&e1,&e2,&e3); 721 e4 = newBrother->edgeTo(newBrothersFather)->unlink(); 722 717 // cout << "move grandson of root\n"; 718 719 AP_tree_nlen *uncle = thisFather->Brother(); 720 721 thisFather->unlinkAllEdges(&e1,&e2,&e3); 722 e4 = newBrother->edgeTo(newBrothersFather)->unlink(); 723 723 724 res = this->AP_tree::move(new_brother,rel_pos); 724 725 sort(&e1,&e2,&e3); 725 726 sort(&e1,&e2,&e3); 726 727 e1->relink(oldBrother,uncle); 727 thisFather->linkAllEdges(e2,e3,e4); 728 } 729 } 730 else 728 thisFather->linkAllEdges(e2,e3,e4); 729 } 730 } 731 else 731 732 { 732 if (newBrothersFather->Father()==NULL) // move to son of root 733 if (newBrothersFather->Father()==NULL) // move to son of root 733 734 { 734 // cout << "Move to son of root\n"; 735 736 AP_tree_nlen *newBrothersBrother = newBrother->Brother(); 737 738 thisFather->unlinkAllEdges(&e1,&e2,&e3); 739 e4 = newBrother->edgeTo(newBrothersBrother)->unlink(); 740 735 // cout << "Move to son of root\n"; 736 737 AP_tree_nlen *newBrothersBrother = newBrother->Brother(); 738 739 thisFather->unlinkAllEdges(&e1,&e2,&e3); 740 e4 = newBrother->edgeTo(newBrothersBrother)->unlink(); 741 741 742 res = this->AP_tree::move(new_brother,rel_pos); 742 743 sort(&e1,&e2,&e3); 744 e1->relink(oldBrother,grandFather); 745 thisFather->linkAllEdges(e2,e3,e4); 743 744 sort(&e1,&e2,&e3); 745 e1->relink(oldBrother,grandFather); 746 thisFather->linkAllEdges(e2,e3,e4); 746 747 } 747 748 else // simple independent move 748 749 { 749 // cout << "Independet move\n"; 750 751 thisFather->unlinkAllEdges(&e1,&e2,&e3); 752 e4 = newBrother->edgeTo(newBrothersFather)->unlink(); 753 750 // cout << "Independet move\n"; 751 752 thisFather->unlinkAllEdges(&e1,&e2,&e3); 753 e4 = newBrother->edgeTo(newBrothersFather)->unlink(); 754 754 755 res = this->AP_tree::move(new_brother,rel_pos); 755 756 sort(&e1,&e2,&e3); 757 e1->relink(oldBrother,grandFather); 758 thisFather->linkAllEdges(e2,e3,e4); 756 757 sort(&e1,&e2,&e3); 758 e1->relink(oldBrother,grandFather); 759 thisFather->linkAllEdges(e2,e3,e4); 759 760 } 760 761 } … … 763 764 else // edgesChange==0 764 765 { 765 // cout << "No edges changed\n"; 766 // cout << "No edges changed\n"; 766 767 res = this->AP_tree::move(new_brother,rel_pos); 767 768 } 768 769 return res; 769 770 return res; 770 771 } 771 772 … … 796 797 //removes the current sequence 797 798 //(not leaf) 798 799 if (sequence != 0) 800 { 801 if (!is_leaf) 799 800 if (sequence != 0) 801 { 802 if (!is_leaf) 802 803 { 803 804 sequence->is_set_flag = AP_FALSE; 804 805 } 805 806 } 806 807 807 808 return; 808 809 } … … 813 814 // AP_FALSE if it is copied into the previous level 814 815 // according if user_buffer is greater than datum 815 816 // cout << "clear\n"; 817 816 817 // cout << "clear\n"; 818 818 819 AP_tree_buffer * buff; 819 820 AP_BOOL result; 820 821 821 822 if (!this->stack_level == datum) 822 823 { … … 824 825 return AP_FALSE; 825 826 } 826 827 827 828 buff = stack.pop(); 828 829 if (buff->controll == datum - 1 || user_buffer_count >= datum) 829 830 if (buff->controll == datum - 1 || user_buffer_count >= datum) 830 831 { 831 832 //previous node is buffered 832 833 if (buff->mode & SEQUENCE) 833 834 if (buff->mode & SEQUENCE) 834 835 { 835 836 delete buff->sequence; 836 837 } 837 838 838 839 stack_level = buff->controll; 839 840 delete buff; 840 841 result = AP_TRUE; 841 } 842 else 842 } 843 else 843 844 { 844 845 stack_level = datum - 1; … … 846 847 result = AP_FALSE; 847 848 } 848 849 849 850 return result; 850 851 } … … 853 854 AP_BOOL AP_tree_nlen::push(AP_STACK_MODE mode, unsigned long datum) 854 855 { 855 // according to mode 856 // according to mode 856 857 // tree_structure / sequence is buffered in the node 857 858 858 859 AP_tree_buffer *new_buff; 859 860 AP_BOOL ret; 860 861 861 862 if (is_leaf && !(STRUCTURE & mode)) return AP_FALSE; // tips push only structure 862 863 if (this->stack_level == datum) 863 864 if (this->stack_level == datum) 864 865 { 865 866 AP_tree_buffer *last_buffer = stack.get_first(); 866 867 if (sequence &&(mode & SEQUENCE)) sequence->is_set_flag = AP_FALSE; 867 868 if (0 == (mode & ~last_buffer->mode)) // already buffered 868 { 869 { 869 870 return AP_FALSE; 870 871 } … … 878 879 new_buff->controll = stack_level; 879 880 new_buff->mode = NOTHING; 880 881 881 882 stack.push(new_buff); 882 883 this->stack_level = datum; 883 884 ret = AP_TRUE; 884 885 } 885 886 if ( (mode & STRUCTURE) && !(new_buff->mode & STRUCTURE) ) 886 887 if ( (mode & STRUCTURE) && !(new_buff->mode & STRUCTURE) ) 887 888 { 888 889 // cout << "push structure " << *this << '\n'; … … 893 894 new_buff->rightlen = rightlen; 894 895 new_buff->gb_node = gb_node; 895 new_buff->distance = distance; 896 897 for (int e=0; e<3; e++) 898 { 899 new_buff->edge[e] = edge[e]; 900 new_buff->edgeIndex[e] = index[e]; 896 new_buff->distance = distance; 897 898 for (int e=0; e<3; e++) 899 { 900 new_buff->edge[e] = edge[e]; 901 new_buff->edgeIndex[e] = index[e]; 901 902 if (edge[e]) 902 903 { … … 905 906 } 906 907 } 907 908 if ( (mode & SEQUENCE) && !(new_buff->mode & SEQUENCE) ) 909 { 910 if (sequence) 908 909 if ( (mode & SEQUENCE) && !(new_buff->mode & SEQUENCE) ) 910 { 911 if (sequence) 911 912 { 912 913 new_buff->sequence = sequence; … … 914 915 mutation_rate = 0.0; 915 916 sequence = 0; 916 } 917 else 917 } 918 else 918 919 { 919 920 new_buff->sequence = 0; … … 921 922 } 922 923 } 923 924 924 925 new_buff->mode = (AP_STACK_MODE)(new_buff->mode|mode); 925 926 926 927 return ret; 927 928 } … … 930 931 { /* pop old tree costs */ 931 932 AP_tree_buffer *buff; 932 933 if (stack_level != datum) 933 934 if (stack_level != datum) 934 935 { 935 936 // new AP_ERR("AP_tree_nlen::pop()", "Error in Node Stack"); 936 937 } 937 938 938 939 buff = stack.pop(); 939 940 940 941 AP_STACK_MODE mode = buff->mode; 941 942 if (mode&STRUCTURE) 942 943 if (mode&STRUCTURE) 943 944 { 944 945 // cout << "pop structure " << this << '\n'; 945 946 946 947 father = buff->father; 947 948 leftson = buff->leftson; … … 950 951 rightlen = buff->rightlen; 951 952 gb_node = buff->gb_node; 952 distance = buff->distance; 953 954 for (int e=0; e<3; e++) 955 { 956 edge[e] = buff->edge[e]; 957 953 distance = buff->distance; 954 955 for (int e=0; e<3; e++) 956 { 957 edge[e] = buff->edge[e]; 958 958 959 if (edge[e]) 959 960 { 960 index[e] = buff->edgeIndex[e]; 961 962 edge[e]->index[index[e]] = e; 961 index[e] = buff->edgeIndex[e]; 962 963 edge[e]->index[index[e]] = e; 963 964 edge[e]->node[index[e]] = this; 964 edge[e]->data = buff->edgeData[e]; 965 } 966 } 967 } 968 969 if (mode&SEQUENCE) 965 edge[e]->data = buff->edgeData[e]; 966 } 967 } 968 } 969 970 if (mode&SEQUENCE) 970 971 { 971 972 if (sequence) delete sequence; 972 973 973 974 sequence = buff->sequence; 974 975 mutation_rate = buff->mutation_rate; 975 976 } 976 977 if (ROOT==mode) 978 { 979 // cout << "root popped:" << this << "\n"; 977 978 if (ROOT==mode) 979 { 980 // cout << "root popped:" << this << "\n"; 980 981 ap_main->set_tree_root(this); 981 982 } 982 983 983 984 stack_level = buff->controll; 984 985 delete buff; … … 993 994 AP_tree_nlen *lefts = (AP_tree_nlen *) leftson; 994 995 AP_tree_nlen *rights = (AP_tree_nlen *) rightson; 995 996 996 997 if (sequence && sequence->is_set_flag) return; 997 998 if (is_leaf) 998 999 if (is_leaf) 999 1000 { 1000 1001 sequence->is_set_flag = AP_TRUE; 1001 1002 return; 1002 1003 } 1003 1004 1004 1005 if (!lefts->sequence || !lefts->sequence->is_set_flag ) lefts->parsimony_rek(); 1005 1006 if (!rights->sequence|| !rights->sequence->is_set_flag ) rights->parsimony_rek(); 1006 1007 if (!lefts->sequence->is_set_flag || !rights->sequence->is_set_flag) 1007 1008 if (!lefts->sequence->is_set_flag || !rights->sequence->is_set_flag) 1008 1009 { 1009 1010 AW_ERROR("AP_tree_nlen::parsimony_rek: Cannot set sequence"); 1010 1011 return; 1011 1012 } 1012 1013 1013 1014 if (sequence == 0) sequence = tree_root->sequence_template->dup(); 1014 1015 1015 1016 mutation_rate = leftson->mutation_rate + rightson->mutation_rate + 1016 1017 sequence->combine(lefts->sequence, rights->sequence); … … 1028 1029 return rootEdge()->nni_rek(openclosestatus,Abort,deep,skip_hidden,mode); 1029 1030 } 1030 1031 1031 1032 if (!father->father) 1032 1033 { 1033 AP_tree_edge *e = rootEdge(); 1034 1034 AP_tree_edge *e = rootEdge(); 1035 1035 1036 return e->nni_rek(openclosestatus,Abort,deep,skip_hidden,mode,e->otherNode(this)); 1036 1037 } 1037 1038 1038 1039 return edgeTo(Father())->nni_rek(openclosestatus,Abort,deep,skip_hidden,mode,Father()); 1039 1040 } … … 1126 1127 //parsimony werte bestimmen 1127 1128 // 1128 1129 1129 1130 // Wurzel setzen 1130 1131 1131 1132 ap_main->push(); 1132 1133 this->set_root(); … … 1138 1139 pars_ref[i] = i; 1139 1140 pars[i] = -1; 1140 1141 1141 1142 if (!pars_refpntr[i]) continue; 1142 1143 if (pars_refpntr[i]->is_leaf) continue; … … 1144 1145 if (pars_refpntr[i]->gr.hidden) continue; 1145 1146 if (pars_refpntr[i]->father->gr.hidden) continue; 1146 1147 1147 1148 //nur wenn kein Blatt ist 1148 1149 ap_main->push(); … … 1195 1196 //Darstellen 1196 1197 1197 1198 1198 1199 // for (i=0;i<visited_subtrees;i++) cout << " " << pars[i]; 1199 1200 1200 1201 1201 1202 if (rek_deep < rek_2_width_max) { … … 1218 1219 } 1219 1220 1220 } 1221 } 1221 1222 1222 1223 if (rek_width > visited_subtrees) rek_width = visited_subtrees; … … 1321 1322 if (rightson->refUp.init == AP_FALSE) 1322 1323 rightson->createListRekUp(list,cn); 1323 1324 1324 1325 refUp.init = AP_TRUE; 1325 1326 refUp.isLeaf = AP_FALSE; 1326 1327 refUp.refNode = *cn; 1327 1328 (*cn)++; 1328 1329 1330 addToList(list,cn,this,leftson->refUp,rightson->refUp); 1329 1330 1331 addToList(list,cn,this,leftson->refUp,rightson->refUp); 1331 1332 if (father == 0) { // at root 1332 1333 refRight.init = rightson->refUp.init; 1333 if ((refRight.isLeaf = rightson->refUp.isLeaf) == AP_TRUE) 1334 if ((refRight.isLeaf = rightson->refUp.isLeaf) == AP_TRUE) 1334 1335 refRight.refLeaf = rightson->refUp.refLeaf; 1335 else 1336 else 1336 1337 refRight.refNode = rightson->refUp.refNode; 1337 1338 refLeft.init = leftson->refUp.init; 1338 if ((refLeft.isLeaf = leftson->refUp.isLeaf) == AP_TRUE) 1339 if ((refLeft.isLeaf = leftson->refUp.isLeaf) == AP_TRUE) 1339 1340 refLeft.refLeaf = leftson->refUp.refLeaf; 1340 else 1341 else 1341 1342 refLeft.refNode = leftson->refUp.refNode; 1342 1343 } … … 1353 1354 refRight.refNode = *cn; 1354 1355 (*cn)++; 1355 1356 1356 1357 if (father->leftson == this) { 1357 1358 if (father->refLeft.init == AP_FALSE) … … 1383 1384 1384 1385 1385 AP_CO_LIST * AP_tree_nlen::createList(int *size) 1386 AP_CO_LIST * AP_tree_nlen::createList(int *size) 1386 1387 { 1387 1388 // returns an list with all … … 1389 1390 AP_CO_LIST *list; 1390 1391 int number = 0; 1391 if (father !=0) 1392 if (father !=0) 1392 1393 { 1393 1394 AW_ERROR("AP_tree_nlen::createList may be called with damaged tree"); … … 1402 1403 return list; 1403 1404 } 1404 1405 1405 1406 #endif 1406 1407 1407 1408 /************************************************************************* 1408 1409 Section Misc stuff: … … 1413 1414 1414 1415 **************************************************************************/ 1415 1416 1416 1417 const char* AP_tree_nlen::sortByName() 1417 1418 { 1418 1419 if (name) return name; // leaves 1419 1420 1420 1421 const char *n1 = Leftson()->sortByName(); 1421 1422 const char *n2 = Rightson()->sortByName(); 1422 1423 if (strcmp(n1,n2)<0) return n1; 1424 1423 1424 if (strcmp(n1,n2)<0) return n1; 1425 1425 1426 AP_tree::swap_sons(); 1426 1427 return n2; 1428 } 1429 1427 1428 return n2; 1429 } 1430 1430 1431 int AP_tree_nlen::test(void) const 1431 1432 { 1432 int edges = 0; 1433 1433 int edges = 0; 1434 1434 1435 { for (int e=0; e<3; e++) if (edge[e]!=NULL) edges++; } 1435 1436 1436 1437 if (!sequence) 1437 1438 { 1438 cout << "Node" << *this << "has no sequence\n"; 1439 } 1440 1441 if (father) 1439 cout << "Node" << *this << "has no sequence\n"; 1440 } 1441 1442 if (father) 1442 1443 { 1443 1444 if (father->father == (AP_tree *)this) 1444 1445 { 1445 cout << "Ooops! I am my own grandfather! How is this possible?\n" << 1446 cout << "Ooops! I am my own grandfather! How is this possible?\n" << 1446 1447 *this << '\n' << 1447 *Father() << '\n'; 1448 } 1449 1448 *Father() << '\n'; 1449 } 1450 1450 1451 if (is_leaf) 1451 1452 { … … 1462 1463 } 1463 1464 } 1464 1465 1465 1466 int e; 1466 1467 1467 1468 for (e=0; e<3; e++) 1468 1469 { … … 1471 1472 if (edge[e]->isConnectedTo(this)) 1472 1473 { 1473 AP_tree_nlen *neighbour = edge[e]->otherNode(this); 1474 1475 if ( ! (neighbour==father || 1476 neighbour==leftson || 1474 AP_tree_nlen *neighbour = edge[e]->otherNode(this); 1475 1476 if ( ! (neighbour==father || 1477 neighbour==leftson || 1477 1478 neighbour==rightson)) 1478 1479 { … … 1489 1490 cout << "Edge " << edge[e] << " connects the nodes" 1490 1491 << *this << "and" << *(edge[e]->otherNode(this)) 1491 << "(they are not neighbours)\n"; 1492 << "(they are not neighbours)\n"; 1492 1493 } 1493 1494 } … … 1495 1496 else 1496 1497 { 1497 cout << "Node" << *this 1498 cout << "Node" << *this 1498 1499 << "is connected to wrong edge" 1499 1500 << edge[e] << '\n'; … … 1509 1510 } 1510 1511 } 1511 1512 1512 1513 test_tree(); // AP_tree:: 1513 1514 return 0; 1514 1515 return 0; 1515 1516 } 1516 1517 … … 1519 1520 if (!name) 1520 1521 { 1521 static char *buffer; 1522 static char *buffer; 1522 1523 char *lName = strdup(Leftson()->fullname()), 1523 *rName = strdup(Rightson()->fullname()); 1524 int len = strlen(lName)+strlen(rName)+4; 1525 1526 if (buffer) free(buffer); 1527 1528 buffer = (char*)malloc(len); 1529 1530 strcpy(buffer,"["); 1531 strcat(buffer,lName); 1524 *rName = strdup(Rightson()->fullname()); 1525 int len = strlen(lName)+strlen(rName)+4; 1526 1527 if (buffer) free(buffer); 1528 1529 buffer = (char*)malloc(len); 1530 1531 strcpy(buffer,"["); 1532 strcat(buffer,lName); 1532 1533 strcat(buffer,","); 1533 strcat(buffer,rName); 1534 strcat(buffer,rName); 1534 1535 strcat(buffer,"]"); 1535 1536 free(lName); 1537 free(rName); 1538 1539 return buffer; 1540 } 1541 1542 return name; 1543 } 1544 1545 char* AP_tree_nlen::getSequence() 1546 { 1547 char *s; 1548 1549 costs(); 1550 AP_sequence_parsimony *pseq = (AP_sequence_parsimony*)sequence; 1551 assert(pseq->is_set_flag); 1552 s = new char[pseq->sequence_len]; 1553 memcpy(s,pseq->sequence,(unsigned int)pseq->sequence_len); 1554 1555 return s; 1556 } 1557 1536 1537 free(lName); 1538 free(rName); 1539 1540 return buffer; 1541 } 1542 1543 return name; 1544 } 1545 1546 char* AP_tree_nlen::getSequence() 1547 { 1548 char *s; 1549 1550 costs(); 1551 AP_sequence_parsimony *pseq = (AP_sequence_parsimony*)sequence; 1552 assert(pseq->is_set_flag); 1553 s = new char[pseq->sequence_len]; 1554 memcpy(s,pseq->sequence,(unsigned int)pseq->sequence_len); 1555 1556 return s; 1557 } 1558 -
trunk/PARSIMONY/GA_genetic.cxx
r2 r655 5 5 #include <stdio.h> 6 6 #include <memory.h> 7 #include <malloc.h>7 // #include <malloc.h> 8 8 #include <iostream.h> 9 9 #include "AP_buffer.hxx" … … 28 28 29 29 GA_genetic::~GA_genetic(void) { 30 if (fout) { 30 if (fout) { 31 31 if (fclose(fout) != 0) { 32 32 new AP_ERR("~GA_genetic","coldnt close output"); … … 43 43 gb_tree_opt = GB_find(gb_genetic,"tree_opt",NULL,down_level); 44 44 gb_joblist = GB_find(gb_genetic,"job_list",NULL,down_level); 45 gb_bestTree = GB_find(gb_presets,"bestTree",NULL,down_level); 45 gb_bestTree = GB_find(gb_presets,"bestTree",NULL,down_level); 46 46 gb_jobCount = GB_find(gb_presets,"jobCount",NULL,down_level); 47 47 gb_maxTree = GB_find(gb_presets,"maxTree",NULL,down_level); 48 48 gb_treeName = GB_find(gb_presets,"treeName",NULL,down_level); 49 49 50 50 if (gb_presets == 0) { 51 51 new AP_ERR("init","No presets defined"); 52 return; 52 return; 53 53 } 54 54 if (gb_joblist == 0){ … … 74 74 } 75 75 max_cluster = (int)GB_read_int(gbp); 76 76 77 77 if ( (gbp = GB_find(gb_presets,"maxTree",NULL,down_level)) == 0) { 78 78 new AP_ERR("GA_init","some preset not found"); … … 81 81 } 82 82 maxTree = (int)GB_read_int(gbp); 83 83 84 84 if ( (gbp = GB_find(gb_presets,"max_jobs",NULL,down_level)) == 0) { 85 85 new AP_ERR("GA_init","some preset not found"); … … 88 88 } 89 89 max_jobs = (int)GB_read_int(gbp); 90 90 91 91 // allocate memory 92 92 treelist = (long **)calloc((size_t)max_cluster+1,sizeof(long **)); … … 95 95 } 96 96 treePerCluster = (int *)calloc((size_t)max_cluster+1,sizeof(int)); 97 97 98 98 GB_pop_transaction(gb_main); 99 99 // … … 116 116 gb_tree_opt = GB_create_container(gb_genetic,0,"trees_opt"); 117 117 gb_joblist = GB_create_container(gb_genetic,0,"job_list"); 118 119 118 119 120 120 121 121 // write presets … … 142 142 143 143 GB_pop_transaction(gb_main); 144 144 145 145 tree_prototype = (AP_tree *) new AP_tree_nlen; 146 146 return; … … 152 152 AP_ERR * GA_genetic::read_presets() { 153 153 GBDATA *gbp; 154 if (gb_presets == 0) 154 if (gb_presets == 0) 155 155 return new AP_ERR("GA_genetic","not inited"); 156 156 if ( (gbp = GB_find(gb_presets,"jobOpt",NULL,down_level)) == 0) { … … 170 170 if (gb_bestTree) bestTree = GB_read_APfloat(gb_bestTree); 171 171 if (gb_maxTree) maxTree = (int)GB_read_int(gb_maxTree); 172 172 173 173 return 0; 174 174 } … … 247 247 char treename[20]; 248 248 long id; 249 249 250 250 if (container == 0) { 251 251 new AP_ERR("get_tree","container valid !"); … … 325 325 node->rightlen = AP_atof(*data); 326 326 *data = p1; 327 327 328 328 node->leftson = read_tree_rek(data); 329 329 if (!node->leftson) { … … 378 378 ga_tree->id = GB_read_int(gb_treeName); 379 379 GB_write_int(gb_treeName,1+ga_tree->id); 380 } 380 } 381 381 if ((gb_tree = get_tree(gb_cluster,ga_tree->id))==0) { 382 382 gb_tree = GB_create_container(gb_cluster,0,"tree"); 383 } 384 383 } 384 385 385 gb_ref_count = GB_create(gb_tree,0,"ref_count"); 386 386 gb_criteria = GB_create(gb_tree,0,"criteria"); 387 387 gb_id = GB_create(gb_tree,0,"id"); 388 388 389 389 GB_write_int(gb_ref_count,ga_tree->ref_count); 390 390 GB_write_APfloat(gb_criteria, ga_tree->criteria); … … 417 417 418 418 GA_tree *GA_genetic::read_tree(GBDATA *gb_cluster,long tree_id) 419 /* read a tree 419 /* read a tree 420 420 and removes it if no referenz is existing */ 421 421 { … … 428 428 char *cptr[1]; 429 429 GA_tree *tree; 430 430 431 431 gb_count = GB_find(gb_cluster,"count",0,down_level); 432 432 count = (int)GB_read_int(gb_count); 433 433 434 434 gb_tree = get_tree(gb_cluster,tree_id); 435 435 if(gb_tree == 0) { … … 446 446 GBDATA *gb_criteria = GB_search(gb_tree,"criteria",GB_FIND); 447 447 GBDATA *gb_id = GB_search(gb_tree,"id",GB_FIND); 448 448 449 449 if (gb_ref_count) 450 450 tree->ref_count = (int)GB_read_int(gb_ref_count); … … 455 455 456 456 gb_treedata = GB_search(gb_tree,"tree_data",GB_FIND); 457 if (gb_treedata) { 457 if (gb_treedata) { 458 458 fbuf =cptr[0] = GB_read_string(gb_treedata); 459 459 tree->tree = (AP_tree_nlen *)read_tree_rek(cptr); … … 462 462 delete_tree(gb_cluster,gb_tree); 463 463 GBT_link_tree((GBT_TREE*)tree->tree,gb_main); 464 return tree; 464 return tree; 465 465 } 466 466 … … 493 493 return new AP_ERR("put_start_tree","cluster unvalid"); 494 494 } 495 495 496 496 if (gb_tree_start == 0) { 497 497 GB_pop_transaction(gb_main); … … 500 500 } 501 501 gb_cluster = get_cluster(gb_tree_start,cluster); 502 502 503 503 if (gb_cluster ==0) { 504 504 char clustername[20]; … … 520 520 ga_tree->id = tree_id; 521 521 ga_tree->tree = (AP_tree_nlen *)tree; 522 522 523 523 ap_err = write_tree(gb_cluster,ga_tree); 524 524 525 525 if (ap_err == 0) { 526 526 anzahl ++; … … 560 560 int anzahl = 0; 561 561 GBDATA *gb_anzahl; 562 562 563 563 GB_push_transaction(gb_main); 564 564 gb_cluster = this->get_cluster(gb_tree_opt,cluster); … … 574 574 GB_write_int(gb_anzahl,0); 575 575 } 576 576 577 577 gb_anzahl = GB_find(gb_cluster,"count",0,down_level); 578 578 anzahl = (int)GB_read_int(gb_anzahl); … … 580 580 remove_job(gb_cluster); 581 581 } 582 582 583 583 // baum speichern und anzahl erhoehen 584 584 // kreire jobs … … 587 587 anzahl ++; 588 588 GB_write_int(gb_anzahl,anzahl); 589 create_jobs(tree,cluster); 589 create_jobs(tree,cluster); 590 590 GB_pop_transaction(gb_main); 591 591 return 0; … … 598 598 return new AP_ERR("delete_tree","no tree given"); 599 599 } 600 600 601 601 GBDATA *gb_ref_count = GB_search(gb_tree,"ref_count",GB_FIND); 602 602 if (gb_ref_count) { … … 617 617 Alles was mit jobs zu tuen hat 618 618 **************************************************/ 619 619 620 620 GA_job * GA_genetic::get_job(int cluster) { 621 621 int count; … … 635 635 return 0; 636 636 } 637 637 638 638 count = (int)GB_read_int(gb_jobCount); // globaler zaehler 639 639 if (count <= 0) { … … 642 642 return 0; 643 643 } 644 644 645 645 // 646 646 // suche besten job aus cluster und liefer ihn zurueck … … 661 661 662 662 gb_best_job = gbp_job = GB_find(gb_cluster,"job",0,down_level); 663 if (gbp_job != 0) 663 if (gbp_job != 0) 664 664 gbp_criteria = GB_find(gbp_job,"criteria",0,down_level); 665 665 666 666 if (gbp_criteria != 0) 667 667 crit_best = GB_read_APfloat(gbp_criteria); 668 668 669 669 while ((gbp_job = GB_find(gbp_job,"job",0,this_level|search_next)) !=0) { 670 670 gbp_criteria = GB_find(gbp_job,"criteria",0,down_level); … … 672 672 if (crit_next > crit_best ) { 673 673 crit_best = crit_next; 674 gb_best_job = gbp_job; 674 gb_best_job = gbp_job; 675 675 } 676 676 } … … 700 700 gb_cluster = get_cluster(gb_tree_opt,job->cluster0); 701 701 job->tree0 = read_tree(gb_cluster,job->id0); 702 703 if (job->id1 != -1 ){ // falls zweiter baum angegeben 702 703 if (job->id1 != -1 ){ // falls zweiter baum angegeben 704 704 gb_cluster = get_cluster(gb_tree_opt,job->cluster1); 705 705 job->tree1 = read_tree(gb_cluster,job->id1); … … 726 726 char *err =0; 727 727 GBDATA *gbp; 728 728 729 729 if (job == 0) { 730 730 return new AP_ERR("put_job","no job given !"); … … 737 737 gb_jobcluster = gb_cluster = get_cluster(gb_joblist,job->cluster0); 738 738 gb_anzahl = GB_find(gb_cluster,"count",0,down_level); 739 anzahl =GB_read_int(gb_anzahl); 739 anzahl =GB_read_int(gb_anzahl); 740 740 // Criteria Ausrechnen !! 741 741 if (job->id1 >= 0) { … … 772 772 gbp = GB_search(gb_job,"id1",GB_CREATE); 773 773 err = GB_write_int(gbp,job->id1); 774 774 775 775 if (err !=0) { 776 776 aperr = new AP_ERR("put job","error while writing job to database"); … … 792 792 793 793 jobCount = (int)GB_read_int(gb_jobCount); 794 794 795 795 while (jobCount >= max_jobs) { 796 796 remove_job(0); 797 797 } 798 798 799 799 GB_pop_transaction(gb_main); 800 800 job->printl(); … … 813 813 GBDATA *jobcl; 814 814 815 if (gb_job == 0) 815 if (gb_job == 0) 816 816 return new AP_ERR("delete_job","no job given !"); 817 817 jobcl = GB_get_father(gb_job); … … 829 829 // Der erste Baum ist im selben Cluster ! 830 830 gbcl = gb_cluster = get_cluster(gb_tree_opt,job->cluster0); 831 831 832 832 gbt = get_tree(gb_cluster,job->id0); 833 833 delete_tree(gb_cluster,gbt); 834 if (job->id1 != -1 ){ // falls zweiter baum angegeben 834 if (job->id1 != -1 ){ // falls zweiter baum angegeben 835 835 gb_cluster = get_cluster(gb_tree_opt,job->cluster1); 836 836 gbt = get_tree(gb_cluster,job->id1); … … 875 875 } 876 876 } 877 877 878 878 gbjob = GB_find(gb_cluster,"job",0,down_level); 879 879 880 880 if (gbjob != 0) { 881 881 gbp_criteria = GB_find(gbjob,"criteria",0,down_level); … … 889 889 if (crit_next > crit_worst ) { 890 890 crit_worst = crit_next; 891 gbworst = gbjob; 891 gbworst = gbjob; 892 892 } 893 893 } … … 897 897 return new AP_ERR("remove_job","No job found"); 898 898 } 899 899 900 900 delete_job(gbworst); 901 901 return 0; 902 902 } 903 903 904 904 905 905 … … 913 913 914 914 read_presets(); 915 915 916 916 /* 917 917 for (i=0;i<jobOpt;i++){ // Optimierungsjobs … … 922 922 job->id1 = -1; 923 923 job->modus = GA_KERNIGHAN; 924 if (put_job(job->cluster0,job) !=0) 924 if (put_job(job->cluster0,job) !=0) 925 925 ; 926 926 delete job; … … 958 958 cout << "\n"; 959 959 cout.flush(); 960 960 961 961 for (i=0;i<jobCrossover;i++){ // Crossoverjobs 962 962 if (treePerCluster[cluster] > 1) { // in same cluster … … 993 993 // search random cluster other than cluster 994 994 rcl = (int)random()%clusterCount; 995 995 996 996 int safty = 0; 997 997 while ((rcl == cluster) || (treePerCluster[rcl] < 1) ) { … … 1008 1008 // while (treelist[rcl][treeid] == job->id0) { 1009 1009 treeid = (int)random()%treePerCluster[rcl]; 1010 1010 1011 1011 //}; 1012 1012 1013 1013 // remove it from treelist by a swap 1014 1014 job->id1 = treelist[rcl][treeid]; … … 1020 1020 jc++; 1021 1021 delete job; 1022 } 1022 } 1023 1023 if (jc < 1) { // create jobs falls keine anderen aufgetaucht sind 1024 1024 job = new GA_job; -
trunk/PARSIMONY/GA_main.cxx
r2 r655 5 5 #include <stdio.h> 6 6 #include <memory.h> 7 #include <malloc.h>7 // #include <malloc.h> 8 8 #include <iostream.h> 9 9 #include "AP_buffer.hxx" … … 36 36 // root is tree with species (needed to build a list of species) 37 37 AP_tree **list; 38 38 39 39 if (root->sequence_proto == 0) tree_init(root); 40 40 … … 47 47 48 48 list = (AP_tree **)calloc(root->gr.leave_sum +1,sizeof(AP_tree *)); 49 49 50 50 buildRandomTreeRek(root,list,&count); 51 51 count--; … … 93 93 list0 = tree0->createList(&size0); 94 94 list1 = tree1->createList(&size1); 95 95 96 96 fprintf(GAgenetic->fout,"\ncrossover tree %d %d size %d %d", 97 97 tree0,tree1,size0,size1); 98 98 99 99 // ruft crossover auf 100 100 return tree0; … … 122 122 GAgenetic->init(gbmain); 123 123 } 124 124 125 125 maxcluster = GAgenetic->getMaxCluster(); 126 126 while (i<maxcluster) { … … 143 143 fclose(GAgenetic->fout); 144 144 } 145 145 146 146 void start_genetic(GBDATA *gbmain) { 147 // 147 // 148 148 // the genetic algorithm is implemented here 149 149 // 150 150 151 151 GA_tree * starttree; 152 152 GA_job *job; 153 153 int cluster; 154 154 155 155 156 156 if (GAgenetic == 0) { 157 157 GAgenetic = new GA_genetic; … … 168 168 169 169 while (i<GAgenetic->getMaxCluster()) { 170 cluster = i; 170 cluster = i; 171 171 while ((starttree = GAgenetic->get_start_tree(cluster)) != 0){ 172 172 if (starttree != 0) { … … 196 196 GA_tree * gaTree = new GA_tree; 197 197 gaTree->tree = crossover(job->tree0->tree,job->tree1->tree); 198 198 199 199 GB_push_transaction(gb_main); 200 200 char *use =GBT_get_default_alignment(gb_main); … … 229 229 } 230 230 } 231 232 233 234 231 232 233 234 -
trunk/PARSIMONY/GA_window.cxx
r2 r655 13 13 #include <aw_display.hxx> 14 14 #include <awt.hxx> 15 #include <malloc.h>15 // #include <malloc.h> 16 16 #include "AP_buffer.hxx" 17 17 #include "parsimony.hxx" … … 37 37 AWUSE(cld1); 38 38 AW_root *aw_root = aww->get_root(); 39 39 40 40 } 41 41 … … 73 73 } 74 74 75 AW_window *create_genetic_window(AW_root *aw_root,AW_display *awd) 75 AW_window *create_genetic_window(AW_root *aw_root,AW_display *awd) 76 76 { 77 77 78 78 AW_window_simple *aws = new AW_window_simple; 79 79 aws->init( aw_root, "GENETIC_MAIN", "Kernighan", 10, 10 ); 80 80 aws->load_xfig("ph_gen.fig"); 81 81 aws->button_length( 10 ); 82 82 83 83 aws->at("close"); 84 84 aws->callback((AW_CB0)AW_POPDOWN); 85 aws->create_button("CLOSE","CLOSE","C"); 86 85 aws->create_button("CLOSE","CLOSE","C"); 86 87 87 88 88 aws->at("start"); 89 89 aws->callback((AW_CB1)start_genetic_cb,(AW_CL)awd); 90 aws->create_button("START","START","S"); 91 90 aws->create_button("START","START","S"); 91 92 92 aws->at("save"); 93 93 aws->callback((AW_CB1)save_genetic_cb,(AW_CL)aw_root); 94 aws->create_button("SAVE","SAVE","S"); 95 94 aws->create_button("SAVE","SAVE","S"); 95 96 96 aws->at("quit"); 97 97 aws->callback((AW_CB1)quit_genetic_cb,(AW_CL)aw_root); 98 aws->create_button("QUIT","QUIT","Q"); 98 aws->create_button("QUIT","QUIT","Q"); 99 99 100 100 aws->at("savetree"); 101 101 aws->callback((AW_CB1)savetree_genetic_cb,(AW_CL)aw_root); 102 aws->create_button("SAVETREE","SaveTree","Q"); 102 aws->create_button("SAVETREE","SaveTree","Q"); 103 103 104 104 aws->at("jobs"); … … 113 113 aws->create_input_field("genetic/presets/jobOther",8); 114 114 aws->at("curCluster"); 115 aws->create_input_field("genetic/presets/curCluster",8); 115 aws->create_input_field("genetic/presets/curCluster",8); 116 116 aws->at("maxTree"); 117 117 aws->create_input_field("genetic/presets/maxTree",8); … … 121 121 aws->at("jobCount"); 122 122 aws->create_label("genetic/presets/jobCount",8); 123 123 124 124 return (AW_window *)aws; 125 125 126 126 } 127 127 -
trunk/PARSIMONY/PARS_klprops.cxx
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <arbdb.h> 5 5 #include <arbdbt.h> … … 28 28 29 29 AW_window *create_kernighan_window(AW_root *aw_root) { 30 30 31 31 AW_window_simple *aws = new AW_window_simple; 32 32 aws->init( aw_root, "OPTIMIZATION_PROPS", "Kernighan Lin Properties", 10, 10 ); 33 33 aws->load_xfig("PARS/kernlin.fig"); 34 34 aws->button_length( 10 ); 35 35 36 36 aws->at("close"); 37 37 aws->callback((AW_CB0)AW_POPDOWN); 38 aws->create_button("CLOSE","CLOSE","C"); 39 40 38 aws->create_button("CLOSE","CLOSE","C"); 39 40 41 41 aws->at("help"); 42 42 aws->callback((AW_CB1)AW_POPUP_HELP,(AW_CL)"kernlin.hlp"); 43 aws->create_button("HELP","HELP","H"); 44 43 aws->create_button("HELP","HELP","H"); 44 45 45 aws->button_length( 6 ); 46 46 … … 68 68 aws->create_input_field("genetic/kh/static/depth4"); 69 69 70 70 71 71 aws->at("dynamic"); 72 72 aws->create_toggle("genetic/kh/dynamic/enable"); … … 80 80 aws->create_input_field("genetic/kh/dynamic/maxy"); 81 81 82 #if 0 82 #if 0 83 83 aws->at("button_4"); 84 84 aws->create_option_menu("genetic/kh/function_type",0,""); … … 90 90 return (AW_window *)aws; 91 91 } 92 92 -
trunk/PARSIMONY/PARS_main.cxx
r563 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <iostream.h> 6 6 #include <limits.h> -
trunk/PHYLO/include.hxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <iostream.h> -
trunk/PRIMER_DESIGN/primer_design.cxx
r478 r655 151 151 #endif 152 152 } 153 154 #ifdef DARWIN 155 // This seems to generate an internal compiler error with gcc 2.95 on OSX 156 #else 153 157 catch (string& s) { 154 158 error = GBS_global_string(s.c_str()); 155 159 } 160 #endif 156 161 catch (...) { 157 162 error = "Unknown error (maybe out of memory ? )"; -
trunk/PROBE/PT_buildtree.cxx
r244 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <unistd.h> 6 6 #include <PT_server.h> -
trunk/PROBE/PT_etc.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <memory.h> 6 6 #include <PT_server.h> … … 15 15 int i; 16 16 psg.w_N_mismatches[0] = 0; 17 psg.w_N_mismatches[1] = 0; 18 psg.w_N_mismatches[2] = 1; 17 psg.w_N_mismatches[1] = 0; 18 psg.w_N_mismatches[2] = 1; 19 19 psg.w_N_mismatches[3] = 2; 20 20 psg.w_N_mismatches[4] = 4; … … 32 32 { 33 33 return psg.data[ml->name].name; 34 } 34 } 35 35 36 36 extern "C" char *virt_fullname(PT_probematch * ml) { … … 41 41 } 42 42 } 43 43 44 44 /* copy one mismatch table to a new one allocating memory */ 45 45 int *table_copy(int *mis_table, int length) … … 47 47 int *result_table; 48 48 int i; 49 49 50 50 result_table = (int *)calloc(length, sizeof(int)); 51 51 for (i=0; i<length; i++) … … 60 60 mis_tabled[i] += mis_tables[i]; 61 61 } 62 62 63 63 /* read the name list seperated by # and set the flag for the group members, + returns a list of names which have not been found */ 64 64 char *ptpd_read_names(PT_local * locs, char *names_listi, char *checksumsi) … … 173 173 if (!i) str[i]=255; /* end flag */ 174 174 }else{ 175 break; 175 break; 176 176 } 177 177 } 178 } 178 } -
trunk/PROBE/PT_family.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <PT_server.h> 6 6 #include <struct_man.h> … … 50 50 */ 51 51 while (mismatches <= max_mismatches && *probe) { 52 if (psg.data[ref_name].data[ref_pos++] != *probe) { 52 if (psg.data[ref_name].data[ref_pos++] != *probe) { 53 53 mismatches++; 54 54 } … … 89 89 return 0; 90 90 } 91 91 92 92 /* Clear all informations in psg.data[i].stat */ 93 93 void clear_statistic(){ … … 124 124 struct probe_input_data *d1 = (struct probe_input_data*)pid_ptr1; 125 125 struct probe_input_data *d2 = (struct probe_input_data*)pid_ptr2; 126 126 127 127 if (d1->stat.match_count < d2->stat.match_count) return 1; 128 128 if (d1->stat.match_count == d2->stat.match_count) return 0; … … 133 133 struct probe_input_data *d1 = (struct probe_input_data*)pid_ptr1; 134 134 struct probe_input_data *d2 = (struct probe_input_data*)pid_ptr2; 135 135 136 136 if (d1->stat.rel_match_count < d2->stat.rel_match_count) return 1; 137 137 if (d1->stat.rel_match_count == d2->stat.rel_match_count) return 0; … … 172 172 fl->matches = my_list[i]->stat.match_count; 173 173 fl->rel_matches = my_list[i]->stat.rel_match_count; 174 aisc_link((struct_dllpublic_ext*)&locs->pfl,(struct_dllheader_ext*)fl); 174 aisc_link((struct_dllpublic_ext*)&locs->pfl,(struct_dllheader_ext*)fl); 175 175 } 176 176 free((char *)my_list); … … 223 223 mark_all_matches(locs,psg.pt,probe,probe_len,0,0,mismatch_nr); 224 224 } 225 225 226 226 make_match_statistic(locs->pr_len); 227 227 make_PT_family_list(locs); -
trunk/PROBE/PT_findEx.cxx
r133 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 6 6 #include <PT_server.h> -
trunk/PROBE/PT_io.cxx
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <memory.h> 5 5 #include <string.h> … … 11 11 12 12 13 /* change a sequence with normal bases the PT_? format and delete all other signs */ 13 /* change a sequence with normal bases the PT_? format and delete all other signs */ 14 14 int compress_data(char *probestring) 15 15 { … … 18 18 *dest; 19 19 dest = src = probestring; 20 20 21 21 while((c=*(src++))) 22 22 { … … 36 36 default: break; 37 37 } 38 38 39 39 } 40 40 *dest = PT_QU; … … 50 50 if (!len) len = strlen(id_string); 51 51 dest = src = id_string; 52 52 53 53 while((len--)>0){ 54 54 c=*(src++); … … 62 62 default: *(dest++) = c;break; 63 63 } 64 64 65 65 } 66 66 *dest = '\0'; … … 100 100 tab['T'] = tab['t'] = PT_T; 101 101 tab['U'] = tab['u'] = PT_T; 102 tab['.'] = PT_QU; 103 } 104 102 tab['.'] = PT_QU; 103 } 104 105 105 char *dest; 106 106 uchar c; -
trunk/PROBE/PT_new_design.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 6 6 #include <PT_server.h> … … 49 49 PT_tprobes *tprobe1 = (PT_tprobes*)PT_tprobes_ptr1; 50 50 PT_tprobes *tprobe2 = (PT_tprobes*)PT_tprobes_ptr2; 51 51 52 52 if (tprobe1->quality < tprobe2->quality) return 1; 53 53 return -1; … … 56 56 PT_tprobes *tprobe1 = (PT_tprobes*)PT_tprobes_ptr1; 57 57 PT_tprobes *tprobe2 = (PT_tprobes*)PT_tprobes_ptr2; 58 58 59 59 return strcmp(tprobe1->sequence,tprobe2->sequence); 60 } 60 } 61 61 62 62 void ptnd_sort_probes_by(PT_pdc *pdc, int mode) /* mode 0 quality … … 84 84 break; 85 85 } 86 86 87 87 for (i=0;i<list_len;i++) { 88 88 aisc_unlink((struct_dllheader_ext*)my_list[i]); … … 174 174 ***********************************************************************/ 175 175 /* count all mishits for a probe */ 176 176 177 177 int ptnd_chain_count_mishits(int name, int apos, int rpos, long dummy) 178 178 { … … 192 192 return 0; 193 193 } 194 194 195 195 /* go down the tree to chains and leafs; count the species that are in the non member group */ 196 196 int ptnd_count_mishits2(POS_TREE *pt) … … 199 199 int name; 200 200 int mishits = 0; 201 201 202 202 if (pt == NULL) 203 203 return 0; … … 206 206 int apos = PT_read_apos(psg.ptmain,pt); 207 207 if (apos>psg.apos) psg.apos = apos; 208 if (!psg.data[name].is_group) return 1; 208 if (!psg.data[name].is_group) return 1; 209 209 return 0; 210 210 }else if (PT_read_type(pt) == PT_NT_CHAIN) { … … 216 216 for (base = PT_QU; base< PT_B_MAX; base++) { 217 217 mishits += ptnd_count_mishits2(PT_read_son(psg.ptmain,pt,(PT_BASES)base)); 218 } 218 } 219 219 return mishits; 220 220 } … … 308 308 s += strlen(s); 309 309 310 sprintf(s,"%2s %4s %4s ","le","apos","ecol"); 310 sprintf(s,"%2s %4s %4s ","le","apos","ecol"); 311 311 s += strlen(s); 312 312 … … 325 325 326 326 return buffer; 327 } 327 } 328 328 329 329 /* search down the tree to find matching species for the given probe */ … … 346 346 } 347 347 if (*probe) { 348 if (PT_read_type(pt) == PT_NT_LEAF) { 348 if (PT_read_type(pt) == PT_NT_LEAF) { 349 349 pos = PT_read_rpos(psg.ptmain,pt) + height; 350 350 name = PT_read_name(psg.ptmain,pt); 351 351 if (pos + (int)(strlen(probe)) >= psg.data[name].size) /* after end */ 352 352 return 0; 353 353 354 354 while (*probe) { 355 355 if (psg.data[name].data[pos++] != *(probe++)) … … 362 362 PT_read_chain(psg.ptmain,pt, ptnd_chain_count_mishits, 0); 363 363 return ptnd.mishits; 364 } 365 } 366 return ptnd_count_mishits2(pt); 364 } 365 } 366 return ptnd_count_mishits2(pt); 367 367 } 368 368 … … 470 470 for (i = PT_A; i <=PT_T; i++) { 471 471 sequence[deep] = i; 472 if ( (split = ptnd_check_split(pdc, insequence, deep, i)) < 0.0) continue; 472 if ( (split = ptnd_check_split(pdc, insequence, deep, i)) < 0.0) continue; 473 473 /* this mismatch splits the probe in several domains */ 474 474 ndt = split + dt; … … 486 486 while (( parts = pdc->parts )) 487 487 destroy_PT_probeparts(parts); /* delete the source */ 488 488 489 489 while (( parts = pdc->dparts )) 490 490 { … … 500 500 PT_probeparts *tprobe1 = (PT_probeparts*)PT_probeparts_ptr1; 501 501 PT_probeparts *tprobe2 = (PT_probeparts*)PT_probeparts_ptr2; 502 502 503 503 return strcmp(tprobe1->sequence,tprobe2->sequence); 504 504 } … … 520 520 } 521 521 GB_mergesort((void **)my_list,0,list_len,ptnd_compare_parts,0); 522 522 523 523 for (i=0;i<list_len;i++) { 524 524 aisc_unlink((struct_dllheader_ext*)my_list[i]); … … 560 560 char *probe; 561 561 int split; 562 562 563 563 if (( start = parts->start )) { /* look backwards */ 564 564 probe = parts->source->sequence; … … 576 576 } 577 577 } 578 ndt = ( dt * pdc->dt + 578 ndt = ( dt * pdc->dt + 579 579 (tprobe->sum_bonds - sum_bonds)*pdc->dte ) 580 580 /tprobe->seq_len; … … 607 607 { 608 608 PT_tprobes *tprobe = parts->source; 609 double ndt = ( dt * pdc->dt + 609 double ndt = ( dt * pdc->dt + 610 610 (tprobe->sum_bonds - sum_bonds)*pdc->dte ) 611 611 /tprobe->seq_len; … … 614 614 return 0; 615 615 } 616 616 617 617 int ptnd_chain_check_part(int name, int apos, int rpos, long split) 618 618 { … … 627 627 if (probe) { 628 628 pos = rpos+psg.height; 629 while (probe[height] && (base = psg.data[name].data[pos])) { 629 while (probe[height] && (base = psg.data[name].data[pos])) { 630 630 if (!split && (h = ptnd_check_split(ptnd.pdc, probe, height, 631 631 base) < 0.0) ){ … … 642 642 return 0; 643 643 } 644 644 645 645 /* go down the tree to chains and leafs; check all */ 646 646 void ptnd_check_part_all(POS_TREE *pt, double dt, double sum_bonds) … … 648 648 int base; 649 649 int name, apos, rpos; 650 650 651 651 if (pt == NULL) 652 652 return; … … 666 666 for (base = PT_QU; base< PT_B_MAX; base++) { 667 667 ptnd_check_part_all(PT_read_son(psg.ptmain,pt,(PT_BASES)base),dt,sum_bonds); 668 } 668 } 669 669 } 670 670 } … … 680 680 int ref; 681 681 if (!pt) return; 682 if (dt/ptnd.parts->source->seq_len > PERC_SIZE) return; /* out of scope */ 682 if (dt/ptnd.parts->source->seq_len > PERC_SIZE) return; /* out of scope */ 683 683 if (PT_read_type(pt) == PT_NT_NODE && probe[height]) { 684 684 if (split && ptnd_check_inc_mode(ptnd.pdc ,ptnd.parts, dt, sum_bonds)) return; … … 700 700 }else{ 701 701 ndt = dt + h; 702 nsum_bonds += 703 ptnd_check_max_bond(ptnd.pdc,probe[height]) - h; 702 nsum_bonds += 703 ptnd_check_max_bond(ptnd.pdc,probe[height]) - h; 704 704 } 705 705 } … … 711 711 } 712 712 if (probe[height]) { 713 if (PT_read_type(pt) == PT_NT_LEAF) { 713 if (PT_read_type(pt) == PT_NT_LEAF) { 714 714 name = PT_read_name(psg.ptmain,pt); 715 715 if (!ptnd.new_match && psg.data[name].is_group) return; … … 743 743 PT_read_chain(psg.ptmain,pt, ptnd_chain_check_part, split); 744 744 return; 745 } 746 } 747 ptnd_check_part_all(pt,dt,sum_bonds); 745 } 746 } 747 ptnd_check_part_all(pt,dt,sum_bonds); 748 748 } 749 749 void ptnd_check_probepart(PT_pdc *pdc) … … 802 802 } 803 803 804 void ptnd_add_sequence_to_hash(PT_pdc *pdc, GB_HASH *hash, register char *sequence, int seq_len, register int probe_len, char *prefix, int prefix_len){ 804 void ptnd_add_sequence_to_hash(PT_pdc *pdc, GB_HASH *hash, register char *sequence, int seq_len, register int probe_len, char *prefix, int prefix_len){ 805 805 register int pos; 806 806 register int c; … … 847 847 PT_init_base_string_counter(partstring,PT_A,partsize); 848 848 while (!PT_base_string_counter_eof(partstring)) { 849 hash = GBS_create_hash(defhash,0); // count in how many groups/sequences the tprobe occurs 850 849 hash = GBS_create_hash(defhash,0); // count in how many groups/sequences the tprobe occurs 850 851 851 for (name = 0; name < psg.data_count; name++) { 852 852 if(psg.data[name].is_group<=0) continue; 853 853 854 854 GB_HASH *hash_one = GBS_create_hash(defhash,0); // count tprobe occurances for one group/sequence 855 855 ptnd_add_sequence_to_hash(pdc, hash_one, psg.data[name].data, psg.data[name].size, pdc->probelen, partstring, partsize); … … 925 925 ptnd_probe_delete_all_but(pdc,pdc->clipresult); 926 926 /* ptnd_print_probes(pdc); */ 927 927 928 928 return 0; 929 } 929 } 930 930 931 931 void ptnd_new_match(PT_local * locs, char *probestring) -
trunk/PROBE/PT_prefixtree.cxx
r237 r655 3 3 #include <sys/types.h> 4 4 #include <sys/mman.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <memory.h> 7 7 #include <PT_server.h> -
trunk/PROBE/PT_secundaer.cxx
r2 r655 1 1 #include <stdio.h> 2 #include <malloc.h>2 // #include <malloc.h> 3 3 #include <stdlib.h> 4 4 #include <string.h> -
trunk/PROBE_COM/PT_extern.c
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h> 3 /* #include <malloc.h> */ 4 4 #include <string.h> 5 5 #include "PT_server.h" … … 11 11 // this source is compiled as C++ !!! 12 12 13 extern "C" int pt_init_bond_matrix(PT_pdc *THIS); 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 int pt_init_bond_matrix(PT_pdc *THIS); 18 19 #ifdef __cplusplus 20 } 21 #endif 14 22 15 23 int init_bond_matrix(PT_pdc *THIS) { … … 21 29 extern "C" { 22 30 #endif 23 31 24 32 // aisc_callback_func_proto(destroy_PT_local); /* prototyp */ 25 33 … … 27 35 destroy_PT_local(THIS); 28 36 } 29 37 30 38 #ifdef __cplusplus 31 39 } 32 40 #endif 33 41 34 42 int pt_init_socket(PT_local *THIS) { 35 43 return aisc_add_destroy_callback((aisc_callback_func)pt_destroy_locs,(long)THIS); 36 44 } 37 45 38 void pt_destroy_socket(PT_local *THIS){ 46 void pt_destroy_socket(PT_local *THIS){ 39 47 THIS = THIS; 40 48 aisc_remove_destroy_callback(); -
trunk/PROBE_DESIGN/probe_design.cxx
r569 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 #include <ctype.h> -
trunk/SERVERCNTRL/servercntrl.c
r599 r655 3 3 #include <unistd.h> 4 4 #include <string.h> 5 #include <malloc.h> 5 /* #include <malloc.h> */ 6 6 #include <client_privat.h> 7 7 #include <client.h> -
trunk/SOURCE_TOOLS/generate_all_links.sh
r642 r655 1 #!/bin/ sh1 #!/bin/tcsh 2 2 3 3 # Liblink … … 26 26 27 27 # Motif stuff 28 ln -s ../Motif/libXm.so.2 LIBLINK/libXm.so.229 ln -s /usr/lib/Motif1.2/libXm.1LIBLINK/libXm.sl28 ln -s $MOTIF_LIBPATH LIBLINK/libXm.so.3 29 ln -s $LIBDIR/libXm.1.dylib LIBLINK/libXm.sl 30 30 31 31 # Links in bin directory -
trunk/STAT/ST_ml.cxx
r645 r655 4 4 #include <math.h> 5 5 #include <memory.h> 6 #include <malloc.h>6 // #include <malloc.h> 7 7 #include <ctype.h> 8 8 #include <arbdb.h> -
trunk/TEST/test_pt_compress.cxx
r2 r655 2 2 #include <string.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <arbdb.h> 6 6 #include <arbdbt.h> … … 116 116 rel_2_abs = (long *)calloc(sizeof(long),memsize); 117 117 } 118 118 119 119 if (rel >= memsize) { 120 120 memsize = memsize * MEM_ALLOC_FACTOR; … … 137 137 138 138 void client_gap_compress::basic_write(long rel, long x, long y){ 139 139 140 140 if (rel >= memsize) { 141 141 memsize = (int)rel * MEM_ALLOC_FACTOR; … … 172 172 cgc_search_by_divide: 173 173 long l; 174 l = 0; r = master->len-1; 174 l = 0; r = master->len-1; 175 175 while (l<r-1) { // search the masters rel_2_abs[?] == abs 176 176 m = (l+r)>>1; … … 188 188 } 189 189 190 // remove (eval. ) duplicated entries in client compress 190 // remove (eval. ) duplicated entries in client compress 191 191 // eg. (4,20,5) (5,21,5) -> delete second 192 192 … … 383 383 master->ref_cnt++; 384 384 385 if (nmasters >= MAX_MASTERS) { // maximum masters exceeded delete 385 if (nmasters >= MAX_MASTERS) { // maximum masters exceeded delete 386 386 int j; // search single refed masters and search new master 387 387 // for the only single child … … 403 403 nmasters--; 404 404 delete masters[i]; 405 } 405 } 406 406 } 407 407 … … 583 583 584 584 // pt_species_class::set destroys the sequence !!!!!! 585 // name and fullname must be a new copy 585 // name and fullname must be a new copy 586 586 void pt_species_class::set(char *sequence, long seq_len, char *name, char *fullname){ 587 587 delete this->fullname; … … 621 621 case 'T': 622 622 case 't': *(dest++) = PT_T;*(abs++) = '+';SET_NN; break; 623 case '.': *(dest)++ = PT_QU;*(abs++) = '+'; 623 case '.': *(dest)++ = PT_QU;*(abs++) = '+'; 624 624 while (*src =='.') { src++; *(abs++) = '-'; } 625 625 SET_NN; … … 637 637 break; 638 638 } 639 639 640 640 } 641 641 *dest = PT_QU; … … 717 717 718 718 pt_main_class::~pt_main_class(void) { 719 GB_CORE; 719 GB_CORE; 720 720 } 721 721 … … 925 925 } 926 926 927 int 927 int 928 928 main(int argc, char **argv) 929 929 { … … 956 956 } 957 957 958 #if 0 958 #if 0 959 959 char *cmp; 960 960 int i; -
trunk/TESTAWT/TB_main.cxx
r2 r655 3 3 * 4 4 * Description: demonstration of the use of AWT and WINDOW libraries, as 5 * a testbed for the vectorfont functions 6 * 5 * a testbed for the vectorfont functions 6 * 7 7 * Integration Notes: use the callback in TB_extern.cxx for your own stuff 8 8 * … … 14 14 * 15 15 * $Log$ 16 * Revision 1.1 2000/11/23 09:41:16 westram 17 * Initial revision 16 * Revision 1.2 2002/06/20 14:08:06 westram 17 * Mac OSX patches from Ben Hines 18 * 19 * Revision 1.1.1.1 2000/11/23 09:41:16 westram 20 * Erster Import 18 21 * 19 22 * Revision 1.2 1995/03/13 16:53:19 jakobi … … 26 29 #include <stdio.h> 27 30 #include <stdlib.h> 28 #include <malloc.h>31 // #include <malloc.h> 29 32 30 33 … … 44 47 45 48 // my own stuff 46 #define EXTERNAL 49 #define EXTERNAL 47 50 #include "tb_extern.hxx" 48 51 … … 53 56 54 57 // required dummy for AWT, even if you don't use trees... 55 void AD_map_viewer(gb_data_base_type *dummy) 58 void AD_map_viewer(gb_data_base_type *dummy) 56 59 { 57 60 AWUSE(dummy); … … 66 69 AW_default aw_default; 67 70 AW_window *aww; 68 71 69 72 // db is *not* used, so we don't care about transactions 70 73 // for getting an non-empty db for getting an empty tree for getting the canvas ... … … 108 111 aw_root->create_float("tbd_alignmenty",&tbd_alignmenty,aw_default,0.0); 109 112 aw_root->create_float("tbd_rotation",&tbd_rotation,aw_default,0.0); 110 111 // open the main window 113 114 // open the main window 112 115 aww = create_tb_main_window(aw_root); 113 116 aww->show(); -
trunk/TESTVECTORFONT/TB_main.cxx
r2 r655 3 3 * 4 4 * Description: demonstration of the use of AWT and WINDOW libraries, as 5 * a testbed for the vectorfont functions 6 * 5 * a testbed for the vectorfont functions 6 * 7 7 * Integration Notes: use the callback in TB_extern.cxx for your own stuff 8 8 * … … 14 14 * 15 15 * $Log$ 16 * Revision 1.1 2000/11/23 09:41:16 westram 17 * Initial revision 16 * Revision 1.2 2002/06/20 14:08:06 westram 17 * Mac OSX patches from Ben Hines 18 * 19 * Revision 1.1.1.1 2000/11/23 09:41:16 westram 20 * Erster Import 18 21 * 19 22 * Revision 1.2 1995/03/13 16:53:19 jakobi … … 26 29 #include <stdio.h> 27 30 #include <stdlib.h> 28 #include <malloc.h>31 // #include <malloc.h> 29 32 30 33 … … 45 48 46 49 // my own stuff 47 #define EXTERNAL 50 #define EXTERNAL 48 51 #include "tb_extern.hxx" 49 52 … … 54 57 55 58 // required dummy for AWT, even if you don't use trees... 56 void AD_map_viewer(gb_data_base_type *dummy) 59 void AD_map_viewer(gb_data_base_type *dummy) 57 60 { 58 61 AWUSE(dummy); … … 67 70 AW_default aw_default; 68 71 AW_window *aww; 69 72 70 73 // db is *not* used, so we don't care about transactions 71 74 // for getting an non-empty db for getting an empty tree for getting the canvas ... … … 109 112 aw_root->create_float("tbd_alignmenty",&tbd_alignmenty,aw_default,0.0); 110 113 aw_root->create_float("tbd_rotation",&tbd_rotation,aw_default,0.0); 111 112 // open the main window 114 115 // open the main window 113 116 aww = create_tb_main_window(aw_root); 114 117 aww->show(); -
trunk/TOOLS/arb_count_chars.cxx
r2 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <string.h> 5 5 #include <ctype.h> … … 18 18 19 19 printf("Counting the number of different chars of all marked sequences\n"); 20 20 21 21 GBDATA *gb_main = GB_open(":","rw"); // open database 22 22 if (!gb_main){ … … 24 24 return -1; 25 25 } 26 26 27 27 GB_begin_transaction(gb_main); // open transaction 28 28 … … 58 58 int slider = 0; 59 59 int all_marked = GBT_count_marked_species(gb_main); 60 60 61 61 for (GBDATA *gb_species = GBT_first_marked_species(gb_main); 62 62 gb_species; … … 94 94 } 95 95 } 96 96 97 97 { // save result as SAI counted_chars 98 98 GBDATA *gb_sai = GBT_create_SAI(gb_main,RESULTNAME); … … 110 110 GB_close(gb_main); // politely disconnect from server 111 111 return 0; 112 112 113 113 } -
trunk/TOOLS/arb_dnarates.c
r618 r655 21 21 #include <stdlib.h> 22 22 #include <unistd.h> 23 #include <malloc.h> 23 /* #include <malloc.h> */ 24 24 #include <string.h> 25 25 #include <math.h> -
trunk/TOOLS/arb_primer.cxx
r646 r655 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 #include <malloc.h>3 // #include <malloc.h> 4 4 #include <string.h> 5 5 #include <arbdb.h> -
trunk/TOOLS/arb_probe.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <string.h> 6 6 … … 98 98 T_PT_TPROBE tprobe; 99 99 bytestring bs; 100 char *match_info; 100 char *match_info; 101 101 102 102 if( !(servername=(char *)probe_pt_look_for_server()) ){ … … 150 150 0); 151 151 } 152 152 153 153 aisc_put(pd_gl.link,PT_PDC, pdc, 154 154 PDC_NAMES,&bs, … … 158 158 { 159 159 char *locs_error = 0; 160 if (aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 160 if (aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 161 161 LOCS_ERROR ,&locs_error, 162 162 0)){ … … 170 170 } 171 171 172 aisc_get( pd_gl.link, PT_PDC, pdc, 172 aisc_get( pd_gl.link, PT_PDC, pdc, 173 173 PDC_TPROBE, &tprobe, 174 174 0); 175 175 176 176 177 177 if (tprobe) { 178 178 aisc_get( pd_gl.link, PT_TPROBE, tprobe, … … 250 250 bytestring bs; 251 251 bs.data = 0; 252 aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 252 aisc_get( pd_gl.link, PT_LOCS, pd_gl.locs, 253 253 LOCS_MATCH_LIST, &match_list, 254 254 LOCS_MATCH_LIST_CNT, &match_list_cnt, -
trunk/TREEGEN/defines.h
r2 r655 2 2 #define __DEFINES_H 3 3 4 #ifndef __MALLOC_H5 #include <malloc.h>6 #endif4 // #ifndef __MALLOC_H 5 // #include <malloc.h> 6 // #endif 7 7 #ifndef __STDIO_H 8 8 #include <stdio.h> -
trunk/TREE_COMPRESS/TC_main.cxx
r2 r655 2 2 #include <string.h> 3 3 #include <memory.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <arbdb.h> 6 6 #include <arbdbt.h> … … 116 116 rel_2_abs = (long *)calloc(sizeof(long),memsize); 117 117 } 118 118 119 119 if (rel >= memsize) { 120 120 memsize = memsize * MEM_ALLOC_FACTOR; … … 137 137 138 138 void client_gap_compress::basic_write(long rel, long x, long y){ 139 139 140 140 if (rel >= memsize) { 141 141 memsize = (int)rel * MEM_ALLOC_FACTOR; … … 172 172 cgc_search_by_divide: 173 173 long l; 174 l = 0; r = master->len-1; 174 l = 0; r = master->len-1; 175 175 while (l<r-1) { // search the masters rel_2_abs[?] == abs 176 176 m = (l+r)>>1; … … 188 188 } 189 189 190 // remove (eval. ) duplicated entries in client compress 190 // remove (eval. ) duplicated entries in client compress 191 191 // eg. (4,20,5) (5,21,5) -> delete second 192 192 … … 383 383 master->ref_cnt++; 384 384 385 if (nmasters >= MAX_MASTERS) { // maximum masters exceeded delete 385 if (nmasters >= MAX_MASTERS) { // maximum masters exceeded delete 386 386 int j; // search single refed masters and search new master 387 387 // for the only single child … … 403 403 nmasters--; 404 404 delete masters[i]; 405 } 405 } 406 406 } 407 407 … … 583 583 584 584 // pt_species_class::set destroys the sequence !!!!!! 585 // name and fullname must be a new copy 585 // name and fullname must be a new copy 586 586 void pt_species_class::set(char *sequence, long seq_len, char *name, char *fullname){ 587 587 delete this->fullname; … … 621 621 case 'T': 622 622 case 't': *(dest++) = PT_T;*(abs++) = '+';SET_NN; break; 623 case '.': *(dest)++ = PT_QU;*(abs++) = '+'; 623 case '.': *(dest)++ = PT_QU;*(abs++) = '+'; 624 624 while (*src =='.') { src++; *(abs++) = '-'; } 625 625 SET_NN; … … 637 637 break; 638 638 } 639 639 640 640 } 641 641 *dest = PT_QU; … … 717 717 718 718 pt_main_class::~pt_main_class(void) { 719 GB_CORE; 719 GB_CORE; 720 720 } 721 721 … … 925 925 } 926 926 927 int 927 int 928 928 main(int argc, char **argv) 929 929 { … … 956 956 } 957 957 958 #if 0 958 #if 0 959 959 char *cmp; 960 960 int i; -
trunk/TRS/tree_lib.cxx
r2 r655 1 /* 1 /* 2 2 ####################################### 3 3 # # … … 11 11 #include <string.h> 12 12 #include <memory.h> 13 #include <malloc.h>13 // #include <malloc.h> 14 14 #include <stdarg.h> 15 15 #include <sys/stat.h> … … 40 40 sprintf (buffer,"ARB ERROR: "); 41 41 p += strlen(p); 42 va_start(parg,templat); 42 va_start(parg,templat); 43 43 44 44 vsprintf(p,templat,parg); … … 159 159 read a file to memory 160 160 ********************************************************************************************/ 161 char *TRS_read_file(const char *path) 161 char *TRS_read_file(const char *path) 162 162 { 163 163 FILE *input; … … 267 267 fputc(o,t2j_out); 268 268 t2j_last_nibble = -1; 269 } 269 } 270 270 } 271 271 … … 571 571 } 572 572 /*********************************************************************** 573 Send the tree. level numbering !!! branch lengths from 0-15 573 Send the tree. level numbering !!! branch lengths from 0-15 574 574 Sideeffects: writes to out 575 575 ***********************************************************************/ … … 607 607 if node.color == 0 -> prune node 608 608 add addbl to branch length 609 609 610 610 ***********************************************************************/ 611 611 #define SEPERATOR '\'' … … 635 635 } 636 636 } 637 637 638 638 CAT_node *ln = &cat_tree->nodes[node->leftson]; 639 639 CAT_node *rn = &cat_tree->nodes[node->rightson]; 640 640 641 641 if ( (ln->color & rn->color ) == 0){ // prune tree, descend into only one branch 642 642 if (ln->color != 0){ … … 647 647 return; 648 648 } 649 649 650 650 if (!node->is_grouped){ 651 651 fprintf(out,"("); … … 733 733 } 734 734 735 735 736 736 char *T2J_send_newick_tree(const char *path_of_tree, 737 737 char *changedNodes, … … 750 750 } 751 751 } 752 752 753 753 T2J_set_color_of_selection(selectedNodes); 754 754 755 755 { 756 756 int i; … … 920 920 node->user_data = cat_tree->data + node->field_offsets[CAT_FIELD_GROUP_NAME]; 921 921 } 922 922 923 923 } 924 924 return T2J_send_tree(0); 925 925 } 926 926 927 long t2j_get_deepest_node_that_contains_all_selected(CAT_node_id nn, 927 long t2j_get_deepest_node_that_contains_all_selected(CAT_node_id nn, 928 928 char *selected_ids,long nselected, CAT_node_id *focusout){ 929 929 CAT_node *node = & cat_tree->nodes[nn]; … … 967 967 if (sel == cat_tree->nnodes) break; // no more selections 968 968 // search a non selected terminal 969 969 970 970 int nsel; 971 971 for (nsel = sel; nsel < cat_tree->nnodes; nsel++){ … … 977 977 int last = nsel; 978 978 if (nsel < cat_tree->nnodes) last = cat_tree->nodes[nsel].numbering[CAT_NUMBERING_LEVELS]; 979 979 980 980 int h = lastWritten; 981 981 lastWritten = last; … … 984 984 985 985 t2j_out_number( first,'A' ); 986 t2j_out_number( last,'a' ); 986 t2j_out_number( last,'a' ); 987 987 } 988 988 printf("\n"); … … 997 997 varname a string that is prepended to the output 998 998 all_nodes output = all nodes or just ranges 999 field_name which field should be placed in the output CAT_FIELD_NAME/CAT_FIELD_FULL_NAME ... 999 field_name which field should be placed in the output CAT_FIELD_NAME/CAT_FIELD_FULL_NAME ... 1000 1000 1001 1001 if all_nodes >0 then the programm calculates: … … 1010 1010 if (!cat_tree) return 0; 1011 1011 CAT_node_id *levelindex = t2j_mcreate_level_indexing(); 1012 1012 1013 1013 char *readp = sel; 1014 1014 int nselected = 0; … … 1020 1020 TRS_strcat(memfile,varname); 1021 1021 readp = sel; 1022 c = *(readp++); 1022 c = *(readp++); 1023 1023 int last = 0; 1024 1024 for (; c >='A' && c <='Z'; ){ … … 1040 1040 if (s >= cat_tree->nnodes) e = cat_tree->nnodes-1; 1041 1041 last = e; 1042 1042 1043 1043 if (all_nodes) { 1044 1044 for (;s<e;s++) { … … 1051 1051 } 1052 1052 }else{ 1053 TRS_strcat(memfile,cat_tree->data + 1053 TRS_strcat(memfile,cat_tree->data + 1054 1054 cat_tree->nodes[levelindex[s]].field_offsets[field_name]); 1055 1055 // thats one of my favourite statements … … 1068 1068 t2j_get_deepest_node_that_contains_all_selected( 1069 1069 0,selected_ids,nselected,focusout); 1070 if (maxnodeout ) *maxnodeout = cat_tree->data + 1070 if (maxnodeout ) *maxnodeout = cat_tree->data + 1071 1071 cat_tree->nodes[*focusout]. 1072 1072 field_offsets[CAT_FIELD_NAME]; … … 1077 1077 CAT_node_id nextuppderlabeldnode = *focusout; 1078 1078 1079 while ( nextuppderlabeldnode > 0 1079 while ( nextuppderlabeldnode > 0 1080 1080 && cat_tree->nodes[nextuppderlabeldnode]. 1081 1081 field_offsets[CAT_FIELD_GROUP_NAME] == 0 ) { … … 1083 1083 } 1084 1084 if (nextuppderlabeldnode) { // get the name of the node 1085 if (maxnodeout ) *maxnodeout = cat_tree->data + 1085 if (maxnodeout ) *maxnodeout = cat_tree->data + 1086 1086 cat_tree->nodes[nextuppderlabeldnode]. 1087 1087 field_offsets[CAT_FIELD_GROUP_NAME]; … … 1140 1140 } 1141 1141 1142 1143 c = *(readp++); 1142 1143 c = *(readp++); 1144 1144 for (; c >='A' && c <='Z'; ){ 1145 1145 fac = 1;s = last; … … 1160 1160 if (s >= cat_tree->nnodes) e = cat_tree->nnodes-1; 1161 1161 last = e; 1162 1162 1163 1163 for (;s<e;s++) { 1164 1164 cat_tree->nodes[levelindex[s]].color = 1; -
trunk/TRS/trs_hash.cxx
r2 r655 5 5 #include <stdio.h> 6 6 #include <stdlib.h> 7 #include <malloc.h>7 // #include <malloc.h> 8 8 #include <string.h> 9 9 #include <ctype.h> … … 216 216 } 217 217 218 long 218 long 219 219 TRS_free_hash_entries(long hash) 220 220 { … … 235 235 } 236 236 237 long 237 long 238 238 TRS_free_hash(long hash) 239 239 { … … 244 244 return 0; 245 245 } 246 long 246 long 247 247 TRS_free_hash_entries_free_pointer(long hash) 248 248 { … … 263 263 return 0; 264 264 } 265 long 265 long 266 266 TRS_free_hash_free_pointer(long hash) 267 267 { -
trunk/TRS/trs_server.cxx
r2 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 6 6 char *TRS_map_file(const char *path,int writeable); … … 30 30 } else if (!strcmp(request_method,"POST")) { 31 31 char *temp; 32 if(!(temp=getenv("CONTENT_LENGTH"))) 33 quit_with_error(TRS_export_error("CONTENT_LENGTH not set")); 32 if(!(temp=getenv("CONTENT_LENGTH"))) 33 quit_with_error(TRS_export_error("CONTENT_LENGTH not set")); 34 34 int len=atoi(temp); 35 35 indata=new char[len+1]; … … 195 195 " only name,fullname,accession is allowed"); 196 196 goto end; 197 } 197 } 198 198 char *dat = TRS_read_file("-"); 199 199 struct T2J_transfer_struct *transfer = T2J_read_query_result_from_data(dat,catfield); … … 216 216 } 217 217 } 218 218 219 219 end: 220 220 if (error) { -
trunk/WINDOW/AW_Xm.cxx
r579 r655 3 3 #include <string.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <math.h> 7 7 #include <X11/X.h> … … 55 55 } 56 56 } 57 58 AUTO_FLUSH(this); 59 57 58 AUTO_FLUSH(this); 59 60 60 return drawflag; 61 61 } … … 71 71 XDrawString(device->common->display, device->common->window_id, device->common->gcs[gc]->gc, 72 72 AW_INT(X), AW_INT(Y), str + start , (int)size); 73 73 74 74 AUTO_FLUSH(device); 75 75 76 76 return 1; 77 77 } … … 81 81 return text_overlay(gc,str,opt_strlen,x,y,alignment,filteri,(AW_CL)this, cd1,cd2,0.0,0.0,AW_draw_string_on_screen); 82 82 } 83 83 84 84 int AW_device_Xm::box(int gc, AW_pos x0,AW_pos y0,AW_pos width,AW_pos height, AW_bitset filteri, AW_CL cd1, AW_CL cd2) { 85 85 AWUSE(cd1);AWUSE(cd2); … … 107 107 } 108 108 } 109 110 AUTO_FLUSH(this); 111 109 110 AUTO_FLUSH(this); 111 112 112 return 0; 113 113 } … … 148 148 } 149 149 } 150 151 AUTO_FLUSH(this); 152 150 151 AUTO_FLUSH(this); 152 153 153 return 0; 154 154 } … … 156 156 void AW_device_Xm::clear() { 157 157 XClearWindow(common->display,common->window_id); 158 158 159 159 AUTO_FLUSH(this); 160 160 } … … 183 183 184 184 XClearArea(common->display,common->window_id,(int)X,(int)Y,(int)width,(int)height,False); 185 186 AUTO_FLUSH(this); 185 186 AUTO_FLUSH(this); 187 187 } 188 188 … … 216 216 XClearArea(common->display, common->window_id, 217 217 (int)X,(int)Y-(int)xfs->max_bounds.ascent,(int)width,(int)height,False); 218 218 219 219 AUTO_FLUSH(this); 220 220 } -
trunk/WINDOW/AW_click.cxx
r2 r655 3 3 #include <string.h> 4 4 #include <memory.h> 5 #include <malloc.h>5 // #include <malloc.h> 6 6 #include <X11/X.h> 7 7 #include <X11/Xlib.h> … … 63 63 //stimmen die Kreise um die Punkte ? 64 64 65 65 66 66 67 67 // distance to the second point of the line … … 149 149 } 150 150 151 if(this->clip_rect.b == common->screen.b) { 151 if(this->clip_rect.b == common->screen.b) { 152 152 if (Yt > this->clip_rect.b) return 0; 153 153 }else { … … 174 174 if(mouse_y < Yt - max_distance_text ){ 175 175 return 0; 176 } else { 176 } else { 177 177 not_optimal = AW_TRUE; 178 178 best_dist = Yt - mouse_y; 179 } 179 } 180 180 } 181 181 … … 187 187 text_width = (int)get_string_size(gc,str,len); 188 188 X0 = common->x_alignment(X0,text_width,alignment); 189 text_width += xfs->max_bounds.width*2; 189 text_width += xfs->max_bounds.width*2; 190 190 191 191 /**************** check against left right clipping areas *********/ 192 192 if (X0 + text_width< this->clip_rect.l) return 0; 193 193 if (X0 > this->clip_rect.r + xfs->max_bounds.width) return 0; 194 194 195 195 /***************** left of text ***************************/ 196 196 if(mouse_x < (X0 - (xfs->max_bounds.width)) ) { -
trunk/WINDOW/AW_xfont.cxx
r444 r655 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 #include <malloc.h>4 // #include <malloc.h> 5 5 #include <memory.h> 6 6 #include <ctype.h> -
trunk/config.makefile.template
r649 r655 15 15 16 16 # export DEBIAN = 1 17 18 #********* Mac OSX ******** 19 20 # MACH = DARWIN# 21 # DARWIN = 1 17 22 18 23 #********* SUN4 / acc CC / dynamic ********
