| 1 | #cxx . . $ `<file>/seatac/filter-nop.C`/include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <string.h> |
| 4 | |
| 5 | // A very simple seatac filter. It reports the single longest match for each pair. |
| 6 | // |
| 7 | // Also shows how to use a C++ object as a filter. C is pretty much the same thing. |
| 8 | |
| 9 | #include "bio.h"cxx . . $ `<file>/libbio/bio.h`/ |
| 10 | #include "util++.H"cxx . . $ `<file>/libutil/util++.H`/ |
| 11 | |
| 12 | extern "C" { |
| 13 | void *construct(char *options); |
| 14 | void destruct(void *handle); |
| 15 | void addHit(void *handle, |
| 16 | char orientation, |
| 17 | uint32cxx . . $ uint32# id1, |
| 18 | uint32cxx . . $ uint32# pos1, |
| 19 | uint32cxx . . $ uint32# len1, |
| 20 | uint32cxx . . $ uint32# id2, |
| 21 | uint32cxx . . $ uint32# pos2, |
| 22 | uint32cxx . . $ uint32# len2, |
| 23 | uint32cxx . . $ uint32# filled); |
| 24 | void filter(void *handle); |
| 25 | uint64cxx . . $ uint64# output(void *handle, FILE *file, uint64cxx . . $ uint64# matchid); |
| 26 | |
| 27 | void *constructStats(char *options); |
| 28 | void destructStats(void *handle); |
| 29 | void addStats(void *handle, void *filterhandle); |
| 30 | void showStats(void *handle, FILE *file); |
| 31 | } |
| 32 | |
| 33 | |
| 34 | |
| 35 | class filterLongestcxx . . $ filterLongest# { |
| 36 | public: |
| 37 | filterLongestcxx . . $ filterLongest#filterLongest(d0489a02ea06dfc6).(char *n1, char *n2) { |
| 38 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Creating a filterLongest\n"); |
| 39 | strncpy(name1cxx . . $ filterLongest#name1., n1, 31); |
| 40 | strncpy(name2cxx . . $ filterLongest#name2., n2, 31); |
| 41 | }; |
| 42 | |
| 43 | ~cxx . . $ filterLongest#`~filterLongest`(ced63f7c635d850d).filterLongestcxx . . $ filterLongest#() { |
| 44 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Destroyed a filterLongest\n"); |
| 45 | }; |
| 46 | |
| 47 | void addHitcxx . . $ filterLongest#addHit(a209694d0a1a92e0).(char orientation, |
| 48 | uint32cxx . . $ uint32# id1, |
| 49 | uint32cxx . . $ uint32# pos1, |
| 50 | uint32cxx . . $ uint32# len1, |
| 51 | uint32cxx . . $ uint32# id2, |
| 52 | uint32cxx . . $ uint32# pos2, |
| 53 | uint32cxx . . $ uint32# len2, |
| 54 | uint32cxx . . $ uint32# filled) { |
| 55 | |
| 56 | if (maxfilledcxx . . $ filterLongest#maxfilled. < filled) { |
| 57 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "filterNOP-- addHit\n"); |
| 58 | |
| 59 | maxfilledcxx . . $ filterLongest#maxfilled. = filled; |
| 60 | #if 0 |
| 61 | sprintf(outstring, |
| 62 | "-%c -e "uint32FMT" "uint32FMT" "uint32FMT" -D "uint32FMT" "uint32FMT" "uint32FMT" -F "uint32FMT"\n", |
| 63 | orientation, id1, pos1, len1, id2, pos2, len2, filled); |
| 64 | #endif |
| 65 | |
| 66 | sprintf(outstringcxx . . $ filterLongest#outstring., |
| 67 | "M x . . %s:"uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" 1 %s:"uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" %s "uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", |
| 68 | name1cxx . . $ filterLongest#name1., id1, pos1, len1, name2cxx . . $ filterLongest#name2., id2, pos2, len2, (orientation == 'f') ? "1" : "-1", filled); |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | void filtercxx . . $ filterLongest#filter(49f6e7a06ebc5aa8).(void) { |
| 73 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "filterNOP-- filter\n"); |
| 74 | }; |
| 75 | |
| 76 | uint64cxx . . $ uint64# outputcxx . . $ filterLongest#output(9bd1d5b934681de1).(FILE *file, uint64cxx . . $ uint64# matchid) { |
| 77 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "filterNOP-- output (ignoring matchid)\n"); |
| 78 | fprintf(file, "%s", outstringcxx . . $ filterLongest#outstring.); |
| 79 | return(matchid); |
| 80 | }; |
| 81 | private: |
| 82 | char outstringcxx . . $ filterLongest#outstring.[512]; |
| 83 | char name1cxx . . $ filterLongest#name1.[32], name2cxx . . $ filterLongest#name2.[32]; |
| 84 | uint32cxx . . $ uint32# maxfilledcxx . . $ filterLongest#maxfilled.; |
| 85 | }; |
| 86 | |
| 87 | |
| 88 | |
| 89 | class statLongestcxx . . $ statLongest# { |
| 90 | public: |
| 91 | statLongestcxx . . $ statLongest#statLongest(49f6e7a06ebc5aa8).() { |
| 92 | numcxx . . $ statLongest#num. = 0; |
| 93 | } |
| 94 | ~cxx . . $ statLongest#`~statLongest`(ced63f7c635d850d).statLongestcxx . . $ statLongest#() { |
| 95 | } |
| 96 | |
| 97 | void addcxx . . $ statLongest#add(573707ecc2669f06).(filterLongestcxx . . $ filterLongest# *F) { |
| 98 | numcxx . . $ statLongest#num.++; |
| 99 | } |
| 100 | |
| 101 | void showcxx . . $ statLongest#show(8d4262d45fc644ab).(FILE *file) { |
| 102 | fprintf(file, "/statObjNum=%d\n", numcxx . . $ statLongest#num.); |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | int numcxx . . $ statLongest#num.; |
| 107 | }; |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | void* |
| 115 | constructcxx . . $ construct(8176fcad44ba9a1b).(char *opts) { |
| 116 | char *seq1 = "UNK"; |
| 117 | char *seq2 = "UNK"; |
| 118 | |
| 119 | // Parse the options to find the parameters |
| 120 | // |
| 121 | splitToWordscxx . . $ splitToWords# Wcxx . . $ splitToWords#splitToWords(fda57c8427c60377).(opts); |
| 122 | |
| 123 | uint32cxx . . $ uint32# arg = 0; |
| 124 | while (arg < W.numWordscxx . . $ splitToWords#numWords(db52760e79bf9054).()) { |
| 125 | if (strcmp(W.getWordcxx . . $ splitToWords#getWord(f109d7e0a0ca42b3).(arg), "-1") == 0) { |
| 126 | seq1 = W.getWordcxx . . $ splitToWords#getWord(f109d7e0a0ca42b3).(++arg); |
| 127 | } else if (strcmp(W.getWordcxx . . $ splitToWords#getWord(f109d7e0a0ca42b3).(arg), "-2") == 0) { |
| 128 | seq2 = W.getWordcxx . . $ splitToWords#getWord(f109d7e0a0ca42b3).(++arg); |
| 129 | } |
| 130 | |
| 131 | arg++; |
| 132 | } |
| 133 | |
| 134 | return(new filterLongestcxx . . $ filterLongest#(seq1, seq2)); |
| 135 | } |
| 136 | |
| 137 | void |
| 138 | destructcxx . . $ destruct(5d22bdacc48458e8).(void *handle) { |
| 139 | delete (filterLongestcxx . . $ filterLongest# *)handle; |
| 140 | } |
| 141 | |
| 142 | void |
| 143 | addHitcxx . . $ addHit(460980392104da20).(void *handle, |
| 144 | char orientation, |
| 145 | uint32cxx . . $ uint32# id1, |
| 146 | uint32cxx . . $ uint32# pos1, |
| 147 | uint32cxx . . $ uint32# len1, |
| 148 | uint32cxx . . $ uint32# id2, |
| 149 | uint32cxx . . $ uint32# pos2, |
| 150 | uint32cxx . . $ uint32# len2, |
| 151 | uint32cxx . . $ uint32# filled) { |
| 152 | ((filterLongestcxx . . $ filterLongest# *)handle)->addHitcxx . . $ filterLongest#addHit(a209694d0a1a92e0).(orientation, id1, pos1, len1, id2, pos2, len2, filled); |
| 153 | } |
| 154 | |
| 155 | void |
| 156 | filtercxx . . $ filter(5d22bdacc48458e8).(void *handle) { |
| 157 | ((filterLongestcxx . . $ filterLongest# *)handle)->filtercxx . . $ filterLongest#filter(49f6e7a06ebc5aa8).(); |
| 158 | } |
| 159 | |
| 160 | uint64cxx . . $ uint64# |
| 161 | outputcxx . . $ output(8d1d8843ae0f6bd5).(void *handle, FILE *file, uint64cxx . . $ uint64# matchid) { |
| 162 | return(((filterLongestcxx . . $ filterLongest# *)handle)->outputcxx . . $ filterLongest#output(9bd1d5b934681de1).(file, matchid)); |
| 163 | } |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | void* |
| 169 | constructStatscxx . . $ constructStats(8176fcad44ba9a1b).(char *options) { |
| 170 | return(new statLongestcxx . . $ statLongest#); |
| 171 | } |
| 172 | |
| 173 | void |
| 174 | destructStatscxx . . $ destructStats(5d22bdacc48458e8).(void *handle) { |
| 175 | delete (statLongestcxx . . $ statLongest# *)handle; |
| 176 | } |
| 177 | |
| 178 | void |
| 179 | addStatscxx . . $ addStats(6c58c5e2437d25a2).(void *handle, void *filterhandle) { |
| 180 | ((statLongestcxx . . $ statLongest# *)handle)->addcxx . . $ statLongest#add(573707ecc2669f06).((filterLongestcxx . . $ filterLongest# *)filterhandle); |
| 181 | } |
| 182 | |
| 183 | void |
| 184 | showStatscxx . . $ showStats(731a702ce4a38a2f).(void *handle, FILE *file) { |
| 185 | ((statLongestcxx . . $ statLongest# *)handle)->showcxx . . $ statLongest#show(8d4262d45fc644ab).(file); |
| 186 | } |