Пример #1
0
 public MatrixZoomData getControlZd() {
   Matrix matrix = getControlMatrix();
   if (matrix == null || currentZoom == null) {
     return null;
   } else {
     return matrix.getZoomData(currentZoom);
   }
 }
Пример #2
0
 public MatrixZoomData getZd() throws UninitializedObjectException {
   Matrix matrix = getMatrix();
   if (matrix == null) {
     throw new UninitializedObjectException("Uninitialized matrix");
   } else if (currentZoom == null) {
     throw new UninitializedObjectException("Uninitialized zoom");
   } else {
     return matrix.getZoomData(currentZoom);
   }
 }
Пример #3
0
  private void unsafeSave1DTrackToWigFile(
      Chromosome chromosomeForPosition, PrintWriter printWriter, int binStartPosition)
      throws IOException {
    int resolution = getZoom().getBinSize();
    for (Chromosome chromosome : chromosomes) {
      if (chromosome.getName().equals(Globals.CHR_ALL)) continue;
      Matrix matrix = null;
      if (displayOption == MatrixType.OBSERVED) {
        matrix = dataset.getMatrix(chromosomeForPosition, chromosome);
      } else if (displayOption == MatrixType.CONTROL) {
        matrix = controlDataset.getMatrix(chromosomeForPosition, chromosome);
      }

      if (matrix == null) continue;

      MatrixZoomData zd = matrix.getZoomData(currentZoom);
      printWriter.println(
          "fixedStep chrom=chr"
              + chromosome.getName().replace("chr", "")
              + " start=1 step="
              + resolution
              + " span="
              + resolution);

      int[] regionIndices;
      if (chromosomeForPosition.getIndex() < chromosome.getIndex()) {
        regionIndices = new int[] {binStartPosition, binStartPosition, 0, chromosome.getLength()};
      } else {
        regionIndices = new int[] {0, chromosome.getLength(), binStartPosition, binStartPosition};
      }

      zd.dump1DTrackFromCrossHairAsWig(
          printWriter,
          chromosomeForPosition,
          binStartPosition,
          chromosomeForPosition.getIndex() == chromosome.getIndex(),
          regionIndices,
          normalizationType,
          displayOption,
          getExpectedValues());
    }
  }
Пример #4
0
  /**
   * ************************************************************* Official Method for setting the
   * zoom and location for heatmap DO NOT IMPLEMENT A NEW FUNCTION Make the necessary
   * customizations, then call this function
   * *************************************************************
   *
   * @param newZoom
   * @param genomeX
   * @param genomeY
   * @param scaleFactor (pass -1 if scaleFactor should be calculated)
   * @return
   */
  public boolean unsafeActuallySetZoomAndLocation(
      String chrXName,
      String chrYName,
      HiCZoom newZoom,
      int genomeX,
      int genomeY,
      double scaleFactor,
      boolean resetZoom,
      ZoomCallType zoomCallType,
      boolean allowLocationBroadcast) {

    if (dataset == null) return false; // No data in view

    // Check this zoom operation is possible, if not, fail it here:
    //        if (superAdapter.testNewZoom(newZoom))
    //        {
    //            return false;
    //        }

    // String chr1OriginalName = xContext.getChromosome().getName();
    // String chr2OriginalName = yContext.getChromosome().getName();
    if (chrXName.length() > 0 && chrYName.length() > 0) {
      setChromosomesFromBroadcast(chrXName, chrYName);
      // We might end with All->All view, make sure normalization state is updates accordingly...
      superAdapter.getMainViewPanel().setNormalizationDisplayState(superAdapter.getHiC());
    }

    if (newZoom == null) {
      System.err.println("Invalid zoom " + newZoom);
    }

    Chromosome chr1 = xContext.getChromosome();
    Chromosome chr2 = yContext.getChromosome();
    final Matrix matrix = dataset.getMatrix(chr1, chr2);

    if (matrix == null) {
      superAdapter.launchGenericMessageDialog(
          "Sorry, this region is not available", "Matrix unavailable", JOptionPane.WARNING_MESSAGE);
      return false;
    }

    MatrixZoomData newZD = matrix.getZoomData(newZoom);
    if (HiCFileTools.isAllChromosome(chr1)) {
      newZD = matrix.getFirstZoomData(Unit.BP);
    }

    if (newZD == null) {
      superAdapter.launchGenericMessageDialog(
          "Sorry, this zoom is not available", "Zoom unavailable", JOptionPane.WARNING_MESSAGE);
      return false;
    }

    /* TODO Undo Zoom implementation mss2 _UZI
    if(currentZoom != null) {
        tempZoomState = new ZoomState(chr1OriginalName, chr2OriginalName, currentZoom.clone(), (int) xContext.getBinOrigin(),
                (int) yContext.getBinOrigin(), getScaleFactor(), resetZoom, ZoomCallType.GOTO);
    }
    */

    currentZoom = newZoom;
    xContext.setZoom(currentZoom);
    yContext.setZoom(currentZoom);

    if (scaleFactor > 0) {
      setScaleFactor(scaleFactor);
    } else {
      int maxBinCount =
          Math.max(newZD.getXGridAxis().getBinCount(), newZD.getYGridAxis().getBinCount());
      double defaultScaleFactor =
          Math.max(
              1.0, (double) superAdapter.getHeatmapPanel().getMinimumDimension() / maxBinCount);
      setScaleFactor(defaultScaleFactor);
    }

    int binX = newZD.getXGridAxis().getBinNumberForGenomicPosition(genomeX);
    int binY = newZD.getYGridAxis().getBinNumberForGenomicPosition(genomeY);
    switch (zoomCallType) {
      case INITIAL:
      case STANDARD:
        center(binX, binY);
        break;
      case DRAG:
        xContext.setBinOrigin(binX);
        yContext.setBinOrigin(binY);
        break;
      case DIRECT:
        xContext.setBinOrigin(genomeX);
        yContext.setBinOrigin(genomeY);
        break;
    }

    // Notify HeatmapPanel render that zoom has changed. Render should update zoom slider once with
    // previous range values

    setZoomChanged();
    if (resetZoom) {
      superAdapter.updateAndResetZoom(newZoom);
    } else {
      superAdapter.updateZoom(newZoom);
    }
    superAdapter.refresh();

    if (linkedMode && allowLocationBroadcast) {
      broadcastLocation();
    }
    /*
    TODO Undo Zoom implementation mss2 _UZI
    if(zoomCallType == ZoomCallType.INITIAL || tempZoomState == null || chrXName.equals(Globals.CHR_ALL) || chrYName.equals(Globals.CHR_ALL)
            || tempZoomState.chr1Name.equals(Globals.CHR_ALL) || tempZoomState.chr2Name.equals(Globals.CHR_ALL)){
        canRedoZoomChange = false;
        canUndoZoomChange = false;
    }
    else {
        // defauts for a normal zoom operation
        canRedoZoomChange = false;
        canUndoZoomChange = true;
        previousZoomState = tempZoomState;
    }
    */

    return true;
  }