(ArrayList<? extends BitSequence> seqs, String outFasta,
long bfSize, int k, int numHash, boolean stranded, boolean useHpcKmers,
int windowSize, int minMatchingWindows, float minMatchingProportion,
int minSeqLen)
| 481 | } |
| 482 | |
| 483 | public static void minimalSet(ArrayList<? extends BitSequence> seqs, String outFasta, |
| 484 | long bfSize, int k, int numHash, boolean stranded, boolean useHpcKmers, |
| 485 | int windowSize, int minMatchingWindows, float minMatchingProportion, |
| 486 | int minSeqLen) throws IOException, InterruptedException { |
| 487 | int numSeq = seqs.size(); |
| 488 | |
| 489 | FastaWriter writer = new FastaWriter(outFasta, false); |
| 490 | |
| 491 | HashFunction h = stranded ? new HashFunction(k) : new CanonicalHashFunction(k); |
| 492 | |
| 493 | BloomFilter bf = new BloomFilter(bfSize, numHash, h); |
| 494 | NTHashIterator itr = h.getHashIterator(numHash, k); |
| 495 | long[] hVals = itr.hVals; |
| 496 | int id = 0; |
| 497 | final int minKmersNeededPerWindow = 2; |
| 498 | |
| 499 | for (BitSequence s : seqs) { |
| 500 | if (s != null && s.length >= minSeqLen) { |
| 501 | String seq = s.toString(); |
| 502 | // ArrayList<String> segments = trimLowComplexityRegions(s.toString(), 100); |
| 503 | // for (String seq : segments) { |
| 504 | if (seq.length() >= minSeqLen) { |
| 505 | String hpc = useHpcKmers ? compressHomoPolymers(seq) : seq; |
| 506 | |
| 507 | if (itr.start(hpc)) { |
| 508 | int numKmers = hpc.length() - k + 1; |
| 509 | int numWindows = numKmers/windowSize; |
| 510 | if (numKmers % windowSize > 0) { |
| 511 | ++numWindows; |
| 512 | } |
| 513 | |
| 514 | // if (numWindows >= minMatchingWindows) { |
| 515 | int numWindowsSeen = 0; |
| 516 | int windowIndex = 0; |
| 517 | int numKmersSeenInWindow = 0; |
| 518 | while (itr.hasNext()) { |
| 519 | itr.next(); |
| 520 | |
| 521 | if (itr.getPos()/windowSize > windowIndex) { |
| 522 | ++windowIndex; |
| 523 | numKmersSeenInWindow = 0; |
| 524 | } |
| 525 | |
| 526 | if (bf.lookup(hVals)) { |
| 527 | if (++numKmersSeenInWindow == minKmersNeededPerWindow) { |
| 528 | ++numWindowsSeen; |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | if (numWindowsSeen < Math.max(minMatchingWindows, Math.round(minMatchingProportion * numWindows))) { |
| 534 | //if (numWindowsSeen < minMatchingProportion * numWindows) { |
| 535 | // a unique sequence |
| 536 | |
| 537 | itr.start(hpc); |
| 538 | while (itr.hasNext()) { |
| 539 | itr.next(); |
| 540 | bf.add(hVals); |
nothing calls this directly
no test coverage detected