Last active
August 29, 2015 14:24
-
-
Save nikhilRP/5c7ada0a924fde588387 to your computer and use it in GitHub Desktop.
Scala class to convert to adam file
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
import org.bdgenomics.formats.avro.AlignmentRecord | |
import org.bdgenomics.adam.rdd.ADAMContext._ | |
import org.bdgenomics.adam.projections.{ AlignmentRecordField, Projection } | |
import org.apache.spark.rdd.RDD | |
import org.bdgenomics.adam.rdd.ReferencePartitioner | |
import org.bdgenomics.adam.models.ReferenceRegion | |
val bamFile = "/user/nikhilrp/ENCFF000QJB.bam" | |
val reads = sc.loadBam(bamFile) | |
val sd = reads.adamGetSequenceDictionary() | |
val mappedReads = reads.filter(read => read.getReadMapped) | |
val referencePartitions = mappedReads.keyBy(read => ReferenceRegion(read)).repartitionAndSortWithinPartitions(ReferencePartitioner(sd)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment