Ejemplo n.º 1
0
 public void setGOtcha(proteinSet train) {
   if (this.blastResult.size() == 0) {
     System.out.println(access + " have no blast result; We use Naive Score");
     this.PredictionScore = train.getNaiveList();
   }
   ArrayList<Integer> ann = new ArrayList<Integer>();
   HashMap<Integer, Double> pred = new HashMap<Integer, Double>();
   double SumBitScore = 0;
   double bitscore;
   for (Pair<String, Double> pair : blastResult) {
     bitscore = pair.getSecond();
     SumBitScore = SumBitScore + bitscore;
     String access = pair.getFirst();
     if (train.containProtein(access)) {
       ann = train.getAnnotation(access);
       for (int node : ann) {
         if (!pred.containsKey(node)) {
           pred.put(node, bitscore);
         } else {
           pred.put(node, pred.get(node) + bitscore);
         }
       }
     }
   }
   for (Map.Entry<Integer, Double> entry : pred.entrySet()) {
     this.PredictionScore.add(
         new Pair<Integer, Double>(entry.getKey(), (double) entry.getValue() / SumBitScore));
   }
 }
Ejemplo n.º 2
0
  public void knn(proteinSet train) {
    ArrayList<Integer> ann = new ArrayList<Integer>();
    HashMap<Integer, Double> pred = new HashMap<Integer, Double>();
    double SumBitScore = 0;
    double sim;
    for (Pair<String, Double> pair : this.Similiar) {
      sim = pair.getSecond();
      SumBitScore = SumBitScore + sim;
      String access = pair.getFirst();
      if (train.containProtein(access)) {
        ann = train.getAnnotation(access);
        for (int node : ann) {
          if (!pred.containsKey(node)) {
            pred.put(node, sim);
          } else {
            pred.put(node, pred.get(node) + sim);
          }
        }
      }
    }
    for (Map.Entry<Integer, Double> entry : pred.entrySet()) {
      double knnScore = 0.0;
      if (SumBitScore > Parameter.resolution) knnScore = (double) entry.getValue() / SumBitScore;

      this.PredictionScore.add(new Pair<Integer, Double>(entry.getKey(), knnScore));
    }
  }
Ejemplo n.º 3
0
 public double miniscore() {
   double miniscore = 1.0;
   for (Pair<Integer, Double> entry : PredictionScore) {
     if (miniscore > entry.getSecond()) miniscore = entry.getSecond();
   }
   return miniscore;
 }
Ejemplo n.º 4
0
 public void OutputPredScore(PrintWriter Fout) {
   Fout.println(this.access);
   Fout.print(this.PredictionScore.size());
   for (Pair<Integer, Double> entry : this.PredictionScore) {
     Fout.printf(" %d:%.4f", entry.getFirst(), entry.getSecond());
   }
   Fout.println();
 }
Ejemplo n.º 5
0
 public oneProtein getSubProtein(char space) {
   oneProtein aProtein = new oneProtein(this.access, getSubAnnotation(space));
   for (Pair<Integer, Double> entry : PredictionScore) {
     int Annotation = entry.getFirst();
     if (learning.aGoSet.getSpace(Annotation) == space) aProtein.addPred(entry);
   }
   return aProtein;
 }
Ejemplo n.º 6
0
 public void setLiblinearFeatureFromSparseFeature() {
   List<Feature> x = new ArrayList<Feature>();
   for (Pair<Integer, Double> pair : this.SparseFeature) {
     Feature node = new FeatureNode(pair.getFirst(), pair.getSecond());
     x.add(node);
   }
   this.liblinearFeature = new Feature[x.size()];
   this.liblinearFeature = x.toArray(this.liblinearFeature);
   this.SparseFeature.clear();
 }
Ejemplo n.º 7
0
 public void recordblastScore() {
   for (Pair<Integer, Double> pair : this.PredictionScore) {
     int label = pair.getFirst();
     if ((this.MFOL2RCandidate.contains(label))
         || (this.BPOL2RCandidate.contains(label))
         || (this.CCOL2RCandidate.contains(label))) {
       this.blastScore.put(pair.getFirst(), pair.getSecond());
     }
   }
 }
Ejemplo n.º 8
0
 public void removeLowPred(int count) {
   ArrayList<Pair<Double, Integer>> ArrSort = new ArrayList<Pair<Double, Integer>>();
   for (Pair<Integer, Double> pair : this.PredictionScore) {
     ArrSort.add(new Pair<Double, Integer>(pair.getSecond(), pair.getFirst()));
   }
   Collections.sort(ArrSort);
   this.PredictionScore.clear();
   int index = Math.max(0, ArrSort.size() - count);
   for (int i = ArrSort.size() - 1; i >= index; i--) {
     this.PredictionScore.add(
         new Pair<Integer, Double>(ArrSort.get(i).getSecond(), ArrSort.get(i).getFirst()));
   }
 }
Ejemplo n.º 9
0
 public void setBlastPred(proteinSet train) {
   ArrayList<Integer> ann = new ArrayList<Integer>();
   HashMap<Integer, Double> pred = new HashMap<Integer, Double>();
   for (Pair<String, Double> pair : blastResult) {
     double bitscore = pair.getSecond();
     String access = pair.getFirst();
     ann = train.getAnnotation(access);
     for (int node : ann) {
       if (!pred.containsKey(node)) {
         pred.put(node, bitscore);
         PredictionScore.add(new Pair<Integer, Double>(node, bitscore));
       }
     }
   }
 }
Ejemplo n.º 10
0
 public void OutputSparseFeature(PrintWriter Fout) {
   for (Pair<Integer, Double> e : this.SparseFeature) {
     Fout.print(" " + e.getFirst() + ":" + e.getSecond());
     Fout.printf(" %d:%.4f", e.getFirst(), e.getSecond());
   }
 }