1 /* 2 Copyright (c) 2003 by Stefan Kurtz and The Institute for 3 Genomic Research. This is OSI Certified Open Source Software. 4 Please see the file LICENSE for licensing information and 5 the file ACKNOWLEDGEMENTS for names of contributors to the 6 code base. 7 */ 8 9 #ifndef STREEMAC_H 10 #define STREEMAC_H 11 12 #include "types.h" 13 #include "symboldef.h" 14 #include "errordef.h" 15 16 /* 17 For each branching node we store five integers, see \cite{KUR:1999}. 18 An or-combination of the following bits allow to access any subset of 19 these five integers via the function \texttt{getbranchinfostree}. 20 */ 21 22 #define ACCESSDEPTH UintConst(1) 23 #define ACCESSHEADPOS (UintConst(1) << 1) 24 #define ACCESSSUFFIXLINK (UintConst(1) << 2) 25 #define ACCESSFIRSTCHILD (UintConst(1) << 3) 26 #define ACCESSBRANCHBROTHER (UintConst(1) << 4) 27 28 /* 29 The following macro simplifies calling the function for constructing 30 suffix trees. 31 */ 32 33 #define CONSTRUCTSTREE(ST,TEXT,TEXTLEN,ACTION)\ 34 if(constructstree(ST,TEXT,TEXTLEN) != 0)\ 35 {\ 36 fprintf(stderr,"%s",messagespace());\ 37 ACTION;\ 38 } 39 40 /* 41 The root of the suffix tree is stored in the first elements of the 42 table \texttt{branchtab}. 43 */ 44 45 #define ROOT(ST) ((ST)->branchtab) 46 47 /* 48 The following macro returns \texttt{True}, if and only if the given 49 location refers to the root. 50 */ 51 52 #define ROOTLOCATION(LOC)\ 53 (((LOC)->locstring.length == 0) ? True : False) 54 55 /* 56 The following macros compute the index of a branch node and a leaf, 57 relative to the first address and the first leaf, respectively. 58 */ 59 60 #define BRADDR2NUM(ST,A) ((Uint) ((A) - ROOT(ST))) 61 #define LEAFADDR2NUM(ST,A) ((Uint) ((A) - (ST)->leaftab)) 62 63 //\Ignore{ 64 65 #ifdef DEBUG 66 #define CHECKADDR(ST,A)\ 67 if((A).toleaf)\ 68 {\ 69 if(LEAFADDR2NUM(ST,(A).address) > (ST)->textlen)\ 70 {\ 71 printf("%s,%lu:",__FILE__,(Showuint) __LINE__);\ 72 printf("leafaddr = %lu invalid\n",\ 73 (Showuint) LEAFADDR2NUM(ST,(A).address));\ 74 exit(EXIT_FAILURE);\ 75 }\ 76 } else\ 77 {\ 78 if(BRADDR2NUM(ST,(A).address) >= (ST)->nextfreebranchnum)\ 79 {\ 80 printf("%s,%lu:",__FILE__,(Showuint) __LINE__);\ 81 printf("branchaddr = %lu invalid\n",\ 82 (Showuint) BRADDR2NUM(ST,(A).address));\ 83 exit(EXIT_FAILURE);\ 84 }\ 85 } 86 #else 87 #define CHECKADDR(ST,A) /* Nothing */ 88 #endif 89 90 //} 91 92 #endif 93