Skip to content

Commit

Permalink
Unit test maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Aug 20, 2024
1 parent 3f4d87b commit 4a739bf
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 72 deletions.
39 changes: 0 additions & 39 deletions src/test/java/org/broad/igv/feature/genome/GenomeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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|";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/broad/igv/util/HttpUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 4a739bf

Please sign in to comment.