Skip to content

Commit

Permalink
Prevent multiple loads of alignments for same region, caused by multi…
Browse files Browse the repository at this point in the history
…ple tracks sharing the alignments spawning asyc loads.

Prevent async loading of a single BAM file from a single reader (htsjdk not thread save)
  • Loading branch information
jrobinso committed Jun 12, 2020
1 parent 6979897 commit b0579ca
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/main/java/org/broad/igv/sam/AlignmentDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ private void initChrMap(Genome genome) throws IOException {

for (Chromosome chromosome : genome.getChromosomes()) {

Long size = new Long(chromosome.getLength());
Long size = (long) chromosome.getLength();
if (!nonUnique.contains(size)) {
if (inverseDict.containsKey(size)) {
inverseDict.remove(size);
nonUnique.add(size);
} else {
inverseDict.put(new Long(size), chromosome.getName());
inverseDict.put(size, chromosome.getName());
}
}
}
Expand Down Expand Up @@ -317,33 +317,20 @@ public boolean isLoaded(ReferenceFrame frame) {
return getLoadedInterval(frame) != null;
}

public boolean isLoading(ReferenceFrame frame) {

// Range range = frame.getCurrentRange();
// for (Range r : isLoading) {
// if (r.contains(range)) return true;
// }
return false;
}


public void load(ReferenceFrame frame,
AlignmentTrack.RenderOptions renderOptions,
boolean expandEnds) {

if (frame.getChrName().equals(Globals.CHR_ALL) || frame.getScale() > getMinVisibleScale()) return; // should not happen

if (isLoaded(frame)) return; // Already loaded
synchronized (loadLock) {

if (isLoading(frame)) return; // Already oading
if (isLoaded(frame)) return; // Already loaded

// synchronized (loadLock) {
Range range = frame.getCurrentRange();

final String chr = frame.getChrName();

final int start = (int) range.getStart();
final int end = (int) range.getEnd();
final int start = range.getStart();
final int end = range.getEnd();
int adjustedStart = start;
int adjustedEnd = end;

Expand Down Expand Up @@ -371,7 +358,7 @@ public void load(ReferenceFrame frame,

// IGVEventBus.getInstance().post(new DataLoadedEvent(frame));

// }
}
}


Expand Down

0 comments on commit b0579ca

Please sign in to comment.