Skip to content

Commit

Permalink
Update to use the locally checked in CRAM 3.1 interop test data.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnbroad committed Mar 5, 2024
1 parent c411ada commit fe0e908
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
21 changes: 3 additions & 18 deletions src/test/java/htsjdk/samtools/cram/CRAMInteropTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,14 @@
import java.util.ArrayList;
import java.util.List;

import htsjdk.utils.SamtoolsTestUtils;

/**
* Interop test data is kept in a separate repository, currently at https://github.com/samtools/htscodecs
* so it can be shared across htslib/samtools/htsjdk.
*/
public class CRAMInteropTestUtils {
public static final String INTEROP_TEST_FILES_PATH = SamtoolsTestUtils.getCRAMInteropData();

/**
* @return true if interop test data is available, otherwise false
*/
public static boolean isInteropTestDataAvailable() {
final Path testDataPath = getInteropTestDataLocation();
return Files.exists(testDataPath);
}

/**
* @return the name and location of the local interop test data as specified by the
* variable INTEROP_TEST_FILES_PATH
* Return the location of the locally checked-in test CRAM 3.1 test interop data dir (the files
* there are copied from the originals in htscodecs), and should be updated periodically.
*/
public static Path getInteropTestDataLocation() {
return Paths.get(INTEROP_TEST_FILES_PATH);
return Paths.get("src/test/resources/htsjdk/samtools/cram/3.1_streams/");
}

// the input files have embedded newlines that the test remove before round-tripping...
Expand Down
18 changes: 2 additions & 16 deletions src/test/java/htsjdk/samtools/cram/RANSInteropTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@

/**
* RANSInteropTest tests if the htsjdk RANS4x8 and RANSNx16 implementations are interoperable
* with the htslib implementations. The test files for Interop tests is kept in a separate repository,
* currently at https://github.com/samtools/htscodecs so it can be shared across htslib/samtools/htsjdk.
*
* For local development env, the Interop test files must be downloaded locally and made available at "../htscodecs/tests"
* For CI env, the Interop test files are made available from the existing samtools installation
* at "/samtools-1.14/htslib-1.14/htscodecs/tests"
* with the htslib implementations. The test files for Interop tests originate a separate repository,
* currently at https://github.com/samtools/htscodecs, but are checked into this repo as wrll.
*/
public class RANSInteropTest extends HtsjdkTest {
public static final String COMPRESSED_RANS4X8_DIR = "r4x8";
Expand Down Expand Up @@ -155,16 +151,7 @@ public Object[][] getDecodeOnlyTestCases() throws IOException {
.toArray(Object[][]::new);
}

@Test(description = "Test if CRAM Interop Test Data is available")
public void testHtsCodecsCorpusIsAvailable() {
if (!CRAMInteropTestUtils.isInteropTestDataAvailable()) {
throw new SkipException(String.format("RANS Interop Test Data is not available at %s",
CRAMInteropTestUtils.INTEROP_TEST_FILES_PATH));
}
}

@Test (
dependsOnMethods = "testHtsCodecsCorpusIsAvailable",
dataProvider = "roundTripTestCases",
description = "Roundtrip using htsjdk RANS. Compare the output with the original file" )
public void testRANSRoundTrip(
Expand Down Expand Up @@ -192,7 +179,6 @@ public void testRANSRoundTrip(
}

@Test (
dependsOnMethods = "testHtsCodecsCorpusIsAvailable",
dataProvider = "decodeOnlyTestCases",
description = "Uncompress the existing compressed file using htsjdk RANS and compare it with the original file.")
public void testDecodeOnly(
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/htsjdk/utils/SamtoolsTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public static String getSamtoolsBin() {
return samtoolsPath == null ? "/usr/local/bin/samtools" : samtoolsPath;
}

public static String getCRAMInteropData() {
final String samtoolsPath = System.getenv(SAMTOOLS_BINARY_ENV_VARIABLE);
return samtoolsPath == null ? "../htscodecs/tests" : "./samtools-"+expectedSamtoolsVersion+ "/htslib-"+expectedHtslibVersion+"/htscodecs/tests";
}

/**
* Execute a samtools command line if a local samtools executable is available see {@link #isSamtoolsAvailable()}.
*
Expand Down

0 comments on commit fe0e908

Please sign in to comment.