Skip to content

Commit

Permalink
Java 17 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lbergelson committed Oct 19, 2023
1 parent 3156369 commit 0478c64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 52 deletions.
16 changes: 8 additions & 8 deletions src/main/java/org/broad/igv/sam/AlignmentRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,10 @@ private static void drawClippedEnds(final Graphics2D g, final int[] xPoly, final
try {
//left side
if (drawLeftClip) {
if (sri != null && sri.previous != null) {
final SupplementaryAlignment previous = sri.previous;
if (previous.contigsMatch(sri.alignment)) {
g.setColor(previous.getStrand() == sri.alignment.getReadStrand() ? NON_INVERSION_COLOR : INVERSION_COLOR);
if (sri != null && sri.previous() != null) {
final SupplementaryAlignment previous = sri.previous();
if (previous.contigsMatch(sri.alignment())) {
g.setColor(previous.getStrand() == sri.alignment().getReadStrand() ? NON_INVERSION_COLOR : INVERSION_COLOR);
} else {
if (previous.getContig() != null) {
g.setColor(ChromosomeColors.getColor(previous.getContig()));
Expand All @@ -969,11 +969,11 @@ private static void drawClippedEnds(final Graphics2D g, final int[] xPoly, final
}
//right side
if (drawRightClip) {
if (sri != null && sri.next != null) {
final SupplementaryAlignment next = sri.next;
if (next.contigsMatch(sri.alignment)) {
if (sri != null && sri.next() != null) {
final SupplementaryAlignment next = sri.next();
if (next.contigsMatch(sri.alignment())) {
//TODO Set to scaled color by contig position
g.setColor(next.getStrand() == sri.alignment.getReadStrand() ? NON_INVERSION_COLOR : INVERSION_COLOR);
g.setColor(next.getStrand() == sri.alignment().getReadStrand() ? NON_INVERSION_COLOR : INVERSION_COLOR);
} else {
g.setColor(ChromosomeColors.getColor(next.getContig()));
rightContigLabel = next.getContig();
Expand Down
60 changes: 16 additions & 44 deletions src/main/java/org/broad/igv/sam/SupplementaryAlignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import htsjdk.samtools.util.Locatable;
import org.broad.igv.Globals;
import org.broad.igv.feature.Strand;
import org.broad.igv.feature.genome.ChromosomeNameComparator;
import org.broad.igv.feature.genome.Genome;
import org.broad.igv.feature.genome.GenomeManager;
import org.broad.igv.logging.LogManager;
Expand All @@ -17,11 +16,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class SupplementaryAlignment implements Locatable {
private static final Logger log = LogManager.getLogger(SupplementaryAlignment.class);
Expand Down Expand Up @@ -145,14 +140,10 @@ public int getCountOfLeadingClipping(){
}

public static int getCountOfLeadingClipping(final ClippingCounts counts, final Strand strand) {
switch(strand){
case NONE: // if there's no strand it's not aligned, and we can assume it's in cycle order
case POSITIVE:
return counts.getLeft();
case NEGATIVE:
return counts.getRight();
default: throw new IllegalStateException(strand + " is not an expected value for strand");
}
return switch (strand) { // if there's no strand it's not aligned, and we can assume it's in cycle order
case NONE, POSITIVE -> counts.getLeft();
case NEGATIVE -> counts.getRight();
};
}

/**
Expand Down Expand Up @@ -186,21 +177,14 @@ public int getLengthOnReference() {
/**
* get the count of non-clipped bases which are in the read
* this differs from {@link #getLengthOnReference()} because it includes insertions bases but not deletions
* @return
*/
public int getNumberOfAlignedBases(){
if( numberOfAlignedBases == null) {
int length = 0;
for(CigarElement element : cigar) {
switch (element.getOperator()) {
case M:
case I:
case EQ:
case X:
length += element.getLength();
break;
default:
break;
case M, I, EQ, X -> length += element.getLength();
default -> {}
}
}
numberOfAlignedBases = length;
Expand All @@ -209,30 +193,18 @@ public int getNumberOfAlignedBases(){
}



static class SupplementaryNeighbors {
final Alignment alignment;
final SupplementaryAlignment previous;
final SupplementaryAlignment next;
public SupplementaryNeighbors(Alignment alignment,
SupplementaryAlignment previous, SupplementaryAlignment next) {
this.alignment = alignment;
if(alignment.isNegativeStrand()){
this.next = previous;
this.previous = next;
} else {
this.next = next;
this.previous = previous;
record SupplementaryNeighbors(Alignment alignment, SupplementaryAlignment previous, SupplementaryAlignment next) {
SupplementaryNeighbors(Alignment alignment, SupplementaryAlignment previous, SupplementaryAlignment next) {
this.alignment = alignment;
if (alignment.isNegativeStrand()) {
this.next = previous;
this.previous = next;
} else {
this.next = next;
this.previous = previous;
}
}
}
public SupplementaryAlignment previousIgnoreOrientation (){
return alignment.isNegativeStrand() ? next : previous;
}

public SupplementaryAlignment nextIgnoreOrientation (){
return alignment.isNegativeStrand() ? previous : next;
}

}

}

0 comments on commit 0478c64

Please sign in to comment.