Пример #1
0
  /**
   * Makes a stair step heat map from an array of windows in bar format. One per chromosome. Don't
   * forget to set the barDirectory and score Index!!!!!!!
   */
  public void makeStairStepBarFiles() {
    // make bar parser
    BarParser bp = new BarParser();
    bp.setZipCompress(true);
    HashMap<String, String> tagVals = new HashMap<String, String>();
    tagVals.put(BarParser.GRAPH_TYPE_TAG, BarParser.GRAPH_TYPE_STAIRSTEP);
    tagVals.put(BarParser.GRAPH_TYPE_COLOR_TAG, "#FF00FF"); // fusha
    tagVals.put(BarParser.SOURCE_TAG, bedFile.toString());

    // for each chromosome
    System.out.print("Printing... ");
    Iterator<String> it = bedLinesHash.keySet().iterator();
    while (it.hasNext()) {
      chromosome = it.next();
      System.out.print(chromosome + " ");
      windows = bedLinesHash.get(chromosome);
      // add blocks
      assembleBlocks();
      // balance by adding max or min at zero base
      balanceValues();
      // write bar file
      File barFile = new File(barDirectory, chromosome + ".bar");
      bp.writeBarFile(
          barFile,
          chromosome,
          genomeVersion,
          '.',
          Num.arrayListOfIntegerToInts(bases),
          Num.arrayListOfFloatToArray(values),
          tagVals);
      // clear ArrayLists
      bases.clear();
      values.clear();
    }
    System.out.println();
  }
Пример #2
0
  @Override
  protected void updateText(final int pre, final byte[] value, final int kind) {
    final boolean text = kind != ATTR;

    if (meta.updindex) {
      // update indexes
      final int id = id(pre);
      final byte[] oldval = text(pre, text);
      final DiskValues index = (DiskValues) (text ? textIndex : attrIndex);
      // don't index document names
      if (index != null && kind != DOC) index.replace(oldval, value, id);
    }

    // reference to text store
    final DataAccess store = text ? texts : values;
    // file length
    final long len = store.length();

    // new entry (offset or value)
    final long v = toSimpleInt(value);
    if (v != Integer.MIN_VALUE) {
      // inline integer value
      textOff(pre, v | IO.OFFNUM);
    } else {
      // text to be stored (possibly packed)
      final byte[] val = COMP.get().pack(value);
      // old entry (offset or value)
      final long old = textOff(pre);

      // find text store offset
      final long off;
      if (number(old)) {
        // numeric entry: append new entry at the end
        off = len;
      } else {
        // text size (0 if value will be inlined)
        final int vl = val.length;
        off = store.free(old & IO.OFFCOMP - 1, vl + Num.length(vl));
      }

      store.writeToken(off, val);
      textOff(pre, val == value ? off : off | IO.OFFCOMP);
    }
  }