Skip to content

Commit

Permalink
Add sort alignments by readname. Fixes #419
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Mar 20, 2020
1 parent f95cb2c commit 0e6a0e3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/broad/igv/batch/CommandExecutor.java
Expand Up @@ -921,6 +921,8 @@ private static AlignmentTrack.SortOption getAlignmentSortOption(String str) {
return AlignmentTrack.SortOption.MATE_CHR;
} else if (str.equalsIgnoreCase("readOrder")) {
return AlignmentTrack.SortOption.READ_ORDER;
} else if (str.equalsIgnoreCase("readname")) {
return AlignmentTrack.SortOption.READ_NAME;
} else {
try {
return AlignmentTrack.SortOption.valueOf(str.toUpperCase());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/broad/igv/sam/AlignmentTrack.java
Expand Up @@ -96,7 +96,7 @@ enum ColorOption {

public enum SortOption {
START, STRAND, NUCLEOTIDE, QUALITY, SAMPLE, READ_GROUP, INSERT_SIZE, FIRST_OF_PAIR_STRAND, MATE_CHR, TAG,
SUPPLEMENTARY, NONE, HAPLOTYPE, READ_ORDER
SUPPLEMENTARY, NONE, HAPLOTYPE, READ_ORDER, READ_NAME
}

public enum GroupOption {
Expand Down Expand Up @@ -1633,6 +1633,7 @@ void addSortMenuItem() {
mappings.put("sample", SortOption.SAMPLE);
mappings.put("read group", SortOption.READ_GROUP);
mappings.put("read order", SortOption.READ_ORDER);
mappings.put("read name", SortOption.READ_NAME);

if (dataManager.isPairedEnd()) {
mappings.put("insert size", SortOption.INSERT_SIZE);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/broad/igv/sam/Row.java
Expand Up @@ -97,7 +97,6 @@ public double calculateScore(AlignmentTrack.SortOption option, double center, Al
else {
score = 0;
}

return score;
case NUCLEOTIDE:
byte base = centerAlignment.getBase(adjustedCenter);
Expand Down Expand Up @@ -172,6 +171,10 @@ public double calculateScore(AlignmentTrack.SortOption option, double center, Al
//String hapname = centerAlignment.getHaplotypeName();
//return hapname == null ? 0 : hapname.hashCode();
return centerAlignment.getHapDistance();
case READ_NAME:
String readName = centerAlignment.getReadName();
score = readName == null ? 0 : readName.hashCode();

This comment has been minimized.

Copy link
@ollenordesjo

ollenordesjo Mar 16, 2021

Question on this? Does this mean that the reads will be sorted by the hashcode of the string? Any idea if there's a way to reproduce readName.hashCode() so that it's possible to know the sort-order beforehand? Thanks!

return score;
default:
return Integer.MAX_VALUE;

Expand Down
Binary file removed sv.png
Binary file not shown.
Binary file removed test.png
Binary file not shown.

0 comments on commit 0e6a0e3

Please sign in to comment.