| 1 |
package prok; |
| 2 |
|
| 3 |
import java.util.Comparator; |
| 4 |
|
| 5 |
import structures.Feature; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
abstract class PFeature extends ProkObject implements Comparable<PFeature>, Feature { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public PFeature(String scafName_, int start_, int stop_, int strand_, int scaflen_){ |
| 20 |
scafName=scafName_; |
| 21 |
start=start_; |
| 22 |
stop=stop_; |
| 23 |
strand=strand_; |
| 24 |
scaflen=scaflen_; |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public final void flip(){ |
| 32 |
int a=scaflen-start-1; |
| 33 |
int b=scaflen-stop-1; |
| 34 |
start=b; |
| 35 |
stop=a; |
| 36 |
flipped=flipped^1; |
| 37 |
} |
| 38 |
|
| 39 |
public final int currentStrand(){ |
| 40 |
return strand^flipped; |
| 41 |
} |
| 42 |
|
| 43 |
public final int length(){ |
| 44 |
return stop-start+1; |
| 45 |
} |
| 46 |
|
| 47 |
@Override |
| 48 |
public final int compareTo(PFeature f) { |
| 49 |
int x=scafName.compareTo(f.scafName); |
| 50 |
if(x!=0){return x;} |
| 51 |
if(stop!=f.stop){return stop-f.stop;} |
| 52 |
return start-f.start; |
| 53 |
} |
| 54 |
|
| 55 |
public final int flipped(){return flipped;} |
| 56 |
|
| 57 |
public abstract float score(); |
| 58 |
|
| 59 |
@Override |
| 60 |
public final int start() {return start;} |
| 61 |
|
| 62 |
@Override |
| 63 |
public final int stop() {return stop;} |
| 64 |
|
| 65 |
@Override |
| 66 |
public final int strand() {return strand;} |
| 67 |
|
| 68 |
@Override |
| 69 |
public final String name() {return null;} |
| 70 |
|
| 71 |
@Override |
| 72 |
public final String seqid() {return scafName;} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public final String scafName; |
| 79 |
public final int strand; |
| 80 |
public final int scaflen; |
| 81 |
|
| 82 |
|
| 83 |
public int start; |
| 84 |
|
| 85 |
public int stop; |
| 86 |
private int flipped=0; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
@SuppressWarnings("synthetic-access") |
| 93 |
public static final FeatureComparatorScore featureComparatorScore=new FeatureComparatorScore(); |
| 94 |
|
| 95 |
|
| 96 |
private static class FeatureComparatorScore implements Comparator<PFeature> { |
| 97 |
|
| 98 |
private FeatureComparatorScore(){} |
| 99 |
|
| 100 |
@Override |
| 101 |
public int compare(PFeature a, PFeature b) { |
| 102 |
float sa=a.score(), sb=b.score(); |
| 103 |
if(sa<sb){return 1;} |
| 104 |
if(sb<sa){return -1;} |
| 105 |
return a.compareTo(b); |
| 106 |
} |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
} |