Skip to content

Commit

Permalink
[ADAM-1486] Respect validation stringency if BAM header load fails.
Browse files Browse the repository at this point in the history
Resolves #1486.
  • Loading branch information
fnothaft committed May 12, 2017
1 parent 18191f9 commit bbc8638
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,13 @@ class ADAMContext(@transient val sc: SparkContext) extends Serializable with Log
Some((sd, rg))
} catch {
case e: Throwable => {
log.error(
s"Loading failed for $fp:n${e.getMessage}\n\t${e.getStackTrace.take(25).map(_.toString).mkString("\n\t")}"
)
if (validationStringency == ValidationStringency.STRICT) {
throw e
} else if (validationStringency == ValidationStringency.LENIENT) {
log.error(
s"Loading failed for $fp:\n${e.getMessage}\n\t${e.getStackTrace.take(25).map(_.toString).mkString("\n\t")}"
)
}
None
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.bdgenomics.adam.rdd

import htsjdk.samtools.{ SAMFormatException, ValidationStringency }
import java.io.{ File, FileNotFoundException }
import com.google.common.io.Files
import org.apache.hadoop.fs.Path
Expand Down Expand Up @@ -81,6 +82,13 @@ class ADAMContextSuite extends ADAMFunSuite {
assert(reads.count() === 20)
}

sparkTest("loading a sam file with a bad header and strict stringency should fail") {
val path = testFile("badheader.sam")
intercept[SAMFormatException] {
sc.loadBam(path, validationStringency = ValidationStringency.STRICT)
}
}

sparkTest("can read a small .CRAM file") {
val path = testFile("artificial.cram")
val referencePath = resourceUrl("artificial.fa").toString
Expand Down

0 comments on commit bbc8638

Please sign in to comment.