[med-svn] [htsjdk] 02/02: Exclude more tests
Andreas Tille
tille at debian.org
Sun Jul 10 16:55:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository htsjdk.
commit 48d1ae35887c69e01340bba7c70bb43345e14617
Author: Andreas Tille <tille at debian.org>
Date: Sun Jul 10 18:55:37 2016 +0200
Exclude more tests
---
debian/patches/13-skip_network_tests | 359 +++++++++++++++++++++++++++++++++++
1 file changed, 359 insertions(+)
diff --git a/debian/patches/13-skip_network_tests b/debian/patches/13-skip_network_tests
index fe62dcd..67d3e6e 100644
--- a/debian/patches/13-skip_network_tests
+++ b/debian/patches/13-skip_network_tests
@@ -949,3 +949,362 @@ Last-Updated: 2015-01-06
- }
- }
}
+--- a/src/test/java/htsjdk/samtools/seekablestream/SeekableFTPStreamTest.java
++++ b/src/test/java/htsjdk/samtools/seekablestream/SeekableFTPStreamTest.java
+@@ -38,68 +38,6 @@ import java.net.URL;
+ public class SeekableFTPStreamTest {
+
+
+- static String urlString = "ftp://ftp.broadinstitute.org/pub/igv/TEST/test.txt";
+- static long fileSize = 27;
+- static byte[] expectedBytes = "abcdefghijklmnopqrstuvwxyz\n".getBytes();
+- SeekableFTPStream stream;
+-
+- @BeforeMethod
+- public void setUp() throws IOException {
+- stream = new SeekableFTPStream(new URL(urlString));
+-
+- }
+-
+- @AfterMethod
+- public void tearDown() throws IOException {
+- stream.close();
+- }
+-
+- @Test
+- public void testLength() throws Exception {
+- long length = stream.length();
+- Assert.assertEquals(fileSize, length);
+- }
+-
+-
+- /**
+- * Test a buffered read. The buffer is much large than the file size, assert that the desired # of bytes are read
+- *
+- * @throws Exception
+- */
+- @Test
+- public void testBufferedRead() throws Exception {
+-
+- byte[] buffer = new byte[64000];
+- int nRead = stream.read(buffer);
+- Assert.assertEquals(fileSize, nRead);
+-
+- }
+-
+- /**
+- * Test requesting a range that extends beyond the end of the file
+- */
+-
+- @Test
+- public void testRange() throws Exception {
+- stream.seek(20);
+- byte[] buffer = new byte[64000];
+- int nRead = stream.read(buffer);
+- Assert.assertEquals(fileSize - 20, nRead);
+-
+- }
+-
+- /**
+- * Test requesting a range that begins beyond the end of the file
+- */
+-
+- @Test
+- public void testBadRange() throws Exception {
+- stream.seek(30);
+- byte[] buffer = new byte[64000];
+- int nRead = stream.read(buffer);
+- Assert.assertEquals(-1, nRead);
+- }
+-
+
+ }
+
+--- a/src/test/java/htsjdk/samtools/BAMRemoteFileTest.java
++++ b/src/test/java/htsjdk/samtools/BAMRemoteFileTest.java
+@@ -42,285 +42,7 @@ import static org.testng.Assert.*;
+ public class BAMRemoteFileTest {
+ private final File BAM_INDEX_FILE = new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/index_test.bam.bai");
+ private final File BAM_FILE = new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/index_test.bam");
+- private final String BAM_URL_STRING = "http://www.broadinstitute.org/~picard/testdata/index_test.bam";
+- private final URL bamURL;
+
+ private final boolean mVerbose = false;
+
+- public BAMRemoteFileTest() throws Exception {
+- bamURL = new URL(BAM_URL_STRING);
+- }
+-
+-
+- @Test
+- void testRemoteLocal()
+- throws Exception {
+- runLocalRemoteTest(bamURL, BAM_FILE, "chrM", 10400, 10600, false);
+- }
+-
+- @Test
+- public void testSpecificQueries()
+- throws Exception {
+- assertEquals(runQueryTest(bamURL, "chrM", 10400, 10600, true), 1);
+- assertEquals(runQueryTest(bamURL, "chrM", 10400, 10600, false), 2);
+- }
+-
+- @Test(enabled = true)
+- public void testRandomQueries()
+- throws Exception {
+- runRandomTest(bamURL, 20, new Random());
+- }
+-
+- @Test
+- public void testWholeChromosomes() {
+- checkChromosome("chrM", 23);
+- checkChromosome("chr1", 885);
+- checkChromosome("chr2", 837);
+- /***
+- checkChromosome("chr3", 683);
+- checkChromosome("chr4", 633);
+- checkChromosome("chr5", 611);
+- checkChromosome("chr6", 585);
+- checkChromosome("chr7", 521);
+- checkChromosome("chr8", 507);
+- checkChromosome("chr9", 388);
+- checkChromosome("chr10", 477);
+- checkChromosome("chr11", 467);
+- checkChromosome("chr12", 459);
+- checkChromosome("chr13", 327);
+- checkChromosome("chr14", 310);
+- checkChromosome("chr15", 280);
+- checkChromosome("chr16", 278);
+- checkChromosome("chr17", 269);
+- checkChromosome("chr18", 265);
+- checkChromosome("chr19", 178);
+- checkChromosome("chr20", 228);
+- checkChromosome("chr21", 123);
+- checkChromosome("chr22", 121);
+- checkChromosome("chrX", 237);
+- checkChromosome("chrY", 29);
+- ***/
+- }
+-
+-
+- private void checkChromosome(final String name, final int expectedCount) {
+- int count = runQueryTest(bamURL, name, 0, 0, true);
+- assertEquals(count, expectedCount);
+- count = runQueryTest(bamURL, name, 0, 0, false);
+- assertEquals(count, expectedCount);
+- }
+-
+- private void runRandomTest(final URL bamFile, final int count, final Random generator) throws IOException {
+- final int maxCoordinate = 10000000;
+- final List<String> referenceNames = getReferenceNames(bamFile);
+- for (int i = 0; i < count; i++) {
+- final String refName = referenceNames.get(generator.nextInt(referenceNames.size()));
+- final int coord1 = generator.nextInt(maxCoordinate + 1);
+- final int coord2 = generator.nextInt(maxCoordinate + 1);
+- final int startPos = Math.min(coord1, coord2);
+- final int endPos = Math.max(coord1, coord2);
+- System.out.println("Testing query " + refName + ":" + startPos + "-" + endPos + " ...");
+- try {
+- runQueryTest(bamFile, refName, startPos, endPos, true);
+- runQueryTest(bamFile, refName, startPos, endPos, false);
+- } catch (Throwable exc) {
+- String message = "Query test failed: " + refName + ":" + startPos + "-" + endPos;
+- message += ": " + exc.getMessage();
+- throw new RuntimeException(message, exc);
+- }
+- }
+- }
+-
+- private List<String> getReferenceNames(final URL bamFile) throws IOException {
+-
+-
+- final SamReader reader = SamReaderFactory.makeDefault().open(SamInputResource.of(bamFile.openStream()));
+-
+- final List<String> result = new ArrayList<String>();
+- final List<SAMSequenceRecord> seqRecords = reader.getFileHeader().getSequenceDictionary().getSequences();
+- for (final SAMSequenceRecord seqRecord : seqRecords) {
+- if (seqRecord.getSequenceName() != null) {
+- result.add(seqRecord.getSequenceName());
+- }
+- }
+- reader.close();
+- return result;
+- }
+-
+- private void runLocalRemoteTest(final URL bamURL, final File bamFile, final String sequence, final int startPos, final int endPos, final boolean contained) {
+- verbose("Testing query " + sequence + ":" + startPos + "-" + endPos + " ...");
+- final SamReader reader1 = SamReaderFactory.makeDefault()
+- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
+- .open(SamInputResource.of(bamFile).index(BAM_INDEX_FILE));
+- final SamReader reader2 = SamReaderFactory.makeDefault()
+- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
+- .open(SamInputResource.of(bamURL).index(BAM_INDEX_FILE));
+- final Iterator<SAMRecord> iter1 = reader1.query(sequence, startPos, endPos, contained);
+- final Iterator<SAMRecord> iter2 = reader2.query(sequence, startPos, endPos, contained);
+-
+- final List<SAMRecord> records1 = new ArrayList<SAMRecord>();
+- final List<SAMRecord> records2 = new ArrayList<SAMRecord>();
+-
+- while (iter1.hasNext()) {
+- records1.add(iter1.next());
+- }
+- while (iter2.hasNext()) {
+- records2.add(iter2.next());
+- }
+-
+- assertTrue(records1.size() > 0);
+- assertEquals(records1.size(), records2.size());
+- for (int i = 0; i < records1.size(); i++) {
+- //System.out.println(records1.get(i).format());
+- assertEquals(records1.get(i).getSAMString(), records2.get(i).getSAMString());
+- }
+-
+-
+- }
+-
+- private int runQueryTest(final URL bamURL, final String sequence, final int startPos, final int endPos, final boolean contained) {
+- verbose("Testing query " + sequence + ":" + startPos + "-" + endPos + " ...");
+- final SamReader reader1 = SamReaderFactory.makeDefault()
+- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
+- .open(SamInputResource.of(bamURL).index(BAM_INDEX_FILE));
+- final SamReader reader2 = SamReaderFactory.makeDefault()
+- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
+- .open(SamInputResource.of(bamURL).index(BAM_INDEX_FILE));
+- final Iterator<SAMRecord> iter1 = reader1.query(sequence, startPos, endPos, contained);
+- final Iterator<SAMRecord> iter2 = reader2.iterator();
+- // Compare ordered iterators.
+- // Confirm that iter1 is a subset of iter2 that properly filters.
+- SAMRecord record1 = null;
+- SAMRecord record2 = null;
+- int count1 = 0;
+- int count2 = 0;
+- int beforeCount = 0;
+- int afterCount = 0;
+- while (true) {
+- if (record1 == null && iter1.hasNext()) {
+- record1 = iter1.next();
+- count1++;
+- }
+- if (record2 == null && iter2.hasNext()) {
+- record2 = iter2.next();
+- count2++;
+- }
+- // System.out.println("Iteration:");
+- // System.out.println(" Record1 = " + ((record1 == null) ? "null" : record1.format()));
+- // System.out.println(" Record2 = " + ((record2 == null) ? "null" : record2.format()));
+- if (record1 == null && record2 == null) {
+- break;
+- }
+- if (record1 == null) {
+- checkPassesFilter(false, record2, sequence, startPos, endPos, contained);
+- record2 = null;
+- afterCount++;
+- continue;
+- }
+- assertNotNull(record2);
+- final int ordering = compareCoordinates(record1, record2);
+- if (ordering > 0) {
+- checkPassesFilter(false, record2, sequence, startPos, endPos, contained);
+- record2 = null;
+- beforeCount++;
+- continue;
+- }
+- assertTrue(ordering == 0);
+- checkPassesFilter(true, record1, sequence, startPos, endPos, contained);
+- checkPassesFilter(true, record2, sequence, startPos, endPos, contained);
+- assertEquals(record1.getReadName(), record2.getReadName());
+- assertEquals(record1.getReadString(), record2.getReadString());
+- record1 = null;
+- record2 = null;
+- }
+- CloserUtil.close(reader1);
+- CloserUtil.close(reader2);
+- verbose("Checked " + count1 + " records against " + count2 + " records.");
+- verbose("Found " + (count2 - beforeCount - afterCount) + " records matching.");
+- verbose("Found " + beforeCount + " records before.");
+- verbose("Found " + afterCount + " records after.");
+- return count1;
+- }
+-
+- private void checkPassesFilter(final boolean expected, final SAMRecord record, final String sequence, final int startPos, final int endPos, final boolean contained) {
+- final boolean passes = passesFilter(record, sequence, startPos, endPos, contained);
+- if (passes != expected) {
+- System.out.println("Error: Record erroneously " +
+- (passes ? "passed" : "failed") +
+- " filter.");
+- System.out.println(" Record: " + record.getSAMString());
+- System.out.println(" Filter: " + sequence + ":" +
+- startPos + "-" + endPos +
+- " (" + (contained ? "contained" : "overlapping") + ")");
+- assertEquals(passes, expected);
+- }
+- }
+-
+- private boolean passesFilter(final SAMRecord record, final String sequence, final int startPos, final int endPos, final boolean contained) {
+- if (record == null) {
+- return false;
+- }
+- if (!safeEquals(record.getReferenceName(), sequence)) {
+- return false;
+- }
+- final int alignmentStart = record.getAlignmentStart();
+- int alignmentEnd = record.getAlignmentEnd();
+- if (alignmentStart <= 0) {
+- assertTrue(record.getReadUnmappedFlag());
+- return false;
+- }
+- if (alignmentEnd <= 0) {
+- // For indexing-only records, treat as single base alignment.
+- assertTrue(record.getReadUnmappedFlag());
+- alignmentEnd = alignmentStart;
+- }
+- if (contained) {
+- if (startPos != 0 && alignmentStart < startPos) {
+- return false;
+- }
+- if (endPos != 0 && alignmentEnd > endPos) {
+- return false;
+- }
+- } else {
+- if (startPos != 0 && alignmentEnd < startPos) {
+- return false;
+- }
+- if (endPos != 0 && alignmentStart > endPos) {
+- return false;
+- }
+- }
+- return true;
+- }
+-
+- private int compareCoordinates(final SAMRecord record1, final SAMRecord record2) {
+- final int seqIndex1 = record1.getReferenceIndex();
+- final int seqIndex2 = record2.getReferenceIndex();
+- if (seqIndex1 == -1) {
+- return ((seqIndex2 == -1) ? 0 : -1);
+- } else if (seqIndex2 == -1) {
+- return 1;
+- }
+- int result = seqIndex1 - seqIndex2;
+- if (result != 0) {
+- return result;
+- }
+- result = record1.getAlignmentStart() - record2.getAlignmentStart();
+- return result;
+- }
+-
+- private boolean safeEquals(final Object o1, final Object o2) {
+- if (o1 == o2) {
+- return true;
+- } else if (o1 == null || o2 == null) {
+- return false;
+- } else {
+- return o1.equals(o2);
+- }
+- }
+-
+- private void verbose(final String text) {
+- if (mVerbose) {
+- System.out.println("# " + text);
+- }
+- }
+ }
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/htsjdk.git
More information about the debian-med-commit
mailing list