-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from compgen-io/bed-combine-2
Bed combine 2
- Loading branch information
Showing
8 changed files
with
445 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.compgen.ngsutils.bed; | ||
|
||
import java.util.Iterator; | ||
|
||
import io.compgen.ngsutils.bam.Strand; | ||
|
||
public class BedStrandFilter implements Iterator<BedRecord>{ | ||
protected final Iterator<BedRecord> it; | ||
protected final Strand strand; | ||
|
||
protected BedRecord cur = null; | ||
|
||
public BedStrandFilter(Iterator<BedRecord> it, Strand strand) { | ||
this.it = it; | ||
this.strand = strand; | ||
} | ||
@Override | ||
public boolean hasNext() { | ||
if (cur == null && it.hasNext()) { | ||
populate(); | ||
} | ||
return cur != null; | ||
} | ||
@Override | ||
public BedRecord next() { | ||
BedRecord ret = cur; | ||
cur = null; | ||
populate(); | ||
|
||
return ret; | ||
} | ||
|
||
private void populate() { | ||
while (it.hasNext()) { | ||
BedRecord tmp = it.next(); | ||
if (strand.matches(tmp.coord.strand)) { | ||
cur = tmp; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.