Skip to content

Instantly share code, notes, and snippets.

@mwiewior
Created January 20, 2016 07:36
Show Gist options
  • Save mwiewior/fcfb181ae608169dbfe4 to your computer and use it in GitHub Desktop.
Save mwiewior/fcfb181ae608169dbfe4 to your computer and use it in GitHub Desktop.
Counting quals
.mapPartitions {
partIterator =>
//val qualStrings = partIterator.toSeq
val maxReadQual=150
val maxReadLength=150
var pIndex = 0
val posQualArray = Array.fill[Int](maxReadLength,maxReadQual)(0) //((pos,qualVal),counter)
for (seq <- partIterator) {
var qIndex = 0
for(q<-seq.getQual){
val qAdj = q-33
posQualArray(qIndex)(qAdj)+=1
qIndex+=1
}
}
val posQualMap = scala.collection.mutable.HashMap[(Int,Int),Int]()
for(i<-posQualArray.indices) {
for (j <- posQualArray(i).indices)
if (posQualArray(i)(j) > 0)
posQualMap.put((i + 1, j), posQualArray(i)(j))
}
Iterator(posQualMap)
}
.flatMap(r=>r)
.reduceByKey(_+_)
.sortBy(r=>r._1)
qualitiesPerPosition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment