Search in sources :

Example 1 with IntSortedSet

use of it.unimi.dsi.fastutil.ints.IntSortedSet in project gridss by PapenfussLab.

the class CollapseIterator method merge.

private void merge(List<KmerPathSubnode> sourcePath, List<KmerPathSubnode> targetPath) {
    assert (sourcePath.get(0).width() == targetPath.get(0).width());
    assert (sourcePath.get(0).firstStart() == targetPath.get(0).firstStart());
    assert (DeBruijnSequenceGraphNodeUtil.basesDifferent(k, sourcePath, targetPath) <= maxBasesMismatch);
    trimCommon(sourcePath, targetPath);
    assertKmerPathNodesUnique(sourcePath, targetPath);
    List<KmerPathNode> source = positionSplit(sourcePath);
    List<KmerPathNode> target = positionSplit(targetPath);
    IntSortedSet kmerStartPositions = new IntRBTreeSet();
    for (KmerPathNode n : source) {
        kmerStartPositions.add(n.firstStart());
        kmerStartPositions.add(n.firstStart() + n.length());
    }
    for (KmerPathNode n : target) {
        kmerStartPositions.add(n.firstStart());
        kmerStartPositions.add(n.firstStart() + n.length());
    }
    source = lengthSplit(kmerStartPositions, source);
    target = lengthSplit(kmerStartPositions, target);
    assert (DeBruijnSequenceGraphNodeUtil.basesDifferent(k, source, target) <= maxBasesMismatch);
    assert (source.size() <= target.size());
    // merge the common nodes
    for (int i = 0; i < source.size(); i++) {
        KmerPathNode toMerge = source.get(i);
        KmerPathNode into = target.get(i);
        merge(toMerge, into);
    }
    if (reprocessMergedNodes()) {
        for (int i = 0; i < source.size(); i++) {
            processed.remove(target.get(i));
            unprocessed.add(target.get(i));
        }
    }
}
Also used : IntRBTreeSet(it.unimi.dsi.fastutil.ints.IntRBTreeSet) IntSortedSet(it.unimi.dsi.fastutil.ints.IntSortedSet)

Aggregations

IntRBTreeSet (it.unimi.dsi.fastutil.ints.IntRBTreeSet)1 IntSortedSet (it.unimi.dsi.fastutil.ints.IntSortedSet)1