Skip to content

Instantly share code, notes, and snippets.

@fstrozzi
Created December 15, 2015 11:15
Show Gist options
  • Save fstrozzi/ff5dd2ad65ac223b9c60 to your computer and use it in GitHub Desktop.
Save fstrozzi/ff5dd2ad65ac223b9c60 to your computer and use it in GitHub Desktop.
Example Scala reading FastQ
import net.sf.picard.fastq.FastqReader
import java.io.File
import scala.collection.JavaConversions._
object Reader extends App {
val file = new File(args(0))
val fr = new FastqReader(file)
printToFile(new File(args(1)))(p => {
for (seq <- fr.iterator()) {
val header = seq.getReadHeader.split(" ")
if ((header.takeRight(2)(0)) != "/") {
p.println(">"+header(0)+"/"+header(1)(0)+"\n"+seq.getReadString)
}
}
})
@rjpbonnal
Copy link

import scala.collection.JavaConversions.asScalaIterator
val reader = new FastqReader(new java.io.File(forward))
for(read <- reader){
println(read.getReadHeader())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment