From 4a739bff7fd4e730547da3c18d199ca62c3ef0ec Mon Sep 17 00:00:00 2001 From: jrobinso <933148+jrobinso@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:05:50 -0700 Subject: [PATCH] Unit test maintenance --- .../broad/igv/feature/genome/GenomeTest.java | 39 ------------------- .../FastaBlockCompressedSequenceTest.java | 10 ++--- .../genome/load/JsonGenomeLoaderTest.java | 24 ------------ .../igv/sam/cram/IGVReferenceSourceTest.java | 4 +- .../org/broad/igv/util/HttpUtilsTest.java | 1 + .../stream/IGVSeekableBufferedStreamTest.java | 4 +- 6 files changed, 10 insertions(+), 72 deletions(-) diff --git a/src/test/java/org/broad/igv/feature/genome/GenomeTest.java b/src/test/java/org/broad/igv/feature/genome/GenomeTest.java index a3e22ab25c..9ff8839e81 100644 --- a/src/test/java/org/broad/igv/feature/genome/GenomeTest.java +++ b/src/test/java/org/broad/igv/feature/genome/GenomeTest.java @@ -53,45 +53,6 @@ public class GenomeTest extends AbstractHeadlessTest { @Rule public TestRule testTimeout = new Timeout((int) 60e3); - /** - * Test some aliases, both manually entered and automatic. - * - * @throws Exception - */ - @Test - public void testAlias_01() throws Exception { - String genomeURL = "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/hg19.genome"; - Genome genome = loadGenomeAssumeSuccess(genomeURL); - - assertEquals("chrUn_gl000229", genome.getCanonicalChrName("GL000229.1")); - assertEquals("chr14", genome.getCanonicalChrName("14")); - } - - @Test - public void testAlias_02() throws Exception { - // NCBI genome, test an auto-generated alias - String genomeURL = "https://igvdata.broadinstitute.org/genomes/NC_000964.genome"; - Genome genome = loadGenomeAssumeSuccess(genomeURL); - assertEquals("gi|255767013|ref|NC_000964.3|", genome.getCanonicalChrName("NC_000964.3")); - } - - /** - * Loads a genome - * - * @param genomeURL - * @return - */ - private Genome loadGenomeAssumeSuccess(String genomeURL) { - Genome genome = null; - try { - genome = GenomeManager.getInstance().loadGenome(genomeURL); - } catch (Exception e) { - e.printStackTrace(); - } - Assume.assumeNotNull(genome); - return genome; - } - @Test public void testGetNCBIName() throws Exception { String ncbiID = "gi|125745044|ref|NC_002229.3|"; diff --git a/src/test/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequenceTest.java b/src/test/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequenceTest.java index af1cfb283d..877389c035 100644 --- a/src/test/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequenceTest.java +++ b/src/test/java/org/broad/igv/feature/genome/fasta/FastaBlockCompressedSequenceTest.java @@ -15,7 +15,7 @@ public class FastaBlockCompressedSequenceTest { @Test public void findBlockContaining() throws Exception { - String fasta = "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/seq/hg38/hg38.fa.gz"; + String fasta = "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg38/hg38.fa.gz"; FastaBlockCompressedSequence seq = new FastaBlockCompressedSequence(fasta); @@ -28,18 +28,18 @@ public void findBlockContaining() throws Exception { @Test public void compareSequences() throws Exception { - String sequencePath = "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/seq/hg38/hg38.fa"; - String compressedSequencePath = "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/seq/hg38/hg38.fa.gz"; + String sequencePath = "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg38/hg38.fa"; + String compressedSequencePath = "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg38/hg38.fa.gz"; Sequence fastaSequence = new FastaIndexedSequence(sequencePath); Sequence bgSequence = new FastaBlockCompressedSequence(compressedSequencePath); - int len1 = fastaSequence.getChromosomeLength("chr12"); int len2 = bgSequence.getChromosomeLength("chr12"); + int len1 = fastaSequence.getChromosomeLength("chr12"); assertEquals(len1, len2); + byte[] seq2 = bgSequence.getSequence("chr12", 50000, 51000); byte[] seq1 = fastaSequence.getSequence("chr12", 50000, 51000); - byte[] seq2 = fastaSequence.getSequence("chr12", 50000, 51000); for (int i = 0; i < seq1.length; i++) { byte b1 = seq1[i]; diff --git a/src/test/java/org/broad/igv/feature/genome/load/JsonGenomeLoaderTest.java b/src/test/java/org/broad/igv/feature/genome/load/JsonGenomeLoaderTest.java index f42671b2a3..bc40f0f917 100644 --- a/src/test/java/org/broad/igv/feature/genome/load/JsonGenomeLoaderTest.java +++ b/src/test/java/org/broad/igv/feature/genome/load/JsonGenomeLoaderTest.java @@ -36,27 +36,3 @@ public void loadGenome() throws IOException { public void loadDescriptor() { } } - - -/* -{ - "id": "hg38", - "name": "Human (GRCh38/hg38)", - "fastaURL": "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/seq/hg38/hg38.fa", - "indexURL": "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/seq/hg38/hg38.fa.fai", - "cytobandURL": "https://s3.amazonaws.com/igv.org.genomes/hg38/annotations/cytoBandIdeo.txt.gz", - "aliasURL": "https://s3.amazonaws.com/igv.org.genomes/hg38/hg38_alias.tab", - "tracks": [ - { - "name": "Refseq Genes", - "format": "refgene", - "url": "https://s3.amazonaws.com/igv.org.genomes/hg38/ncbiRefSeq.sorted.txt.gz", - "indexURL": "https://s3.amazonaws.com/igv.org.genomes/hg38/ncbiRefSeq.sorted.txt.gz.tbi", - "visibilityWindow": -1, - "removable": false, - "order": 1000000 - } - ], - "chromosomeOrder": "chr1, chr2, chr3, chr4, chr5, chr6, chr7, chr8, chr9, chr10, chr11, chr12, chr13, chr14, chr15, chr16, chr17, chr18, chr19, chr20, chr21, chr22, chrX, chrY" -} - */ \ No newline at end of file diff --git a/src/test/java/org/broad/igv/sam/cram/IGVReferenceSourceTest.java b/src/test/java/org/broad/igv/sam/cram/IGVReferenceSourceTest.java index 24b4bd4112..6021445bf9 100644 --- a/src/test/java/org/broad/igv/sam/cram/IGVReferenceSourceTest.java +++ b/src/test/java/org/broad/igv/sam/cram/IGVReferenceSourceTest.java @@ -43,8 +43,8 @@ public class IGVReferenceSourceTest { - public static final String FASTA_URL = "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/seq/hg38/hg38.fa"; - public static final String COMPRESSED_FASTA_URL = "https://s3.amazonaws.com/igv.broadinstitute.org/genomes/seq/hg38/hg38.fa.gz"; + public static final String FASTA_URL = "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg38/hg38.fa"; + public static final String COMPRESSED_FASTA_URL = "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg38/hg38.fa.gz"; public static final String EXPECTED_REFERENCE_BASES = "AAACCCAGGGCAAAGAATCTGGCCCTA"; //bases at 22:27198875-271988902 @Before diff --git a/src/test/java/org/broad/igv/util/HttpUtilsTest.java b/src/test/java/org/broad/igv/util/HttpUtilsTest.java index 433104bee0..85c8165785 100644 --- a/src/test/java/org/broad/igv/util/HttpUtilsTest.java +++ b/src/test/java/org/broad/igv/util/HttpUtilsTest.java @@ -66,6 +66,7 @@ public void testGetContentLength() throws IOException { HttpURLConnection conn = null; try { conn = (HttpURLConnection) (HttpUtils.createURL(broadURLString)).openConnection(); + conn.setRequestProperty("User-Agent", "IGV"); String contentLength = conn.getHeaderField("Content-length"); assertEquals("52330665", contentLength); diff --git a/src/test/java/org/broad/igv/util/stream/IGVSeekableBufferedStreamTest.java b/src/test/java/org/broad/igv/util/stream/IGVSeekableBufferedStreamTest.java index 1568e410ce..5f8f23ac65 100644 --- a/src/test/java/org/broad/igv/util/stream/IGVSeekableBufferedStreamTest.java +++ b/src/test/java/org/broad/igv/util/stream/IGVSeekableBufferedStreamTest.java @@ -261,7 +261,7 @@ public void testRandomRead() throws IOException { assertEquals(length, bytesRead); byte[] buffer2 = new byte[length]; - SeekableStream bufferedStream = new IGVSeekableBufferedStream(new SeekableHTTPStream(HttpUtils.createURL(BAM_URL_STRING))); + SeekableStream bufferedStream = new IGVSeekableBufferedStream(new IGVSeekableHTTPStream(HttpUtils.createURL(BAM_URL_STRING))); bufferedStream.seek(startPosition); bytesRead = bufferedStream.read(buffer2, 0, length); assertEquals(length, bytesRead); @@ -286,7 +286,7 @@ public void testEOF() throws IOException { byte[] buffer = new byte[length]; - SeekableStream bufferedStream = new IGVSeekableBufferedStream(new SeekableHTTPStream(HttpUtils.createURL(BAM_URL_STRING))); + SeekableStream bufferedStream = new IGVSeekableBufferedStream(new IGVSeekableHTTPStream(HttpUtils.createURL(BAM_URL_STRING))); bufferedStream.seek(startPosition); int bytesRead = bufferedStream.read(buffer, 0, length); assertEquals(remainder, bytesRead);