Skip to content

Commit

Permalink
Fix unit tests and issue with "chrom.sizes" genomes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Aug 13, 2024
1 parent 8c599b8 commit 1a426ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/main/java/org/broad/igv/feature/genome/Genome.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Genome(GenomeConfig config) throws IOException {
List<Chromosome> chromosomeList = null;
if (config.chromSizesURL != null) {
chromosomeList = ChromSizesParser.parse(config.chromSizesURL);
} else if (sequence.hasChromosomes()) {
} else if (sequence != null && sequence.hasChromosomes()) {
chromosomeList = sequence.getChromosomes();
} else if (config.indexURL != null) {
FastaIndex index = new FastaIndex(config.indexURL);
Expand Down Expand Up @@ -173,7 +173,7 @@ public Genome(GenomeConfig config) throws IOException {

// Whole genome view is enabled by default if we have the chromosome information amd the
// number of chromosomes is not too large
showWholeGenomeView = config.wholeGenomeView &&
showWholeGenomeView = config.wholeGenomeView &&
chromosomeList.size() > 1 &&
longChromosomeNames.size() <= MAX_WHOLE_GENOME_LONG;

Expand Down Expand Up @@ -242,6 +242,7 @@ public Genome(String id, List<Chromosome> chromosomes) {
chromosomeMap.put(chromosome.getName(), chromosome);
}
this.longChromosomeNames = computeLongChromosomeNames();
this.chromAliasSource = (new ChromAliasDefaults(id, chromosomeNames));
}

private void addTracks(GenomeConfig config) {
Expand Down Expand Up @@ -291,7 +292,9 @@ public String getCanonicalChrName(String str) {
ChromAlias aliasRecord = chromAliasSource.search(str);
if (aliasRecord != null) {
String chr = aliasRecord.getChr();
chrAliasCache.put(str, chr);
for (String a : aliasRecord.values()) {
chrAliasCache.put(a, chr);
}
return chr;
}
} catch (IOException e) {
Expand Down Expand Up @@ -404,17 +407,16 @@ public Chromosome getChromosome(String name) {
String chrName = getCanonicalChrName(name);
if (chromosomeMap.containsKey(chrName)) {
return chromosomeMap.get(chrName);
} else {
} else if (sequence != null) {
int length = this.sequence.getChromosomeLength(chrName);
if (length > 0) {
int idx = this.chromosomeMap.size();
Chromosome chromosome = new Chromosome(idx, chrName, length);
chromosomeMap.put(chrName, chromosome);
return chromosome;
} else {
return null;
}
}
return null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Genome loadGenome() throws IOException {
config.fastaURL = sequencePath;
config.indexURL = sequencePath + ".fai";
if (sequencePath.endsWith(".gz")) {
config.gziIndexURL = sequencePath + "gzi";
config.gziIndexURL = sequencePath + ".gzi";
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/test/java/org/broad/igv/tools/IGVToolsCountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ public void testCountBEDoutWig() throws Exception {
@Test
public void testCountBEDoutWigCheckBW() throws Exception {

GenomeUtils.main(null);

String inputFile = TestUtils.DATA_DIR + "bed/test2.bed";
String fullout = TestUtils.TMP_OUTPUT_DIR + "twig.wig";
String input = "count " + inputFile + " " + fullout + " " + genomePath;
Expand Down

0 comments on commit 1a426ee

Please sign in to comment.