File: ReadErrorComparator.java

package info (click to toggle)
bbmap 39.20%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,024 kB
  • sloc: java: 312,743; sh: 18,099; python: 5,247; ansic: 2,074; perl: 96; makefile: 39; xml: 38
file content (38 lines) | stat: -rwxr-xr-x 1,053 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package sort;

import java.util.Comparator;

import stream.Read;

/**
 * @author Brian Bushnell
 * @date May 30, 2013
 *
 */
public final class ReadErrorComparator implements Comparator<Read>{
	
	@Override
	public int compare(Read r1, Read r2) {

		int a=(r1.errors+(r1.mate==null ? 0 : r1.mate.errors));
		int b=(r2.errors+(r2.mate==null ? 0 : r2.mate.errors));
		if(a!=b){return a-b;}
		
		a=(r1.length()+(r1.mate==null ? 0 : r1.mateLength()));
		b=(r2.length()+(r2.mate==null ? 0 : r2.mateLength()));
		if(a!=b){return b-a;}
		
		float a2=(r1.expectedErrors(true, 0)+(r1.mate==null ? 0 : r1.mate.expectedErrors(true, 0)));
		float b2=(r2.expectedErrors(true, 0)+(r2.mate==null ? 0 : r2.mate.expectedErrors(true, 0)));
		if(a2!=b2){return a2>b2 ? 1 : -1;}
		
		if(r1.numericID<r2.numericID){return -1;}
		else if(r1.numericID>r2.numericID){return 1;}
		
		if(!r1.id.equals(r2.id)){return r1.id.compareTo(r2.id);}
		return 0;
	}
	
	public static final ReadErrorComparator comparator=new ReadErrorComparator();
	
}