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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
package hiseq;
import shared.Tools;
public class FlowcellCoordinate implements Comparable<FlowcellCoordinate> {
public FlowcellCoordinate() {}
public FlowcellCoordinate(String id) {
setFrom(id);
}
// public float distance(FlowcellCoordinate fc){ //Comment out due to being unused
// assert(isSet());
// assert(fc.isSet());
//
// if(lane!=fc.lane){return big;}
//
// long a=Tools.absdif(x, fc.x), b=Tools.absdif(y, fc.y);
// if(tile!=fc.tile){
// return spanTiles ? Tools.min(a, b) : big;
// }
// return (float)Math.sqrt(a*a+b*b);
//
// //Hard to say... could consider adjacent tiles?
//// if(tile!=fc.tile){
//// if(allowAdjacentTiles && Tools.absdif(tile, fc.tile)<2){return Tools.min(x-fc.x, y-fc.y);}
//// return big;
//// }
////
//// long a=x-fc.x, b=y-fc.y;
//// return (float)Math.sqrt(a*a+b*b);
// }
//2402:6:1101:6337:2237/1
//MISEQ08:172:000000000-ABYD0:1:1101:18147:1925 1:N:0:TGGATATGCGCCAATT
//HISEQ07:419:HBFNEADXX:1:1101:1238:2072
public void setFrom(String id){
final int lim=id.length();
int i=0;
int current=0;
while(i<lim && id.charAt(i)!=' ' && id.charAt(i)!='/'){i++;}
if(i>=lim){i--;}
for(int semis=0; i>=0; i--){
if(id.charAt(i)==':'){
semis++;
if(semis==4){break;}
}
}
i++;
assert(Tools.isDigit(id.charAt(i))) : id;
while(i<lim && Tools.isDigit(id.charAt(i))){
current=current*10+(id.charAt(i)-'0');
i++;
}
lane=current;
current=0;
i++;
if(!Tools.isDigit(id.charAt(i))){//Hiseq 3000?
while(i<lim && id.charAt(i)!=':'){i++;}
i++;
assert(Tools.isDigit(id.charAt(i))) : id;
while(i<lim && Tools.isDigit(id.charAt(i))){
current=current*10+(id.charAt(i)-'0');
i++;
}
lane=current;
current=0;
i++;
}
assert(Tools.isDigit(id.charAt(i))) : id;
while(i<lim && Tools.isDigit(id.charAt(i))){
current=current*10+(id.charAt(i)-'0');
i++;
}
tile=current;
current=0;
i++;
assert(Tools.isDigit(id.charAt(i))) : id;
while(i<lim && Tools.isDigit(id.charAt(i))){
current=current*10+(id.charAt(i)-'0');
i++;
}
x=current;
current=0;
i++;
assert(Tools.isDigit(id.charAt(i))) : id;
while(i<lim && Tools.isDigit(id.charAt(i))){
current=current*10+(id.charAt(i)-'0');
i++;
}
y=current;
current=0;
i++;
}
public boolean isSet(){
return lane>=0 && tile>=0 && x>=0 && y>=0;
}
@Override
public int compareTo(FlowcellCoordinate b) {
if(lane!=b.lane){return lane-b.lane;}
if(tile!=b.tile){return tile-b.tile;}
if(y!=b.y){return y-b.y;}
if(x!=b.x){return x-b.x;}
return 0;
}
public int lane=-1;
public int tile=-1;
public int x=-1;
public int y=-1;
public static final float big=10000000;
// public static boolean spanTiles=false;
public static FlowcellCoordinate getFC(){
FlowcellCoordinate fc=localFC.get();
if(fc==null){
fc=new FlowcellCoordinate();
localFC.set(fc);
}
return fc;
}
private static final ThreadLocal<FlowcellCoordinate> localFC=new ThreadLocal<FlowcellCoordinate>();
}
|