Created
January 13, 2016 14:26
-
-
Save rjpbonnal/fdc94a2637a208d47a03 to your computer and use it in GitHub Desktop.
Scala Create an iterator using a Stream over 2 "aligned" files
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
test("Detect barcodes in forward and reverse reads in Fastq format") { | |
val readerR1 = new FastqReader(new java.io.File(getClass.getResource("/R1.fastq.gz").getPath)) | |
val readerR2 = new FastqReader(new java.io.File(getClass.getResource("/R2.fastq.gz").getPath)) | |
var list = List[String]() | |
case class Reads( r1: FastqRecord, r2: FastqRecord) | |
val stream: Stream[Reads]= { | |
def reads(readerR1: FastqReader, readerR2: FastqReader): Stream[Reads] = { | |
readerR1.hasNext() && readerR2.hasNext() match { | |
case true => Reads(readerR1.next(), readerR2.next()) #:: reads(readerR1, readerR2) | |
case _ => Stream.empty | |
} | |
} | |
reads(readerR1, readerR2) | |
} | |
for ( read <- stream) { | |
println(read.r1.getReadHeader) | |
println(read.r2.getReadHeader) | |
//list = list:+ TcrIndex.detect(barcode, read.r1, read.r2) | |
} | |
assert(list == List("1A1","1B4","" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment