Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing symbolic test resource links, read from test classpath instead #927

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion adam-apis/src/test/resources/small.sam

This file was deleted.

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.

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
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
}
}