From 947a5562263feca42bba1a56dc99d2fc489cea68 Mon Sep 17 00:00:00 2001 From: MahdiSayadSadr <61241675+MahdiSayadSadr@users.noreply.github.com> Date: Fri, 7 Oct 2022 10:54:08 -0500 Subject: [PATCH 1/7] fixing shift click bug --- src/juicebox/assembly/AssemblyStateTracker.java | 2 +- src/juicebox/windowui/SaveAssemblyDialog.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/juicebox/assembly/AssemblyStateTracker.java b/src/juicebox/assembly/AssemblyStateTracker.java index 9dbbb167d..25bd97fab 100644 --- a/src/juicebox/assembly/AssemblyStateTracker.java +++ b/src/juicebox/assembly/AssemblyStateTracker.java @@ -48,7 +48,7 @@ public AssemblyStateTracker(AssemblyScaffoldHandler assemblyScaffoldHandler, Sup redoStack = new Stack<>(); this.initialAssemblyScaffoldHandler = assemblyScaffoldHandler; this.superAdapter = superAdapter; - this.autoSaveFileName = DirectoryManager.getHiCDirectory() + "/" + (SuperAdapter.getDatasetTitle().split(".+?/(?=[^/]+$)")[1]).split("\\.(?=[^\\.]+$)")[0] + ".review.autosave"; + this.autoSaveFileName = SuperAdapter.getDatasetTitle().split("\\.(?=[^\\.]+$)")[0] + ".review.autosave"; } public AssemblyScaffoldHandler getAssemblyHandler() { diff --git a/src/juicebox/windowui/SaveAssemblyDialog.java b/src/juicebox/windowui/SaveAssemblyDialog.java index 526800623..a8470def9 100644 --- a/src/juicebox/windowui/SaveAssemblyDialog.java +++ b/src/juicebox/windowui/SaveAssemblyDialog.java @@ -73,10 +73,10 @@ private void menuOptions() { assemblyFileExporter.exportAssemblyFile(); } - String autoSaveFileName = DirectoryManager.getHiCDirectory() + "/" + (SuperAdapter.getDatasetTitle().split(".+?/(?=[^/]+$)")[1]).split("\\.(?=[^\\.]+$)")[0] + ".review.autosave.assembly"; + String autoSaveFileName = SuperAdapter.getDatasetTitle().split("\\.(?=[^\\.]+$)")[0] + ".review.autosave.assembly"; File autoSaveFile = new File(autoSaveFileName); autoSaveFile.delete(); } } } -} +} \ No newline at end of file From 465091a04973691b565e27c33bf8be56f72dde3c Mon Sep 17 00:00:00 2001 From: MahdiSayadSadr <61241675+MahdiSayadSadr@users.noreply.github.com> Date: Fri, 7 Oct 2022 14:49:29 -0500 Subject: [PATCH 2/7] fixing autosave path --- src/juicebox/MainWindow.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/juicebox/MainWindow.java b/src/juicebox/MainWindow.java index 92776cd3a..84fd382ff 100644 --- a/src/juicebox/MainWindow.java +++ b/src/juicebox/MainWindow.java @@ -420,11 +420,9 @@ public void exitActionPerformed() { if (option == 0) { setVisible(false); dispose(); - String autoSaveFileName = DirectoryManager.getHiCDirectory() + "/" + - System.nanoTime() + ".review.autosave.assembly"; + String autoSaveFileName = System.nanoTime() + ".review.autosave.assembly"; try { - autoSaveFileName = DirectoryManager.getHiCDirectory() + "/" + - (SuperAdapter.getDatasetTitle().split(".+?/(?=[^/]+$)")[1]).split("\\.(?=[^\\.]+$)")[0] + + autoSaveFileName = SuperAdapter.getDatasetTitle().split("\\.(?=[^\\.]+$)")[0] + ".review.autosave.assembly"; } catch (Exception e) { System.err.println("Unable to get desired file name"); From d831292f8309fbef3f18ce9c7c7fbc1c7acf3a1e Mon Sep 17 00:00:00 2001 From: MahdiSayadSadr <61241675+MahdiSayadSadr@users.noreply.github.com> Date: Sat, 29 Oct 2022 10:11:11 -0500 Subject: [PATCH 3/7] adding tester class --- src/juicebox/AnnotatedExample.java | 117 +++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 src/juicebox/AnnotatedExample.java diff --git a/src/juicebox/AnnotatedExample.java b/src/juicebox/AnnotatedExample.java new file mode 100644 index 000000000..599e4da90 --- /dev/null +++ b/src/juicebox/AnnotatedExample.java @@ -0,0 +1,117 @@ +package juicebox; + +import javastraw.reader.Dataset; +import javastraw.reader.basics.Chromosome; +import javastraw.reader.block.Block; +import javastraw.reader.block.ContactRecord; +import javastraw.reader.mzd.Matrix; +import javastraw.reader.mzd.MatrixZoomData; +import javastraw.reader.norm.NormalizationPicker; +import javastraw.reader.type.HiCZoom; +import javastraw.reader.type.NormalizationType; +import javastraw.tools.HiCFileTools; + +import java.util.Iterator; +import java.util.List; + +public class AnnotatedExample { + public static void main(String[] args) { + // do you want to cache portions of the file? + // this uses more RAM, but if you want to repeatedly + // query nearby regions, it can improve speed by a lot + boolean useCache = false; + String filename = "https://www.dropbox.com/s/a6ykz8ajgszv0b6/Trachops_cirrhosus.rawchrom.hic"; + + // create a hic dataset object + + long s1 = System.nanoTime(); + Dataset ds = HiCFileTools.extractDatasetForCLT(filename, false, useCache, false); + long s2 = System.nanoTime(); + System.out.println((s2-s1)*1e-9); + System.out.println("^^^^ line 28 execution line"); + + // pick the normalization we would like + // this line will check multiple possible norms + // and pick whichever is available (in order of preference) + + long s3 = System.nanoTime(); + NormalizationType norm = NormalizationPicker.getFirstValidNormInThisOrder(ds, new String[]{"KR", "SCALE", "VC", "VC_SQRT", "NONE"}); + long s4 = System.nanoTime(); + System.out.println((s4-s3)*1e-9); + System.out.println("^^^^ line 40 execution line"); + System.out.println("Norm being used: " + norm.getLabel()); + + // let's set our resolution + int resolution = 5000; + + // let's grab the chromosomes + + long s5 = System.nanoTime(); + Chromosome[] chromosomes = ds.getChromosomeHandler().getChromosomeArrayWithoutAllByAll(); + long s6 = System.nanoTime(); + System.out.println((s6-s5)*1e-9); + System.out.println("^^^^ line 52 execution line"); + + + // now let's iterate on every chromosome (only intra-chromosomal regions for now) + for (Chromosome chromosome : chromosomes) { + long s7 = System.nanoTime(); + Matrix matrix = ds.getMatrix(chromosome, chromosome); + long s8 = System.nanoTime(); + System.out.println((s8-s7)*1e-9); + System.out.println("^^^^ line 59 execution line"); + + + if (matrix == null) continue; + long s9 = System.nanoTime(); + + MatrixZoomData zd = matrix.getZoomData(new HiCZoom(resolution)); + long s10 = System.nanoTime(); + System.out.println((s10-s9)*1e-9); + System.out.println("^^^^ line 70 execution line"); + + if (zd == null) continue; + + // zd is now a data structure that contains pointers to the data + // *** Let's show 2 different ways to access data *** + + // OPTION 2 + // just grab sparse data for a specific region + + // choose your setting for when the diagonal is in the region + boolean getDataUnderTheDiagonal = true; + + // our bounds will be binXStart, binYStart, binXEnd, binYEnd + // these are in BIN coordinates, not genome coordinates + int binXStart = 500, binYStart = 600, binXEnd = 1000, binYEnd = 1200; + long s11 = System.nanoTime(); + List blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm, getDataUnderTheDiagonal); + long s12 = System.nanoTime(); + System.out.println((s12-s11)*1e-9); + System.out.println("^^^^ line 88 execution line"); + + + long s13 = System.nanoTime(); + for (Block b : blocks) { + if (b != null) { + for (ContactRecord rec : b.getContactRecords()) { + if (rec.getCounts() > 0) { // will skip NaNs + // can choose to use the BIN coordinates + int binX = rec.getBinX(); + int binY = rec.getBinY(); + + // you could choose to use relative coordinates for the box given + int relativeX = rec.getBinX() - binXStart; + int relativeY = rec.getBinY() - binYStart; + + float counts = rec.getCounts(); + } + } + } + } + long s14 = System.nanoTime(); + System.out.println((s14-s13)*1e-9); + System.out.println("^^^^ for loop execution line"); + } + } +} \ No newline at end of file From da75f82e5dae83e39efa11f8cf74f0cdeb5a8262 Mon Sep 17 00:00:00 2001 From: Muhammad Saad Shamim Date: Sat, 29 Oct 2022 11:31:43 -0500 Subject: [PATCH 4/7] some fixes --- .idea/misc.xml | 2 +- src/juicebox/AnnotatedExample.java | 89 +++++++++++++++--------------- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 52401e0c3..89ac15670 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/src/juicebox/AnnotatedExample.java b/src/juicebox/AnnotatedExample.java index 599e4da90..742d2ef0b 100644 --- a/src/juicebox/AnnotatedExample.java +++ b/src/juicebox/AnnotatedExample.java @@ -1,9 +1,32 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2011-2022 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; import javastraw.reader.Dataset; import javastraw.reader.basics.Chromosome; import javastraw.reader.block.Block; -import javastraw.reader.block.ContactRecord; import javastraw.reader.mzd.Matrix; import javastraw.reader.mzd.MatrixZoomData; import javastraw.reader.norm.NormalizationPicker; @@ -11,7 +34,6 @@ import javastraw.reader.type.NormalizationType; import javastraw.tools.HiCFileTools; -import java.util.Iterator; import java.util.List; public class AnnotatedExample { @@ -21,54 +43,43 @@ public static void main(String[] args) { // query nearby regions, it can improve speed by a lot boolean useCache = false; String filename = "https://www.dropbox.com/s/a6ykz8ajgszv0b6/Trachops_cirrhosus.rawchrom.hic"; + filename = juicebox.data.HiCFileTools.cleanUpDropboxURL(filename); // create a hic dataset object long s1 = System.nanoTime(); Dataset ds = HiCFileTools.extractDatasetForCLT(filename, false, useCache, false); long s2 = System.nanoTime(); - System.out.println((s2-s1)*1e-9); - System.out.println("^^^^ line 28 execution line"); + System.out.println((s2 - s1) * 1e-9); + System.out.println("^^^^ line 29 execution line"); // pick the normalization we would like // this line will check multiple possible norms // and pick whichever is available (in order of preference) - long s3 = System.nanoTime(); NormalizationType norm = NormalizationPicker.getFirstValidNormInThisOrder(ds, new String[]{"KR", "SCALE", "VC", "VC_SQRT", "NONE"}); - long s4 = System.nanoTime(); - System.out.println((s4-s3)*1e-9); - System.out.println("^^^^ line 40 execution line"); System.out.println("Norm being used: " + norm.getLabel()); - // let's set our resolution int resolution = 5000; - - // let's grab the chromosomes - - long s5 = System.nanoTime(); Chromosome[] chromosomes = ds.getChromosomeHandler().getChromosomeArrayWithoutAllByAll(); - long s6 = System.nanoTime(); - System.out.println((s6-s5)*1e-9); - System.out.println("^^^^ line 52 execution line"); // now let's iterate on every chromosome (only intra-chromosomal regions for now) for (Chromosome chromosome : chromosomes) { + if (chromosome.getIndex() > 6) continue; long s7 = System.nanoTime(); Matrix matrix = ds.getMatrix(chromosome, chromosome); long s8 = System.nanoTime(); - System.out.println((s8-s7)*1e-9); - System.out.println("^^^^ line 59 execution line"); - + System.out.println((s8 - s7) * 1e-9); + System.out.println("^^^^ line 49 execution line"); if (matrix == null) continue; long s9 = System.nanoTime(); MatrixZoomData zd = matrix.getZoomData(new HiCZoom(resolution)); long s10 = System.nanoTime(); - System.out.println((s10-s9)*1e-9); - System.out.println("^^^^ line 70 execution line"); + System.out.println((s10 - s9) * 1e-9); + System.out.println("^^^^ line 57 execution line"); if (zd == null) continue; @@ -87,31 +98,19 @@ public static void main(String[] args) { long s11 = System.nanoTime(); List blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm, getDataUnderTheDiagonal); long s12 = System.nanoTime(); - System.out.println((s12-s11)*1e-9); + System.out.println((s12 - s11) * 1e-9); + System.out.println("^^^^ line 77 execution line"); + + + binXStart = 1500; + binYStart = 1600; + binXEnd = 2000; + binYEnd = 2200; + s11 = System.nanoTime(); + blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm, getDataUnderTheDiagonal); + s12 = System.nanoTime(); + System.out.println((s12 - s11) * 1e-9); System.out.println("^^^^ line 88 execution line"); - - - long s13 = System.nanoTime(); - for (Block b : blocks) { - if (b != null) { - for (ContactRecord rec : b.getContactRecords()) { - if (rec.getCounts() > 0) { // will skip NaNs - // can choose to use the BIN coordinates - int binX = rec.getBinX(); - int binY = rec.getBinY(); - - // you could choose to use relative coordinates for the box given - int relativeX = rec.getBinX() - binXStart; - int relativeY = rec.getBinY() - binYStart; - - float counts = rec.getCounts(); - } - } - } - } - long s14 = System.nanoTime(); - System.out.println((s14-s13)*1e-9); - System.out.println("^^^^ for loop execution line"); } } } \ No newline at end of file From 4cd5b2ea732b2172b1566a7ad11914c84ba0021c Mon Sep 17 00:00:00 2001 From: MahdiSayadSadr <61241675+MahdiSayadSadr@users.noreply.github.com> Date: Sat, 29 Oct 2022 15:23:18 -0500 Subject: [PATCH 5/7] testingclass updated --- src/juicebox/AnnotatedExample.java | 113 +++++++++++++++-------------- 1 file changed, 59 insertions(+), 54 deletions(-) diff --git a/src/juicebox/AnnotatedExample.java b/src/juicebox/AnnotatedExample.java index 599e4da90..b440c6783 100644 --- a/src/juicebox/AnnotatedExample.java +++ b/src/juicebox/AnnotatedExample.java @@ -1,16 +1,37 @@ -package juicebox; +/* + * The MIT License (MIT) + * + * Copyright (c) 2011-2022 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. + */ + -import javastraw.reader.Dataset; -import javastraw.reader.basics.Chromosome; -import javastraw.reader.block.Block; -import javastraw.reader.block.ContactRecord; -import javastraw.reader.mzd.Matrix; -import javastraw.reader.mzd.MatrixZoomData; +package juicebox; import javastraw.reader.norm.NormalizationPicker; -import javastraw.reader.type.HiCZoom; -import javastraw.reader.type.NormalizationType; -import javastraw.tools.HiCFileTools; +import juicebox.data.*; +import juicebox.data.basics.Chromosome; +import juicebox.windowui.HiCZoom; +import juicebox.windowui.NormalizationHandler; +import juicebox.windowui.NormalizationType; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -21,54 +42,51 @@ public static void main(String[] args) { // query nearby regions, it can improve speed by a lot boolean useCache = false; String filename = "https://www.dropbox.com/s/a6ykz8ajgszv0b6/Trachops_cirrhosus.rawchrom.hic"; + filename = juicebox.data.HiCFileTools.cleanUpDropboxURL(filename); // create a hic dataset object long s1 = System.nanoTime(); - Dataset ds = HiCFileTools.extractDatasetForCLT(filename, false, useCache, false); + + List files = new ArrayList<>(); + files.add(filename); + Dataset ds = HiCFileTools.extractDatasetForCLT(files, false); long s2 = System.nanoTime(); - System.out.println((s2-s1)*1e-9); - System.out.println("^^^^ line 28 execution line"); + System.out.println((s2 - s1) * 1e-9); + System.out.println("^^^^ line 29 execution line"); // pick the normalization we would like // this line will check multiple possible norms // and pick whichever is available (in order of preference) - long s3 = System.nanoTime(); - NormalizationType norm = NormalizationPicker.getFirstValidNormInThisOrder(ds, new String[]{"KR", "SCALE", "VC", "VC_SQRT", "NONE"}); - long s4 = System.nanoTime(); - System.out.println((s4-s3)*1e-9); - System.out.println("^^^^ line 40 execution line"); + NormalizationType norm = NormalizationHandler.NONE; + System.out.println("Norm being used: " + norm.getLabel()); - // let's set our resolution int resolution = 5000; - // let's grab the chromosomes - long s5 = System.nanoTime(); Chromosome[] chromosomes = ds.getChromosomeHandler().getChromosomeArrayWithoutAllByAll(); - long s6 = System.nanoTime(); - System.out.println((s6-s5)*1e-9); - System.out.println("^^^^ line 52 execution line"); + // now let's iterate on every chromosome (only intra-chromosomal regions for now) for (Chromosome chromosome : chromosomes) { + if (chromosome.getIndex() > 6) continue; long s7 = System.nanoTime(); Matrix matrix = ds.getMatrix(chromosome, chromosome); long s8 = System.nanoTime(); - System.out.println((s8-s7)*1e-9); - System.out.println("^^^^ line 59 execution line"); + System.out.println((s8 - s7) * 1e-9); + System.out.println("^^^^ line 49 execution line"); if (matrix == null) continue; long s9 = System.nanoTime(); - MatrixZoomData zd = matrix.getZoomData(new HiCZoom(resolution)); + MatrixZoomData zd = matrix.getZoomData(new HiCZoom(HiC.Unit.BP, resolution)); long s10 = System.nanoTime(); - System.out.println((s10-s9)*1e-9); - System.out.println("^^^^ line 70 execution line"); + System.out.println((s10 - s9) * 1e-9); + System.out.println("^^^^ line 57 execution line"); if (zd == null) continue; @@ -85,33 +103,20 @@ public static void main(String[] args) { // these are in BIN coordinates, not genome coordinates int binXStart = 500, binYStart = 600, binXEnd = 1000, binYEnd = 1200; long s11 = System.nanoTime(); - List blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm, getDataUnderTheDiagonal); + List blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm,false, getDataUnderTheDiagonal); long s12 = System.nanoTime(); - System.out.println((s12-s11)*1e-9); + System.out.println((s12 - s11) * 1e-9); + System.out.println("^^^^ line 77 execution line"); + + binXStart = 1500; + binYStart = 1600; + binXEnd = 2000; + binYEnd = 2200; + s11 = System.nanoTime(); + blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm,false, getDataUnderTheDiagonal); + s12 = System.nanoTime(); + System.out.println((s12 - s11) * 1e-9); System.out.println("^^^^ line 88 execution line"); - - - long s13 = System.nanoTime(); - for (Block b : blocks) { - if (b != null) { - for (ContactRecord rec : b.getContactRecords()) { - if (rec.getCounts() > 0) { // will skip NaNs - // can choose to use the BIN coordinates - int binX = rec.getBinX(); - int binY = rec.getBinY(); - - // you could choose to use relative coordinates for the box given - int relativeX = rec.getBinX() - binXStart; - int relativeY = rec.getBinY() - binYStart; - - float counts = rec.getCounts(); - } - } - } - } - long s14 = System.nanoTime(); - System.out.println((s14-s13)*1e-9); - System.out.println("^^^^ for loop execution line"); } } } \ No newline at end of file From 00c9d284e18afe4238df653fc3600cd3abf3a7fe Mon Sep 17 00:00:00 2001 From: MahdiSayadSadr <61241675+MahdiSayadSadr@users.noreply.github.com> Date: Tue, 1 Nov 2022 09:05:45 -0500 Subject: [PATCH 6/7] updating tester class to write times to csv --- src/juicebox/AnnotatedExample.java | 94 +++++++++++++++++++----------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/src/juicebox/AnnotatedExample.java b/src/juicebox/AnnotatedExample.java index 803715657..f572a491d 100644 --- a/src/juicebox/AnnotatedExample.java +++ b/src/juicebox/AnnotatedExample.java @@ -22,37 +22,40 @@ * THE SOFTWARE. */ -<<<<<<< HEAD package juicebox; -======= -package juicebox; +import java.io.*; -import javastraw.reader.Dataset; -import javastraw.reader.basics.Chromosome; -import javastraw.reader.block.Block; -import javastraw.reader.mzd.Matrix; -import javastraw.reader.mzd.MatrixZoomData; ->>>>>>> da75f82e5dae83e39efa11f8cf74f0cdeb5a8262 -import javastraw.reader.norm.NormalizationPicker; +import com.opencsv.CSVWriter; import juicebox.data.*; import juicebox.data.basics.Chromosome; import juicebox.windowui.HiCZoom; import juicebox.windowui.NormalizationHandler; import juicebox.windowui.NormalizationType; -<<<<<<< HEAD +import java.io.File; +import java.io.FileInputStream; import java.util.ArrayList; import java.util.Iterator; -======= ->>>>>>> da75f82e5dae83e39efa11f8cf74f0cdeb5a8262 import java.util.List; + +import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + public class AnnotatedExample { - public static void main(String[] args) { + public static void main(String[] args) throws IOException { // do you want to cache portions of the file? // this uses more RAM, but if you want to repeatedly // query nearby regions, it can improve speed by a lot + + String[] timedata = { "80", "10", "620","100", "230" }; + boolean useCache = false; String filename = "https://www.dropbox.com/s/a6ykz8ajgszv0b6/Trachops_cirrhosus.rawchrom.hic"; filename = juicebox.data.HiCFileTools.cleanUpDropboxURL(filename); @@ -68,11 +71,12 @@ public static void main(String[] args) { System.out.println((s2 - s1) * 1e-9); System.out.println("^^^^ line 29 execution line"); + timedata[0]=String.valueOf((s2 - s1) * 1e-9); + // pick the normalization we would like // this line will check multiple possible norms // and pick whichever is available (in order of preference) -<<<<<<< HEAD NormalizationType norm = NormalizationHandler.NONE; System.out.println("Norm being used: " + norm.getLabel()); @@ -80,15 +84,8 @@ public static void main(String[] args) { int resolution = 5000; - Chromosome[] chromosomes = ds.getChromosomeHandler().getChromosomeArrayWithoutAllByAll(); - -======= - NormalizationType norm = NormalizationPicker.getFirstValidNormInThisOrder(ds, new String[]{"KR", "SCALE", "VC", "VC_SQRT", "NONE"}); - System.out.println("Norm being used: " + norm.getLabel()); + juicebox.data.basics.Chromosome[] chromosomes = ds.getChromosomeHandler().getChromosomeArrayWithoutAllByAll(); - int resolution = 5000; - Chromosome[] chromosomes = ds.getChromosomeHandler().getChromosomeArrayWithoutAllByAll(); ->>>>>>> da75f82e5dae83e39efa11f8cf74f0cdeb5a8262 // now let's iterate on every chromosome (only intra-chromosomal regions for now) @@ -99,10 +96,10 @@ public static void main(String[] args) { long s8 = System.nanoTime(); System.out.println((s8 - s7) * 1e-9); System.out.println("^^^^ line 49 execution line"); -<<<<<<< HEAD -======= ->>>>>>> da75f82e5dae83e39efa11f8cf74f0cdeb5a8262 + timedata[1]=String.valueOf((s8 - s7) * 1e-9); + + if (matrix == null) continue; long s9 = System.nanoTime(); @@ -112,6 +109,11 @@ public static void main(String[] args) { System.out.println((s10 - s9) * 1e-9); System.out.println("^^^^ line 57 execution line"); + timedata[2]=String.valueOf((s10 - s9) * 1e-9); + + + + if (zd == null) continue; // zd is now a data structure that contains pointers to the data @@ -132,23 +134,49 @@ public static void main(String[] args) { System.out.println((s12 - s11) * 1e-9); System.out.println("^^^^ line 77 execution line"); -<<<<<<< HEAD -======= + timedata[3]=String.valueOf((s12 - s11) * 1e-9); + ->>>>>>> da75f82e5dae83e39efa11f8cf74f0cdeb5a8262 binXStart = 1500; binYStart = 1600; binXEnd = 2000; binYEnd = 2200; s11 = System.nanoTime(); -<<<<<<< HEAD blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm,false, getDataUnderTheDiagonal); -======= - blocks = zd.getNormalizedBlocksOverlapping(binXStart, binYStart, binXEnd, binYEnd, norm, getDataUnderTheDiagonal); ->>>>>>> da75f82e5dae83e39efa11f8cf74f0cdeb5a8262 s12 = System.nanoTime(); System.out.println((s12 - s11) * 1e-9); System.out.println("^^^^ line 88 execution line"); + + timedata[4]=String.valueOf((s12 - s11) * 1e-9); + + + //change file path for the different versions of juicebox you are testing, and to wherever you want to store the file. I had two different paths. + String csvFilePath = "C:\\Users\\Mahdi\\Downloads\\Juicebox2.csv"; + File f = new File(csvFilePath); + + if (f.exists()){ + CSVWriter writer = new CSVWriter(new FileWriter(csvFilePath, true)); + + writer.writeNext(timedata); + + writer.close(); + } + + else{ + FileWriter outputfile = new FileWriter(csvFilePath); + + // create CSVWriter object filewriter object as parameter + CSVWriter writer = new CSVWriter(outputfile); + + // adding header to csv + String[] header = { "L29", "L49", "L57", "L77", "L88" }; + writer.writeNext(header); + + // add data to csv + writer.writeNext(timedata); + writer.close(); + } + } } } \ No newline at end of file From 7c530c79994b4d94bf3730eb60a096ae2fd4fbdb Mon Sep 17 00:00:00 2001 From: MahdiSayadSadr <61241675+MahdiSayadSadr@users.noreply.github.com> Date: Tue, 1 Nov 2022 09:08:55 -0500 Subject: [PATCH 7/7] updating importa --- src/juicebox/AnnotatedExample.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/juicebox/AnnotatedExample.java b/src/juicebox/AnnotatedExample.java index f572a491d..d85dea0b4 100644 --- a/src/juicebox/AnnotatedExample.java +++ b/src/juicebox/AnnotatedExample.java @@ -34,20 +34,10 @@ import juicebox.windowui.NormalizationType; import java.io.File; -import java.io.FileInputStream; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; -import org.apache.poi.EncryptedDocumentException; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; - public class AnnotatedExample { public static void main(String[] args) throws IOException { // do you want to cache portions of the file?