Changeset 4361


Ignore:
Timestamp:
Oct 23, 2012, 2:39:26 PM (10 years ago)
Author:
Fredrik Levander
Message:

Refs #773. Small optimisation of score counting. And more logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugin/src/org/proteios/plugins/CombinedHitsReport.java

    r4360 r4361  
    336336    try
    337337    {
    338       int actual_score_types = 0;
    339338      int db_entries = 0;
    340339      List<CombinedHit> combinedHits = new ArrayList<CombinedHit>();
     
    409408        log.info("CombinedHitsReport Query result size:" + queryhits);
    410409        output.write(", total hits to consider: " + queryhits + "\n");
    411         if (queryhits > 0)
    412         {
    413           actual_score_types++;
    414         }
    415410        if (!proteins && localSampleId != null)
    416411        {
     
    553548                Integer currentFileId = currenthit
    554549                  .getPeakListFile().getId();
    555                 log.debug("File ID:" + currentFileId + " spectrum: " + currenthit
    556                   .getSpectrumStringId() + " description: " + currenthit
    557                   .getDescription());
     550                // log.debug("File ID:" + currentFileId + " spectrum: " + currenthit.getSpectrumStringId() + " description: " + currenthit.getDescription());
    558551                // If there is a sample id we sort on input
    559552                // filename
     
    701694          "Querying done. Setting default score values.");
    702695      }
     696      log.debug("Querying done. Starting to sort.");
    703697      // The actual filtering:
    704698      Collections.sort(combinedHits);
     699      log.debug("First sorting done. Setting score values");
    705700      // Set dummy scores
    706701      for (CombinedHit ch : combinedHits)
     
    721716        }
    722717      }
     718      float[][] revScores = new float[revCombinedHits.size()][score_types.length];
     719      int index=0;
    723720      for (CombinedHit ch : revCombinedHits)
    724721      {
     
    736733            }
    737734          }
    738         }
    739       }
     735          revScores[index][i]=ch.scores[i];
     736        }
     737        index++;
     738      }
     739      log.debug("Adding of extreme scores done.");
    740740      // count spots
    741741      int spots = 0;
     
    777777        progress.display(65, "Querying done. Calculating scores.");
    778778      }
    779       countBetterRandomHits(combinedHits, revCombinedHits);
    780       countBetterRandomHits(revCombinedHits, revCombinedHits);
     779      log.debug("Counting better hits for targets.");
     780      countBetterRandomHits(combinedHits, revScores);
     781      log.debug("Counting better hits for decoys.");
     782      countBetterRandomHits(revCombinedHits, revScores);
     783      log.debug("Counting done. Sorting after score counts");
    781784      if (progress != null)
    782785      {
     
    787790      Collections.sort(combinedHits, hitPValueSort);
    788791      Collections.sort(revCombinedHits, hitPValueSort);
     792      log.debug("Score count sorting done");
    789793      // Dummy lowest FDR
    790794      double lowestFDR = 1d / (double) combinedHits.size();
     
    834838        combinedHits.get(i).hit.setPrimaryCombined(new Boolean(true));
    835839      }
     840      log.debug("FDR calculation done");
    836841      if (progress != null)
    837842      {
     
    953958
    954959  private void countBetterRandomHits(List<CombinedHit> combinedHits,
    955       List<CombinedHit> revCombinedHits)
     960      float[][] revScores)
    956961  {
    957962    int combinedHitsSize = combinedHits.size();
    958     int revCombinedHitsSize = revCombinedHits.size();
     963    int revCombinedHitsSize = revScores.length;
    959964    int scoreSize = score_types.length;
    960965    for (int i = 0; i < combinedHitsSize; i++)
     
    965970       * If the reverse hit has all the score types that the forward hit
    966971       * has, and any of them is above those of the forward hit, it should
    967        * counted.
     972       * be counted.
    968973       */
    969974      for (int j = 0; j < revCombinedHitsSize; j++)
    970975      {
    971         boolean count = true;
    972976        boolean above = true;
    973977        for (int k = 0; k < scoreSize; k++)
    974978        {
    975           /*
    976            * if ((combinedHits.get(i).scores[k] == null) &&
    977            * (revCombinedHits .get(j).scores[k] != null)) { count =
    978            * false; } else
    979            */
    980           if ((combinedHits.get(i).scores[k] != null) && (revCombinedHits
    981             .get(j).scores[k] != null))
    982           {
    983             if ((!compareE[k] && (revCombinedHits.get(j).scores[k] < combinedHits
    984               .get(i).scores[k])) || (compareE[k] && (revCombinedHits
    985               .get(j).scores[k] > combinedHits.get(i).scores[k])))
     979            if ((!compareE[k] && (revScores[j][k] < combinedHits
     980              .get(i).scores[k])) || (compareE[k] && (revScores
     981              [j][k] > combinedHits.get(i).scores[k])))
    986982            {
    987983              above = false;
    988984            }
    989           }
    990         }
    991         if (above && count)
     985        }
     986        if (above)
    992987        {
    993988          scores_above++;
     
    995990      }
    996991      combinedHits.get(i).count = scores_above;
     992      if (i % 10000 == 0)
     993      {
     994        log.debug("Counting ..."+i);
     995      }
    997996    }
    998997  }
Note: See TracChangeset for help on using the changeset viewer.