public static void main(String[] args) {

    if (args.length != 2) {
      System.err.println(
          "Usage: MemoryBasedLeft2Right <in score file> <out aggregated scores redis file>");
      System.exit(0);
    }

    String infile = args[0];
    String redisSimilarityFile = args[1];

    try {

      BufferedReader reader = new BufferedReader(new FileReader(new File(infile)));
      String line;
      TIntObjectMap<TIntDoubleMap> scoresMap = new TIntObjectHashMap<TIntDoubleMap>();

      while ((line = reader.readLine()) != null) {
        String[] toks = line.split("\t");

        int id1 = Integer.parseInt(toks[0]);
        int id2 = Integer.parseInt(toks[1]);
        double score = Double.parseDouble(toks[2]);
        TIntDoubleMap scores = scoresMap.get(id1);
        if (scores == null) {
          scores = new TIntDoubleHashMap();
          scoresMap.put(id1, scores);
        }
        scores.put(id2, score);
      }
      reader.close();

      RedisBasedIDKeyPersistentBasicMap<LinkedHashMap<Integer, Double>> redis =
          new RedisBasedIDKeyPersistentBasicMap<LinkedHashMap<Integer, Double>>(
              redisSimilarityFile, false);
      redis.clear();
      TIntObjectIterator<TIntDoubleMap> it = scoresMap.iterator();
      while (it.hasNext()) {
        it.advance();
        int id1 = it.key();
        TIntDoubleMap scores = it.value();
        redis.put(id1, SortUtil.sortMapByValue(scores, true));
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  private void initial() {
    NormalDistribution nd = new NormalDistribution();
    String[] seqList = this.sequence.split(";");
    for (String seq : seqList) {
      BaseIsotopomer bIso = new BaseIsotopomer(seq, this.isotopomerWidth);
      TIntDoubleMap chargeScaleMap = new TIntDoubleHashMap();
      int centralCharge = bIso.getCentralChargeState();
      int totalChargeState = (bIso.getMaxChargeState() - centralCharge) * 2;
      double step = 6.0 / totalChargeState;
      // calculate right side of the central charge state (inclusive) to 10+ charge
      double x = 0.0;
      for (int i = centralCharge; i > 8; i--) {
        double factor = nd.density(x);
        x += step;
        chargeScaleMap.put(i, factor);
      }

      // calculate left side of the central charge state (exclusive) to max charge
      x = step;
      for (int i = centralCharge + 1; i <= bIso.getMaxChargeState(); i++) {
        double factor = nd.density(x);
        x += step;
        chargeScaleMap.put(i, factor);
      }

      // build list of Isotopomer
      for (int charge : chargeScaleMap.keys()) {
        ChargedIsotopomer cIso = new ChargedIsotopomer(bIso, charge);
        isotopomerList.add(cIso);

        TDoubleDoubleMap tempPeakMap = cIso.getScaledPeakMap(chargeScaleMap.get(charge));

        for (double mz : tempPeakMap.keys()) {
          double intensity = peakMap.get(mz);
          if (intensity == peakMap.getNoEntryValue()) {
            peakMap.put(mz, tempPeakMap.get(mz));
          } else {
            peakMap.put(mz, intensity + tempPeakMap.get(mz));
          }
        }
      }
    }
  }
Exemplo n.º 3
0
 @Override
 public int getSerializedSizeUnlocked() {
   return (Integer.SIZE + params.size() * (Integer.SIZE + Double.SIZE)) / Byte.SIZE;
 }