Last active
April 24, 2017 09:51
-
-
Save MooxxNew/086052a781eaa9c734f8 to your computer and use it in GitHub Desktop.
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
time{ | |
import org.bdgenomics.adam.rdd.ADAMContext | |
import org.bdgenomics.adam.projections.{AlignmentRecordField, Projection} | |
val ac = new ADAMContext(sc) | |
val reads = ac.loadAlignments( | |
"/home/deploy/data/HG00096.unmapped.ILLUMINA.bwa.GBR.low_coverage.20120522.adam", | |
projection = Some( | |
Projection( | |
AlignmentRecordField.sequence, | |
AlignmentRecordField.readMapped, | |
AlignmentRecordField.mapq | |
) | |
) | |
) | |
val kmers = | |
reads | |
.rdd | |
.flatMap(_.getSequence.sliding(10).map(k => (k, 1L))) | |
.reduceByKey(_ + _) | |
.map(_.swap) | |
.sortByKey(ascending = false) | |
kmers.take(10).foreach(println) | |
} |
time{
import org.bdgenomics.adam.rdd.ADAMContext
import org.bdgenomics.adam.projections.{AlignmentRecordField, Projection}
val ac = new ADAMContext(sc)
val reads = ac.loadAlignments(
"/home/deploy/data/HG00096.unmapped.ILLUMINA.bwa.GBR.low_coverage.20120522.adam",
projection = Some(
Projection(
AlignmentRecordField.sequence,
AlignmentRecordField.readMapped,
AlignmentRecordField.mapq
)
)
)
val script = "/home/deploy/mapv2/mapv2"
val result = reads.rdd .map(x => x.getSequence).pipe(script).map(.split(',') match {case Array(x,y) => (x, y.toLong)}).reduceByKey( + _)
result.take(10).foreach(println)
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def time[T](block: => T): T = {
val start = System.currentTimeMillis
val res = block
val totalTime = System.currentTimeMillis - start
println("Elapsed time: %1d ms".format(totalTime))
res
}