Skip to content

Commit

Permalink
fix inconsistent display of the selected read in mouseover
Browse files Browse the repository at this point in the history
fix order issue caused by my nemesis HashSet
  • Loading branch information
lbergelson committed Oct 4, 2023
1 parent dee9ce9 commit fa85202
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/main/java/org/broad/igv/sam/SAMAlignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -996,14 +996,13 @@ private String getSupplAlignmentString() {
}

private String getThisReadDescriptionForSAList() {
return "<br>" +
"<b>"
return "<br>"
+ "<b>"
+ chr + ":" + Globals.DECIMAL_FORMAT.format(getAlignmentStart() + 1) + "-" + Globals.DECIMAL_FORMAT.format(getAlignmentEnd())
+ " (" + getReadStrand().toShortString() + ")" +
"</b>";
+ " (" + this.getReadStrand().toShortString() + ") = " + Globals.DECIMAL_FORMAT.format(getLengthOnReference()) + "bp @MAPQ " + this.getMappingQuality() + " NM" + getAttribute(SAMTag.NM)
+ "</b>";
}


public float getScore() {
return getMappingQuality();
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/broad/igv/sam/SupplementaryAlignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ public class SupplementaryAlignment implements Locatable {
public final String chr;
public final int start;

public Strand getStrand() {
return strand;
}

private final Strand strand;
private final Cigar cigar;

Expand All @@ -52,6 +48,10 @@ public SupplementaryAlignment(String chr, int start, Strand strand, Cigar cigar,
this.numMismatches = numMismatches;
}

public Strand getStrand() {
return strand;
}

public static int getInsertionIndex(final Alignment alignment, final List<SupplementaryAlignment> supplementaryAlignments) {
final SupplementaryAlignment alignmentAsSupplementary = new SupplementaryAlignment(null, 0, alignment.getReadStrand(), alignment.getCigar(),
0, 0); //We're just using this as a placeholder for sorting since Alignment
Expand Down Expand Up @@ -118,7 +118,7 @@ public static List<SupplementaryAlignment> parseFromSATag(String saTag){
return Arrays.stream(Globals.semicolonPattern.split(saTag))
.map(SupplementaryAlignment::fromSingleSaTagRecord)
.sorted(LEADING_CLIP_COMPARATOR)
.collect(Collectors.toList());
.toList();
}

public static SupplementaryAlignment fromSingleSaTagRecord(String saTagRecord){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collector;
import java.util.stream.Collectors;

class SupplementalAlignmentDiagram extends JComponent {
Expand Down Expand Up @@ -145,7 +146,6 @@ private static Composite getAlphaComposite() {
return AlphaComposite.getInstance(type, alpha);
}


private Map<SupplementaryAlignment, AlignmentArrow> drawAlignmentsInReadOrder(final Graphics2D g, final SupplementaryAlignment.SupplementaryGroup toDraw,
final Set<SupplementaryAlignment> selected, final int width, final int midline) {
final Map<SupplementaryAlignment, AlignmentArrow> positions = new LinkedHashMap<>();
Expand Down Expand Up @@ -218,7 +218,8 @@ private static Map<SupplementaryAlignment, AlignmentArrow> drawAlignmentsInConde
final var groupedBySpan = groupBySpanningInterval(toDraw.streamInPositionOrder().toList());
final Map<String, List<Locatable>> byContig = groupedBySpan.keySet()
.stream()
.collect(Collectors.groupingBy(Locatable::getContig));
.collect(Collectors.groupingBy(Locatable::getContig, LinkedHashMap::new, Collectors.toList()));


//tihs should probably vary per contig instead of being uniform
final double perContigAvailableSpace = (width - (2 * scaledBorderGap + (contigs.size() -1) * scaledContigGap))/((double)contigs.size());
Expand Down

0 comments on commit fa85202

Please sign in to comment.