Skip to content

Commit

Permalink
Removing symbolic test resource links, read from test classpath instead
Browse files Browse the repository at this point in the history
  • Loading branch information
heuermh committed Jan 25, 2016
1 parent cd6ef41 commit aa446d2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
1 change: 0 additions & 1 deletion adam-apis/src/test/resources/small.sam

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import org.bdgenomics.formats.avro.AlignmentRecord
class JavaADAMContextSuite extends ADAMFunSuite {

sparkTest("can read a small .SAM file") {
val path = resourcePath("small.sam")
val path = copyResource("small.sam")
val ctx = new JavaADAMContext(sc)
val reads = ctx.adamRecordLoad(path)
assert(reads.jrdd.count() === 20)
}

ignore("can read a small .SAM file inside of java") {
val path = resourcePath("small.sam")
sparkTest("can read a small .SAM file inside of java") {
val path = copyResource("small.sam")
val aRdd = sc.loadAlignments(path)

val newReads = JavaADAMConduit.conduit(aRdd.rdd, aRdd.sequences, aRdd.recordGroups)
Expand Down
1 change: 0 additions & 1 deletion adam-cli/src/test/resources/ordered.sam

This file was deleted.

1 change: 0 additions & 1 deletion adam-cli/src/test/resources/unordered.sam

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ import org.bdgenomics.adam.util.ADAMFunSuite

class TransformSuite extends ADAMFunSuite {
sparkTest("unordered sam to unordered sam") {
val inputPath = resourcePath("unordered.sam")
val inputPath = copyResource("unordered.sam")
val actualPath = tmpFile("unordered.sam")
val expectedPath = inputPath
Transform(Array("-single", inputPath, actualPath)).run(sc)
checkFiles(expectedPath, actualPath)
}

sparkTest("unordered sam to ordered sam") {
val inputPath = resourcePath("unordered.sam")
val inputPath = copyResource("unordered.sam")
val actualPath = tmpFile("ordered.sam")
val expectedPath = resourcePath("ordered.sam")
val expectedPath = copyResource("ordered.sam")
Transform(Array("-single", "-sort_reads", inputPath, actualPath)).run(sc)
checkFiles(expectedPath, actualPath)
}

sparkTest("unordered sam, to adam, to sam") {
val inputPath = resourcePath("unordered.sam")
val inputPath = copyResource("unordered.sam")
val intermediateAdamPath = tmpFile("unordered.adam")
val actualPath = tmpFile("unordered.sam")
val expectedPath = inputPath
Expand All @@ -49,10 +49,10 @@ class TransformSuite extends ADAMFunSuite {
}

sparkTest("unordered sam, to adam, to ordered sam") {
val inputPath = resourcePath("unordered.sam")
val inputPath = copyResource("unordered.sam")
val intermediateAdamPath = tmpFile("unordered.adam")
val actualPath = tmpFile("ordered.sam")
val expectedPath = resourcePath("ordered.sam")
val expectedPath = copyResource("ordered.sam")
Transform(Array(inputPath, intermediateAdamPath)).run(sc)
Transform(Array("-single", "-sort_reads", intermediateAdamPath, actualPath)).run(sc)
checkFiles(expectedPath, actualPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.bdgenomics.adam.util

import java.nio.file.Files

import com.google.common.io.Resources

import org.bdgenomics.utils.misc.SparkFunSuite

import scala.io.Source
Expand Down Expand Up @@ -50,5 +52,11 @@ trait ADAMFunSuite extends SparkFunSuite {
)
}
}

def copyResource(name: String): String = {
val tempFile = Files.createTempFile(name, "." + name.split('.').last)
Files.write(tempFile, Resources.toByteArray(getClass().getResource("/" + name)))
tempFile.toString
}
}

0 comments on commit aa446d2

Please sign in to comment.