| 1 |
package pp2.prediction.knn; |
| 2 |
|
| 3 |
import java.util.LinkedList; |
| 4 |
|
| 5 |
/** |
| 6 |
* for each GO term, stores by which sequences it is supported |
| 7 |
* @author Thomas Hopf |
| 8 |
* |
| 9 |
*/ |
| 10 |
public class GoNode implements Comparable<GoNode> { |
| 11 |
|
| 12 |
private String goTerm; |
| 13 |
private LinkedList<Double> reliabilities; |
| 14 |
private LinkedList<Integer> hitIndex; |
| 15 |
private double score; |
| 16 |
|
| 17 |
public GoNode(String goTerm, int index, double reliability) |
| 18 |
{ |
| 19 |
this.goTerm = goTerm; |
| 20 |
hitIndex = new LinkedList<Integer>(); |
| 21 |
reliabilities = new LinkedList<Double>(); |
| 22 |
|
| 23 |
hitIndex.add(index); |
| 24 |
reliabilities.add(reliability); |
| 25 |
} |
| 26 |
|
| 27 |
public void addHit(int index, double reliability) |
| 28 |
{ |
| 29 |
hitIndex.add(index); |
| 30 |
reliabilities.add(reliability); |
| 31 |
} |
| 32 |
|
| 33 |
public LinkedList<Integer> getHitIndex() |
| 34 |
{ |
| 35 |
return hitIndex; |
| 36 |
} |
| 37 |
|
| 38 |
public LinkedList<Double> getReliabilities() |
| 39 |
{ |
| 40 |
return reliabilities; |
| 41 |
} |
| 42 |
|
| 43 |
public void setScore(double score) |
| 44 |
{ |
| 45 |
this.score = score; |
| 46 |
} |
| 47 |
|
| 48 |
public double getScore() |
| 49 |
{ |
| 50 |
return score; |
| 51 |
} |
| 52 |
|
| 53 |
public String getGoTerm() |
| 54 |
{ |
| 55 |
return goTerm; |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public int compareTo(GoNode o) { |
| 60 |
|
| 61 |
// highest scores are "smallest" so they end up as the first list elements |
| 62 |
|
| 63 |
if(this.score < o.score) |
| 64 |
return 1; |
| 65 |
else { |
| 66 |
if (this.score > o.score) |
| 67 |
return -1; |
| 68 |
else |
| 69 |
return 0; |
| 70 |
} |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
} |