예제 #1
0
 public String encode(LocusScore score) {
   String[] tokens = new String[4];
   tokens[0] = score.getChr();
   tokens[1] = "" + score.getStart();
   tokens[2] = "" + score.getEnd();
   tokens[3] = "" + score.getScore();
   String out = StringUtils.join(tokens, delimiter);
   return out;
 }
예제 #2
0
  @Override
  protected DataTile getRawData(String chr, int startLocation, int endLocation) {

    int queryLength = endLocation - startLocation;
    int longestFeature = getLongestFeature(chr);
    int adjustedStart = startLocation;
    int adjustedEnd = endLocation;
    if (queryLength < longestFeature) {
      int halfDiff = (longestFeature - queryLength) / 2;
      adjustedStart = startLocation - halfDiff - 1;
      adjustedEnd = endLocation + halfDiff;
    }

    try {
      Iterator<LocusScore> iter =
          pluginFeatureSource.getFeatures(chr, adjustedStart, adjustedEnd, -1);
      List<LocusScore> list = new ArrayList<LocusScore>(1000);
      LocusScore score;
      dataMin = Double.MAX_VALUE;
      dataMax = -Double.MAX_VALUE;

      while (iter.hasNext()) {
        score = iter.next();
        dataMin = Math.min(dataMin, score.getScore());
        dataMax = Math.max(dataMax, score.getScore());
        list.add(score);
        longestFeature = Math.max(longestFeature, score.getEnd() - score.getStart());
      }
      longestFeatureMap.put(chr, longestFeature);

      int length = list.size();
      int[] startLocations = new int[length];
      int[] endLocations = new int[length];
      float[] scores = new float[length];
      String[] names = new String[length];
      int idx = 0;
      for (LocusScore locusScore : list) {
        startLocations[idx] = locusScore.getStart();
        endLocations[idx] = locusScore.getEnd();
        scores[idx] = locusScore.getScore();
        names[idx] =
            Locus.getFormattedLocusString(
                locusScore.getChr(), locusScore.getStart(), locusScore.getEnd());
        idx++;
      }
      return new DataTile(startLocations, endLocations, scores, names);

    } catch (IOException e) {
      log.error(e.getMessage(), e);
      throw new RuntimeException(e);
    }
  }