(ArrayList<? extends BitSequence> seqs,
String outSubsampleFasta,
long bfSize, int k, int numHash, boolean stranded,
int maxMultiplicity, int maxEdgeClip, boolean verbose,
int numThreads)
| 118 | } |
| 119 | |
| 120 | public static void kmerBased(ArrayList<? extends BitSequence> seqs, |
| 121 | String outSubsampleFasta, |
| 122 | long bfSize, int k, int numHash, boolean stranded, |
| 123 | int maxMultiplicity, int maxEdgeClip, boolean verbose, |
| 124 | int numThreads) throws IOException, InterruptedException, ExecutionException { |
| 125 | |
| 126 | System.out.println("k-mers: n=2, k=" + k); |
| 127 | int numSeq = seqs.size(); |
| 128 | |
| 129 | final int shift = k + 1; |
| 130 | final int shiftD = k; |
| 131 | final int shiftI = k + 2; |
| 132 | final int missingChainThreshold = k + shift; |
| 133 | int numSubsample = 0; |
| 134 | float fpr; |
| 135 | |
| 136 | ConcurrentLinkedQueue<String> subQueue = new ConcurrentLinkedQueue<>(); |
| 137 | FastaWriter subWriter = new FastaWriter(outSubsampleFasta, false); |
| 138 | FastaWriterWorker subWriterWorker = new FastaWriterWorker(subQueue, subWriter, "s"); |
| 139 | Thread subWriterThread = new Thread(subWriterWorker); |
| 140 | subWriterThread.start(); |
| 141 | |
| 142 | CountingBloomFilter cbf; |
| 143 | ForkJoinPool customThreadPool = new ForkJoinPool(numThreads); |
| 144 | |
| 145 | if (stranded) { |
| 146 | HashFunction h = new HashFunction(k); |
| 147 | NTHashIterator hashItr = h.getHashIterator(1); |
| 148 | cbf = new CountingBloomFilter(bfSize, numHash, h); |
| 149 | |
| 150 | for (int seqIndex=0; seqIndex<numSeq; ++seqIndex) { |
| 151 | String seq = seqs.get(seqIndex).toString(); |
| 152 | |
| 153 | if (hashItr.start(seq)) { |
| 154 | int seqLen = seq.length(); |
| 155 | boolean tooShort = seqLen < 3 * maxEdgeClip; |
| 156 | int missingChainLen = 0; |
| 157 | boolean write = false; |
| 158 | int numKmers = seqLen - k + 1; |
| 159 | |
| 160 | // get hash value of all kmers |
| 161 | long[] kmerHashVals = new long[numKmers]; |
| 162 | for (int i=0; i<numKmers; ++i) { |
| 163 | hashItr.next(); |
| 164 | kmerHashVals[i] = hashItr.hVals[0]; |
| 165 | } |
| 166 | |
| 167 | final int start, end; |
| 168 | if (tooShort) { |
| 169 | start = 0; |
| 170 | end = numKmers - shift; |
| 171 | } |
| 172 | else { |
| 173 | start = maxEdgeClip; |
| 174 | end = numKmers - maxEdgeClip - shift; |
| 175 | } |
| 176 | |
| 177 | // look up counts of k-mer pairs |
no test coverage detected