Last active
November 12, 2015 17:27
-
-
Save ipurusho/db932aa92a0a89811e66 to your computer and use it in GitHub Desktop.
UCSC binning scheme ported to Scala (http://genomewiki.ucsc.edu/index.php/Bin_indexing_system)
This file contains hidden or 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
import scala.collection.mutable.ArrayBuffer | |
def binFromRange(start: Int, end: Int): ArrayBuffer[Int] ={ | |
val bin_offsets = Array(512+64+8+1,64+8+1,8+1,0) | |
val binFirstShift = 17 | |
val binNextShift = 3 | |
var startBin = start >> binFirstShift | |
var endBin = (end -1) >> binFirstShift | |
var binArray = ArrayBuffer[Int]() | |
for(i<-bin_offsets){ | |
val bin = i + startBin | |
binArray += bin | |
startBin >>= binNextShift | |
endBin >>= binNextShift | |
} | |
return binArray | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment