Skip to content
Snippets Groups Projects
Commit dce13c3a authored by tjc's avatar tjc
Browse files

fix SAMRecordPositionComparator by looking up offset

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@13861 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 4b193746
No related branches found
No related tags found
No related merge requests found
...@@ -624,7 +624,7 @@ public class BamView extends JPanel ...@@ -624,7 +624,7 @@ public class BamView extends JPanel
bamList.size() > 1) bamList.size() > 1)
{ {
// merge multiple BAM files // merge multiple BAM files
Collections.sort(readsInView, new SAMRecordPositionComparator()); Collections.sort(readsInView, new SAMRecordPositionComparator(BamView.this));
} }
} }
catch (OutOfMemoryError ome) catch (OutOfMemoryError ome)
......
...@@ -30,14 +30,23 @@ import net.sf.samtools.SAMRecord; ...@@ -30,14 +30,23 @@ import net.sf.samtools.SAMRecord;
class SAMRecordPositionComparator implements Comparator<Object> class SAMRecordPositionComparator implements Comparator<Object>
{ {
public BamView bamView;
public SAMRecordPositionComparator(BamView bamView)
{
this.bamView = bamView;
}
public int compare(Object o1, Object o2) public int compare(Object o1, Object o2)
{ {
SAMRecord pr1 = (SAMRecord) o1; SAMRecord pr1 = (SAMRecord) o1;
SAMRecord pr2 = (SAMRecord) o2; SAMRecord pr2 = (SAMRecord) o2;
if(pr1.getAlignmentStart() < pr2.getAlignmentStart()) int offset1 = bamView.getSequenceOffset(pr1.getReferenceName());
int offset2 = bamView.getSequenceOffset(pr2.getReferenceName());
if(pr1.getAlignmentStart()+offset1 < pr2.getAlignmentStart()+offset2)
return -1; return -1;
else if(pr1.getAlignmentStart() > pr2.getAlignmentStart()) else if(pr1.getAlignmentStart()+offset1 > pr2.getAlignmentStart()+offset2)
return 1; return 1;
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment