Debian Codegraph @

current/sort/ReadErrorComparator.java

raw symbols SCIP
1 package sort;
2
3 import java.util.Comparator;
4
5 import stream.Read;
6
7 /**
8 * @author Brian Bushnell
9 * @date May 30, 2013
10 *
11 */
12 public final class ReadErrorComparator implements Comparator<Read>{
13
14 @Override
15 public int compare(Read r1, Read r2) {
16
17 int a=(r1.errors+(r1.mate==null ? 0 : r1.mate.errors));
18 int b=(r2.errors+(r2.mate==null ? 0 : r2.mate.errors));
19 if(a!=b){return a-b;}
20
21 a=(r1.length()+(r1.mate==null ? 0 : r1.mateLength()));
22 b=(r2.length()+(r2.mate==null ? 0 : r2.mateLength()));
23 if(a!=b){return b-a;}
24
25 float a2=(r1.expectedErrors(true, 0)+(r1.mate==null ? 0 : r1.mate.expectedErrors(true, 0)));
26 float b2=(r2.expectedErrors(true, 0)+(r2.mate==null ? 0 : r2.mate.expectedErrors(true, 0)));
27 if(a2!=b2){return a2>b2 ? 1 : -1;}
28
29 if(r1.numericID<r2.numericID){return -1;}
30 else if(r1.numericID>r2.numericID){return 1;}
31
32 if(!r1.id.equals(r2.id)){return r1.id.compareTo(r2.id);}
33 return 0;
34 }
35
36 public static final ReadErrorComparator comparator=new ReadErrorComparator();
37
38 }