private void setChromosomesFromBroadcast(String chrXName, String chrYName) { if (!chrXName.equals(xContext.getChromosome().getName()) || !chrYName.equals(yContext.getChromosome().getName())) { Chromosome chrX = HiCFileTools.getChromosomeNamed(chrXName, chromosomes); Chromosome chrY = HiCFileTools.getChromosomeNamed(chrYName, chromosomes); if (chrX == null || chrY == null) { // log.info("Most probably origin is a different species saved location or sync/link between // two different species maps."); return; } this.xContext = new Context(chrX); this.yContext = new Context(chrY); superAdapter.setSelectedChromosomesNoRefresh(chrX, chrY); refreshEigenvectorTrackIfExists(); } }
@Override public void run() { List<Chromosome> chromosomes = HiCFileTools.loadChromosomes(genomeId); try { AsciiToBinConverter.convert(ifile, ofile, chromosomes); } catch (Exception e) { System.err.println("Unable to convert from ascii to bin"); e.printStackTrace(); } }
/** * ************************************************************* 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; }
public boolean isWholeGenome() { return xContext != null && HiCFileTools.isAllChromosome(xContext.getChromosome()); }