| 1 | // PatMaN DNA pattern matchercxx . . $ `<file>/prefix_tree.h`/ |
| 2 | // (C) 2007 Kay Pruefer, Udo Stenzel |
| 3 | // |
| 4 | // This program is free software; you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation; either version 2 of the License, or (at |
| 7 | // your option) any later version. See the LICENSE file for details. |
| 8 | |
| 9 | #ifndef INCLUDED_PREFIX_TREE_H |
| 10 | #define INCLUDED_PREFIX_TREE_Hcxx . . $ `prefix_tree.h:10:9`! |
| 11 | |
| 12 | #include <deque> |
| 13 | #include <string> |
| 14 | |
| 15 | #ifndef NDEBUGcxx . . $ `<built-in>:482:9`! |
| 16 | #include <istream> |
| 17 | #endif |
| 18 | |
| 19 | #include "global.h"cxx . . $ `<file>/global.h`/ |
| 20 | |
| 21 | struct probe_scxx . . $ probe_s# { |
| 22 | probe_scxx . . $ probe_s# *nextcxx . . $ probe_s#next. ; |
| 23 | stdcxx . . $ std/::stringcxx . . $ std/string# namecxx . . $ probe_s#name. ; |
| 24 | int lengthcxx . . $ probe_s#length. ; |
| 25 | char strandcxx . . $ probe_s#strand. ; // + or - |
| 26 | } ; |
| 27 | |
| 28 | struct nodecxx . . $ node# { |
| 29 | nodecxx . . $ node#* childscxx . . $ node#childs.[5] ; |
| 30 | nodecxx . . $ node#* suffixcxx . . $ node#suffix. ; |
| 31 | probe_scxx . . $ probe_s# *probescxx . . $ node#probes. ; |
| 32 | unsigned char dropcxx . . $ node#drop.[5] ; |
| 33 | unsigned char drop_suffixcxx . . $ node#drop_suffix. ; |
| 34 | unsigned char depthcxx . . $ node#depth. ; |
| 35 | #ifndef NDEBUGcxx . . $ `<built-in>:482:9`! |
| 36 | std::string label ; |
| 37 | #endif |
| 38 | |
| 39 | nodecxx . . $ node#node(49f6e7a06ebc5aa8).() : suffixcxx . . $ node#suffix.(0), probescxx . . $ node#probes.(0), drop_suffixcxx . . $ node#drop_suffix.(0), depthcxx . . $ node#depth.(0) |
| 40 | { |
| 41 | for( int i = 0 ; i != 5 ; ++i ) |
| 42 | { |
| 43 | childscxx . . $ node#childs.[i] = 0 ; |
| 44 | dropcxx . . $ node#drop.[i] = 0 ; |
| 45 | } |
| 46 | } |
| 47 | } ; |
| 48 | |
| 49 | /* Mismatch pointers (elsewhere called "walkers") point into the prefix |
| 50 | * trie, track the history of an alignment and are advanced according to |
| 51 | * the read database. |
| 52 | * |
| 53 | * We will keep mismatch pointers in a queue, implemented as singly |
| 54 | * linked list, and because we splice inside that list, it's probably |
| 55 | * best to implement it directly (instead of encapsulating everything |
| 56 | * behind an object). Unused nodes will be collected in another list |
| 57 | * (the junk heap). |
| 58 | */ |
| 59 | struct mismatch_ptrcxx . . $ mismatch_ptr# { |
| 60 | struct mismatch_ptrcxx . . $ mismatch_ptr# *nextcxx . . $ mismatch_ptr#next. ; |
| 61 | const nodecxx . . $ node# *ptrcxx . . $ mismatch_ptr#ptr. ; |
| 62 | unsigned char mismatchcxx . . $ mismatch_ptr#mismatch. ; |
| 63 | unsigned char firstcxx . . $ mismatch_ptr#first. ; |
| 64 | unsigned char matchedcxx . . $ mismatch_ptr#matched. ; |
| 65 | unsigned char isgapcxx . . $ mismatch_ptr#isgap. : 1 ; |
| 66 | unsigned char gapscxx . . $ mismatch_ptr#gaps. : 7 ; |
| 67 | } ; |
| 68 | |
| 69 | class prefix_treecxx . . $ prefix_tree# |
| 70 | { |
| 71 | public: |
| 72 | prefix_treecxx . . $ prefix_tree#prefix_tree(49f6e7a06ebc5aa8).( ) ; |
| 73 | void add_seqcxx . . $ prefix_tree#add_seq(63deecd705778e94).( const stdcxx . . $ std/::stringcxx . . $ std/string#& seq, const stdcxx . . $ std/::stringcxx . . $ std/string#& name, bool ambi_codes ) ; |
| 74 | mismatch_ptrcxx . . $ mismatch_ptr# *comparecxx . . $ prefix_tree#compare(b3dcdb8feb03de9).( char c, mismatch_ptrcxx . . $ mismatch_ptr# *ptrs ) const ; |
| 75 | void add_suffix_linkscxx . . $ prefix_tree#add_suffix_links(49f6e7a06ebc5aa8).() ; |
| 76 | mismatch_ptrcxx . . $ mismatch_ptr# *initcxx . . $ prefix_tree#init(9f4eb692c23f96cc).( mismatch_ptrcxx . . $ mismatch_ptr#* ) const ; |
| 77 | |
| 78 | #ifndef NDEBUGcxx . . $ `<built-in>:482:9`! |
| 79 | void debug( std::ostream& s ) const { debug( s, nodes[0] ) ; } |
| 80 | void debug( std::ostream&, const node& ) const ; |
| 81 | #endif |
| 82 | |
| 83 | private: |
| 84 | nodecxx . . $ node#* create_go_nodecxx . . $ prefix_tree#create_go_node(ded99998152b81f8).( nodecxx . . $ node#* n, int pos ) ; |
| 85 | mismatch_ptrcxx . . $ mismatch_ptr# *seedcxx . . $ prefix_tree#seed(3606ea0e0471eaa7).() const ; |
| 86 | void add_recursioncxx . . $ prefix_tree#add_recursion(633306f8a470b339).( const stdcxx . . $ std/::stringcxx . . $ std/string#& seq, const stdcxx . . $ std/::stringcxx . . $ std/string#& name, nodecxx . . $ node#* ptr, size_tcxx . . $ size_t# i, char strand ) ; |
| 87 | void add_recursion_ambiguitycxx . . $ prefix_tree#add_recursion_ambiguity(633306f8a470b339).( const stdcxx . . $ std/::stringcxx . . $ std/string#& seq, const stdcxx . . $ std/::stringcxx . . $ std/string#& name, nodecxx . . $ node#* ptr, size_tcxx . . $ size_t# i, char strand ) ; |
| 88 | |
| 89 | stdcxx . . $ std/::dequecxx . . $ std/deque#<nodecxx . . $ node#> nodescxx . . $ prefix_tree#nodes. ; |
| 90 | } ; |
| 91 | |
| 92 | #endif |