Skip to content

Commit

Permalink
added java friendly version of filterByOverlappingRegions
Browse files Browse the repository at this point in the history
  • Loading branch information
akmorrow13 committed Jan 30, 2018
1 parent 95e7109 commit e3540ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.bdgenomics.adam.cli

import scala.collection.JavaConverters._
import htsjdk.samtools.ValidationStringency
import java.time.Instant
import org.apache.parquet.filter2.dsl.Dsl._
Expand Down Expand Up @@ -488,7 +487,7 @@ class TransformAlignments(protected val args: TransformAlignmentsArgs) extends B

if (args.regionPredicate != null) {
val loci = ReferenceRegion.fromString(args.regionPredicate)
loadedReads.filterByOverlappingRegions(loci.asJava)
loadedReads.filterByOverlappingRegions(loci)
} else {
loadedReads
}
Expand Down
19 changes: 19 additions & 0 deletions adam-core/src/main/scala/org/bdgenomics/adam/rdd/GenomicRDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,25 @@ trait GenomicRDD[T, U <: GenomicRDD[T, U]] extends Logging {
* @return Returns a new GenomicRDD containing only data that overlaps the
* querys region.
*/
def filterByOverlappingRegions(querys: Iterable[ReferenceRegion]): U = {
replaceRdd(rdd.filter(elem => {

val regions = getReferenceRegions(elem)

querys.exists(query => {
regions.exists(_.overlaps(query))
})
}), optPartitionMap)
}

/**
* Runs a filter that selects data in the underlying RDD that overlaps
* several genomic regions. Java friendly version.
*
* @param querys The regions to query for.
* @return Returns a new GenomicRDD containing only data that overlaps the
* querys region.
*/
def filterByOverlappingRegions(querys: java.lang.Iterable[ReferenceRegion]): U = {
replaceRdd(rdd.filter(elem => {

Expand Down

0 comments on commit e3540ac

Please sign in to comment.