diff --git a/.idea/artifacts/Juicebox.xml b/.idea/artifacts/Juicebox.xml
deleted file mode 100644
index ab2fbc3a..00000000
--- a/.idea/artifacts/Juicebox.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
- $PROJECT_DIR$/out/artifacts/Juicebox
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/artifacts/JuicerTools.xml b/.idea/artifacts/JuicerTools.xml
index 303b9924..ecceaa06 100644
--- a/.idea/artifacts/JuicerTools.xml
+++ b/.idea/artifacts/JuicerTools.xml
@@ -3,7 +3,7 @@
$PROJECT_DIR$/out/artifacts/JuicerTools
-
+
@@ -12,6 +12,7 @@
+
diff --git a/README.md b/README.md
index 19f55c77..8ca8c35f 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ The former turns on all warnings, the latter gives some flexibility since some p
* Set the main class by clicking the little `...` button next to the text box for main class
MainWindow.java is the main method class for the visualization/GUI portion of the software.
- HiCTools.java is the main method class for the analysis/CLT portion.
+ juicebox.HiCTools.java is the main method class for the analysis/CLT portion.
* For the GUI under VM Options:
diff --git a/build.xml b/build.xml
index 51e45d5f..90b9c198 100644
--- a/build.xml
+++ b/build.xml
@@ -2,7 +2,7 @@
upstream
+ public static GenomeWide1DList extractDirectionalAnchors(GenomeWide1DList featureAnchors,
+ final boolean direction) {
+ final GenomeWide1DList directionalAnchors = new GenomeWide1DList<>();
+ featureAnchors.processLists((chr, featureList) -> {
+ for (MotifAnchor anchor : featureList) {
+ if (anchor.isDirectionalAnchor(direction)) {
+ directionalAnchors.addFeature(chr, anchor);
+ }
+ }
+ });
+
+ return directionalAnchors;
+ }
+
+ public static void retainBestMotifsInLocus(final GenomeWide1DList firstList, final GenomeWide1DList secondList) {
+ firstList.filterLists((key, anchorList) -> {
+ if (secondList.containsKey(key)) {
+ return retainBestMotifsInLocus(anchorList, secondList.getFeatures(key));
+ } else {
+ return new ArrayList<>();
+ }
+ });
+ }
+
+ private static List retainBestMotifsInLocus(List topAnchors, List baseList) {
+ Map> bottomListToTopList = getMotifTopBottomMatching(topAnchors, baseList);
+
+ for (MotifAnchor anchor : bottomListToTopList.keySet()) {
+ for (MotifAnchor anchor2 : bottomListToTopList.get(anchor)) {
+ anchor2.addFeatureReferencesFrom(anchor);
+ if (HiCGlobals.printVerboseComments) {
+ if (anchor2.getSequence().equals("TGAGTCACTAGAGGGAGGCA")) {
+ System.out.println(bottomListToTopList.get(anchor));
+ }
+ }
+ }
+ }
+
+ List uniqueAnchors = new ArrayList<>();
+ for (Set motifs : bottomListToTopList.values()) {
+ if (motifs.size() == 1) {
+ uniqueAnchors.addAll(motifs);
+ } else if (motifs.size() > 1) {
+ MotifAnchor best = motifs.iterator().next();
+ for (MotifAnchor an : motifs) {
+ if (an.getScore() > best.getScore()) {
+ best = an;
+ }
+ }
+ uniqueAnchors.add(best);
+ }
+ }
+ return uniqueAnchors;
+ }
+
+ private static Map> getMotifTopBottomMatching(List topAnchors, List baseList) {
+ Map> bottomListToTopList = new HashMap<>();
+
+ for (MotifAnchor anchor : baseList) {
+ bottomListToTopList.put(anchor, new HashSet<>());
+ }
+
+ int topIndex = 0;
+ int bottomIndex = 0;
+ int maxTopIndex = topAnchors.size();
+ int maxBottomIndex = baseList.size();
+ Collections.sort(topAnchors);
+ Collections.sort(baseList);
+
+ while (topIndex < maxTopIndex && bottomIndex < maxBottomIndex) {
+ MotifAnchor topAnchor = topAnchors.get(topIndex);
+ MotifAnchor bottomAnchor = baseList.get(bottomIndex);
+ if (topAnchor.hasOverlapWith(bottomAnchor) || bottomAnchor.hasOverlapWith(topAnchor)) {
+
+ bottomListToTopList.get(bottomAnchor).add(topAnchor);
+
+ // iterate over all possible intersections with top element
+ for (int i = bottomIndex; i < maxBottomIndex; i++) {
+ MotifAnchor newAnchor = baseList.get(i);
+ if (topAnchor.hasOverlapWith(newAnchor) || newAnchor.hasOverlapWith(topAnchor)) {
+ bottomListToTopList.get(newAnchor).add(topAnchor);
+ } else {
+ break;
+ }
+ }
+
+ // iterate over all possible intersections with bottom element
+ // start from +1 because +0 checked in the for loop above
+ for (int i = topIndex + 1; i < maxTopIndex; i++) {
+ MotifAnchor newAnchor = topAnchors.get(i);
+ if (bottomAnchor.hasOverlapWith(newAnchor) || newAnchor.hasOverlapWith(bottomAnchor)) {
+ bottomListToTopList.get(bottomAnchor).add(newAnchor);
+ } else {
+ break;
+ }
+ }
+
+ // increment both
+ topIndex++;
+ bottomIndex++;
+ } else if (topAnchor.isStrictlyToTheLeftOf(bottomAnchor)) {
+ topIndex++;
+ } else if (topAnchor.isStrictlyToTheRightOf(bottomAnchor)) {
+ bottomIndex++;
+ } else {
+ System.err.println("Error while intersecting anchors.");
+ System.err.println(topAnchor + " & " + bottomAnchor);
+ }
+ }
+ return bottomListToTopList;
+ }
+
+ public static int[] calculateConvergenceHistogram(Feature2DList features) {
+
+ // ++, +- (convergent), -+ (divergent), --, other (incomplete)
+ final int[] results = new int[6];
+ features.processLists((chr, feature2DList) -> {
+ for (Feature2D feature : feature2DList) {
+ results[Feature2DWithMotif.createFromFeature(feature).getConvergenceStatus()]++;
+ }
+ });
+
+ return results;
+ }
+
+ public static void mergeAndExpandSmallAnchors(GenomeWide1DList regionsInCustomChromosome, int minSize) {
+ MotifAnchorTools.mergeAnchors(regionsInCustomChromosome);
+ MotifAnchorTools.expandSmallAnchors(regionsInCustomChromosome, minSize);
+ MotifAnchorTools.mergeAnchors(regionsInCustomChromosome);
+ }
+}
diff --git a/src/juicebox/data/NormFactorMapReader.java b/src/juicebox/data/NormFactorMapReader.java
deleted file mode 100644
index 153d0e51..00000000
--- a/src/juicebox/data/NormFactorMapReader.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data;
-
-import htsjdk.tribble.util.LittleEndianInputStream;
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class NormFactorMapReader {
- private final int version, nFactors;
- private final Map normFactors = new LinkedHashMap<>();
-
- public NormFactorMapReader(int nFactors, int version, LittleEndianInputStream dis)
- throws IOException {
- this.version = version;
- this.nFactors = nFactors;
-
- for (int j = 0; j < nFactors; j++) {
- int chrIdx = dis.readInt();
- if (version > 8) {
- normFactors.put(chrIdx, (double) dis.readFloat());
- } else {
- normFactors.put(chrIdx, dis.readDouble());
- }
- }
- }
-
- public Map getNormFactors() {
- return normFactors;
- }
-
- public int getOffset() {
- if (version > 8) {
- return 8 * nFactors;
- } else {
- return 12 * nFactors;
- }
- }
-}
diff --git a/src/juicebox/data/NormalizationVector.java b/src/juicebox/data/NormalizationVector.java
deleted file mode 100644
index 4960a364..00000000
--- a/src/juicebox/data/NormalizationVector.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-package juicebox.data;
-
-import juicebox.HiC;
-import juicebox.data.basics.Chromosome;
-import juicebox.data.basics.ListOfDoubleArrays;
-import juicebox.data.basics.ListOfFloatArrays;
-import juicebox.data.iterator.IteratorContainer;
-import juicebox.tools.utils.norm.ZeroScale;
-import juicebox.windowui.HiCZoom;
-import juicebox.windowui.NormalizationType;
-
-/**
- * @author jrobinso
- * Date: 2/10/13
- * Time: 9:19 AM
- */
-public class NormalizationVector {
-
- private final NormalizationType type;
- private final int chrIdx;
- private final HiC.Unit unit;
- private final int resolution;
- private final ListOfDoubleArrays data;
- private boolean needsToBeScaledTo = false;
-
- public NormalizationVector(NormalizationType type, int chrIdx, HiC.Unit unit, int resolution, ListOfDoubleArrays data) {
- this.type = type;
- this.chrIdx = chrIdx;
- this.unit = unit;
- this.resolution = resolution;
- this.data = data;
- }
-
- public NormalizationVector(NormalizationType type, int chrIdx, HiC.Unit unit, int resolution, ListOfDoubleArrays data, boolean needsToBeScaledTo) {
- this(type, chrIdx, unit, resolution, data);
- this.needsToBeScaledTo = needsToBeScaledTo;
- }
-
- public static String getKey(NormalizationType type, int chrIdx, String unit, int resolution) {
- return type + "_" + chrIdx + "_" + unit + "_" + resolution;
- }
-
- public int getChrIdx() {
- return chrIdx;
- }
-
- public int getResolution() {
- return resolution;
- }
-
- public String getKey() {
- return NormalizationVector.getKey(type, chrIdx, unit.toString(), resolution);
- }
-
- public ListOfDoubleArrays getData() {
- return data;
- }
-
- public boolean doesItNeedToBeScaledTo() {
- return needsToBeScaledTo;
- }
-
- public NormalizationVector mmbaScaleToVector(Dataset ds) {
- Chromosome chromosome = ds.getChromosomeHandler().getChromosomeFromIndex(chrIdx);
- MatrixZoomData zd = HiCFileTools.getMatrixZoomData(ds, chromosome, chromosome, new HiCZoom(unit, resolution));
- if (zd == null) return null;
- return mmbaScaleToVector(zd.getIteratorContainer());
- }
-
- public NormalizationVector mmbaScaleToVector(IteratorContainer ic) {
-
- ListOfFloatArrays newNormVector = ZeroScale.scale(ic, data.convertToFloats(), getKey());
- if (newNormVector != null) {
- newNormVector = ZeroScale.normalizeVectorByScaleFactor(newNormVector, ic);
- }
- ListOfDoubleArrays newDoubleNormVector = newNormVector.convertToDoubles();
- return new NormalizationVector(type, chrIdx, unit, resolution, newDoubleNormVector);
- }
-}
diff --git a/src/juicebox/data/ZoomAction.java b/src/juicebox/data/ZoomAction.java
deleted file mode 100644
index 4df21d55..00000000
--- a/src/juicebox/data/ZoomAction.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data;
-
-import juicebox.HiC;
-import juicebox.windowui.HiCZoom;
-
-/**
- * Created by ranganmostofa on 7/8/17.
- */
-public class ZoomAction {
- private final String chromosomeX, chromosomeY;
- private final HiCZoom hiCZoom;
- private final long genomeX, genomeY;
- private double scaleFactor;
- private final boolean resetZoom;
- private final HiC.ZoomCallType zoomCallType;
- private final int resolutionLocked;
-
- public ZoomAction(String chromosomeX, String chromosomeY, HiCZoom hiCZoom, long genomeX, long genomeY,
- double scaleFactor, boolean resetZoom, HiC.ZoomCallType zoomCallType, int resolutionLocked) {
- this.chromosomeX = chromosomeX;
- this.chromosomeY = chromosomeY;
- this.hiCZoom = hiCZoom;
- this.genomeX = genomeX;
- this.genomeY = genomeY;
- this.scaleFactor = scaleFactor;
- this.resetZoom = resetZoom;
- this.zoomCallType = zoomCallType;
- this.resolutionLocked = resolutionLocked;
- }
-
- public boolean equals(ZoomAction other) {
- return this == other || other != null && chromosomeX.equals(other.getChromosomeX()) && chromosomeY.equals(other.getChromosomeY()) && hiCZoom.equals(other.getHiCZoom()) && genomeX == other.getGenomeX() && genomeY == other.getGenomeY() && scaleFactor == other.getScaleFactor() && resetZoom == other.getResetZoom() && zoomCallType == other.getZoomCallType() && resolutionLocked == other.getResolutionLocked();
- }
-
- public String getChromosomeX() {
- return this.chromosomeX;
- }
-
- public String getChromosomeY() {
- return this.chromosomeY;
- }
-
- public HiCZoom getHiCZoom() {
- return this.hiCZoom;
- }
-
- public long getGenomeX() {
- return this.genomeX;
- }
-
- public long getGenomeY() {
- return this.genomeY;
- }
-
- public double getScaleFactor() {
- return this.scaleFactor;
- }
-
- public void setScaleFactor(double newScaleFactor) {
- this.scaleFactor = newScaleFactor;
- }
-
- public boolean getResetZoom() {
- return this.resetZoom;
- }
-
- public HiC.ZoomCallType getZoomCallType() {
- return this.zoomCallType;
- }
-
- public int getResolutionLocked() {
- return this.resolutionLocked;
- }
-
-}
diff --git a/src/juicebox/data/ZoomActionTracker.java b/src/juicebox/data/ZoomActionTracker.java
deleted file mode 100644
index 045f561e..00000000
--- a/src/juicebox/data/ZoomActionTracker.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data;
-
-import java.util.Stack;
-
-/**
- * Created by ranganmostofa on 7/8/17.
- */
-public class ZoomActionTracker {
- private final int stackSizeLimit = 100;
- private ZoomAction currentZoomAction;
- private final Stack undoZoomActions = new Stack<>();
- private final Stack redoZoomActions = new Stack<>();
-
- public void undoZoom() {
- if (validateUndoZoom()) {
- redoZoomActions.push(undoZoomActions.pop());
- setCurrentZoomAction(undoZoomActions.peek());
- }
- }
-
- public void redoZoom() {
- if (validateRedoZoom()) {
- undoZoomActions.push(redoZoomActions.pop());
- setCurrentZoomAction(undoZoomActions.peek());
- }
- }
-
- public boolean validateUndoZoom() {
- return undoZoomActions.size() > 1;
- }
-
- public boolean validateRedoZoom() {
- return !redoZoomActions.isEmpty();
- }
-
- public void addZoomState(ZoomAction newZoomAction) {
- undoZoomActions.add(newZoomAction);
- setCurrentZoomAction(undoZoomActions.peek());
- redoZoomActions.clear();
- if (undoZoomActions.size() > stackSizeLimit) {
- undoZoomActions.remove(0);
- }
- }
-
- public void clear() {
- this.currentZoomAction = null;
- this.undoZoomActions.clear();
- this.redoZoomActions.clear();
- }
-
- public boolean equals(ZoomActionTracker other) {
- if (this == other) return true;
- if (other != null) {
- if (this.undoZoomActions.equals(other.getUndoZoomActions())) {
- if (this.redoZoomActions.equals(other.getRedoZoomActions())) {
- return this.currentZoomAction.equals(other.getCurrentZoomAction());
- }
- }
- }
- return false;
- }
-
- public ZoomAction getCurrentZoomAction() {
- return this.currentZoomAction;
- }
-
- private void setCurrentZoomAction(ZoomAction zoomAction) {
- this.currentZoomAction = zoomAction;
- }
-
- private Stack getUndoZoomActions() {
- return this.undoZoomActions;
- }
-
- private Stack getRedoZoomActions() {
- return this.redoZoomActions;
- }
-}
diff --git a/src/juicebox/data/anchor/MotifAnchorTools.java b/src/juicebox/data/anchor/MotifAnchorTools.java
deleted file mode 100644
index 801aba85..00000000
--- a/src/juicebox/data/anchor/MotifAnchorTools.java
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.anchor;
-
-import juicebox.HiCGlobals;
-import juicebox.data.ChromosomeHandler;
-import juicebox.data.basics.Chromosome;
-import juicebox.data.feature.FeatureFilter;
-import juicebox.data.feature.GenomeWideList;
-import juicebox.gui.SuperAdapter;
-import juicebox.track.feature.Feature2D;
-import juicebox.track.feature.Feature2DList;
-import juicebox.track.feature.FeatureFunction;
-import org.broad.igv.ui.util.MessageUtils;
-
-import java.util.*;
-
-/**
- * Created by muhammadsaadshamim on 9/28/15.
- */
-public class MotifAnchorTools {
-
- /**
- * @param features
- * @return anchor list from features (i.e. split anchor1 and anchor2)
- */
- public static GenomeWideList extractAnchorsFromIntrachromosomalFeatures(Feature2DList features,
- final boolean onlyUninitializedFeatures,
- final ChromosomeHandler handler) {
-
- final GenomeWideList extractedAnchorList = new GenomeWideList<>(handler);
- features.processLists(new FeatureFunction() {
- @Override
- public void process(String chr, List feature2DList) {
- List anchors = new ArrayList<>();
- for (Feature2D f : feature2DList) {
- anchors.addAll(f.getAnchors(onlyUninitializedFeatures, handler));
- }
- String newKey = chr.split("_")[0].replace("chr", "");
- extractedAnchorList.setFeatures(newKey, anchors);
- }
- });
-
- MotifAnchorTools.mergeAnchors(extractedAnchorList);
- MotifAnchorTools.expandSmallAnchors(extractedAnchorList, 15000);
-
- return extractedAnchorList;
- }
-
- public static GenomeWideList extractAllAnchorsFromAllFeatures(Feature2DList features, final ChromosomeHandler handler) {
-
- final GenomeWideList extractedAnchorList = new GenomeWideList<>(handler);
- features.processLists(new FeatureFunction() {
- @Override
- public void process(String chr, List feature2DList) {
- for (Feature2D f : feature2DList) {
- Chromosome chrom = handler.getChromosomeFromName((f.getChr1()));
- extractedAnchorList.addFeature(chrom.getName(), new MotifAnchor(chrom.getName(), f.getStart1(), f.getEnd1()));
- chrom = handler.getChromosomeFromName((f.getChr2()));
- extractedAnchorList.addFeature(chrom.getName(), new MotifAnchor(chrom.getName(), f.getStart2(), f.getEnd2()));
- }
- }
- });
-
- mergeAndExpandSmallAnchors(extractedAnchorList, getMinSizeForExpansionFromGUI());
-
- return extractedAnchorList;
- }
-
- public static int getMinSizeForExpansionFromGUI() {
- int minSize = 10000;
- String newSize = MessageUtils.showInputDialog("Specify a minimum size for 1D anchors", "" + minSize);
- try {
- minSize = Integer.parseInt(newSize);
- } catch (Exception e) {
- if (HiCGlobals.guiIsCurrentlyActive) {
- SuperAdapter.showMessageDialog("Invalid integer, using default size " + minSize);
- } else {
- MessageUtils.showMessage("Invalid integer, using default size " + minSize);
- }
- }
- return minSize;
- }
-
- /**
- * Merge anchors which have overlap
- */
- private static void mergeAnchors(GenomeWideList anchorList) {
- anchorList.filterLists(new FeatureFilter() {
- @Override
- public List filter(String chr, List anchorList) {
- return BEDTools.merge(anchorList);
- }
- });
- }
-
- /**
- * update the original features that the motifs belong to
- */
- public static void updateOriginalFeatures(GenomeWideList anchorList, final boolean uniqueStatus,
- final int specificStatus) {
- anchorList.processLists(new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List anchorList) {
- for (MotifAnchor anchor : anchorList) {
- anchor.updateOriginalFeatures(uniqueStatus, specificStatus);
- }
- }
- });
- }
-
- /**
- * Merge anchors which have overlap
- */
- public static void intersectLists(final GenomeWideList firstList, final GenomeWideList secondList,
- final boolean conductFullIntersection) {
- firstList.filterLists(new FeatureFilter() {
- @Override
- public List filter(String key, List anchorList) {
- if (secondList.containsKey(key)) {
- return BEDTools.intersect(anchorList, secondList.getFeatures(key), conductFullIntersection);
- } else {
- return new ArrayList<>();
- }
- }
- });
- }
-
- public static void preservativeIntersectLists(final GenomeWideList firstList, final GenomeWideList secondList,
- final boolean conductFullIntersection) {
- firstList.filterLists(new FeatureFilter() {
- @Override
- public List filter(String key, List anchorList) {
- if (secondList.containsKey(key)) {
- return BEDTools.preservativeIntersect(anchorList, secondList.getFeatures(key), conductFullIntersection);
- } else {
- return new ArrayList<>();
- }
- }
- });
- }
-
-
- /**
- * Guarantees that all anchors have minimum width of gapThreshold
- */
- private static void expandSmallAnchors(GenomeWideList anchorList, final int gapThreshold) {
- anchorList.processLists(new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List anchorList) {
- expandSmallAnchors(anchorList, gapThreshold);
- }
- });
- }
-
- /**
- * Guarantees that all anchors have minimum width of gapThreshold
- * PreProcessing step for anchors in MotifFinder code
- * derived from:
- * (awk on BED file) ... if($3-$2<15000){d=15000-($3-$2); print $1 \"\\t\" $2-int(d/2) \"\\t\" $3+int(d/2)
- *
- * @param anchors
- */
- private static void expandSmallAnchors(List anchors, int gapThreshold) {
- for (MotifAnchor anchor : anchors) {
- int width = anchor.getWidth();
- if (width < gapThreshold) {
- anchor.widenMargins(gapThreshold - width);
- }
- }
- }
-
- /**
- * @param anchors
- * @param threshold
- * @return unique motifs within a given threshold from a given AnchorList
- */
- public static GenomeWideList extractUniqueMotifs(GenomeWideList anchors, final int threshold) {
-
- GenomeWideList uniqueAnchors = anchors.deepClone();
- uniqueAnchors.filterLists(new FeatureFilter() {
- @Override
- public List filter(String chr, List anchorList) {
-
- // bin the motifs within resolution/threshold
- Map> uniqueMapping = new HashMap<>();
- for (MotifAnchor motif : anchorList) {
- String key = (motif.getX1() / threshold) + "_" + (motif.getX2() / threshold);
- if (uniqueMapping.containsKey(key)) {
- uniqueMapping.get(key).add(motif);
- } else {
- List motifList = new ArrayList<>();
- motifList.add(motif);
- uniqueMapping.put(key, motifList);
- }
- }
-
- // select for bins with only one value
- List uniqueMotifs = new ArrayList<>();
- for (List motifList : uniqueMapping.values()) {
- if (motifList.size() == 1) {
- uniqueMotifs.add(motifList.get(0));
- }
- }
-
- return uniqueMotifs;
- }
- });
-
- return uniqueAnchors;
- }
-
- /**
- * @param anchors
- * @param threshold
- * @return best (highest scoring) motifs within a given threshold from a given anchors list
- */
- public static GenomeWideList extractBestMotifs(GenomeWideList anchors, final int threshold) {
- GenomeWideList bestAnchors = anchors.deepClone();
- bestAnchors.filterLists(new FeatureFilter() {
- @Override
- public List filter(String chr, List anchorList) {
-
- // bin the motifs within resolution/threshold, saving only the highest scoring motif
- Map bestMapping = new HashMap<>();
- for (MotifAnchor motif : anchorList) {
- String key = (motif.getX1() / threshold) + "_" + (motif.getX2() / threshold);
- if (bestMapping.containsKey(key)) {
- if (bestMapping.get(key).getScore() < motif.getScore()) {
- bestMapping.put(key, motif);
- }
- } else {
- bestMapping.put(key, motif);
- }
- }
-
- return new ArrayList<>(bestMapping.values());
- }
- });
-
- return bestAnchors;
- }
-
- public static MotifAnchor searchForFeature(final String chrID, final String sequence, GenomeWideList anchorList) {
- final MotifAnchor[] anchor = new MotifAnchor[1];
- anchorList.processLists(new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- for (MotifAnchor motif : featureList) {
- if (motif.getChr().equalsIgnoreCase(chrID) && motif.getSequence().equals(sequence)) {
- anchor[0] = (MotifAnchor) motif.deepClone();
- }
- }
- }
- });
- return anchor[0];
- }
-
- public static MotifAnchor searchForFeature(final String chrID, final int start, final int end, GenomeWideList anchorList) {
- final MotifAnchor[] anchor = new MotifAnchor[1];
- anchorList.processLists(new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- for (MotifAnchor motif : featureList) {
- if (motif.getChr().equalsIgnoreCase(chrID) && motif.getX1() == start && motif.getX2() == end) {
- anchor[0] = (MotifAnchor) motif.deepClone();
- }
- }
- }
- });
- return anchor[0];
- }
-
- public static MotifAnchor searchForFeatureWithin(final String chrID, final int start, final int end, GenomeWideList anchorList) {
- final MotifAnchor[] anchor = new MotifAnchor[1];
- anchorList.processLists(new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- for (MotifAnchor motif : featureList) {
- if (motif.getChr().equalsIgnoreCase(chrID) && motif.getX1() >= start && motif.getX2() <= end) {
- anchor[0] = (MotifAnchor) motif.deepClone();
- }
- }
- }
- });
- return anchor[0];
- }
-
- public static List searchForFeaturesWithin(final String chrID, final int start, final int end, GenomeWideList anchorList) {
- final List anchors = new ArrayList<>();
- anchorList.processLists(new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- for (MotifAnchor motif : featureList) {
- if (motif.getChr().equalsIgnoreCase(chrID) && motif.getX1() >= start && motif.getX2() <= end) {
- anchors.add((MotifAnchor) motif.deepClone());
- }
- }
- }
- });
- return anchors;
- }
-
-
- public static void retainProteinsInLocus(final GenomeWideList firstList, final GenomeWideList secondList,
- final boolean retainUniqueSites, final boolean copyFeatureReferences) {
- firstList.filterLists(new FeatureFilter() {
- @Override
- public List filter(String key, List anchorList) {
- if (secondList.containsKey(key)) {
- return retainProteinsInLocus(anchorList, secondList.getFeatures(key), retainUniqueSites, copyFeatureReferences);
- } else {
- return new ArrayList<>();
- }
- }
- });
- }
-
- private static List retainProteinsInLocus(List topAnchors, List baseList,
- boolean retainUniqueSites, boolean copyFeatureReferences) {
- Map> bottomListToTopList = new HashMap<>();
-
- for (MotifAnchor anchor : baseList) {
- bottomListToTopList.put(anchor, new HashSet<>());
- }
-
- int topIndex = 0;
- int bottomIndex = 0;
- int maxTopIndex = topAnchors.size();
- int maxBottomIndex = baseList.size();
- Collections.sort(topAnchors);
- Collections.sort(baseList);
-
-
- while (topIndex < maxTopIndex && bottomIndex < maxBottomIndex) {
- MotifAnchor topAnchor = topAnchors.get(topIndex);
- MotifAnchor bottomAnchor = baseList.get(bottomIndex);
- if (topAnchor.hasOverlapWith(bottomAnchor) || bottomAnchor.hasOverlapWith(topAnchor)) {
-
- bottomListToTopList.get(bottomAnchor).add(topAnchor);
-
- // iterate over all possible intersections with top element
- for (int i = bottomIndex; i < maxBottomIndex; i++) {
- MotifAnchor newAnchor = baseList.get(i);
- if (topAnchor.hasOverlapWith(newAnchor) || newAnchor.hasOverlapWith(topAnchor)) {
- bottomListToTopList.get(newAnchor).add(topAnchor);
- } else {
- break;
- }
- }
-
- // iterate over all possible intersections with bottom element
- // start from +1 because +0 checked in the for loop above
- for (int i = topIndex + 1; i < maxTopIndex; i++) {
- MotifAnchor newAnchor = topAnchors.get(i);
- if (bottomAnchor.hasOverlapWith(newAnchor) || newAnchor.hasOverlapWith(bottomAnchor)) {
- bottomListToTopList.get(bottomAnchor).add(newAnchor);
- } else {
- break;
- }
- }
-
- // increment both
- topIndex++;
- bottomIndex++;
- } else if (topAnchor.isStrictlyToTheLeftOf(bottomAnchor)) {
- topIndex++;
- } else if (topAnchor.isStrictlyToTheRightOf(bottomAnchor)) {
- bottomIndex++;
- } else {
- System.err.println("Error while intersecting anchors.");
- System.err.println(topAnchor + " & " + bottomAnchor);
- }
- }
-
- List uniqueAnchors = new ArrayList<>();
-
- if (copyFeatureReferences) {
- for (MotifAnchor anchor : bottomListToTopList.keySet()) {
- for (MotifAnchor anchor2 : bottomListToTopList.get(anchor)) {
- anchor2.addFeatureReferencesFrom(anchor);
- }
- }
- }
-
- if (retainUniqueSites) {
- for (Set motifs : bottomListToTopList.values()) {
- if (motifs.size() == 1) {
- uniqueAnchors.addAll(motifs);
- }
- }
- } else {
- for (Set motifs : bottomListToTopList.values()) {
- if (motifs.size() > 1) {
- uniqueAnchors.addAll(motifs);
- }
- }
- }
- return uniqueAnchors;
- }
-
- // true --> upstream
- public static GenomeWideList extractDirectionalAnchors(GenomeWideList featureAnchors,
- final boolean direction) {
- final GenomeWideList directionalAnchors = new GenomeWideList<>();
- featureAnchors.processLists(new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- for (MotifAnchor anchor : featureList) {
- if (anchor.isDirectionalAnchor(direction)) {
- directionalAnchors.addFeature(chr, anchor);
- }
- }
- }
- });
-
- return directionalAnchors;
- }
-
- public static void retainBestMotifsInLocus(final GenomeWideList firstList, final GenomeWideList secondList) {
- firstList.filterLists(new FeatureFilter() {
- @Override
- public List filter(String key, List anchorList) {
- if (secondList.containsKey(key)) {
- return retainBestMotifsInLocus(anchorList, secondList.getFeatures(key));
- } else {
- return new ArrayList<>();
- }
- }
- });
- }
-
- private static List retainBestMotifsInLocus(List topAnchors, List baseList) {
- Map> bottomListToTopList = new HashMap<>();
-
- for (MotifAnchor anchor : baseList) {
- bottomListToTopList.put(anchor, new HashSet<>());
- }
-
- int topIndex = 0;
- int bottomIndex = 0;
- int maxTopIndex = topAnchors.size();
- int maxBottomIndex = baseList.size();
- Collections.sort(topAnchors);
- Collections.sort(baseList);
-
-
- while (topIndex < maxTopIndex && bottomIndex < maxBottomIndex) {
- MotifAnchor topAnchor = topAnchors.get(topIndex);
- MotifAnchor bottomAnchor = baseList.get(bottomIndex);
- if (topAnchor.hasOverlapWith(bottomAnchor) || bottomAnchor.hasOverlapWith(topAnchor)) {
-
- bottomListToTopList.get(bottomAnchor).add(topAnchor);
-
- // iterate over all possible intersections with top element
- for (int i = bottomIndex; i < maxBottomIndex; i++) {
- MotifAnchor newAnchor = baseList.get(i);
- if (topAnchor.hasOverlapWith(newAnchor) || newAnchor.hasOverlapWith(topAnchor)) {
- bottomListToTopList.get(newAnchor).add(topAnchor);
- } else {
- break;
- }
- }
-
- // iterate over all possible intersections with bottom element
- // start from +1 because +0 checked in the for loop above
- for (int i = topIndex + 1; i < maxTopIndex; i++) {
- MotifAnchor newAnchor = topAnchors.get(i);
- if (bottomAnchor.hasOverlapWith(newAnchor) || newAnchor.hasOverlapWith(bottomAnchor)) {
- bottomListToTopList.get(bottomAnchor).add(newAnchor);
- } else {
- break;
- }
- }
-
- // increment both
- topIndex++;
- bottomIndex++;
- } else if (topAnchor.isStrictlyToTheLeftOf(bottomAnchor)) {
- topIndex++;
- } else if (topAnchor.isStrictlyToTheRightOf(bottomAnchor)) {
- bottomIndex++;
- } else {
- System.err.println("Error while intersecting anchors.");
- System.err.println(topAnchor + " & " + bottomAnchor);
- }
- }
-
- for (MotifAnchor anchor : bottomListToTopList.keySet()) {
- for (MotifAnchor anchor2 : bottomListToTopList.get(anchor)) {
- anchor2.addFeatureReferencesFrom(anchor);
- if (HiCGlobals.printVerboseComments) {
- if (anchor2.getSequence().equals("TGAGTCACTAGAGGGAGGCA")) {
- System.out.println(bottomListToTopList.get(anchor));
- }
- }
- }
- }
-
- List uniqueAnchors = new ArrayList<>();
- for (Set motifs : bottomListToTopList.values()) {
- if (motifs.size() == 1) {
- uniqueAnchors.addAll(motifs);
- } else if (motifs.size() > 1) {
- MotifAnchor best = motifs.iterator().next();
- for (MotifAnchor an : motifs) {
- if (an.getScore() > best.getScore()) {
- best = an;
- }
- }
- uniqueAnchors.add(best);
- }
- }
- return uniqueAnchors;
- }
-
- public static int[] calculateConvergenceHistogram(Feature2DList features) {
-
- // ++, +- (convergent), -+ (divergent), --, other (incomplete)
- final int[] results = new int[6];
-
- features.processLists(new FeatureFunction() {
- @Override
- public void process(String chr, List feature2DList) {
- for (Feature2D feature : feature2DList) {
- results[feature.toFeature2DWithMotif().getConvergenceStatus()]++;
- }
- }
- });
-
- return results;
- }
-
- public static void mergeAndExpandSmallAnchors(GenomeWideList regionsInCustomChromosome, int minSize) {
- MotifAnchorTools.mergeAnchors(regionsInCustomChromosome);
- MotifAnchorTools.expandSmallAnchors(regionsInCustomChromosome, minSize);
- MotifAnchorTools.mergeAnchors(regionsInCustomChromosome);
- }
-}
diff --git a/src/juicebox/data/basics/Chromosome.java b/src/juicebox/data/basics/Chromosome.java
deleted file mode 100644
index 9831227b..00000000
--- a/src/juicebox/data/basics/Chromosome.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.basics;
-import java.util.Objects;
-
-public class Chromosome {
- private final String name;
- private int index;
- private long length = 0;
-
- public Chromosome(int index, String name, long length) {
- this.index = index;
- this.name = name;
- this.length = length;
- }
-
- public int getIndex() {
- return this.index;
- }
-
- public void setIndex(int ii) {
- this.index = ii;
- }
-
- public long getLength() {
- return this.length;
- }
-
- public String getName() {
- return this.name;
- }
-
- public String toString() {
- return this.name;
- }
-
- public boolean equals(Object obj) {
- return obj instanceof Chromosome && ((Chromosome) obj).getIndex() == this.getIndex() && ((Chromosome) obj).getLength() == this.getLength();
- }
-
- public int hashCode() {
- return Objects.hash(this.index, this.length);
- }
-
- public org.broad.igv.feature.Chromosome toIGVChromosome() {
- return new org.broad.igv.feature.Chromosome(index, name, (int) length); // assumed for IGV
- }
-}
-
diff --git a/src/juicebox/data/basics/ListOfDoubleArrays.java b/src/juicebox/data/basics/ListOfDoubleArrays.java
deleted file mode 100644
index a930edc2..00000000
--- a/src/juicebox/data/basics/ListOfDoubleArrays.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.basics;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * can't use because we need to instantiate the array, otherwise that would have been nice
- */
-public class ListOfDoubleArrays {
-
- private final long DEFAULT_LENGTH = Integer.MAX_VALUE - 10;
- private final long overallLength;
- private final List internalList = new ArrayList<>();
-
- public ListOfDoubleArrays(long length) {
- this.overallLength = length;
- long tempLength = length;
- while (tempLength > 0) {
- if (tempLength < DEFAULT_LENGTH) {
- internalList.add(new double[(int) tempLength]);
- break;
- } else {
- internalList.add(new double[(int) DEFAULT_LENGTH]);
- tempLength -= DEFAULT_LENGTH;
- }
- }
- }
-
- public ListOfDoubleArrays(long totSize, double defaultValue) {
- this(totSize);
- for (double[] array : internalList) {
- Arrays.fill(array, defaultValue);
- }
- }
-
- public void clear() {
- internalList.clear();
- }
-
- public double get(long index) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- return internalList.get(pseudoRow)[pseudoCol];
- } else {
- System.err.println("long index exceeds max size of list of arrays while getting: " + index + " " + overallLength);
- Exception ioe = new Exception();
- ioe.printStackTrace();
- return Double.NaN;
- }
- }
-
- public void set(long index, double value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] = value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while setting");
- }
- }
-
- public long getLength() {
- return overallLength;
- }
-
- public ListOfDoubleArrays deepClone() {
- ListOfDoubleArrays clone = new ListOfDoubleArrays(overallLength);
- for (int k = 0; k < internalList.size(); k++) {
- System.arraycopy(internalList.get(k), 0, clone.internalList.get(k), 0, internalList.get(k).length);
- }
- return clone;
- }
-
- public void divideBy(long index, double value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] /= value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while dividing");
- }
- }
-
- public void multiplyBy(long index, double value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] *= value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while mutiplying");
- }
- }
-
- public void addTo(long index, double value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- try {
- internalList.get(pseudoRow)[pseudoCol] += value;
- } catch (Exception e) {
- System.err.println(index + " " + pseudoCol);
- e.printStackTrace();
- }
- } else {
- System.err.println("long index exceeds max size of list of arrays while adding: " + index + " " + overallLength);
- Exception ioe = new Exception();
- ioe.printStackTrace();
- }
- }
-
- public void addValuesFrom(ListOfDoubleArrays other) {
- if (overallLength == other.overallLength) {
- for (int i = 0; i < internalList.size(); i++) {
- for (int j = 0; j < internalList.get(i).length; j++) {
- internalList.get(i)[j] += other.internalList.get(i)[j];
- }
- }
- } else {
- System.err.println("Adding objects of different sizes!");
- }
- }
-
- public double getFirstValue() {
- return internalList.get(0)[0];
- }
-
- public double getLastValue() {
- double[] temp = internalList.get(internalList.size() - 1);
- return temp[temp.length - 1];
- }
-
- public List getValues() {
- return internalList;
- }
-
- public void multiplyEverythingBy(double val) {
- for (double[] array : internalList) {
- for (int k = 0; k < array.length; k++) {
- array[k] *= val;
- }
- }
- }
-
- public ListOfFloatArrays convertToFloats() {
- ListOfFloatArrays newList = new ListOfFloatArrays(overallLength);
- for (int j = 0; j < internalList.size(); j++) {
- for (int k = 0; k < internalList.get(j).length; k++) {
- newList.getValues().get(j)[k] = (float) internalList.get(j)[k];
- }
- }
- return newList;
- }
-}
diff --git a/src/juicebox/data/basics/ListOfFloatArrays.java b/src/juicebox/data/basics/ListOfFloatArrays.java
deleted file mode 100644
index e4565f5a..00000000
--- a/src/juicebox/data/basics/ListOfFloatArrays.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.basics;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * can't use because we need to instantiate the array, otherwise that would have been nice
- */
-public class ListOfFloatArrays {
-
- private final long DEFAULT_LENGTH = Integer.MAX_VALUE - 10;
- private final long overallLength;
- private final List internalList = new ArrayList<>();
-
- public ListOfFloatArrays(long length) {
- this.overallLength = length;
- long tempLength = length;
- while (tempLength > 0) {
- if (tempLength < DEFAULT_LENGTH) {
- internalList.add(new float[(int) tempLength]);
- break;
- } else {
- internalList.add(new float[(int) DEFAULT_LENGTH]);
- tempLength -= DEFAULT_LENGTH;
- }
- }
- }
-
- public ListOfFloatArrays(long totSize, float defaultValue) {
- this(totSize);
- for (float[] array : internalList) {
- Arrays.fill(array, defaultValue);
- }
- }
-
- public void clear() {
- internalList.clear();
- }
-
- public float get(long index) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- return internalList.get(pseudoRow)[pseudoCol];
- } else {
- System.err.println("long index exceeds max size of list of arrays while getting: " + index + " " + overallLength);
- Exception ioe = new Exception();
- ioe.printStackTrace();
- return Float.NaN;
- }
- }
-
- public void set(long index, float value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] = value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while setting");
- }
- }
-
- public long getLength() {
- return overallLength;
- }
-
- public long getMaxRow() {
- long maxIndex = 0;
- float maxVal = 0;
- for (int index = 0; index < overallLength; index++) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- if (maxVal < internalList.get(pseudoRow)[pseudoCol]) {
- maxVal = internalList.get(pseudoRow)[pseudoCol];
- maxIndex = index;
- }
- }
- return maxIndex;
- }
-
- public ListOfFloatArrays deepClone() {
- ListOfFloatArrays clone = new ListOfFloatArrays(overallLength);
- for (int k = 0; k < internalList.size(); k++) {
- System.arraycopy(internalList.get(k), 0, clone.internalList.get(k), 0, internalList.get(k).length);
- }
- return clone;
- }
-
- public void divideBy(long index, float value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] /= value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while dividing");
- }
- }
-
- public void multiplyBy(long index, float value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] *= value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while mutiplying");
- }
- }
-
- public void addTo(long index, float value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- try {
- internalList.get(pseudoRow)[pseudoCol] += value;
- } catch (Exception e) {
- System.err.println(index + " " + pseudoCol);
- e.printStackTrace();
- }
- } else {
- System.err.println("long index exceeds max size of list of arrays while adding: " + index + " " + overallLength);
- Exception ioe = new Exception();
- ioe.printStackTrace();
- }
- }
-
- public void addValuesFrom(ListOfFloatArrays other) {
- if (overallLength == other.overallLength) {
- for (int i = 0; i < internalList.size(); i++) {
- float[] array = internalList.get(i);
- float[] otherArray = other.internalList.get(i);
- for (int j = 0; j < array.length; j++) {
- array[j] += otherArray[j];
- }
- }
- } else {
- System.err.println("Adding objects of different sizes!");
- }
- }
-
- public float getFirstValue() {
- return internalList.get(0)[0];
- }
-
- public float getLastValue() {
- float[] temp = internalList.get(internalList.size() - 1);
- return temp[temp.length - 1];
- }
-
- public List getValues() {
- return internalList;
- }
-
- public void multiplyEverythingBy(double val) {
- for (float[] array : internalList) {
- for (int k = 0; k < array.length; k++) {
- array[k] *= val;
- }
- }
- }
-
- public ListOfDoubleArrays convertToDoubles() {
- ListOfDoubleArrays newList = new ListOfDoubleArrays(overallLength);
- for (int j = 0; j < internalList.size(); j++) {
-
- float[] array = internalList.get(j);
- double[] newArray = newList.getValues().get(j);
-
- for (int k = 0; k < array.length; k++) {
- newArray[k] = array[k];
- }
- }
- return newList;
- }
-}
diff --git a/src/juicebox/data/basics/ListOfIntArrays.java b/src/juicebox/data/basics/ListOfIntArrays.java
deleted file mode 100644
index 6ac0cbac..00000000
--- a/src/juicebox/data/basics/ListOfIntArrays.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.basics;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * can't use because we need to instantiate the array, otherwise that would have been nice
- */
-public class ListOfIntArrays {
-
- private final int DEFAULT_LENGTH = Integer.MAX_VALUE - 10;
- private final long overallLength;
- private final List internalList = new ArrayList<>();
-
- public ListOfIntArrays(long length) {
- this.overallLength = length;
- long tempLength = length;
- while (tempLength > 0) {
- if (tempLength < DEFAULT_LENGTH) {
- internalList.add(new int[(int) tempLength]);
- break;
- } else {
- internalList.add(new int[DEFAULT_LENGTH]);
- tempLength -= DEFAULT_LENGTH;
- }
- }
- }
-
- public ListOfIntArrays(long totSize, int defaultValue) {
- this(totSize);
- for (int[] array : internalList) {
- Arrays.fill(array, defaultValue);
- }
- }
-
- public void clear() {
- internalList.clear();
- }
-
- public int get(long index) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- return internalList.get(pseudoRow)[pseudoCol];
- } else {
- System.err.println("long index exceeds max size of list of int arrays while getting");
- return -Integer.MAX_VALUE;
- }
- }
-
- public void set(long index, int value) {
- long tempIndex = index;
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] = value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while setting");
- return;
- }
- //System.err.println("unusual - long index exceeds max size of list of arrays while setting");
- }
-
- public long getLength() {
- return overallLength;
- }
-
- public ListOfIntArrays deepClone() {
- ListOfIntArrays clone = new ListOfIntArrays(overallLength);
- for (int k = 0; k < internalList.size(); k++) {
- System.arraycopy(internalList.get(k), 0, clone.internalList.get(k), 0, internalList.get(k).length);
- }
- return clone;
- }
-
- public void divideBy(long index, int value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] /= value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while dividing");
- return;
- }
- System.err.println("unusual - long index exceeds max size of list of arrays while dividing");
- }
-
- public void addValuesFrom(ListOfIntArrays other) {
- if (overallLength == other.overallLength) {
- for (int i = 0; i < internalList.size(); i++) {
- for (int j = 0; j < internalList.get(i).length; j++) {
- internalList.get(i)[j] += other.internalList.get(i)[j];
- }
- }
- } else {
- System.err.println("Adding objects of different sizes!");
- }
- }
-
- public void addTo(long index, int value) {
- if (index < overallLength) {
- int pseudoRow = (int) (index / DEFAULT_LENGTH);
- int pseudoCol = (int) (index % DEFAULT_LENGTH);
- internalList.get(pseudoRow)[pseudoCol] += value;
- } else {
- System.err.println("long index exceeds max size of list of arrays while adding");
- }
- }
-
- public List getValues() {
- return internalList;
- }
-}
diff --git a/src/juicebox/data/binary_file_layout.txt b/src/juicebox/data/binary_file_layout.txt
deleted file mode 100644
index af9c82dc..00000000
--- a/src/juicebox/data/binary_file_layout.txt
+++ /dev/null
@@ -1,80 +0,0 @@
-------
-Header
-------
-
- masterIndexPointer
-
-
- --------
- Chr dictionary
- --------
- numberOfChromosomes
-
- ------------
- Chromosome // repeat for each chromosome
- ------------
- name
- size
-
- ---------
- Attribute dictionary
- ---------
- attributeCount
- attKey
- attValue
- attKey
- attValue
- ....
-
- --------
- Matrix
- --------
- chr1 // lowest index chromosome
- chr2 // highest index chromosome
- numberOfZooms
-
- --------------
- MatrixZoomData //repeat for each zoom
- --------------
-
- zoom
- sum // Sum of counts over all records
- binSize // in bp
- blockBinCount // in # bin columns
- columnCount
- numberOfBlocks
-
- -----------
- Block Index // repeat for each block
- -----------
- blockNumber
- filePosition
- sizeInbytes
-
-
-
- ----------
- Block // repeat for each block
- ----------
- numberOfRecords
-
- -----------
- ContactRecord // repeat for each contact record
- -----------
- bin1
- bin2
- counts // int
-
-
-------------
-Master Index
-------------
-numberOfEntries
-
- -----
- Entry // repeat for each entry
- -----
- matrixKey // chr1_chr2
- filePosition
- sizeInBytes
-
diff --git a/src/juicebox/data/censoring/CustomMZDRegionHandler.java b/src/juicebox/data/censoring/CustomMZDRegionHandler.java
deleted file mode 100644
index 644c98b0..00000000
--- a/src/juicebox/data/censoring/CustomMZDRegionHandler.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.censoring;
-
-import juicebox.data.ChromosomeHandler;
-import juicebox.data.anchor.MotifAnchor;
-import juicebox.data.basics.Chromosome;
-import juicebox.windowui.HiCZoom;
-import org.broad.igv.util.Pair;
-
-import java.util.*;
-
-public class CustomMZDRegionHandler {
-
- private final Map, List>> allRegionsForChr = new HashMap<>();
- private final List boundariesOfCustomChromosomeX = new ArrayList<>();
- private final List boundariesOfCustomChromosomeY = new ArrayList<>();
-
- private static Pair, List> getAllRegionsFromSubChromosomes(
- final ChromosomeHandler handler, Chromosome chr) {
-
- if (handler.isCustomChromosome(chr)) {
- final List allRegions = new ArrayList<>();
- final List translatedRegions = new ArrayList<>();
-
- handler.getListOfRegionsInCustomChromosome(chr.getIndex()).processLists(
- new juicebox.data.feature.FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- allRegions.addAll(featureList);
- }
- });
- Collections.sort(allRegions);
-
- long previousEnd = 0;
- for (MotifAnchor anchor : allRegions) {
- long currentEnd = previousEnd + anchor.getWidth();
- MotifAnchor anchor2 = new MotifAnchor(chr.getName(), previousEnd, currentEnd);
- translatedRegions.add(anchor2);
- previousEnd = currentEnd + ChromosomeHandler.CUSTOM_CHROMOSOME_BUFFER;
- }
-
- return new Pair<>(allRegions, translatedRegions);
- } else {
- // just a standard chromosome
- final List allRegions = new ArrayList<>();
- final List translatedRegions = new ArrayList<>();
- allRegions.add(new MotifAnchor(chr.getName(), 0, (int) chr.getLength()));
- translatedRegions.add(new MotifAnchor(chr.getName(), 0, (int) chr.getLength()));
- return new Pair<>(allRegions, translatedRegions);
- }
- }
-
- /**
- * @param handler
- */
- public void initialize(Chromosome chr1, Chromosome chr2, HiCZoom zoom, ChromosomeHandler handler) {
- allRegionsForChr.clear();
- boundariesOfCustomChromosomeX.clear();
- boundariesOfCustomChromosomeY.clear();
-
- populateRegions(chr1, handler, boundariesOfCustomChromosomeX, zoom);
- if (chr1.getIndex() != chr2.getIndex()) {
- populateRegions(chr2, handler, boundariesOfCustomChromosomeY, zoom);
- } else {
- boundariesOfCustomChromosomeY.addAll(boundariesOfCustomChromosomeX);
- }
- }
-
- public List getBoundariesOfCustomChromosomeX() {
- return boundariesOfCustomChromosomeX;
- }
-
- public List getBoundariesOfCustomChromosomeY() {
- return boundariesOfCustomChromosomeY;
- }
-
- private void populateRegions(Chromosome chr, ChromosomeHandler handler, List boundaries, HiCZoom zoom) {
- String name = chr.getName();
- Pair, List> allRegionsInfo = getAllRegionsFromSubChromosomes(handler, chr);
-
- if (allRegionsInfo != null) {
- allRegionsForChr.put(name, allRegionsInfo);
- List translatedRegions = allRegionsInfo.getSecond();
- for (MotifAnchor anchor : translatedRegions) {
- boundaries.add(anchor.getX2() / zoom.getBinSize());
- }
- }
- }
-
- public List> getIntersectingFeatures(String name, long gx1, long gx2) {
-
- int idx1 = OneDimSearchUtils.indexedBinaryNearestSearch(
- allRegionsForChr.get(name).getSecond(), new MotifAnchor(name, gx1, gx1), true);
- int idx2 = OneDimSearchUtils.indexedBinaryNearestSearch(
- allRegionsForChr.get(name).getSecond(), new MotifAnchor(name, gx2, gx2), false);
-
- final List> foundFeatures = new ArrayList<>();
- for (int i = idx1; i <= idx2; i++) {
- foundFeatures.add(new Pair<>(
- allRegionsForChr.get(name).getFirst().get(i),
- allRegionsForChr.get(name).getSecond().get(i)));
- }
-
- return foundFeatures;
- }
-
- public List> getIntersectingFeatures(String name, int gx1) {
- int idx1 = OneDimSearchUtils.indexedBinaryNearestSearch(
- allRegionsForChr.get(name).getSecond(), new MotifAnchor(name, gx1, gx1), true);
-
- final List> foundFeatures = new ArrayList<>();
- if (idx1 > 0) {
- foundFeatures.add(new Pair<>(
- allRegionsForChr.get(name).getFirst().get(idx1),
- allRegionsForChr.get(name).getSecond().get(idx1)));
- }
-
- return foundFeatures;
- }
-}
-
-
diff --git a/src/juicebox/data/censoring/OneDimSearchUtils.java b/src/juicebox/data/censoring/OneDimSearchUtils.java
deleted file mode 100644
index 1f27baa8..00000000
--- a/src/juicebox/data/censoring/OneDimSearchUtils.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.censoring;
-
-import java.util.List;
-
-class OneDimSearchUtils {
-
- /**
- * Searches the specified list for the specified object or its closest
- * counter part using a modified binary search algorithm. The list must
- * be sorted into ascending order according to the natural ordering of
- * its elements prior to making this call. If it is not sorted, the
- * results are undefined. If the list contains multiple elements equal
- * to the specified object, there is no guarantee which one will be found.
- *
- * @param the class of the objects in the list
- * @param list the list to be searched.
- * @param key the key to be searched for.
- * @param useFloor to get the lesser of two indices given no exact match
- * @return the index of the search key, if it is contained in the list;
- */
- public static int indexedBinaryNearestSearch(List extends Comparable super T>> list, T key, boolean useFloor) {
- int low = 0;
- int high = list.size() - 1;
-
- if (useFloor && list.get(low).compareTo(key) > 0) {
- return low;
- } else if (!useFloor && list.get(high).compareTo(key) < 0) {
- return high;
- }
-
- while (low < high) {
- int mid = (low + high) >>> 1;
- int cmp = list.get(mid).compareTo(key);
- int cmpPlus1 = list.get(mid + 1).compareTo(key);
-
- if (cmpPlus1 < 0) {
- low = Math.min(high, mid + 1);
- } else if (cmp > 0) {
- high = Math.max(low, mid - 1);
- } else if (cmp == 0) {
- return mid;
- } else if (cmpPlus1 == 0) {
- return mid + 1;
- } else if (useFloor) {
- return mid;
- } else {
- return mid + 1;
- }
- if (high == low) {
- return low;
- }
- }
- System.err.println("something went wrong " + low + " " + high + " " + useFloor);
- return -(low); // key not found
- }
-}
diff --git a/src/juicebox/data/censoring/OneDimTrackCensoring.java b/src/juicebox/data/censoring/OneDimTrackCensoring.java
deleted file mode 100644
index 476b7923..00000000
--- a/src/juicebox/data/censoring/OneDimTrackCensoring.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.censoring;
-
-import juicebox.HiC;
-import juicebox.data.anchor.MotifAnchor;
-import juicebox.data.basics.Chromosome;
-import juicebox.track.*;
-import juicebox.windowui.HiCZoom;
-import org.broad.igv.track.WindowFunction;
-import org.broad.igv.util.Pair;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class OneDimTrackCensoring {
-
-
- public static HiCDataPoint[] getFilteredData(HiCDataSource dataSource, HiC hic, Chromosome chromosome,
- int startBin, int endBin, HiCGridAxis gridAxis,
- double scaleFactor, WindowFunction windowFunction) {
- HiCZoom zoom;
- try {
- zoom = hic.getZd().getZoom();
- } catch (Exception e) {
- return null;
- }
-
- // x window
- int binSize = zoom.getBinSize();
- int gx1 = startBin * binSize;
- int gx2 = endBin * binSize;
-
- //net.sf.jsi.Rectangle currentWindow = new net.sf.jsi.Rectangle(gx1, gx1, gx2, gx2);
- List> axisRegions = hic.getRTreeHandlerIntersectingFeatures(chromosome.getName(), gx1, gx2);
-
- List dataPointArrays = new ArrayList<>();
- for (Pair regionPair : axisRegions) {
-
- MotifAnchor originalRegion = regionPair.getFirst();
- MotifAnchor translatedRegion = regionPair.getSecond();
-
- Chromosome orig = hic.getChromosomeHandler().getChromosomeFromName(originalRegion.getChr());
- HiCDataPoint[] array = dataSource.getData(orig, (int) (originalRegion.getX1() / binSize),
- (int) (originalRegion.getX2() / binSize), gridAxis, scaleFactor, windowFunction);
- HiCDataPoint[] translatedArray = OneDimTrackCensoring.translateDataPointArray(zoom.getBinSize(), array, originalRegion, translatedRegion);
- dataPointArrays.add(translatedArray);
- }
-
- return OneDimTrackCensoring.mergeDataPoints(dataPointArrays);
- }
-
- private static HiCDataPoint[] translateDataPointArray(int binSize, HiCDataPoint[] array,
- MotifAnchor originalRegion, MotifAnchor translatedRegion) {
- List translatedPoints = new ArrayList<>();
-
- if (array.length > 0 && array[0] instanceof HiCCoverageDataSource.CoverageDataPoint) {
- for (HiCDataPoint pointGen : array) {
- HiCCoverageDataSource.CoverageDataPoint point = (HiCCoverageDataSource.CoverageDataPoint) pointGen;
- if (point.genomicStart >= originalRegion.getX1() && point.genomicEnd <= originalRegion.getX2()) {
- long newGStart = translatedRegion.getX1() + point.genomicStart - originalRegion.getX1();
- long newGEnd = translatedRegion.getX1() + point.genomicEnd - originalRegion.getX1();
- long newBinNum = newGStart / binSize;
- translatedPoints.add(new HiCCoverageDataSource.CoverageDataPoint((int) newBinNum, newGStart, newGEnd, point.value));
- }
- }
- } else if (array.length > 0 && array[0] instanceof HiCDataAdapter.DataAccumulator) {
- for (HiCDataPoint pointGen : array) {
- HiCDataAdapter.DataAccumulator point = (HiCDataAdapter.DataAccumulator) pointGen;
- if (point.genomicStart >= originalRegion.getX1() && point.genomicEnd <= originalRegion.getX2()) {
- long newGStart = translatedRegion.getX1() + point.genomicStart - originalRegion.getX1();
- long newGEnd = translatedRegion.getX1() + point.genomicEnd - originalRegion.getX1();
- long newBinNum = newGStart / binSize;
- HiCDataAdapter.DataAccumulator accum = new HiCDataAdapter.DataAccumulator(newBinNum, point.width,
- newGStart, newGEnd);
- accum.nPts = point.nPts;
- accum.weightedSum = point.weightedSum;
- accum.max = point.max;
- translatedPoints.add(accum);
- }
- }
- }
-
- HiCDataPoint[] points = new HiCDataPoint[translatedPoints.size()];
- for (int i = 0; i < points.length; i++) {
- points[i] = translatedPoints.get(i);
- }
-
- return points;
- }
-
- private static HiCDataPoint[] mergeDataPoints(List dataPointArrays) {
- int length = 0;
- for (HiCDataPoint[] array : dataPointArrays) {
- length += array.length;
- }
-
- HiCDataPoint[] mergedArray = new HiCDataPoint[length];
- int index = 0;
- for (HiCDataPoint[] array : dataPointArrays) {
- System.arraycopy(array, 0, mergedArray, index, array.length);
- index += array.length;
- }
- return mergedArray;
- }
-}
diff --git a/src/juicebox/data/censoring/RegionPair.java b/src/juicebox/data/censoring/RegionPair.java
deleted file mode 100644
index 3400fbca..00000000
--- a/src/juicebox/data/censoring/RegionPair.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.censoring;
-
-import juicebox.data.ChromosomeHandler;
-import juicebox.data.anchor.MotifAnchor;
-import org.broad.igv.util.Pair;
-
-import java.util.Objects;
-
-public class RegionPair {
-
- public final int xI;
- public final int yI;
- public final MotifAnchor xRegion;
- public final MotifAnchor xTransRegion;
- public final MotifAnchor yRegion;
- public final MotifAnchor yTransRegion;
-
- private RegionPair(int xI, Pair xLocalRegion,
- int yI, Pair yLocalRegion) {
- this.xI = xI;
- this.yI = yI;
- this.xRegion = xLocalRegion.getFirst();
- this.xTransRegion = xLocalRegion.getSecond();
- this.yRegion = yLocalRegion.getFirst();
- this.yTransRegion = yLocalRegion.getSecond();
- }
-
- public static RegionPair generateRegionPair(Pair xRegion, Pair yRegion, ChromosomeHandler handler) {
- int xI = handler.getChromosomeFromName(xRegion.getFirst().getChr()).getIndex();
- int yI = handler.getChromosomeFromName(yRegion.getFirst().getChr()).getIndex();
-
- // todo debug for diff custom chrs against each other
- // return new RegionPair(xI, xRegion, yI, yRegion);
-
- if (xI <= yI) {
- return new RegionPair(xI, xRegion, yI, yRegion);
- } else {
- return new RegionPair(yI, yRegion, xI, xRegion);
- }
- }
-
- public String getDescription() {
- return "" + xI + "_" + yI + xRegion.toString() + xTransRegion.toString() + yRegion.toString() + yTransRegion.toString();
- }
-
- public long[] getOriginalGenomeRegion() {
- return new long[]{
- xRegion.getX1(), xRegion.getX2(),
- yRegion.getX1(), yRegion.getX2()};
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj instanceof RegionPair) {
- RegionPair o = (RegionPair) obj;
-
- return xI == o.xI
- && yI == o.yI
- && xRegion.equals(o.xRegion)
- && xTransRegion.equals(o.xTransRegion)
- && yRegion.equals(o.yRegion)
- && yTransRegion.equals(o.yTransRegion);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(xI, yI, xRegion.hashCode(), xTransRegion.hashCode(), yRegion.hashCode(), yTransRegion.hashCode());
- }
-}
diff --git a/src/juicebox/data/feature/Feature.java b/src/juicebox/data/feature/Feature.java
deleted file mode 100644
index 43e61285..00000000
--- a/src/juicebox/data/feature/Feature.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.feature;
-
-/**
- * Created by muhammadsaadshamim on 11/17/15.
- */
-public abstract class Feature {
- public abstract String getKey();
-
- public abstract Feature deepClone();
-}
diff --git a/src/juicebox/data/feature/FeatureFilter.java b/src/juicebox/data/feature/FeatureFilter.java
deleted file mode 100644
index 5f42bdfb..00000000
--- a/src/juicebox/data/feature/FeatureFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.feature;
-
-import java.util.List;
-
-/**
- * Created by muhammadsaadshamim on 7/30/15.
- */
-public interface FeatureFilter {
- List filter(String chr, List featureList);
-}
diff --git a/src/juicebox/data/feature/FeatureFunction.java b/src/juicebox/data/feature/FeatureFunction.java
deleted file mode 100644
index e37ea069..00000000
--- a/src/juicebox/data/feature/FeatureFunction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.feature;
-
-import java.util.List;
-
-/**
- * Created by muhammadsaadshamim on 7/30/15.
- */
-public interface FeatureFunction {
- void process(String chr, List featureList);
-}
diff --git a/src/juicebox/data/feature/GenomeWideList.java b/src/juicebox/data/feature/GenomeWideList.java
deleted file mode 100644
index b0758277..00000000
--- a/src/juicebox/data/feature/GenomeWideList.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.feature;
-
-import juicebox.data.ChromosomeHandler;
-import juicebox.data.basics.Chromosome;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Created by muhammadsaadshamim on 11/17/15.
- */
-public class GenomeWideList {
-
- /**
- * Genome-wide list of features, where each string is a key for an
- * inter or intra-chromosomal region
- */
- private final Map> featureLists = new HashMap<>();
-
- /** Constructors**/
-
- /**
- * Private constructor only used for cloning
- * todo delete / make private @mss
- */
- public GenomeWideList() {
- }
-
- /**
- * @param handler
- */
- public GenomeWideList(ChromosomeHandler handler) {
- for (Chromosome c : handler.getChromosomeArray()) {
- featureLists.put("" + c.getIndex(), new ArrayList<>());
- }
- }
-
- /**
- * @param handler
- * @param features to be added to list
- */
- public GenomeWideList(ChromosomeHandler handler, List features) {
- this(handler);
- addAll(features);
- }
-
- /**
- * Basic methods/functions
- */
-
- /**
- * Initialize a genome wide list using an existing list (creates deep copy)
- *
- * @param gwList
- */
- public GenomeWideList(final GenomeWideList gwList) {
- processLists(new FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- if (gwList.containsKey(chr)) {
- addAll(gwList.getFeatures(chr));
- }
- }
- });
- }
-
- /**
- * @param key
- * @return
- */
- public boolean containsKey(String key) {
- return featureLists.containsKey(key);
- }
-
- /**
- * @param key
- * @param features
- */
- public synchronized void setFeatures(String key, List features) {
- featureLists.put(key, features);
- }
-
- /**
- * @param key
- * @return features for corresponding region
- */
- public List getFeatures(String key) {
- return featureLists.get(key);
- }
-
- /**
- * @return number of features in full list
- */
- public synchronized int size() {
- int val = 0;
- for (List features : featureLists.values()) {
- val += features.size();
- }
- return val;
- }
-
- /**
- * @param features to be added to this list (deep copy)
- */
- @SuppressWarnings("unchecked")
- public synchronized void addAll(List features) {
- for (T feature : features) {
- featureLists.get(feature.getKey()).add((T) feature.deepClone());
- }
- }
-
- /**
- * pass interface implementing a filter for anchors
- *
- * @param filter
- */
- public synchronized void filterLists(FeatureFilter filter) {
- for (String chr : featureLists.keySet()) {
- featureLists.put(chr, filter.filter(chr, featureLists.get(chr)));
- }
- }
-
- /** methods to create copies **/
-
- /**
- * pass interface implementing a process for all anchors
- *
- * @param function
- */
- public synchronized void processLists(FeatureFunction function) {
- for (String key : featureLists.keySet()) {
- function.process(key, featureLists.get(key));
- }
- }
-
- /**
- * @return deep copy of the anchor list
- */
- public GenomeWideList deepClone() {
- GenomeWideList clone = new GenomeWideList<>();
- for (String key : featureLists.keySet()) {
- clone.featureLists.put(key, cloneFeatureList(featureLists.get(key)));
- }
- return clone;
- }
-
- /**
- * @param features
- * @return deep copy of the list of features
- */
- @SuppressWarnings("unchecked")
- private List cloneFeatureList(List features) {
- List clonedFeatures = new ArrayList<>();
- for (T feature : features) {
- clonedFeatures.add((T) feature.deepClone());//feature.deepClone()
- }
- return clonedFeatures;
- }
-
- /**
- * @return set of keys for genome-wide regions (i.e. category/location keys)
- */
- public Set keySet() {
- return featureLists.keySet();
- }
-
- /**
- * Add feature to genome-wide list with specified key
- *
- * @param key
- * @param feature
- */
- public synchronized void addFeature(String key, T feature) {
- if (featureLists.containsKey(key)) {
- featureLists.get(key).add(feature);
- } else {
- List features = new ArrayList<>();
- features.add(feature);
- featureLists.put(key, features);
- }
- }
-
- public void simpleExport(final File file) {
- try {
- final FileWriter fw = new FileWriter(file);
- processLists(new FeatureFunction() {
- @Override
- public void process(String chr, List featureList) {
- for (T t : featureList) {
- try {
- if (fw != null) fw.write(t.toString() + "\n");
- } catch (IOException e) {
- System.err.println("Unable to write to file for exporting GWList");
- }
- }
- }
- });
- try {
- fw.close();
- } catch (IOException e) {
- System.err.println("Unable to close file for exporting GWList");
- }
- } catch (IOException e) {
- System.err.println("Unable to open file for exporting GWList");
- }
- }
-}
diff --git a/src/juicebox/data/iterator/BigContactRecordList.java b/src/juicebox/data/iterator/BigContactRecordList.java
deleted file mode 100644
index 69463d70..00000000
--- a/src/juicebox/data/iterator/BigContactRecordList.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.ContactRecord;
-
-import java.util.*;
-
-public class BigContactRecordList {
-
- private static final int MAX_LIMIT = Integer.MAX_VALUE - 10;
- private List> internalList = new ArrayList<>();
- private long numOfContactRecords = 0;
-
- public static BigContactRecordList populateListOfListsFromSingleIterator(Iterator iterator) {
- BigContactRecordList allRecords = new BigContactRecordList();
- List tempList = new ArrayList<>();
- int counter = 0;
- while (iterator.hasNext()) {
- tempList.add(iterator.next());
- counter++;
- if (counter > MAX_LIMIT) {
- allRecords.addSubList(tempList);
- tempList = new ArrayList<>();
- counter = 0;
- }
- }
- if (tempList.size() > 0) {
- allRecords.addSubList(tempList);
- }
- return allRecords;
- }
-
- public void addAllSubLists(BigContactRecordList other) {
- internalList.addAll(other.internalList);
- for (List records : other.internalList) {
- numOfContactRecords += records.size();
- }
- }
-
- private void addSubList(List cList) {
- internalList.add(cList);
- numOfContactRecords += cList.size();
- }
-
- public long getTotalSize() {
- return numOfContactRecords;
- }
-
- public int getNumLists() {
- return internalList.size();
- }
-
- public List getSubList(int index) {
- return internalList.get(index);
- }
-
- public void clear() {
- for (List cList : internalList) {
- cList.clear();
- }
- internalList.clear();
- internalList = new ArrayList<>();
- numOfContactRecords = 0;
- }
-
- public void sort() {
- internalList.sort(Comparator.comparing(o -> o.get(0)));
- }
-
- public void collapse() {
- System.out.println("Was n " + internalList.size());
-
- int numFinList = (int) Math.max(numOfContactRecords / 200000000, 20);
- List> newInternalList = new ArrayList<>();
- int[] countForList = new int[numFinList];
- Arrays.fill(countForList, 0);
- for (int z = 0; z < numFinList; z++) {
- newInternalList.add(new ArrayList<>());
- }
-
- for (List subList : internalList) {
- int whichIndexToAddTo = getIndexOfMin(countForList);
- countForList[whichIndexToAddTo] += subList.size();
- newInternalList.get(whichIndexToAddTo).addAll(subList);
- }
-
- internalList.clear();
- internalList = newInternalList;
-
- System.out.println("Now is n " + internalList.size());
- }
-
- private int getIndexOfMin(int[] counts) {
- int minIndex = 0;
- for (int k = 1; k < counts.length; k++) {
- if (counts[k] < counts[minIndex]) {
- minIndex = k;
- }
- }
- return minIndex;
- }
-}
diff --git a/src/juicebox/data/iterator/ContactRecordIterator.java b/src/juicebox/data/iterator/ContactRecordIterator.java
deleted file mode 100644
index c327700e..00000000
--- a/src/juicebox/data/iterator/ContactRecordIterator.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.HiCGlobals;
-import juicebox.data.Block;
-import juicebox.data.ContactRecord;
-import juicebox.data.DatasetReader;
-import juicebox.data.MatrixZoomData;
-import juicebox.windowui.NormalizationHandler;
-import org.broad.igv.util.collections.LRUCache;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-public /**
- * Class for iterating over the contact records
- */
-class ContactRecordIterator implements Iterator {
-
- private final List blockNumbers;
- private int blockIdx;
- private Iterator currentBlockIterator;
- private final DatasetReader reader;
- private final MatrixZoomData zd;
- private final LRUCache blockCache;
-
- /**
- * Initializes the iterator
- */
- ContactRecordIterator(DatasetReader reader, MatrixZoomData zd, LRUCache blockCache) {
- this.reader = reader;
- this.zd = zd;
- this.blockCache = blockCache;
- this.blockIdx = -1;
- this.blockNumbers = reader.getBlockNumbers(zd);
- }
-
- /**
- * Indicates whether or not there is another block waiting; checks current block
- * iterator and creates a new one if need be
- *
- * @return true if there is another block to be read
- */
- @Override
- public boolean hasNext() {
-
- if (currentBlockIterator != null && currentBlockIterator.hasNext()) {
- return true;
- } else {
- blockIdx++;
- if (blockNumbers != null && blockIdx < blockNumbers.size()) {
- try {
- int blockNumber = blockNumbers.get(blockIdx);
-
- // Optionally check the cache
- String key = zd.getBlockKey(blockNumber, NormalizationHandler.NONE);
- Block nextBlock;
- if (HiCGlobals.useCache && blockCache.containsKey(key)) {
- nextBlock = blockCache.get(key);
- } else {
- nextBlock = reader.readNormalizedBlock(blockNumber, zd, NormalizationHandler.NONE);
- }
- currentBlockIterator = nextBlock.getContactRecords().iterator();
- return true;
- } catch (IOException e) {
- System.err.println("Error fetching block " + e.getMessage());
- return false;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Returns the next contact record
- *
- * @return The next contact record
- */
- @Override
- public ContactRecord next() {
- return currentBlockIterator == null ? null : currentBlockIterator.next();
- }
-
- /**
- * Not supported
- */
- @Override
- public void remove() {
- //Not supported
- throw new RuntimeException("remove() is not supported");
- }
-}
diff --git a/src/juicebox/data/iterator/CoupledIteratorAndOffset.java b/src/juicebox/data/iterator/CoupledIteratorAndOffset.java
deleted file mode 100644
index d85968e3..00000000
--- a/src/juicebox/data/iterator/CoupledIteratorAndOffset.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.ContactRecord;
-
-import java.util.Iterator;
-
-public class CoupledIteratorAndOffset implements Iterator {
-
- private final Iterator internalIterator;
- private final int xOffset, yOffset;
-
- public CoupledIteratorAndOffset(Iterator iterator, int xOffset, int yOffset) {
- internalIterator = iterator;
- this.xOffset = xOffset;
- this.yOffset = yOffset;
- }
-
- @Override
- public boolean hasNext() {
- return internalIterator.hasNext();
- }
-
- @Override
- public ContactRecord next() {
- ContactRecord cr = internalIterator.next();
- int binX = cr.getBinX() + xOffset;
- int binY = cr.getBinY() + yOffset;
- return new ContactRecord(binX, binY, cr.getCounts());
- }
-}
diff --git a/src/juicebox/data/iterator/GWIteratorContainer.java b/src/juicebox/data/iterator/GWIteratorContainer.java
deleted file mode 100644
index 68433ddb..00000000
--- a/src/juicebox/data/iterator/GWIteratorContainer.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.ChromosomeHandler;
-import juicebox.data.ContactRecord;
-import juicebox.data.Dataset;
-import juicebox.data.basics.Chromosome;
-import juicebox.data.basics.ListOfFloatArrays;
-import juicebox.tools.dev.ParallelizedJuicerTools;
-import juicebox.windowui.HiCZoom;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-public class GWIteratorContainer extends IteratorContainer {
-
- private final Dataset dataset;
- private final ChromosomeHandler handler;
- private final HiCZoom zoom;
- private final boolean includeIntra;
-
- public GWIteratorContainer(Dataset dataset, ChromosomeHandler handler,
- HiCZoom zoom, boolean includeIntra) {
- super(calculateMatrixSize(handler, zoom));
- this.dataset = dataset;
- this.handler = handler;
- this.zoom = zoom;
- this.includeIntra = includeIntra;
-
- }
-
- private static long calculateMatrixSize(ChromosomeHandler handler, HiCZoom zoom) {
- long totalSize = 0;
- for (Chromosome c1 : handler.getChromosomeArrayWithoutAllByAll()) {
- totalSize += (c1.getLength() / zoom.getBinSize()) + 1;
- }
- return totalSize;
- }
-
- @Override
- public Iterator getNewContactRecordIterator() {
- return new GenomeWideIterator(dataset, handler, zoom, includeIntra);
- }
-
- public List> getAllFromFileContactRecordIterators() {
- return GenomeWideIterator.getAllFromFileIterators(dataset, handler, zoom, includeIntra);
- }
-
- @Override
- public ListOfFloatArrays sparseMultiply(ListOfFloatArrays vector, long vectorLength) {
- final ListOfFloatArrays totalSumVector = new ListOfFloatArrays(vectorLength);
-
- List> allIterators = getAllFromFileContactRecordIterators();
-
- AtomicInteger index = new AtomicInteger(0);
- ParallelizedJuicerTools.launchParallelizedCode(numCPUMatrixThreads, () -> {
- int i = index.getAndIncrement();
- ListOfFloatArrays accumSumVector = new ListOfFloatArrays(vectorLength);
- while (i < allIterators.size()) {
- accumSumVector.addValuesFrom(ZDIteratorContainer.matrixVectorMultiplyOnIterator(
- allIterators.get(i), vector, vectorLength));
- i = index.getAndIncrement();
- }
- synchronized (totalSumVector) {
- totalSumVector.addValuesFrom(accumSumVector);
- }
- });
-
- allIterators.clear();
-
- return totalSumVector;
- }
-
- @Override
- public void clear() {
- // null, doesn't need to clean anything
- }
-}
diff --git a/src/juicebox/data/iterator/GenomeWideIterator.java b/src/juicebox/data/iterator/GenomeWideIterator.java
deleted file mode 100644
index ac0b9034..00000000
--- a/src/juicebox/data/iterator/GenomeWideIterator.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.*;
-import juicebox.data.basics.Chromosome;
-import juicebox.windowui.HiCZoom;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class GenomeWideIterator implements Iterator {
-
- private final Chromosome[] chromosomes;
- private final boolean includeIntra;
- private final HiCZoom zoom;
- private final Dataset dataset;
- private Iterator currentIterator = null;
-
- private int recentAddX = 0;
- private int recentAddY = 0;
- private int c1i = 0, c2i = 0;
-
- public GenomeWideIterator(Dataset dataset, ChromosomeHandler handler,
- HiCZoom zoom, boolean includeIntra) {
- this.chromosomes = handler.getChromosomeArrayWithoutAllByAll();
- this.includeIntra = includeIntra;
- this.zoom = zoom;
- this.dataset = dataset;
- getNextIterator();
- }
-
- @Override
- public boolean hasNext() {
- if (currentIterator.hasNext()) {
- return true;
- } else {
- recentAddY += chromosomes[c2i].getLength() / zoom.getBinSize() + 1;
- c2i++;
- }
- return getNextIterator();
- }
-
- public static List> getAllFromFileIterators(Dataset dataset, ChromosomeHandler handler,
- HiCZoom zoom, boolean includeIntra) {
- Chromosome[] chromosomes = handler.getChromosomeArrayWithoutAllByAll();
- List> allIterators = new ArrayList<>();
-
- int xOffset = 0;
- for (int i = 0; i < chromosomes.length; i++) {
- Chromosome c1 = chromosomes[i];
- int yOffset = 0 + xOffset;
- for (int j = i; j < chromosomes.length; j++) {
- Chromosome c2 = chromosomes[j];
-
- if (c1.getIndex() < c2.getIndex() || (c1.equals(c2) && includeIntra)) {
- MatrixZoomData zd = HiCFileTools.getMatrixZoomData(dataset, c1, c2, zoom);
- if (zd != null) {
- IteratorContainer ic = zd.getFromFileIteratorContainer();
- Iterator iterator = ic.getNewContactRecordIterator();
- if (iterator != null && iterator.hasNext()) {
- allIterators.add(new CoupledIteratorAndOffset(iterator, xOffset, yOffset));
- }
- }
- }
- yOffset += c2.getLength() / zoom.getBinSize() + 1;
- }
- xOffset += c1.getLength() / zoom.getBinSize() + 1;
- }
- return allIterators;
- }
-
- private boolean getNextIterator() {
- while (c1i < chromosomes.length) {
- Chromosome c1 = chromosomes[c1i];
- while (c2i < chromosomes.length) {
- Chromosome c2 = chromosomes[c2i];
-
- if (c1.getIndex() < c2.getIndex() || (c1.equals(c2) && includeIntra)) {
- MatrixZoomData zd = HiCFileTools.getMatrixZoomData(dataset, c1, c2, zoom);
- if (zd != null) {
- Iterator newIterator = zd.getFromFileIteratorContainer().getNewContactRecordIterator();
- if (newIterator != null && newIterator.hasNext()) {
- currentIterator = new CoupledIteratorAndOffset(newIterator, recentAddX, recentAddY);
- return true;
- }
- }
- }
- recentAddY += c2.getLength() / zoom.getBinSize() + 1;
- c2i++;
- }
- recentAddX += c1.getLength() / zoom.getBinSize() + 1;
- recentAddY = 0 + recentAddX;
- c1i++;
- c2i = c1i;
- }
- return false;
- }
-
- @Override
- public ContactRecord next() {
- return currentIterator.next();
- }
-}
diff --git a/src/juicebox/data/iterator/IteratorContainer.java b/src/juicebox/data/iterator/IteratorContainer.java
deleted file mode 100644
index 409f7148..00000000
--- a/src/juicebox/data/iterator/IteratorContainer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.ContactRecord;
-import juicebox.data.basics.ListOfDoubleArrays;
-import juicebox.data.basics.ListOfFloatArrays;
-
-import java.util.Iterator;
-
-public abstract class IteratorContainer {
-
- private final long matrixSize;
- private long numberOfContactRecords = -1;
- public static int numCPUMatrixThreads = 10;
-
- public IteratorContainer(long matrixSize) {
- this.matrixSize = matrixSize;
- }
-
- abstract public Iterator getNewContactRecordIterator();
-
- protected void setNumberOfContactRecords(long numberOfContactRecords) {
- this.numberOfContactRecords = numberOfContactRecords;
- }
-
- public long getNumberOfContactRecords() {
- if (numberOfContactRecords > 0) return numberOfContactRecords;
-
- numberOfContactRecords = 0;
- Iterator iterator = getNewContactRecordIterator();
- while (iterator.hasNext()) {
- iterator.next();
- numberOfContactRecords++;
- }
-
- return numberOfContactRecords;
- }
-
- public long getMatrixSize() {
- return matrixSize;
- }
-
- public boolean getIsThereEnoughMemoryForNormCalculation() {
- // when using an iterator, we basically only worry
- // about the vector of row sums
- // float is 4 bytes; one for each row
- return matrixSize * 4 < Runtime.getRuntime().maxMemory();
- }
-
- public abstract ListOfFloatArrays sparseMultiply(ListOfFloatArrays vector, long vectorLength);
-
- public abstract void clear();
-
- protected static ListOfFloatArrays[] getArrayOfFloatVectors(int size, long vectorLength) {
- ListOfFloatArrays[] array = new ListOfFloatArrays[size];
- for (int i = 0; i < size; i++) {
- array[i] = new ListOfFloatArrays(vectorLength);
- }
- return array;
- }
-
- protected static ListOfDoubleArrays[] getArrayOfDoubleVectors(int size, long vectorLength) {
- ListOfDoubleArrays[] array = new ListOfDoubleArrays[size];
- for (int i = 0; i < size; i++) {
- array[i] = new ListOfDoubleArrays(vectorLength);
- }
- return array;
- }
-}
diff --git a/src/juicebox/data/iterator/ListIteratorContainer.java b/src/juicebox/data/iterator/ListIteratorContainer.java
deleted file mode 100644
index 04e74f47..00000000
--- a/src/juicebox/data/iterator/ListIteratorContainer.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.ContactRecord;
-import juicebox.data.basics.ListOfDoubleArrays;
-import juicebox.data.basics.ListOfFloatArrays;
-import juicebox.tools.dev.ParallelizedJuicerTools;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class ListIteratorContainer extends IteratorContainer {
-
- private final List readList;
-
- public ListIteratorContainer(List readList, long matrixSize) {
- super(matrixSize);
- setNumberOfContactRecords(readList.size());
- this.readList = readList;
- }
-
- @Override
- public Iterator getNewContactRecordIterator() {
- return readList.iterator();
- }
-
- @Override
- public boolean getIsThereEnoughMemoryForNormCalculation() {
- // float is 4 bytes; one for each row (row sums)
- // 12 bytes (2 ints, 1 float) for contact record
- return 4 * getMatrixSize() + 12 * getNumberOfContactRecords() < Runtime.getRuntime().maxMemory();
- }
-
- public static ListOfFloatArrays sparseMultiplyByListContacts(List readList, ListOfFloatArrays vector,
- long vectorLength, int numThreads) {
- final ListOfDoubleArrays totalSumVector = new ListOfDoubleArrays(vectorLength);
-
- int[] cutoffs = ParallelizedListOperations.createCutoffs(numThreads, readList.size());
-
- AtomicInteger index = new AtomicInteger(0);
- ParallelizedJuicerTools.launchParallelizedCode(numThreads, () -> {
- int sIndx = index.getAndIncrement();
- ListOfDoubleArrays sumVector = new ListOfDoubleArrays(vectorLength);
- for (int i = cutoffs[sIndx]; i < cutoffs[sIndx + 1]; i++) {
- ContactRecord cr = readList.get(i);
- matrixVectorMult(vector, sumVector, cr);
- }
-
- synchronized (totalSumVector) {
- totalSumVector.addValuesFrom(sumVector);
- }
- });
-
- return totalSumVector.convertToFloats();
- }
-
- public static void matrixVectorMult(ListOfFloatArrays vector, ListOfDoubleArrays sumVector, ContactRecord cr) {
- int x = cr.getBinX();
- int y = cr.getBinY();
- double counts = cr.getCounts();
- if (x == y) {
- counts *= .5;
- }
-
- sumVector.addTo(x, counts * vector.get(y));
- sumVector.addTo(y, counts * vector.get(x));
- }
-
- @Override
- public ListOfFloatArrays sparseMultiply(ListOfFloatArrays vector, long vectorLength) {
- return sparseMultiplyByListContacts(readList, vector, vectorLength, numCPUMatrixThreads);
- }
-
- @Override
- public void clear() {
- readList.clear();
- }
-}
diff --git a/src/juicebox/data/iterator/ListOfListGenerator.java b/src/juicebox/data/iterator/ListOfListGenerator.java
deleted file mode 100644
index 584e54cd..00000000
--- a/src/juicebox/data/iterator/ListOfListGenerator.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.HiCGlobals;
-import juicebox.data.*;
-import juicebox.tools.dev.ParallelizedJuicerTools;
-import juicebox.windowui.HiCZoom;
-import org.broad.igv.util.collections.LRUCache;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class ListOfListGenerator {
-
- public static IteratorContainer createFromZD(DatasetReader reader, MatrixZoomData matrixZoomData,
- LRUCache blockCache) {
- IteratorContainer ic = new ZDIteratorContainer(reader, matrixZoomData, blockCache);
- return tryToCreateIteratorInRAM(ic);
- }
-
- public static IteratorContainer createForWholeGenome(Dataset dataset, ChromosomeHandler chromosomeHandler,
- HiCZoom zoom, boolean includeIntraData) {
- IteratorContainer ic = new GWIteratorContainer(dataset, chromosomeHandler, zoom, includeIntraData);
- return tryToCreateIteratorInRAM(ic);
- }
-
- private static IteratorContainer tryToCreateIteratorInRAM(IteratorContainer ic0) {
- if (HiCGlobals.USE_ITERATOR_NOT_ALL_IN_RAM) {
- return ic0;
- }
-
- try {
- // we should count once to ensure this is reasonable to do so memory-wise
- boolean shouldFitInMemory = true;
- if (HiCGlobals.CHECK_RAM_USAGE) {
- shouldFitInMemory = checkMemory(ic0);
- }
-
- if (shouldFitInMemory) {
- BigContactRecordList allContactRecords = populateListOfLists(ic0);
- long numOfContactRecords = allContactRecords.getTotalSize();
-
- IteratorContainer newIC = new ListOfListIteratorContainer(allContactRecords,
- ic0.getMatrixSize(),
- numOfContactRecords);
- return newIC;
- }
- } catch (Exception e) {
- System.err.println(e.getLocalizedMessage());
- System.err.println("Will use default iterator");
- }
-
- return ic0;
- }
-
- private static BigContactRecordList populateListOfLists(IteratorContainer ic) {
-
- if (ic instanceof GWIteratorContainer) {
- List> iterators = ((GWIteratorContainer) ic).getAllFromFileContactRecordIterators();
- BigContactRecordList allRecords = new BigContactRecordList();
-
- AtomicInteger index = new AtomicInteger(0);
- ParallelizedJuicerTools.launchParallelizedCode(IteratorContainer.numCPUMatrixThreads, () -> {
- int i = index.getAndIncrement();
- BigContactRecordList recordsForThread = new BigContactRecordList();
- while (i < iterators.size()) {
- BigContactRecordList recordsForIter = BigContactRecordList.populateListOfListsFromSingleIterator(iterators.get(i));
- recordsForThread.addAllSubLists(recordsForIter);
- i = index.getAndIncrement();
- }
- synchronized (allRecords) {
- allRecords.addAllSubLists(recordsForThread);
- }
- });
- return allRecords;
- } else {
- return BigContactRecordList.populateListOfListsFromSingleIterator(ic.getNewContactRecordIterator());
- }
- }
-
- private static boolean checkMemory(IteratorContainer ic) {
- long ramForRowSums = ic.getMatrixSize() * 4;
- long ramForAllContactRecords = ic.getNumberOfContactRecords() * 12;
- return ramForRowSums + ramForAllContactRecords < Runtime.getRuntime().maxMemory();
- }
-}
diff --git a/src/juicebox/data/iterator/ListOfListIterator.java b/src/juicebox/data/iterator/ListOfListIterator.java
deleted file mode 100644
index 573522b9..00000000
--- a/src/juicebox/data/iterator/ListOfListIterator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.ContactRecord;
-
-import java.util.Iterator;
-
-public class ListOfListIterator implements Iterator {
-
- private final BigContactRecordList allContactRecords;
- private Iterator currentIterator = null;
- private int currentListIndex = 0;
-
- public ListOfListIterator(BigContactRecordList allContactRecords) {
- this.allContactRecords = allContactRecords;
- getNextIterator();
- }
-
- @Override
- public boolean hasNext() {
- if (currentIterator.hasNext()) {
- return true;
- } else {
- currentListIndex++;
- }
- return getNextIterator();
- }
-
- private boolean getNextIterator() {
- while (currentListIndex < allContactRecords.getNumLists()) {
- currentIterator = allContactRecords.getSubList(currentListIndex).iterator();
- if (currentIterator.hasNext()) {
- return true;
- }
- currentListIndex++;
- }
- return false;
- }
-
- @Override
- public ContactRecord next() {
- return currentIterator.next();
- }
-}
diff --git a/src/juicebox/data/iterator/ListOfListIteratorContainer.java b/src/juicebox/data/iterator/ListOfListIteratorContainer.java
deleted file mode 100644
index e53d8db7..00000000
--- a/src/juicebox/data/iterator/ListOfListIteratorContainer.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.ContactRecord;
-import juicebox.data.basics.ListOfDoubleArrays;
-import juicebox.data.basics.ListOfFloatArrays;
-import juicebox.tools.dev.ParallelizedJuicerTools;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class ListOfListIteratorContainer extends IteratorContainer {
-
- private final BigContactRecordList allContactRecords;
-
- public ListOfListIteratorContainer(BigContactRecordList allContactRecords, long matrixSize,
- long totalNumberOfContacts) {
- super(matrixSize);
- setNumberOfContactRecords(totalNumberOfContacts);
- this.allContactRecords = allContactRecords;
- }
-
- @Override
- public Iterator getNewContactRecordIterator() {
- return new ListOfListIterator(allContactRecords);
- }
-
- @Override
- public boolean getIsThereEnoughMemoryForNormCalculation() {
- // float is 4 bytes; one for each row (row sums)
- // 12 bytes (2 ints, 1 float) for contact record
- return 4 * getMatrixSize() + 12 * getNumberOfContactRecords() < Runtime.getRuntime().maxMemory();
- }
-
- @Override
- public ListOfFloatArrays sparseMultiply(ListOfFloatArrays vector, long vectorLength) {
-
- if (allContactRecords.getNumLists() < numCPUMatrixThreads) {
- final ListOfFloatArrays totalSumVector = new ListOfFloatArrays(vectorLength);
- for (int k = 0; k < allContactRecords.getNumLists(); k++) {
- List contactRecords = allContactRecords.getSubList(k);
- totalSumVector.addValuesFrom(ListIteratorContainer.sparseMultiplyByListContacts(
- contactRecords, vector, vectorLength, numCPUMatrixThreads));
- }
- return totalSumVector;
- }
-
- return sparseMultiplyAcrossLists(vector, vectorLength);
- }
-
- @Override
- public void clear() {
- allContactRecords.clear();
- }
-
- private ListOfFloatArrays sparseMultiplyAcrossLists(ListOfFloatArrays vector, long vectorLength) {
- final ListOfDoubleArrays totalSumVector = new ListOfDoubleArrays(vectorLength);
-
- AtomicInteger index = new AtomicInteger(0);
- ParallelizedJuicerTools.launchParallelizedCode(numCPUMatrixThreads, () -> {
- int sIndx = index.getAndIncrement();
- ListOfDoubleArrays sumVector = new ListOfDoubleArrays(vectorLength);
- while (sIndx < allContactRecords.getNumLists()) {
- for (ContactRecord cr : allContactRecords.getSubList(sIndx)) {
- ListIteratorContainer.matrixVectorMult(vector, sumVector, cr);
- }
- sIndx = index.getAndIncrement();
- }
-
- synchronized (totalSumVector) {
- totalSumVector.addValuesFrom(sumVector);
- }
- });
-
- return totalSumVector.convertToFloats();
- }
-}
diff --git a/src/juicebox/data/iterator/ParallelizedListOperations.java b/src/juicebox/data/iterator/ParallelizedListOperations.java
deleted file mode 100644
index 78d24baf..00000000
--- a/src/juicebox/data/iterator/ParallelizedListOperations.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-public class ParallelizedListOperations {
-
- public static int[] createCutoffs(int n, int listSize) {
- int[] cutoffs = new int[n + 1];
- int increment = listSize / n;
- for (int k = 1; k < n; k++) {
- cutoffs[k] = k * increment;
- }
- cutoffs[0] = 0;
- cutoffs[n] = listSize;
- return cutoffs;
- }
-}
diff --git a/src/juicebox/data/iterator/ZDIteratorContainer.java b/src/juicebox/data/iterator/ZDIteratorContainer.java
deleted file mode 100644
index 4d627fca..00000000
--- a/src/juicebox/data/iterator/ZDIteratorContainer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.iterator;
-
-import juicebox.data.Block;
-import juicebox.data.ContactRecord;
-import juicebox.data.DatasetReader;
-import juicebox.data.MatrixZoomData;
-import juicebox.data.basics.ListOfDoubleArrays;
-import juicebox.data.basics.ListOfFloatArrays;
-import org.broad.igv.util.collections.LRUCache;
-
-import java.util.Iterator;
-
-public class ZDIteratorContainer extends IteratorContainer {
-
- private final LRUCache blockCache;
- private final DatasetReader reader;
- private final MatrixZoomData zd;
-
- public ZDIteratorContainer(DatasetReader reader, MatrixZoomData zd, LRUCache blockCache) {
- super(zd.getXGridAxis().getBinCount());
- this.reader = reader;
- this.zd = zd;
- this.blockCache = blockCache;
- }
-
- @Override
- public Iterator getNewContactRecordIterator() {
- return new ContactRecordIterator(reader, zd, blockCache);
- }
-
- public static ListOfFloatArrays matrixVectorMultiplyOnIterator(Iterator iterator,
- ListOfFloatArrays vector, long vectorLength) {
- ListOfDoubleArrays sumVector = new ListOfDoubleArrays(vectorLength);
- while (iterator.hasNext()) {
- ContactRecord cr = iterator.next();
- ListIteratorContainer.matrixVectorMult(vector, sumVector, cr);
- }
- return sumVector.convertToFloats();
- }
-
- @Override
- public ListOfFloatArrays sparseMultiply(ListOfFloatArrays vector, long vectorLength) {
- return matrixVectorMultiplyOnIterator(getNewContactRecordIterator(), vector, vectorLength);
- }
-
- @Override
- public void clear() {
- //blockCache.clear();
- }
-}
diff --git a/src/juicebox/data/v9depth/ConstantDepth.java b/src/juicebox/data/v9depth/ConstantDepth.java
deleted file mode 100644
index 027bf463..00000000
--- a/src/juicebox/data/v9depth/ConstantDepth.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.v9depth;
-
-public class ConstantDepth extends V9Depth {
-
- public ConstantDepth(int base, int blockBinCount) {
- super(blockBinCount);
- this.BASE = Math.abs(base);
- }
-
- @Override
- protected int logBase(double v) {
- return (int) Math.abs(v / BASE);
- }
-}
diff --git a/src/juicebox/data/v9depth/LogDepth.java b/src/juicebox/data/v9depth/LogDepth.java
deleted file mode 100644
index 833e652e..00000000
--- a/src/juicebox/data/v9depth/LogDepth.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.v9depth;
-
-public class LogDepth extends V9Depth {
-
- public LogDepth(int base, int blockBinCount) {
- super(blockBinCount);
- this.BASE = Math.log(base);
- }
-
- @Override
- protected int logBase(double v) {
- return (int) (Math.log(1 + v) / BASE);
- }
-}
diff --git a/src/juicebox/data/v9depth/V9Depth.java b/src/juicebox/data/v9depth/V9Depth.java
deleted file mode 100644
index 87707cc3..00000000
--- a/src/juicebox/data/v9depth/V9Depth.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package juicebox.data.v9depth;
-
-public abstract class V9Depth {
- protected final int blockBinCount;
- protected double BASE;
-
- V9Depth(int blockBinCount) {
- this.blockBinCount = blockBinCount;
- }
-
- public static V9Depth setDepthMethod(int depthBase, int blockBinCount) {
- if (depthBase > 1) {
- return new LogDepth(depthBase, blockBinCount);
- } else if (depthBase < 0) {
- return new ConstantDepth(-depthBase, blockBinCount);
- }
-
- // Default
- return new LogDepth(2, blockBinCount);
- }
-
- public int getDepth(int val1, int val2) {
- return logBase(Math.abs(val1 - val2) / Math.sqrt(2) / blockBinCount);
- }
-
- protected abstract int logBase(double value);
-}
diff --git a/src/juicebox/encode/EncodeFileBrowser.java b/src/juicebox/encode/EncodeFileBrowser.java
deleted file mode 100644
index 52e96276..00000000
--- a/src/juicebox/encode/EncodeFileBrowser.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-package juicebox.encode;
-
-import com.jidesoft.swing.JideBoxLayout;
-import juicebox.HiCGlobals;
-import org.broad.igv.Globals;
-import org.broad.igv.ui.IGV;
-import org.broad.igv.util.Pair;
-import org.broad.igv.util.ParsingUtils;
-import org.broad.igv.util.ResourceLocator;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.text.NumberFormatter;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.text.ParseException;
-import java.util.List;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author Jim Robinson
- */
-public class EncodeFileBrowser extends JDialog {
-
- private static final long serialVersionUID = 9000016;
- private static final Map instanceMap = Collections.synchronizedMap(new HashMap<>());
- private static final NumberFormatter numberFormatter = new NumberFormatter();
- private final EncodeTableModel model;
- private JTable table;
- private JTextField filterTextField;
- private JLabel rowCountLabel;
- private boolean canceled;
-
- private EncodeFileBrowser(Frame owner, EncodeTableModel model) {
- super(owner);
- this.model = model;
- setModal(true);
- initComponents();
- init(model);
- }
-
- public synchronized static EncodeFileBrowser getInstance(String genomeId) throws IOException {
-
- String encodeGenomeId = getEncodeGenomeId(genomeId);
- EncodeFileBrowser instance = instanceMap.get(encodeGenomeId);
- if (instance == null) {
- Pair> records = getEncodeFileRecords(encodeGenomeId);
- if (records == null) {
- return null;
- }
- Frame parent = IGV.hasInstance() ? IGV.getMainFrame() : null;
- instance = new EncodeFileBrowser(parent, new EncodeTableModel(records.getFirst(), records.getSecond()));
- instanceMap.put(encodeGenomeId, instance);
- }
-
- return instance;
- }
-
-
- private static String getEncodeGenomeId(String genomeId) {
- if (genomeId.equals("b37") || genomeId.equals("1kg_v37")) return "hg19";
- else if (genomeId.equals("hg38")) return "GRCh38";
- else return genomeId;
- }
-
- private static Pair> getEncodeFileRecords(String genomeId) throws IOException {
- boolean urlVersion = false;
- InputStream is = null;
-
- try {
- //is = EncodeFileBrowser.class.getResourceAsStream("encode." + genomeId + ".txt");
- //if (is == null) {
- try {
- is = ParsingUtils.openInputStream("https://s3.amazonaws.com/igv.org.app/encode/" + getEncodeGenomeId(genomeId) + ".txt.gz");
- urlVersion = true;
- }
- catch (Exception error) {
- return null;
- }
- //}
- BufferedReader reader = new BufferedReader(new InputStreamReader(is), HiCGlobals.bufferSize);
-
- String[] headers = Globals.tabPattern.split(reader.readLine());
-
- List records = new ArrayList<>(20000);
- String nextLine;
- int pathLocation = 0;
- if (urlVersion) {
- pathLocation = Arrays.asList(headers).indexOf("HREF");
- }
- while ((nextLine = reader.readLine()) != null) {
- if (!nextLine.startsWith("#")) {
-
- String[] tokens = Globals.tabPattern.split(nextLine, -1);
- String path = tokens[pathLocation];
-
- // Filter BAMs for hic
- if (path == null || path.endsWith("bam")) continue;
- if (urlVersion) path = "https://www.encodeproject.org" + path;
-
- Map attributes = new HashMap<>();
- for (int i = 0; i < headers.length; i++) {
- String value = i < tokens.length ? tokens[i] : "";
- if (value.length() > 0) {
- attributes.put(headers[i], value);
- }
- }
-
- final EncodeFileRecord record = new EncodeFileRecord(path, attributes);
- if (record.hasMetaData()) records.add(record);
-
- }
-
- }
- return new Pair<>(headers, records);
- } finally {
- if (is != null) is.close();
- }
- }
-
- private void init(final EncodeTableModel model) {
- setModal(true);
- setTitle("Encode Production Data");
-
- table.setAutoCreateRowSorter(true);
- table.setModel(model);
- table.setRowSorter(model.getSorter());
- try {
- rowCountLabel.setText(numberFormatter.valueToString(table.getRowCount()) + " rows");
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
- table.setRowSelectionAllowed(false);
- table.setColumnSelectionAllowed(false);
-
- filterTextField.getDocument().addDocumentListener(
- new DocumentListener() {
- public void changedUpdate(DocumentEvent e) {
- updateFilter();
- }
-
- public void insertUpdate(DocumentEvent e) {
- updateFilter();
- }
-
- public void removeUpdate(DocumentEvent e) {
- updateFilter();
- }
- });
-
- }
-
- /**
- * Update the row filter regular expression from the expression in
- * the text box.
- */
- private void updateFilter() {
-
-
- RowFilter rf = null;
- //If current expression doesn't parse, don't update.
- try {
- rf = new RegexFilter(filterTextField.getText());
- } catch (java.util.regex.PatternSyntaxException | ClassCastException e) {
- return;
- }
- model.getSorter().setRowFilter(rf);
-
- try {
- rowCountLabel.setText(numberFormatter.valueToString(table.getRowCount()) + " rows");
- } catch (ParseException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
-
- private void loadButtonActionPerformed(ActionEvent e) {
- canceled = false;
- setVisible(false);
- }
-
- private void cancelButtonActionPerformed(ActionEvent e) {
- canceled = true;
- setVisible(false);
- }
-
- public boolean isCanceled() {
- return canceled;
- }
-
- /**
- * @return the list of VISIBLE selected records. Filtered records are not returned even if record.selected == true
- * @throws java.io.IOException
- */
- public List getSelectedRecords() {
-
- List selectedRecords = new ArrayList<>();
- List allRecords = model.getRecords();
-
- int rowCount = table.getRowCount();
- for (int i = 0; i < rowCount; i++) {
- int modelIdx = table.convertRowIndexToModel(i);
- EncodeFileRecord record = allRecords.get(modelIdx);
- if (record.isSelected()) {
- selectedRecords.add(record);
- }
- }
-
- return selectedRecords;
- }
-
- public void checkEncodeTracks(String track) {
- List allRecords = model.getRecords();
- int rowCount = table.getRowCount();
-
- for (int i = 0; i < rowCount; i++) {
- int modelIdx = table.convertRowIndexToModel(i);
- EncodeFileRecord record = allRecords.get(modelIdx);
- if (record.getTrackName().contains(track)) {
- record.setSelected(true);
- }
- }
- }
-
- public void remove(ResourceLocator locator) {
- List allRecords = model.getRecords();
- int rowCount = table.getRowCount();
- int i = 0;
- boolean notFound = true;
- while (i < rowCount && notFound) {
- int modelIdx = table.convertRowIndexToModel(i);
- EncodeFileRecord record = allRecords.get(modelIdx);
- ResourceLocator rl = new ResourceLocator(record.getPath());
- rl.setName(record.getTrackName());
- if (rl.equals(locator)) {
- record.setSelected(false);
- notFound = false;
- }
- i++;
- }
- }
-
- private void initComponents() {
-
- JPanel dialogPane = new JPanel();
- JPanel contentPanel = new JPanel();
- JScrollPane scrollPane1 = new JScrollPane();
- table = new JTable();
- JPanel filterPanel = new JPanel();
- JLabel filterLabel = new JLabel();
- filterTextField = new JTextField();
- rowCountLabel = new JLabel();
- JPanel buttonBar = new JPanel();
- JButton okButton = new JButton();
- JButton cancelButton = new JButton();
-
- getRootPane().setDefaultButton(okButton);
-
- final String filterToolTip = "Enter multiple filter strings separated by commas. e.g. GM12878, ChipSeq";
- filterLabel.setToolTipText(filterToolTip);
- filterTextField.setToolTipText(filterToolTip);
-
- //======== this ========
- Container contentPane = getContentPane();
- contentPane.setLayout(new BorderLayout());
-
- //======== dialogPane ========
-
- dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
- dialogPane.setLayout(new BorderLayout());
-
- //======== contentPanel ========
-
- contentPanel.setLayout(new BorderLayout(0, 10));
-
- //======== scrollPane1 ========
-
- scrollPane1.setViewportView(table);
-
- contentPanel.add(scrollPane1, BorderLayout.CENTER);
-
- //======== panel1 ========
-
- filterPanel.setLayout(new JideBoxLayout(filterPanel, JideBoxLayout.X_AXIS, 5));
-
- //---- label1 ----
- filterLabel.setText("Filter:");
- filterPanel.add(filterLabel, JideBoxLayout.FIX);
-
- //---- filterTextField ----
- filterPanel.add(filterTextField, JideBoxLayout.VARY);
-
- rowCountLabel.setHorizontalAlignment(JLabel.RIGHT);
- JPanel sillyPanel = new JPanel();
- sillyPanel.setLayout(new JideBoxLayout(sillyPanel, JideBoxLayout.X_AXIS, 0));
- sillyPanel.setPreferredSize(new Dimension(100, 28));
- sillyPanel.add(rowCountLabel, JideBoxLayout.VARY);
-
- filterPanel.add(sillyPanel, JideBoxLayout.FIX);
-
- contentPanel.add(filterPanel, BorderLayout.NORTH);
-
- dialogPane.add(contentPanel, BorderLayout.CENTER);
-
- //======== buttonBar ========
-
- buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
- buttonBar.setLayout(new GridBagLayout());
- ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[]{0, 85, 80};
- ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[]{1.0, 0.0, 0.0};
-
- //---- okButton ----
- okButton.setText("Load");
- okButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- loadButtonActionPerformed(e);
- }
- });
- buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 5), 0, 0));
-
- //---- cancelButton ----
- cancelButton.setText("Cancel");
- cancelButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- cancelButtonActionPerformed(e);
- }
- });
- buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 0), 0, 0));
-
- dialogPane.add(buttonBar, BorderLayout.SOUTH);
-
- contentPane.add(dialogPane, BorderLayout.CENTER);
- setSize(700, 620);
- setLocationRelativeTo(getOwner());
- }
-
- private class RegexFilter extends RowFilter {
-
- List> matchers;
-
- RegexFilter(String text) {
-
- if (text == null) {
- throw new IllegalArgumentException("Pattern must be non-null");
- }
- matchers = new ArrayList<>();
- String[] tokens = Globals.whitespacePattern.split(text);
- for (String t : tokens) {
- // If token contains an = sign apply to specified column only
- String column = "*";
- String value = t.trim();
- if (t.contains("=")) {
- String[] kv = Globals.equalPattern.split(t);
- if (kv.length > 1) {
- column = kv[0].trim();
- value = kv[1].trim();
- } else {
- value = kv[0]; // Value is column name until more input is entered
- }
- }
-
- matchers.add(new Pair<>(column, Pattern.compile("(?i)" + value).matcher("")));
- }
-
- }
-
- /**
- * Include row if each matcher succeeds in at least one column. In other words all the conditions
- * are combined with "and"
- *
- * @param value value to check
- * @return if matched
- */
- @Override
- public boolean include(Entry extends EncodeTableModel, ?> value) {
-
- for (Pair entry : matchers) {
- String column = entry.getFirst();
- Matcher matcher = entry.getSecond();
-
-
- // Search for a match in at least one column. The first column is the checkbox.
- boolean found = false; // Pessimistic
- int nColumns = table.getColumnCount();
- for (int index = 1; index < nColumns; index++) {
-
- // Include column headings in search. This is to prevent premature filtering when entering a
- // specific column condition (e.g. cataType=ChipSeq)
- matcher.reset(table.getColumnName(index).toLowerCase());
- if (matcher.find()) {
- found = true;
- break;
- }
-
- boolean wildcard = column.equals("*");
- if (wildcard || column.equalsIgnoreCase(table.getColumnName(index))) {
- matcher.reset(value.getStringValue(index));
- if (matcher.find()) {
- found = true;
- break;
- }
- }
- }
- if (!found) return false;
- }
- return true; // If we get here we matched them all
- }
-
- }
-
-}
diff --git a/src/juicebox/encode/EncodeFileRecord.java b/src/juicebox/encode/EncodeFileRecord.java
deleted file mode 100644
index 8b1065fe..00000000
--- a/src/juicebox/encode/EncodeFileRecord.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-package juicebox.encode;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * @author jrobinso
- * Date: 10/31/13
- * Time: 10:11 PM
- */
-public class EncodeFileRecord {
-
- private final String path;
- private final Map attributes;
- private boolean selected = false;
- private String trackName;
-
- public EncodeFileRecord(String path, Map attributes) {
- this.path = path;
- this.attributes = attributes;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getFileType() {
- //String off trailing gz, if present
- String filetype = path;
- if (filetype.endsWith(".gz")) {
- filetype = filetype.substring(0, filetype.length() - 3);
- }
- int idx = filetype.lastIndexOf(".");
- return filetype.substring(idx + 1);
- }
-
- public String getAttributeValue(String name) {
- String value = attributes.get(name);
- if (name.equals("type") && value == null) value = getFileType();
- return value;
- }
-
- public Collection getAttributeNames() {
- return attributes.keySet();
- }
-
- public boolean containsText(String filter) {
- for (String value : attributes.values()) {
- if (value.contains(filter)) return true;
- }
- return false;
- }
-
- boolean isSelected() {
- return selected;
- }
-
- public void setSelected(boolean selected) {
- this.selected = selected;
- }
-
- /**
- * Return a friendly name for the track. Unfortunately it is neccessary to hardcode certain attributes.
- *
- * @return
- */
- public String getTrackName() {
-
- if (trackName == null) {
- StringBuilder sb = new StringBuilder();
- if (attributes.containsKey("cell")) sb.append(attributes.get("cell")).append(" ");
- if (attributes.containsKey("antibody")) sb.append(attributes.get("antibody")).append(" ");
- if (attributes.containsKey("dataType")) sb.append(attributes.get("dataType")).append(" ");
- if (attributes.containsKey("view")) sb.append(attributes.get("view")).append(" ");
- if (attributes.containsKey("replicate")) sb.append("rep ").append(attributes.get("replicate"));
-
- trackName = sb.toString().trim();
- if (sb.length() == 0) trackName = (new File(path)).getName();
- }
-
- return trackName;
-
- }
-
- /**
- * Test if record has a eough of meta-data to be interpretable
- *
- * @return
- */
- public boolean hasMetaData() {
-
- return (attributes.containsKey("cell")) || (attributes.containsKey("antibody") || attributes.containsKey("Biosample"));
-
- }
-}
diff --git a/src/juicebox/encode/EncodeTableModel.java b/src/juicebox/encode/EncodeTableModel.java
deleted file mode 100644
index 55a14bf5..00000000
--- a/src/juicebox/encode/EncodeTableModel.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2021 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-package juicebox.encode;
-
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableModel;
-import javax.swing.table.TableRowSorter;
-import javax.swing.table.TableStringConverter;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * //wgEncodeBroadHistoneGm12878H3k4me1StdSig.bigWig
- * // size=346M;
- * // dateSubmitted=2009-01-05;
- * // dataType=ChipSeq;
- * // cell=GM12878;
- * // antibody=H3K4me1;
- * // control=std;
- * // expId=33;
- * // setType=exp;
- * // controlId=GM12878/Input/std;
- * // subId=2804;
- * // dataVersion=ENCODE Jan 2011 Freeze;
- * // dateResubmitted=2010-11-05;
- * // grant=Bernstein;
- * // lab=Broad;
- * // view=Signal;
- * // type=bigWig;
- * // dccAccession=wgEncodeEH000033;
- * // origAssembly=hg18
- *
- * @author jrobinso
- * Date: 10/31/13
- * Time: 10:09 PM
- */
-class EncodeTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 9000015;
- private final String[] columnHeadings;
- private final List records;
- private final TableRowSorter sorter;
-
- public EncodeTableModel(String[] headings, List records) {
-
- this.records = records;
-
- List tmp = new ArrayList<>();
- tmp.add(""); // Checkbox heading
- for (String h : headings) {
- String heading = h.trim();
- if (heading.length() > 0 && !"path".equals(heading)) {
- tmp.add(heading);
- }
- }
- //tmp.add("path");
- columnHeadings = tmp.toArray(new String[tmp.size()]);
-
-
- sorter = new TableRowSorter<>(this);
-
- sorter.setStringConverter(new TableStringConverter() {
- @Override
- public String toString(TableModel model, int row, int column) {
- final Object value = model.getValueAt(row, column);
- return value == null ? "" : value.toString();
- }
- });
- }
-
- public TableRowSorter getSorter() {
- return sorter;
- }
-
- @Override
- public Class> getColumnClass(int columnIndex) {
- return columnIndex == 0 ? Boolean.class : String.class;
- }
-
- @Override
- public String getColumnName(int column) {
- return columnHeadings[column];
- }
-
- @Override
- public int getRowCount() {
- return records.size();
- }
-
- @Override
- public int getColumnCount() {
- return columnHeadings.length;
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
-
- if (rowIndex >= records.size() || columnIndex >= columnHeadings.length) {
- return null;
- }
-
- EncodeFileRecord record = records.get(rowIndex);
- if (columnIndex == 0) {
- return record.isSelected();
- } else {
- String att = columnHeadings[columnIndex];
- return record.getAttributeValue(att);
- }
-
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return columnIndex == 0;
- }
-
- @Override
- public void setValueAt(Object value, int row, int col) {
- if (col == 0) {
- records.get(row).setSelected((Boolean) value);
- }
- fireTableCellUpdated(row, col);
- }
-
- public List getRecords() {
- return records;
- }
-}
\ No newline at end of file
diff --git a/src/juicebox/encode/UCSCEncodeUtils.java b/src/juicebox/encode/UCSCEncodeUtils.java
deleted file mode 100644
index e2bfffee..00000000
--- a/src/juicebox/encode/UCSCEncodeUtils.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2011-2020 Broad Institute, Aiden Lab, Rice University, Baylor College of Medicine
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-package juicebox.encode;
-
-import juicebox.HiCGlobals;
-import org.broad.igv.Globals;
-import org.broad.igv.util.HttpUtils;
-import org.broad.igv.util.ParsingUtils;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * @author jrobinso
- * Date: 10/31/13
- * Time: 12:16 PM
- */
-class UCSCEncodeUtils {
-
- private static final HashSet labs = new HashSet<>();
- private static final HashSet dataTypes = new HashSet<>();
- private static final HashSet cells = new HashSet<>();
- private static final HashSet antibodies = new HashSet<>();
- private static final HashSet fileTypes = new HashSet<>();
- private static final HashSet allHeaders = new LinkedHashSet<>();
-
- private static final List rnaChipQualifiers = Arrays.asList("CellTotal", "Longnonpolya", "Longpolya",
- "NucleolusTotal", "ChromatinTotal", "ChromatinTotal", "NucleoplasmTotal");
- private static final String[] columnHeadings = {"cell", "dataType", "antibody", "view", "replicate", "type", "lab"};
- private static final HashSet knownFileTypes = new HashSet<>(Arrays.asList("bam", "bigBed", "bed", "bb", "bw", "bigWig", "gtf", "broadPeak", "narrowPeak", "gff"));
-
- public static void main(String[] args) throws IOException {
-
-
-// List