From ac36e15c2019b3939ff39fc95a0ad937cd6a556c Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Fri, 22 May 2020 11:42:06 -0400 Subject: [PATCH 01/27] test interchromosomal interaction --- src/process/DumpInterChromosomal.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/process/DumpInterChromosomal.java diff --git a/src/process/DumpInterChromosomal.java b/src/process/DumpInterChromosomal.java new file mode 100644 index 0000000..93007a0 --- /dev/null +++ b/src/process/DumpInterChromosomal.java @@ -0,0 +1,4 @@ +package process; + +public class DumpInterChromosomal { +} From 39135ae7c2841f7aee30a6eb134a0df9623eb76c Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Fri, 22 May 2020 11:48:26 -0400 Subject: [PATCH 02/27] test interchromosomal interaction --- src/process/DumpInterChromosomal.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/process/DumpInterChromosomal.java b/src/process/DumpInterChromosomal.java index 93007a0..470bf62 100644 --- a/src/process/DumpInterChromosomal.java +++ b/src/process/DumpInterChromosomal.java @@ -1,4 +1,8 @@ package process; public class DumpInterChromosomal { + + public DumpInterChromosomal(){ + + } } From 6e44aaff161889ce292bfa61c7f1ce62a40ea417 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Sat, 22 Aug 2020 18:37:26 -0400 Subject: [PATCH 03/27] add differential test to detect loop. Start the new class organisation for inter chromo loops detection. --- src/process/CallLoops.java | 5 +- src/process/CallLoopsInter.java | 58 ++++ src/process/DumpInterChromosomal.java | 74 ++++- src/process/TupleFileToImage.java | 50 +++- src/test/TestInter.java | 180 +++++++++++++ src/utils/CoordinatesCorrection.java | 33 +++ src/utils/FindMaxima.java | 115 +++++++- src/utils/Loop.java | 105 ++++++-- src/utils/SIPInter.java | 374 ++++++++++++++++++++++++++ src/utils/SIPObject.java | 5 +- 10 files changed, 967 insertions(+), 32 deletions(-) create mode 100644 src/process/CallLoopsInter.java create mode 100644 src/test/TestInter.java create mode 100644 src/utils/SIPInter.java diff --git a/src/process/CallLoops.java b/src/process/CallLoops.java index 58ff415..7ea46d4 100644 --- a/src/process/CallLoops.java +++ b/src/process/CallLoops.java @@ -155,8 +155,9 @@ private void imageProcessing(ImagePlus imgFilter, String fileName, ImageProcessi /** * Make Image * - * @param file path - * @return ImagePlus with oMe value + * + * @param readFile + * @return */ private ImagePlus doImage(TupleFileToImage readFile){ String file = readFile.getInputFile(); diff --git a/src/process/CallLoopsInter.java b/src/process/CallLoopsInter.java new file mode 100644 index 0000000..eca58cc --- /dev/null +++ b/src/process/CallLoopsInter.java @@ -0,0 +1,58 @@ +package process; + +import ij.ImagePlus; +import ij.io.FileSaver; +import ij.plugin.filter.GaussianBlur; +import ij.process.FloatProcessor; +import ij.process.ImageProcessor; + +public class CallLoopsInter { + + + /** + * Save the image file + * + * @param imagePlusInput image to save + * @param pathFile path to save the image + */ + public static ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ + GaussianBlur gb = new GaussianBlur(); + ImageProcessor ip = imagePlusInput.getProcessor(); + gb.blurGaussian(ip, 2); + FloatProcessor pRaw = new FloatProcessor(ip.getWidth(), ip.getHeight()); + //faire un gaussiane + + for(int i = 3; i < ip.getWidth()-3; ++i){ + for(int j = 3; j < ip.getWidth()-3; ++j){ + float sum = 0; + for(int ii = i-3; ii < i+3; ++ii) { + for (int jj = j-3; jj < j+3; ++jj) { + sum = sum+(ip.getf(i,j)- ip.getf(ii,jj)); + } + } + //if(sum < 0 ) sum = 0; + pRaw.setf(i,j,sum); + } + } + ImagePlus img = new ImagePlus(); + img.setProcessor(pRaw); + + pathFile = pathFile.replace(".tif","_diff.tif"); + saveFile(img, pathFile); + return img; + + } + + /** + * Save the image file + * + * @param imagePlusInput image to save + * @param pathFile path to save the image + */ + public void saveFile ( ImagePlus imagePlusInput, String pathFile){ + FileSaver fileSaver = new FileSaver(imagePlusInput); + fileSaver.saveAsTiff(pathFile); + } + + +} diff --git a/src/process/DumpInterChromosomal.java b/src/process/DumpInterChromosomal.java index 470bf62..ce315b3 100644 --- a/src/process/DumpInterChromosomal.java +++ b/src/process/DumpInterChromosomal.java @@ -1,8 +1,80 @@ package process; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + public class DumpInterChromosomal { - public DumpInterChromosomal(){ + private String _juiceBoxTools; + private String _hicFile; + private String _normalisation; + private String _log = ""; + private String _logError = ""; + + public DumpInterChromosomal(String juiceboxTools,String hicFile, String norm) { + this._juiceBoxTools = juiceboxTools; + this._normalisation = norm; + this._hicFile = hicFile; + } + + + public boolean dumpObserved(String chr1, String chr2, String obs, int resolution) throws IOException { + int exitValue=1; + Runtime runtime = Runtime.getRuntime(); + try { + String line = "java"+" -jar "+this._juiceBoxTools+" dump observed "+this._normalisation+" "+this._hicFile+" "+chr1+" "+chr2+" BP "+resolution+" "+obs; + System.out.println(line); + this._log = this._log+"\n"+obs+"\t"+line; + Process process = runtime.exec(line); + + new DumpInterChromosomal.ReturnFlux(process.getInputStream()).start(); + new DumpInterChromosomal.ReturnFlux(process.getErrorStream()).start(); + exitValue=process.waitFor(); + } + catch (IOException e) { e.printStackTrace();} + catch (InterruptedException e) {e.printStackTrace();} + + if(_logError.contains("Exception")) { + System.out.println(_logError); + System.exit(0); + } + return exitValue==0; + } + + /** + * Class to run command line in java + * @author axel poulet + * + */ + public class ReturnFlux extends Thread { + + /** Flux to redirect */ + private InputStream _flux; + + /** + * Constructor of ReturnFlux + * @param flux + * flux to redirect + */ + public ReturnFlux(InputStream flux){this._flux = flux; } + /** + * + */ + public void run(){ + try { + InputStreamReader reader = new InputStreamReader(this._flux); + BufferedReader br = new BufferedReader(reader); + String line=null; + while ( (line = br.readLine()) != null) { + if(line.contains("WARN")== false && line.contains("INFO")== false) _logError = _logError+line+"\n"; + } + } + catch (IOException ioe){ + ioe.printStackTrace(); + } + } } } diff --git a/src/process/TupleFileToImage.java b/src/process/TupleFileToImage.java index c40b40d..38508fd 100644 --- a/src/process/TupleFileToImage.java +++ b/src/process/TupleFileToImage.java @@ -130,7 +130,55 @@ public void correctImage(ImagePlus img){ } img.setProcessor(ip); } - + + /** + * + * @param file + * @param matrixSize + * @param resolution + * @return + */ + public static ImagePlus readTupleFileInter(String file, int matrixSize, int resolution){ + System.out.println("plop"); + ImagePlus img = new ImagePlus(); + BufferedReader br; + FloatProcessor pRaw = new FloatProcessor(matrixSize, matrixSize); + String[] tfile = file.split("_"); + //4_0_191154275_6_0_171115066 + int numImageX = Integer.parseInt(tfile[tfile.length-5])/(matrixSize*resolution); + int numImageY = Integer.parseInt(tfile[tfile.length-2])/(matrixSize*resolution); + try { + pRaw.abs(); + br = new BufferedReader(new FileReader(file)); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null){ + sb.append(line); + String[] parts = line.split("\\t"); + float raw = 0; + + if(!(parts[2].equals("NAN"))){ + raw =Float.parseFloat(parts[2]); + if (raw < 0) raw = 0; + } + + int correctionX = numImageX*matrixSize*resolution; + int correctionY = numImageY*matrixSize*resolution; + int i = (Integer.parseInt(parts[0]) - correctionX)/resolution; + int j = (Integer.parseInt(parts[1]) - correctionY)/resolution; + if(i < matrixSize && j< matrixSize){ + pRaw.setf(i, j, raw); + } + sb.append(System.lineSeparator()); + line = br.readLine(); + } + br.close(); + } catch (IOException e) { e.printStackTrace();} + img.setProcessor(pRaw); + return img; + } + + /** * Compute the standard deviation of the pixel non zero values of m_img * @param mean average value in m_img diff --git a/src/test/TestInter.java b/src/test/TestInter.java new file mode 100644 index 0000000..4aa65e4 --- /dev/null +++ b/src/test/TestInter.java @@ -0,0 +1,180 @@ +package test; + +import ij.ImagePlus; +import ij.io.FileSaver; +import ij.plugin.filter.GaussianBlur; +import ij.plugin.filter.MaximumFinder; +import ij.process.ByteProcessor; +import ij.process.FloatProcessor; +import ij.process.ImageProcessor; +import process.DumpInterChromosomal; +import utils.CoordinatesCorrection; +import utils.FindMaxima; +import utils.Loop; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +public class TestInter { + + static ArrayList _chr= new ArrayList(); + + public static void main(String[] args) throws IOException, InterruptedException { + //String chr = "chr21"; + String input = "/home/plop/Desktop/SIP/GSE104333_Rao-2017-treated_6hr_combined_30.hic"; + String output = "/home/plop/Desktop/testInter/"; + String fileChr = "/home/plop/Desktop/SIP/w_hg19.sizes"; + String juicerTools = "/home/plop/Tools/juicer_tools_1.19.02.jar"; + HashMap chrsize = readChrSizeFile(fileChr); + int resolution = 100000; + int matrixSize = 500; + int diagSize = 5; + double gauss = 1.5; + double min = 2; + double max = 2; + int nbZero = 6; + String norm = "KR"; + int thresholdMax = 2800; + double saturatedPixel = 0.01; + ArrayList factor = new ArrayList(); + factor.add(1); + factor.add(2); + factor.add(5); + boolean keepTif = false; + int cpu = 1; + + //for (int i = 0; i < 1; ++i){ + //for(int j = i+1; j < 2; ++j){ + String chrName1 = _chr.get(3); + String chrName2 = _chr.get(5); + int chrSize1 = chrsize.get(chrName1); + int chrSize2 = chrsize.get(chrName2); + int step = matrixSize; + String nameRes = String.valueOf(resolution); + nameRes = nameRes.replace("000", ""); + nameRes = nameRes+"kb"; + String outdir = output+nameRes+ File.separator+chrName1+"_"+chrName2+File.separator; + File file = new File(outdir); + if (file.exists()==false) file.mkdirs(); + step = step*resolution; + DumpInterChromosomal dumpInter = new DumpInterChromosomal(juicerTools,input, norm); + System.out.println("start dump "+chrName1+" size "+chrSize1+" "+chrName2+" size "+chrSize2+" res "+ nameRes); + int endChr1 = matrixSize*resolution; + if(endChr1 > chrSize1) endChr1 = chrSize1; + + for(int startChr1 = 0 ; endChr1-1 <= chrSize1; startChr1+=step,endChr1+=step){ + int endChr2 = matrixSize*resolution; + if(endChr2 > chrSize2) endChr2 = chrSize2; + int end1 =endChr1-1; + String dump1 = chrName1+":"+startChr1+":"+end1; + for(int startChr2 = 0 ; endChr2-1 <= chrSize2; startChr2+=step,endChr2+=step) { + int end2 =endChr2-1; + String dump2 = chrName2+":"+startChr2+":"+end2; + String name = outdir + chrName1 +"_" + startChr1 + "_" + end1 +"_" +chrName2 +"_" + startChr2 + "_" + end2 + ".txt"; + //System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); + dumpInter.dumpObserved(dump1, dump2, name, resolution); + if (endChr2 + step > chrSize2 && endChr2 < chrSize2) { + endChr2 = chrSize2-1; + startChr2 += step; + dump2 = chrName2+":"+startChr2+":"+endChr2; + name = outdir + chrName1 +"_" + startChr1 + "_" + end1 +"_" +chrName2 +"_" + startChr2 + "_" + endChr2 + ".txt"; + //System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); + dumpInter.dumpObserved(dump1, dump2, name, resolution); + } + } + if (endChr1 + step > chrSize1 && endChr1 < chrSize1) { + endChr1 = chrSize1-1; + startChr1 += step; + dump1 = chrName1+":"+startChr1+":"+endChr1; + endChr2 = matrixSize*resolution; + for(int startChr2 = 0 ; endChr2-1 <= chrSize2; startChr2+=step,endChr2+=step) { + int end2 =endChr2-1; + String dump2 = chrName2+":"+startChr2+":"+end2; + String name = outdir + chrName1 +"_" + startChr1 + "_" + endChr1 +"_" +chrName2 +"_" + startChr2 + "_" + end2 + ".txt"; + //System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); + dumpInter.dumpObserved(dump1, dump2, name, resolution); + if (endChr2 + step > chrSize2 && endChr2 < chrSize2) { + endChr2 = chrSize2-1; + startChr2 += step; + dump2 = chrName2+":"+startChr2+":"+endChr2; + name = outdir + chrName1 +"_" + startChr1 + "_" + endChr1 +"_" +chrName2 +"_" + startChr2 + "_" + endChr2 + ".txt"; + // System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); + dumpInter.dumpObserved(dump1, dump2, name, resolution); + } + } + } + } + //System.out.println("##### End dump "+chrName1+" "+chrName2+" "+nameRes); + // } + //} + + File folder = new File(outdir); + File[] listOfFiles = folder.listFiles(); + //System.out.println(outdir+" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + listOfFiles.length); + for (int i = 0; i hloop = imageToGenomeCoordinate(findMaxima.findloopInter(5,img,3) , name[name.length-1]); + Set key = hloop.keySet(); + Iterator it = key.iterator(); + while (it.hasNext()) { + Loop loop = hloop.get(it.next()); + ArrayList coord = loop.getCoordinates(); + System.out.println(loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t"+loop.getChr2()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t0,0,0" + +"\t"+loop.getPaScoreAvg()+"\t"+loop.getRegionalPaScoreAvg()+"\t"+loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" + +loop.getStd()+"\t"+loop.getValue()+"\t"+loop.getNbOfZero()); + } + } + } + System.out.println("end"); + + } + + + /** + * + * @param chrSizeFile + * @return + * @throws IOException + */ + private static HashMap readChrSizeFile( String chrSizeFile) throws IOException{ + HashMap chrSize = new HashMap(); + + BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null){ + sb.append(line); + String[] parts = line.split("\\t"); + String chr = parts[0]; + int size = Integer.parseInt(parts[1]); + chrSize.put(chr, size); + _chr.add(chr); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + br.close(); + return chrSize; + } + + + + + + + +} diff --git a/src/utils/CoordinatesCorrection.java b/src/utils/CoordinatesCorrection.java index 01ac5de..9a2fabf 100644 --- a/src/utils/CoordinatesCorrection.java +++ b/src/utils/CoordinatesCorrection.java @@ -70,6 +70,39 @@ public HashMap imageToGenomeCoordinate(HashMap temp, i return this._data; } + /** + * For loop inter chromosomal + * @param temp + * @param rawImageName + * @return + */ + public HashMap imageToGenomeCoordinate(HashMap temp, String rawImageName) { + //4_0_49999999_6_0_49999999.tif + HashMap data = new HashMap<>(); + String[] chrCoord = rawImageName.split("_"); + int chr1Start = Integer.parseInt(chrCoord[1]); + int chr2Start = Integer.parseInt(chrCoord[4]); + int x; + int y; + Set key = temp.keySet(); + Iterator it = key.iterator(); + while (it.hasNext()) { + Loop loop = temp.get(it.next()); + x = loop.getX(); + y = loop.getY(); + int resolution = loop.getResolution(); + int a = (x * resolution) + chr1Start; + int a_end = a + resolution; + int b = (y * resolution) + chr2Start; + ; + int b_end = b + resolution; + String newName = loop.getChr() + "\t" + loop.getChr2() + a + "\t" + b; + loop.setCoordinates(a, a_end, b, b_end); + loop.setName(newName); + data.put(newName, loop); + } + return data; + } /** * getter of m_data * @return HashMap of loops diff --git a/src/utils/FindMaxima.java b/src/utils/FindMaxima.java index 277cfc1..4727f42 100644 --- a/src/utils/FindMaxima.java +++ b/src/utils/FindMaxima.java @@ -21,6 +21,8 @@ public class FindMaxima{ private ImagePlus _imgNorm; /** name of the chromosome*/ private String _chr; + /** name of the chromosome2*/ + private String _chr2; /** Image fileterred with min, max and gaussian filter*/ private ImagePlus _imgFilter; /** binary image pixel white = the maxima detected*/ @@ -50,19 +52,33 @@ public FindMaxima(ImagePlus img, ImagePlus imgFilter, String chr, double noiseTo this._diagSize = diag; this._resolution = resolution; } - - + /** - * Method to find loops in oMe image, and fill the loop collection. - * - * @param hichip - * @param index int index of the image - * @param nbZero int nb zero allowed around the loop - * @param raw ImagePlus raw image - * @param val int background value of the image - * @param factor + * + * @param imgFilter + * @param chr1 + * @param chr2 + * @param noiseTolerance + * @param resolution + */ + public FindMaxima( ImagePlus imgFilter, String chr1,String chr2, double noiseTolerance, int resolution){ + this._imgFilter = imgFilter; + this._noiseTolerance = noiseTolerance; + this._chr2 = chr2; + this._chr = chr1; + this._resolution = resolution; + } + + + /** + * + * @param index + * @param nbZero + * @param raw + * @param val * @return */ + public HashMap findloop(int index, int nbZero, ImagePlus raw, float val){ run(nbZero, raw, val); ArrayList temp = this.getMaxima(); @@ -95,6 +111,49 @@ public HashMap findloop(int index, int nbZero, ImagePlus raw, float //System.out.println("after filter ################# "+raw.getTitle()+" "+data.size()); return data; } + + /** + * + * @param nbZero + * @param raw + * @param val + * @return + */ + + public HashMap findloopInter( int nbZero, ImagePlus raw, float val){ + runInter(nbZero, raw, val); + ArrayList temp = this.getMaxima(); + ImageProcessor ipRaw = raw.getProcessor(); + HashMap data = new HashMap<>(); + this._imgNorm = raw; + //System.out.println("size raw maxima !!!!!!!!!!!!!! "+raw.getTitle()+" "+temp.size()); + for(int j = 0; j < temp.size();++j){ + String[] parts = temp.get(j).split("\\t"); + int x = Integer.parseInt(parts[0]); + int y = Integer.parseInt(parts[1]); + String name= this._chr+"\t"+this._chr2+"\t"+temp.get(j); + float avg = average(x,y); + float std = standardDeviation(x,y,avg); + int nbOfZero = detectNbOfZero(x,y,raw,ipRaw.getf(x, y)); + //if(avg > 1.45 && ipRaw.getf(x, y) >= 1.85){ // filter on the loop value and region value + DecayAnalysis da = new DecayAnalysis(raw,x,y); + float n1 =da.getNeighbourhood1(); + float n2 =da.getNeighbourhood2(); + //if(n1 < n2 && n1 >= 0.15 && n2 >= 0.25){ // filter on the neighborood for hic datatset + Loop maxima = new Loop(temp.get(j),x,y,this._chr,this._chr2,avg,std,ipRaw.getf(x, y)); + maxima.setNeigbhoord1(n1); + maxima.setNeigbhoord2(n2); + maxima.setResolution(this._resolution); + maxima.setNbOfZero(nbOfZero); + //System.out.println(_resolution+" "+maxima.getResolution()); + maxima.setMatrixSize(raw.getWidth()); + data.put(name, maxima); + //} + //} + } + //System.out.println("after filter ################# "+raw.getTitle()+" "+data.size()); + return data; + } /** * Detect maxima with the oMe or observed methods, call the different methods @@ -114,6 +173,42 @@ private void run(int nbZero, ImagePlus rawImage, float backgroundValue){ this.correctMaxima(); this.removeMaximaCloseToZero(nbZero,rawImage, backgroundValue); } + + + /** + * + * @param nbZero + * @param rawImage + * @param backgroundValue + */ + private void runInter(int nbZero, ImagePlus rawImage, float backgroundValue){ + ImagePlus temp = this._imgFilter.duplicate(); + ImageProcessor ip = temp.getProcessor(); + MaximumFinder mf = new MaximumFinder(); + ByteProcessor bp = mf.findMaxima(ip, this._noiseTolerance, MaximumFinder.SINGLE_POINTS, true); + this._imgResu.setProcessor(bp); + //this.removedCloseMaxima(); + //this.correctMaxima(); + //this.removeMaximaCloseToZero(nbZero,rawImage, backgroundValue); + } + + + private int detectNbOfZero(int x, int y, ImagePlus rawImage, float val){ + int w = this._imgResu.getWidth(); + int h = this._imgResu.getHeight(); + ImageProcessor ipResu = this._imgResu.getProcessor(); + ImageProcessor ip = rawImage.getProcessor(); + int nbZero = 0; + for(int i = x - 2; i <= x+2; ++i) { + for (int j = y-2; j <= y+2; ++j) { + if(ip.getf(i,j) <= 1) { + nbZero++; + System.out.println("yup"); + } + } + } + return nbZero; + } /** * Save the image diff --git a/src/utils/Loop.java b/src/utils/Loop.java index fd97915..4627c49 100644 --- a/src/utils/Loop.java +++ b/src/utils/Loop.java @@ -11,6 +11,8 @@ public class Loop { /** chromosome name.*/ private String _chr =""; + /** chromosome name.*/ + private String _chr2 =""; /** loops name: chr start end value.*/ private String _name; /** x coordinate.*/ @@ -23,6 +25,8 @@ public class Loop { private int _matrixSize; /** diagonal size.*/ private int _diagSize; + /** nb of zero n = 28.*/ + private int _nbZero; /** x coordinate+resolution.*/ private int _xEnd; /** y coordinate+resolution.*/ @@ -84,16 +88,16 @@ public Loop(String loop){ this._y = Integer.parseInt(tLoop[4]); this._yEnd= Integer.parseInt(tLoop[5]); } - /** + + /** * Loop constructor - * @param name String name of the loop - * @param chr String name of the chromosome - * @param x int x coordinate - * @param y int y coordinate - * @param value float - * @param int resolution + * @param name + * @param x + * @param y + * @param chr + * @param value + * @param resolution */ - public Loop(String name, int x, int y, String chr, float value, int resolution){ this.setName(name); this.setX(x); @@ -122,7 +126,29 @@ public Loop(String name, int x, int y, String chr, float avg, float std, float v this._std = std; this._peakValue = value; } - + + /** + * Loop constructor + * @param name String name of the loop + * @param x int x coordinate + * @param y int y coordinate + * @param chr String Chromosme name + * @param avg float Average + * @param std float Standard deviation + * @param value float + */ + public Loop(String name, int x, int y, String chr, String chr2, float avg, float std, float value){ + this.setName(name); + this.setX(x); + this.setY(y); + this._chr = chr; + this._chr2 = chr2; + this._avg = avg; + this._std = std; + this._peakValue = value; + } + + /** * Getter of the name loop * @return String name of the loop @@ -138,7 +164,8 @@ public Loop(String name, int x, int y, String chr, float avg, float std, float v /** * Setter of the name loop - * @param name String + * + * @return */ public String loopToString(){ String loop = _chr+"\t"+_name+"\t"+_x+"\t"+_y+"\t"+ _resolution+"\t"+_matrixSize+"\t"+ _diagSize+"\t"+ @@ -148,6 +175,21 @@ public String loopToString(){ +_paScoreFDR3+"\t"+_regPaScoreFDR3; return loop; } + + /** + * Setter of the name loop + * + * @return + */ + public String loopToStringInter(){ + String loop = _chr+"\t"+_chr2+"\t"+_name+"\t"+_x+"\t"+_y+"\t"+ _resolution+"\t"+_matrixSize+"\t"+ _diagSize+"\t"+ + _xEnd+"\t"+ _yEnd+"\t"+_neigbhoord1+"\t"+_paScoreAvg+"\t"+_paScoreAvgdev+"\t"+_paScoreMed + +"\t"+_neigbhoord2+"\t"+_regPaScoreMed+"\t"+_regPaScoreAvg+"\t"+_avg+"\t"+_peakValue + +"\t"+_std+"\t"+_paScoreFDR+"\t"+_regPaScoreFDR+"\t"+_paScoreFDR2+"\t"+_regPaScoreFDR2+"\t" + +_paScoreFDR3+"\t"+_regPaScoreFDR3; + return loop; + } + /** * Getter of the x coordinate * @return int x coordinate @@ -254,12 +296,24 @@ public String loopToString(){ * @return double PA score */ public float getPaScoreAvg(){ return this._paScoreAvg; } + + /** + * + * @return + */ public float getPaScoreAvgdev(){ return this._paScoreAvgdev; } + /** * Setter of the peak analysis loop score - * @param m_paScore double PA score + * + * @param paScore */ public void setPaScoreAvg(float paScore){ this._paScoreAvg = paScore; } + + /** + * + * @param paScoredev + */ public void setPaScoreAvgdev(float paScoredev){ this._paScoreAvgdev = paScoredev; } /** @@ -270,7 +324,8 @@ public String loopToString(){ /** * Setter of the peak analysis loop score - * @param m_paScore double PA score + * + * @param paScore */ public void setPaScoreMed(float paScore){ this._paScoreMed = paScore; } @@ -293,7 +348,7 @@ public void setCoordinates(int x, int x_end, int y, int y_end){ * @return ArrayList of integer */ public ArrayList getCoordinates(){ - ArrayList listCoord = new ArrayList(); + ArrayList listCoord = new ArrayList<>(); listCoord.add(this._x); listCoord.add(this._xEnd); listCoord.add(this._y); @@ -318,10 +373,10 @@ public ArrayList getCoordinates(){ * @return doubl reginal PA score */ public float getRegionalPaScoreAvg(){ return this._regPaScoreAvg; } - + /** - * Setter of regional PA score - * @param m_RpaScore double + * + * @param rpaScore */ public void setRegionalPaScoreAvg(float rpaScore){ this._regPaScoreAvg = rpaScore; } @@ -331,6 +386,12 @@ public ArrayList getCoordinates(){ */ public String getChr(){ return this._chr; } + /** + * Getter of the name of the chromosome + * @return String chr + */ + public String getChr2(){ return this._chr2; } + /** * Setter of the avg of th n 8 * @param avg double @@ -398,5 +459,17 @@ public ArrayList getCoordinates(){ * @param paScoreFDR3 */ public void setPaScoreAvgFDR3(float paScoreFDR3){ this._paScoreFDR3 = paScoreFDR3; } + /** + * + * @param nbOfZero + */ + public void setNbOfZero(int nbOfZero){ this._nbZero = nbOfZero; } + + /** + * getter of the nb of zero + * + * @return int the number of zero around the loop + */ + public int getNbOfZero(){ return this._nbZero; } } diff --git a/src/utils/SIPInter.java b/src/utils/SIPInter.java new file mode 100644 index 0000000..94ac491 --- /dev/null +++ b/src/utils/SIPInter.java @@ -0,0 +1,374 @@ +package utils; + +import java.io.*; +import java.util.*; + +/** + * Analyse and detect a whole genome HiC with .hic file or already processed data. + * The class is used for the observed and oMe method. + * + * MorpholibJ method used + * + * Collection of mathematical morphology methods and plugins for ImageJ, created at the INRA-IJPB Modeling and Digital Imaging lab. + * David Legland, Ignacio Arganda-Carreras, Philippe Andrey; MorphoLibJ: integrated library and plugins for mathematical morphology with ImageJ. + * Bioinformatics 2016; 32 (22): 3532-3534. doi: 10.1093/bioinformatics/btw413 + * + * @author axel poulet + * + */ + +public class SIPInter { + + /** String path of the input data*/ + private String _input; + /** Path of the output file*/ + private String _output; + /** Image size*/ + private int _matrixSize = 0; + /** Resolution of the bin dump in base*/ + private int _resolution; + /** Threshold for the maxima detection*/ + private int _thresholdMaxima; + /** HashMap of the chr size, the key = chr name, value = size of chr*/ + private HashMap _chrSize = new HashMap(); + /** Number of pixel = 0 allowed around the loop*/ + private int _nbZero = -1; + /** fdr value */ + private double _fdr; + /** is processed booelan*/ + private boolean _isProcessed = false; + /** if is gui analysis*/ + private boolean _isGui = false; + /** if rfdr*/ + private boolean _isDroso = false; + private double _medianAP = 0; + private double _medianAPReg = 0; + private boolean _isCooler = false; + private double _gauss = 1; + public SIPInter() { + } + + /** + * SIPInter constructor + * + */ + + public SIPInter(String output, HashMap chrSize, double gauss, int resolution, int thresholdMax, + int matrixSize, int nbZero, double fdr, boolean isProcessed) { + if(!output.endsWith(File.separator)) + output = output+File.separator; + this._output = output; + this._input = output; + this._chrSize = chrSize; + this._gauss = gauss; + this._matrixSize = matrixSize; + this._resolution = resolution; + this._thresholdMaxima = thresholdMax; + this._nbZero = nbZero; + this._fdr = fdr; + this._isProcessed = isProcessed; + } + + /** + + * + * @param input + * @param output + * @param chrSize + * @param gauss + * @param resolution + * @param thresholdMax + * @param matrixSize + * @param nbZero + * @param fdr + * @param isProcessed + */ + public SIPInter(String input, String output, HashMap chrSize, double gauss, int resolution, + int thresholdMax, int matrixSize, int nbZero, double fdr, boolean isProcessed) { + if(output.endsWith(File.separator) == false) + output = output+File.separator; + if(input.endsWith(File.separator) == false) + input = input+File.separator; + this._output = output; + this._input = input; + this._chrSize = chrSize; + this._gauss = gauss; + this._matrixSize = matrixSize; + this._resolution = resolution; + this._thresholdMaxima = thresholdMax; + this._nbZero = nbZero; + this._fdr = fdr; + this._isProcessed = isProcessed; + } + + + /** + * Save the result file in tabulated file + * + * @param pathFile String path for the results file + * @param first boolean to know idf it is teh first chromo + * @param data + * @throws IOException + */ + public void saveFile(String pathFile, HashMap data, boolean first) throws IOException{ + FDR fdrDetection = new FDR (); + fdrDetection.run(this._fdr, data); + double RFDRcutoff = fdrDetection.getRFDRcutoff(); + double FDRcutoff = fdrDetection.getFDRcutoff(); + boolean supToTen = false; + if(this._isDroso){ + median(data,FDRcutoff); + System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore "); + if(_medianAPReg > 10){ + supToTen = true; + _medianAPReg = _medianAPReg/4; + _medianAP = _medianAP/10; + } + } + else + System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); + BufferedWriter writer; + if(first) writer = new BufferedWriter(new FileWriter(new File(pathFile), true)); + else{ + writer = new BufferedWriter(new FileWriter(new File(pathFile))); + writer.write("chromosome1\tx1\tx2\tchromosome2\ty1\ty2\tcolor\tAPScoreAvg\tProbabilityofEnrichment\tRegAPScoreAvg\tAvg_diffMaxNeihgboor_1\tAvg_diffMaxNeihgboor_2\tavg\tstd\tvalue\n"); + } + + if(data.size()>0){ + Set key = data.keySet(); + Iterator it = key.iterator(); + while (it.hasNext()){ + String name = it.next(); + Loop loop = data.get(name); + ArrayList coord = loop.getCoordinates(); + if(this._isDroso){ + if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > FDRcutoff && loop.getPaScoreAvgdev() > .9 && (loop.getNeigbhoord1() > 1 || loop.getNeigbhoord2() > 1)){ + if(supToTen){ + if(loop.getRegionalPaScoreAvg() >= (_medianAPReg-_medianAPReg*0.7) && loop.getRegionalPaScoreAvg() <= (_medianAPReg*2)&& loop.getPaScoreAvg() <= (_medianAP*2)){ + writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" + +"\t"+loop.getPaScoreAvg()+"\t"+loop.getPaScoreAvgdev()+"\t"+loop.getRegionalPaScoreAvg()+"\t" + +loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" + +loop.getStd()+"\t"+loop.getValue()+"\n"); + } + }else{ + if( loop.getRegionalPaScoreAvg() >= (_medianAPReg-_medianAPReg*0.5) && loop.getRegionalPaScoreAvg() <= (_medianAPReg*2)&& loop.getPaScoreAvg() <= (_medianAP*2)){ + writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" + +"\t"+loop.getPaScoreAvg()+"\t"+loop.getPaScoreAvgdev()+"\t"+loop.getRegionalPaScoreAvg()+"\t" + +loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" + +loop.getStd()+"\t"+loop.getValue()+"\n"); + } + } + } + }else{ + if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > FDRcutoff && loop.getRegionalPaScoreAvg() > RFDRcutoff && loop.getPaScoreAvgdev() > .9){ + writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" + +"\t"+loop.getPaScoreAvg()+"\t"+loop.getPaScoreAvgdev()+"\t"+loop.getRegionalPaScoreAvg()+"\t" + +loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" + +loop.getStd()+"\t"+loop.getValue()+"\n"); + } + } + } + writer.close(); + } + } + + + + /** + * Full the list with file in directory + * @param dir + * @return + * @throws IOException + */ + + public File[] fillList(String dir) throws IOException{ + File folder = new File(dir); + File[] listOfFiles = folder.listFiles(); + return listOfFiles; + } + + + /** + * Test the normalized vector by chromosme + * @param normFile + */ + public HashMap getNormValueFilter(String normFile){ + BufferedReader br; + int lineNumber = 0; + HashMap vector = new HashMap(); + try { + br = new BufferedReader(new FileReader(normFile)); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null){ + sb.append(line); + if((line.equals("NaN")|| line.equals("NAN") || line.equals("nan") || line.equals("na") || Double.parseDouble(line) < 0.30)){ + vector.put(lineNumber*this._resolution, "plop"); + } + ++lineNumber; + sb.append(System.lineSeparator()); + line = br.readLine(); + } + br.close(); + } catch (IOException e) { e.printStackTrace();} + return vector; + } + + + /** + * + * @return + */ + private void median(HashMap data, double fdrCutoff){ + Set key = data.keySet(); + Iterator it = key.iterator(); + ArrayList n1 = new ArrayList (); + ArrayList n2 = new ArrayList (); + int nb = 0; + while (it.hasNext()){ + String name = it.next(); + Loop loop = data.get(name); + if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > fdrCutoff && loop.getPaScoreAvgdev() > .9){ + n1.add(loop.getPaScoreAvg()); + n2.add(loop.getRegionalPaScoreAvg()); + nb++; + } + } + if(nb>0){ + n1.sort(Comparator.naturalOrder()); + n2.sort(Comparator.naturalOrder()); + double pos1 = Math.floor((n1.size() - 1.0) / 2.0); + double pos2 = Math.ceil((n1.size() - 1.0) / 2.0); + if (pos1 == pos2 ) _medianAP = n1.get((int)pos1); + else _medianAP = (n1.get((int)pos1) + n1.get((int)pos2)) / 2.0 ; + pos1 = Math.floor((n2.size() - 1.0) / 2.0); + pos2 = Math.ceil((n2.size() - 1.0) / 2.0); + if (pos1 == pos2 ) _medianAPReg = n2.get((int)pos1); + else _medianAPReg = (n2.get((int)pos1) + n2.get((int)pos2)) / 2.0 ; + System.out.println("AP\t"+_medianAP+"\nAPREG\t"+_medianAPReg); + } + } + + + public double getFdr() { return this._fdr; } + public void setFdr(double fdr) { this._fdr = fdr; } + /** + * Getter of the input dir + * @return path of the input dir + */ + public String getInputDir(){ return this._input; } + + /** + * Getter of the matrix size + * + * @return the size of the image + */ + public int getMatrixSize(){ return this._matrixSize; } + + + + /** + * Setter of the path of the input directory + * @param inputDir String of the input directory + */ + public void setInputDir(String inputDir){ this._input = inputDir; } + + /** + * Getter of the path of the output directory + * @return path + */ + public String getOutputDir(){ return this._output; } + + /** + * Setter of the path of the output directory + * @param outputDir + */ + public void setOutputDir(String outputDir){ this._output = outputDir;} + + /** + * Getter of the gaussian blur strength + * @return double gaussian + */ + public double getGauss(){ return this._gauss; } + + /** + * Setter of the gaussian blur strength + * @param gauss double + */ + public void setGauss(double gauss){ this._gauss = gauss; } + + + /** + * Getter of resolution of the bin + * @return + */ + public int getResolution(){ return this._resolution;} + + /** + * Setter of resolution of the bin + * @param resolution + */ + public void setResolution(int resolution){ this._resolution = resolution;} + + /** + * Setter of size of the matrix + * @param size + */ + public void setMatrixSize(int size){ this._matrixSize = size; } + + /** + * Getter of threshold for the detction of the maxima + * @return + */ + public int getThresholdMaxima(){ return _thresholdMaxima;} + /** + * Setter of threshold for the detection of the maxima + * @param thresholdMaxima + */ + public void setThresholdMaxima(int thresholdMaxima) { this._thresholdMaxima = thresholdMaxima;} + + + + + + /** + * Getter of getNbZero + * @return + */ + public int getNbZero(){ return this._nbZero;} + + + public void setNbZero(int nbZero){ this._nbZero = nbZero;} + + + + public boolean isDroso(){return this._isDroso;} + public void setIsDroso(boolean droso){ this._isDroso = droso;} + + public HashMap getChrSizeHashMap(){return this._chrSize;} + public void setChrSizeHashMap(HashMap chrSize){this._chrSize = chrSize;} + + + + /** + * + * @return + */ + public boolean isProcessed() { return _isProcessed;} + public void setIsProcessed(boolean isProcessed) { this._isProcessed = isProcessed;} + + /** + * + * @return + */ + public boolean isCooler() { return _isCooler;} + public void setIsCooler(boolean cool) { this._isCooler = cool;} + + /** + * + * @return + */ + public boolean isGui() { return _isGui;} + public void setIsGui(boolean _isGui) { this._isGui = _isGui;} +} + diff --git a/src/utils/SIPObject.java b/src/utils/SIPObject.java index 48f78ec..c9a0536 100644 --- a/src/utils/SIPObject.java +++ b/src/utils/SIPObject.java @@ -75,6 +75,7 @@ public SIPObject() { /** * SIPObject constructor * + * * @param output * @param chrSize * @param gauss @@ -89,7 +90,7 @@ public SIPObject() { * @param listFactor * @param fdr * @param isProcessed - * @param isHichip + * @param rfdr */ public SIPObject(String output, HashMap chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, int thresholdMax, @@ -133,7 +134,7 @@ public SIPObject(String output, HashMap chrSize, double gauss, * @param listFactor * @param fdr * @param isProcessed - * @param isHichip + * @param rfdr */ public SIPObject(String input, String output, HashMap chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, int thresholdMax, From 2f216e2537a572b9faead74b6f015ccddd571623 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Mon, 12 Oct 2020 10:32:08 -0400 Subject: [PATCH 04/27] add classes for the process of inter chromo intereaction --- src/multiProcesing/ProcessDetectLoops.java | 51 +- src/multiProcesing/ProcessDumpData.java | 120 ++++ src/multiProcesing/ProcessHicDumpData.java | 69 --- .../RunnableDetectInterLoops.java | 62 ++ src/multiProcesing/RunnableDetectLoops.java | 9 +- .../RunnableDumpInterChromoData.java | 109 ++++ src/process/CallLoopsInter.java | 5 +- src/process/DumpInterChromosomal.java | 18 + src/sipMain/Hic_main.java | 4 +- src/test/TestCallLoopsHicFile.java | 4 +- src/test/TestCoolFormat.java | 5 - src/test/TestGui.java | 4 +- src/test/TestInter.java | 92 +-- src/utils/SIPInter.java | 529 +++++++----------- 14 files changed, 575 insertions(+), 506 deletions(-) create mode 100644 src/multiProcesing/ProcessDumpData.java delete mode 100644 src/multiProcesing/ProcessHicDumpData.java create mode 100644 src/multiProcesing/RunnableDetectInterLoops.java create mode 100644 src/multiProcesing/RunnableDumpInterChromoData.java diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index a712aca..21e4cd3 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -3,6 +3,7 @@ import java.util.Iterator; import gui.Progress; +import utils.SIPInter; import utils.SIPObject; import java.util.concurrent.Executors; @@ -19,12 +20,6 @@ */ public class ProcessDetectLoops{ - /**int: number of processus*/ - static int _nbLance = 0; - /** boolean: if true continue the process else take a break*/ - static boolean _continuer; - /** */ - static int _indice = 0; /** progress bar if gui is true*/ private Progress _p; @@ -70,7 +65,43 @@ public void go(SIPObject sip,int nbCPU, boolean delImage, String resuFile,String if(sip.isGui()) _p.dispose(); } - + + /** + * + * @param sipInter + * @param nbCPU + * @param delImage + * @param resuFile + * @param resName + * @throws InterruptedException + */ + public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile, String resName) throws InterruptedException { + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + Iterator chrName = sipInter.getChrSizeHashMap().keySet().iterator(); + if(sipInter.isProcessed()) { + boolean isCool = isProcessedMcool(sipInter.getOutputDir()+resName+File.separator+"normVector"); + sipInter.setIsCooler(isCool); + } + while(chrName.hasNext()){ + String chr = chrName.next(); + RunnableDetectInterLoops task = new RunnableDetectInterLoops(resuFile, chr, sipInter, delImage); + executor.execute(task); + } + executor.shutdown(); + int nb = 0; + if(sipInter.isGui()){ + _p = new Progress(resName+" Loops Detection step",sipInter.getChrSizeHashMap().size()+1); + _p._bar.setValue(nb); + } + while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { + if (nb != executor.getCompletedTaskCount()) { + nb = (int) executor.getCompletedTaskCount(); + if(sipInter.isGui()) _p._bar.setValue(nb); + } + } + if(sipInter.isGui()) _p.dispose(); + + } /** * * @param dirToTest @@ -78,9 +109,7 @@ public void go(SIPObject sip,int nbCPU, boolean delImage, String resuFile,String */ private boolean isProcessedMcool(String dirToTest) { File test = new File (dirToTest); - if (test.exists() == false) - return true; - else - return false; + boolean b = !test.exists(); + return b; } } \ No newline at end of file diff --git a/src/multiProcesing/ProcessDumpData.java b/src/multiProcesing/ProcessDumpData.java new file mode 100644 index 0000000..cb2b2ba --- /dev/null +++ b/src/multiProcesing/ProcessDumpData.java @@ -0,0 +1,120 @@ +package multiProcesing; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import gui.Progress; +import process.DumpData; +import process.DumpInterChromosomal; +import utils.SIPInter; +import utils.SIPObject; + + +/** + * multi thread class dumping the data via cooler + * and make file step by step + * bed file: start1 start2 obs-expected distanceNormalizedValue + * + * @author axel poulet + * + */ +public class ProcessDumpData { + /** progress bar if gui is true*/ + private Progress _p; + + /** + * + */ + public ProcessDumpData(){ } + + /** + * run SiP for intra chr loops + * + * @param hicFile Sting input file path + * @param sip SIPObject with all the paramters needed + * @param chrSize HashMap Name and size of chr + * @param juiceBoxTools juicerTools.jar path + * @param normJuiceBox String normalization method + * @param nbCPU int nb cpu + * @throws InterruptedException exception + */ + public void go(String hicFile, SIPObject sip, HashMap chrSize, String juiceBoxTools, String normJuiceBox,int nbCPU) throws InterruptedException { + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + Iterator chrName = chrSize.keySet().iterator(); + File outDir = new File(sip.getOutputDir()); + if (!outDir.exists()) outDir.mkdir(); + while(chrName.hasNext()){ + String chr = chrName.next(); + DumpData dumpData = new DumpData(juiceBoxTools, hicFile, normJuiceBox); + RunnableDumpDataHiC task = new RunnableDumpDataHiC(sip.getOutputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); + executor.execute(task); + } + executor.shutdown(); + int nb = 0; + + if(sip.isGui()){ + _p = new Progress("Loop Detection step",sip.getChrSizeHashMap().size()+1); + _p._bar.setValue(nb); + } + while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { + if (nb != executor.getCompletedTaskCount()) { + nb = (int) executor.getCompletedTaskCount(); + if(sip.isGui()) _p._bar.setValue(nb); + } + } + if(sip.isGui()) _p.dispose(); + } + + /** + * run SiP for inter chr loops + * + * @param hicFile Sting input file path + * @param sipInter SIPInter object with all the parameters needed + * @param chrSize HashMap Name and size of chr + * @param juiceBoxTools juicerTools.jar path + * @param normJuiceBox String normalization method + * @param nbCPU int nb cpu + * @throws InterruptedException exception + */ + public void go(String hicFile, SIPInter sipInter, HashMap chrSize, String juiceBoxTools, String normJuiceBox, int nbCPU) throws InterruptedException { + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + Object [] chrName = chrSize.keySet().toArray(); + + System.out.println(sipInter.getOutputDir()); + File outDir = new File(sipInter.getOutputDir()); + if (!outDir.exists()) outDir.mkdir(); + for(int i = 0; i < chrName.length;++i){ + String chr1 = chrName[i].toString(); + for(int j = i+1; j < chrName.length;++j){ + String chr2 = chrName[j].toString(); + int size1 = chrSize.get(chr1); + int size2 = chrSize.get(chr2); + System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); + DumpInterChromosomal DumpInterChromosomal = new DumpInterChromosomal(juiceBoxTools, hicFile, normJuiceBox); + RunnableDumpInterChromoData task = new RunnableDumpInterChromoData(sipInter.getOutputDir(), chr1, chrSize.get(chr1), + chr2, chrSize.get(chr2),DumpInterChromosomal, sipInter.getResolution(), sipInter.getMatrixSize()); + executor.execute(task); + } + } + + executor.shutdown(); + int nb = 0; + + if(sipInter.isGui()){ + _p = new Progress("Loop Detection step",sipInter.getChrSizeHashMap().size()+1); + _p._bar.setValue(nb); + } + while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { + if (nb != executor.getCompletedTaskCount()) { + nb = (int) executor.getCompletedTaskCount(); + if(sipInter.isGui()) _p._bar.setValue(nb); + } + } + if(sipInter.isGui()) _p.dispose(); + } + +} \ No newline at end of file diff --git a/src/multiProcesing/ProcessHicDumpData.java b/src/multiProcesing/ProcessHicDumpData.java deleted file mode 100644 index e248ebe..0000000 --- a/src/multiProcesing/ProcessHicDumpData.java +++ /dev/null @@ -1,69 +0,0 @@ -package multiProcesing; - -import java.io.File; -import java.util.HashMap; -import java.util.Iterator; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import gui.Progress; -import process.DumpData; -import utils.SIPObject; - - -/** - * multi thread class dumping the data via cooler - * and make file step by step - * bed file: start1 start2 obs-expected distanceNormalizedValue - * - * @author axel poulet - * - */ -public class ProcessHicDumpData{ - /** progress bar if gui is true*/ - private Progress _p; - - /** - * - */ - public ProcessHicDumpData(){ } - - /** - * * run the processing on different cpu, if all cpu are running, take break else run a new one. - * - * @param hicFile - * @param sip - * @param chrSize - * @param juiceBoxTools - * @param normJuiceBox - * @param nbCPU - * @throws InterruptedException - */ - public void go(String hicFile, SIPObject sip, HashMap chrSize, String juiceBoxTools, String normJuiceBox,int nbCPU) throws InterruptedException { - ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); - Iterator chrName = chrSize.keySet().iterator(); - File outDir = new File(sip.getOutputDir()); - if (outDir.exists()==false) outDir.mkdir(); - while(chrName.hasNext()){ - String chr = chrName.next(); - DumpData dumpData = new DumpData(juiceBoxTools, hicFile, normJuiceBox); - RunnableDumpDataHiC task = new RunnableDumpDataHiC(sip.getOutputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); - executor.execute(task); - } - executor.shutdown(); - int nb = 0; - - if(sip.isGui()){ - _p = new Progress("Loop Detection step",sip.getChrSizeHashMap().size()+1); - _p._bar.setValue(nb); - } - while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { - if (nb != executor.getCompletedTaskCount()) { - nb = (int) executor.getCompletedTaskCount(); - if(sip.isGui()) _p._bar.setValue(nb); - } - } - if(sip.isGui()) _p.dispose(); - } -} \ No newline at end of file diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/multiProcesing/RunnableDetectInterLoops.java new file mode 100644 index 0000000..6572a4d --- /dev/null +++ b/src/multiProcesing/RunnableDetectInterLoops.java @@ -0,0 +1,62 @@ +package multiProcesing; + +import process.CallLoopsInter; +import utils.Loop; +import utils.SIPInter; + + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; + + +public class RunnableDetectInterLoops extends Thread implements Runnable { + + /** + * SIP object containing all the parameter for the loops detection + */ + private SIPInter _sip; + /** + * CallLoops object + */ + private CallLoopsInter _callLoops; + /** + * String results file + */ + private String _resuFile; + /** + * String name of the chr + */ + private String _chr; + /** + * String name of the chr + */ + private boolean _delImages = true; + /** + * norn vector table for the chr of interest + */ + private HashMap _normVector = new HashMap(); + + + /** + * Construtor, initialize all the variables of interest + */ + public RunnableDetectInterLoops(String chr, String resuFile, SIPInter sip, boolean delFile) { + this._sip = sip; + this._callLoops = new CallLoopsInter(); + this._chr = chr; + this._resuFile = resuFile; + this._delImages = delFile; + } + + + + + /** + * Run all the process for loops detection by chr using the objet CallLoops and then save loops in + * txt file with SIPObject via he method saveFile + */ + public void run() { + + } +} diff --git a/src/multiProcesing/RunnableDetectLoops.java b/src/multiProcesing/RunnableDetectLoops.java index 41bd0c6..72e7124 100644 --- a/src/multiProcesing/RunnableDetectLoops.java +++ b/src/multiProcesing/RunnableDetectLoops.java @@ -48,7 +48,14 @@ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, String n this._delImages = delFile; this._normvectorFile = normVectorFile; } - + + /** + * + * @param chr + * @param resuFile + * @param sip + * @param delFile + */ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, boolean delFile){ this._sip = sip; this._callLoops = new CallLoops(sip); diff --git a/src/multiProcesing/RunnableDumpInterChromoData.java b/src/multiProcesing/RunnableDumpInterChromoData.java new file mode 100644 index 0000000..232a77c --- /dev/null +++ b/src/multiProcesing/RunnableDumpInterChromoData.java @@ -0,0 +1,109 @@ +package multiProcesing; + +import process.DumpInterChromosomal; + +import java.io.File; +import java.io.IOException; + + +/** + * + */ +public class RunnableDumpInterChromoData extends Thread implements Runnable{ + + private String _outDir; + private String _chr1; + private String _chr2; + private int _sizeChr1; + private int _sizeChr2; + private DumpInterChromosomal _dumpInter; + private int _resolution; + private int _matrixSize; + + /** + * + * @param outputDir String path for the output dir + * @param chr1 String chr1 name + * @param sizeChr1 int chr1 size + * @param chr2 String chr2 name + * @param sizeChr2 int chr2 size + * @param dumpInterChromosomal DumpInterChromosomal object dumping the data of interest + * @param resolution int resolution == size of the bins to dump + * @param matrixSize int size of the ImagePlus + */ + public RunnableDumpInterChromoData(String outputDir, String chr1, int sizeChr1, String chr2, int sizeChr2, + DumpInterChromosomal dumpInterChromosomal, int resolution, int matrixSize) { + + _outDir = outputDir; + _chr1 = chr1; + _chr2 = chr2; + _sizeChr1 = sizeChr1; + _sizeChr2 = sizeChr2; + _dumpInter = dumpInterChromosomal; + _resolution = resolution; + _matrixSize = matrixSize; + + } + + /** + * define the name and the region to dump for each chr + */ + public void run(){ + int step = _matrixSize; + String nameRes = String.valueOf(_resolution); + nameRes = nameRes.replace("000", ""); + nameRes = nameRes+"kb"; + String outdir = _outDir+nameRes+ File.separator+_chr1+"_"+_chr2+File.separator; + File file = new File(outdir); + if (!file.exists()) + file.mkdirs(); + step = step*_resolution; + System.out.println("start dump "+_chr1+" size "+_sizeChr1+" "+_chr2+" size "+_sizeChr2+" res "+ nameRes); + int endChr1 = _matrixSize*_resolution; + if(endChr1 > _sizeChr1) endChr1 = _sizeChr1; + try { + for(int startChr1 = 0 ; endChr1-1 <= _sizeChr1; startChr1+=step,endChr1+=step){ + int endChr2 = _matrixSize*_resolution; + if(endChr2 > _sizeChr2) endChr2 = _sizeChr2; + int end1 =endChr1-1; + String dump1 = _chr1+":"+startChr1+":"+end1; + for(int startChr2 = 0 ; endChr2-1 <= _sizeChr2; startChr2+=step,endChr2+=step) { + int end2 =endChr2-1; + String dump2 = _chr2+":"+startChr2+":"+end2; + String name = outdir + _chr1 +"_" + startChr1 + "_" + end1 +"_" +_chr2 +"_" + startChr2 + "_" + end2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + if (endChr2 + step > _sizeChr2 && endChr2 < _sizeChr2) { + endChr2 = _sizeChr2-1; + startChr2 += step; + dump2 = _chr2+":"+startChr2+":"+endChr2; + name = outdir + _chr1 +"_" + startChr1 + "_" + end1 +"_" +_chr2 +"_" + startChr2 + "_" + endChr2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + } + } + if (endChr1 + step > _sizeChr1 && endChr1 < _sizeChr1) { + endChr1 = _sizeChr1-1; + startChr1 += step; + dump1 = _chr1+":"+startChr1+":"+endChr1; + endChr2 = _matrixSize*_resolution; + for(int startChr2 = 0 ; endChr2-1 <= _sizeChr2; startChr2+=step,endChr2+=step) { + int end2 =endChr2-1; + String dump2 = _chr2+":"+startChr2+":"+end2; + String name = outdir + _chr1 +"_" + startChr1 + "_" + endChr1 +"_" +_chr2 +"_" + startChr2 + "_" + end2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + if (endChr2 + step > _sizeChr2 && endChr2 < _sizeChr2) { + endChr2 = _sizeChr2-1; + startChr2 += step; + dump2 = _chr2+":"+startChr2+":"+endChr2; + name = outdir + _chr1 +"_" + startChr1 + "_" + endChr1 +"_" +_chr2 +"_" + startChr2 + "_" + endChr2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + } + } + } + } + System.gc(); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/process/CallLoopsInter.java b/src/process/CallLoopsInter.java index eca58cc..7d9f9c0 100644 --- a/src/process/CallLoopsInter.java +++ b/src/process/CallLoopsInter.java @@ -8,6 +8,9 @@ public class CallLoopsInter { + void CallLoopsInter(){ + + } /** * Save the image file @@ -15,7 +18,7 @@ public class CallLoopsInter { * @param imagePlusInput image to save * @param pathFile path to save the image */ - public static ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ + public ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ GaussianBlur gb = new GaussianBlur(); ImageProcessor ip = imagePlusInput.getProcessor(); gb.blurGaussian(ip, 2); diff --git a/src/process/DumpInterChromosomal.java b/src/process/DumpInterChromosomal.java index ce315b3..c640208 100644 --- a/src/process/DumpInterChromosomal.java +++ b/src/process/DumpInterChromosomal.java @@ -5,6 +5,9 @@ import java.io.InputStream; import java.io.InputStreamReader; +/** + * + */ public class DumpInterChromosomal { private String _juiceBoxTools; @@ -13,6 +16,12 @@ public class DumpInterChromosomal { private String _log = ""; private String _logError = ""; + /** + * + * @param juiceboxTools + * @param hicFile + * @param norm + */ public DumpInterChromosomal(String juiceboxTools,String hicFile, String norm) { this._juiceBoxTools = juiceboxTools; this._normalisation = norm; @@ -20,6 +29,15 @@ public DumpInterChromosomal(String juiceboxTools,String hicFile, String norm) { } + /** + * + * @param chr1 + * @param chr2 + * @param obs + * @param resolution + * @return + * @throws IOException + */ public boolean dumpObserved(String chr1, String chr2, String obs, int resolution) throws IOException { int exitValue=1; Runtime runtime = Runtime.getRuntime(); diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index ef5808a..d734404 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -14,7 +14,7 @@ import gui.GuiAnalysis; import multiProcesing.ProcessCoolerDumpData; -import multiProcesing.ProcessHicDumpData; +import multiProcesing.ProcessDumpData; import process.MultiResProcess; import utils.SIPObject; @@ -244,7 +244,7 @@ public static void main(String[] args) throws IOException, InterruptedException sip = new SIPObject(_output, _chrSize, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); sip.setIsGui(_gui); - ProcessHicDumpData processDumpData = new ProcessHicDumpData(); + ProcessDumpData processDumpData = new ProcessDumpData(); processDumpData.go(_input, sip, _chrSize, _juiceBoxTools, _juiceBoXNormalisation, _cpu); System.out.println("########### End of the dump Step"); }else if(_isCool){ diff --git a/src/test/TestCallLoopsHicFile.java b/src/test/TestCallLoopsHicFile.java index 93f5920..20da776 100644 --- a/src/test/TestCallLoopsHicFile.java +++ b/src/test/TestCallLoopsHicFile.java @@ -8,7 +8,7 @@ import java.util.ArrayList; import java.util.HashMap; -import multiProcesing.ProcessHicDumpData; +import multiProcesing.ProcessDumpData; import process.MultiResProcess; import utils.SIPObject; @@ -80,7 +80,7 @@ public static void main(String[] args) throws IOException, InterruptedException SIPObject sip = new SIPObject(output, chrsize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,keepTif,false); sip.setIsGui(false); - ProcessHicDumpData processDumpData = new ProcessHicDumpData(); + ProcessDumpData processDumpData = new ProcessDumpData(); processDumpData.go(input, sip, chrsize, juiceBoxTools, juiceBoXNormalisation,cpu); MultiResProcess multi = new MultiResProcess(sip, cpu, keepTif,fileChr); diff --git a/src/test/TestCoolFormat.java b/src/test/TestCoolFormat.java index f21045c..21a84e2 100644 --- a/src/test/TestCoolFormat.java +++ b/src/test/TestCoolFormat.java @@ -1,17 +1,12 @@ package test; import java.io.BufferedReader; -import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import multiProcesing.ProcessCoolerDumpData; -import multiProcesing.ProcessHicDumpData; -import process.CoolerDumpData; import process.MultiResProcess; -import utils.CoolerExpected; import utils.SIPObject; @SuppressWarnings("unused") public class TestCoolFormat { diff --git a/src/test/TestGui.java b/src/test/TestGui.java index 5e769f4..47d1df6 100644 --- a/src/test/TestGui.java +++ b/src/test/TestGui.java @@ -7,7 +7,7 @@ import java.util.HashMap; import gui.GuiAnalysis; -import multiProcesing.ProcessHicDumpData; +import multiProcesing.ProcessDumpData; import utils.SIPObject; @@ -63,7 +63,7 @@ public static void main(String[] args) throws IOException, InterruptedException{ +"\nthreshold: "+thresholdMax+"\n number of zero:"+nbZero+"\n "); sip = new SIPObject(output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,gui.isProcessed(),false); sip.setIsGui(true); - ProcessHicDumpData processDumpData = new ProcessHicDumpData(); + ProcessDumpData processDumpData = new ProcessDumpData(); processDumpData.go(input, sip, chrSize, juiceBoxTools, juiceBoXNormalisation,gui.getNbCpu()); }else{ System.out.println("processed mode:\ninput: "+input+"\noutput: "+output+"\njuiceBox: "+juiceBoxTools+"\nnorm: "+ juiceBoXNormalisation+"\ngauss: "+gauss diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 4aa65e4..44c8874 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -1,25 +1,13 @@ package test; -import ij.ImagePlus; -import ij.io.FileSaver; -import ij.plugin.filter.GaussianBlur; -import ij.plugin.filter.MaximumFinder; -import ij.process.ByteProcessor; -import ij.process.FloatProcessor; -import ij.process.ImageProcessor; -import process.DumpInterChromosomal; -import utils.CoordinatesCorrection; -import utils.FindMaxima; -import utils.Loop; +import multiProcesing.ProcessDumpData; +import utils.SIPInter; import java.io.BufferedReader; -import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; public class TestInter { @@ -48,71 +36,13 @@ public static void main(String[] args) throws IOException, InterruptedException factor.add(5); boolean keepTif = false; int cpu = 1; + SIPInter sipInter = new SIPInter(output, chrsize, gauss, min, max, resolution, saturatedPixel, thresholdMax, matrixSize, nbZero,keepTif); + ProcessDumpData process = new ProcessDumpData(); + process.go(input,sipInter,chrsize,juicerTools,norm,2); - //for (int i = 0; i < 1; ++i){ - //for(int j = i+1; j < 2; ++j){ - String chrName1 = _chr.get(3); - String chrName2 = _chr.get(5); - int chrSize1 = chrsize.get(chrName1); - int chrSize2 = chrsize.get(chrName2); - int step = matrixSize; - String nameRes = String.valueOf(resolution); - nameRes = nameRes.replace("000", ""); - nameRes = nameRes+"kb"; - String outdir = output+nameRes+ File.separator+chrName1+"_"+chrName2+File.separator; - File file = new File(outdir); - if (file.exists()==false) file.mkdirs(); - step = step*resolution; - DumpInterChromosomal dumpInter = new DumpInterChromosomal(juicerTools,input, norm); - System.out.println("start dump "+chrName1+" size "+chrSize1+" "+chrName2+" size "+chrSize2+" res "+ nameRes); - int endChr1 = matrixSize*resolution; - if(endChr1 > chrSize1) endChr1 = chrSize1; - for(int startChr1 = 0 ; endChr1-1 <= chrSize1; startChr1+=step,endChr1+=step){ - int endChr2 = matrixSize*resolution; - if(endChr2 > chrSize2) endChr2 = chrSize2; - int end1 =endChr1-1; - String dump1 = chrName1+":"+startChr1+":"+end1; - for(int startChr2 = 0 ; endChr2-1 <= chrSize2; startChr2+=step,endChr2+=step) { - int end2 =endChr2-1; - String dump2 = chrName2+":"+startChr2+":"+end2; - String name = outdir + chrName1 +"_" + startChr1 + "_" + end1 +"_" +chrName2 +"_" + startChr2 + "_" + end2 + ".txt"; - //System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); - dumpInter.dumpObserved(dump1, dump2, name, resolution); - if (endChr2 + step > chrSize2 && endChr2 < chrSize2) { - endChr2 = chrSize2-1; - startChr2 += step; - dump2 = chrName2+":"+startChr2+":"+endChr2; - name = outdir + chrName1 +"_" + startChr1 + "_" + end1 +"_" +chrName2 +"_" + startChr2 + "_" + endChr2 + ".txt"; - //System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); - dumpInter.dumpObserved(dump1, dump2, name, resolution); - } - } - if (endChr1 + step > chrSize1 && endChr1 < chrSize1) { - endChr1 = chrSize1-1; - startChr1 += step; - dump1 = chrName1+":"+startChr1+":"+endChr1; - endChr2 = matrixSize*resolution; - for(int startChr2 = 0 ; endChr2-1 <= chrSize2; startChr2+=step,endChr2+=step) { - int end2 =endChr2-1; - String dump2 = chrName2+":"+startChr2+":"+end2; - String name = outdir + chrName1 +"_" + startChr1 + "_" + endChr1 +"_" +chrName2 +"_" + startChr2 + "_" + end2 + ".txt"; - //System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); - dumpInter.dumpObserved(dump1, dump2, name, resolution); - if (endChr2 + step > chrSize2 && endChr2 < chrSize2) { - endChr2 = chrSize2-1; - startChr2 += step; - dump2 = chrName2+":"+startChr2+":"+endChr2; - name = outdir + chrName1 +"_" + startChr1 + "_" + endChr1 +"_" +chrName2 +"_" + startChr2 + "_" + endChr2 + ".txt"; - // System.out.println("\tstart dump " + chrName1 + " " + chrName2 + " dump " + dump1 +" "+ dump2 + " res " + nameRes); - dumpInter.dumpObserved(dump1, dump2, name, resolution); - } - } - } - } - //System.out.println("##### End dump "+chrName1+" "+chrName2+" "+nameRes); - // } - //} + + /* File folder = new File(outdir); File[] listOfFiles = folder.listFiles(); @@ -139,7 +69,7 @@ public static void main(String[] args) throws IOException, InterruptedException +loop.getStd()+"\t"+loop.getValue()+"\t"+loop.getNbOfZero()); } } - } + }*/ System.out.println("end"); } @@ -171,10 +101,4 @@ private static HashMap readChrSizeFile( String chrSizeFile) thr return chrSize; } - - - - - - } diff --git a/src/utils/SIPInter.java b/src/utils/SIPInter.java index 94ac491..b6b09d4 100644 --- a/src/utils/SIPInter.java +++ b/src/utils/SIPInter.java @@ -4,371 +4,242 @@ import java.util.*; /** - * Analyse and detect a whole genome HiC with .hic file or already processed data. - * The class is used for the observed and oMe method. * - * MorpholibJ method used - * - * Collection of mathematical morphology methods and plugins for ImageJ, created at the INRA-IJPB Modeling and Digital Imaging lab. - * David Legland, Ignacio Arganda-Carreras, Philippe Andrey; MorphoLibJ: integrated library and plugins for mathematical morphology with ImageJ. - * Bioinformatics 2016; 32 (22): 3532-3534. doi: 10.1093/bioinformatics/btw413 * * @author axel poulet * */ -public class SIPInter { +public class SIPInter{ + /** String path of the input data*/ private String _input; /** Path of the output file*/ private String _output; + /** Strength of the gaussian filter*/ + private double _gauss; + /** Strength of the min filter*/ + private double _min; + /** Strength of the max filter*/ + private double _max; + /** % of staurated pixel after enhance contrast*/ + private double _saturatedPixel; /** Image size*/ - private int _matrixSize = 0; + private int _matrixSize; /** Resolution of the bin dump in base*/ private int _resolution; /** Threshold for the maxima detection*/ private int _thresholdMaxima; /** HashMap of the chr size, the key = chr name, value = size of chr*/ - private HashMap _chrSize = new HashMap(); + private HashMap _chrSize; + /** Size of the step to process each chr (step = matrixSize/2)*/ + private int _step; /** Number of pixel = 0 allowed around the loop*/ - private int _nbZero = -1; - /** fdr value */ - private double _fdr; + private int _nbZero; /** is processed booelan*/ - private boolean _isProcessed = false; + private boolean _isProcessed; /** if is gui analysis*/ - private boolean _isGui = false; - /** if rfdr*/ - private boolean _isDroso = false; - private double _medianAP = 0; - private double _medianAPReg = 0; - private boolean _isCooler = false; - private double _gauss = 1; - public SIPInter() { - } + private boolean _isGui; + private boolean _isCooler; + /** */ + private boolean _keepTif; + + public SIPInter(String output, HashMap chrsize, double gauss, double min, double max, int resolution, + double saturatedPixel, int thresholdMax, int matrixSize, int nbZero, boolean keepTif) { - /** - * SIPInter constructor - * - */ - - public SIPInter(String output, HashMap chrSize, double gauss, int resolution, int thresholdMax, - int matrixSize, int nbZero, double fdr, boolean isProcessed) { - if(!output.endsWith(File.separator)) - output = output+File.separator; this._output = output; - this._input = output; - this._chrSize = chrSize; + this._chrSize = chrsize; this._gauss = gauss; - this._matrixSize = matrixSize; + this._min = min; + this._max = max; this._resolution = resolution; + this._saturatedPixel = saturatedPixel; this._thresholdMaxima = thresholdMax; + this._matrixSize = matrixSize; this._nbZero = nbZero; - this._fdr = fdr; - this._isProcessed = isProcessed; + this._keepTif = keepTif; + } + + /** + * Getter of the input dir + * @return path of the input dir + */ + public String getInputDir(){ return this._input; } + + /** + * Getter of the matrix size + * @return the size of the image + */ + public int getMatrixSize(){ return this._matrixSize; } + + + /** + * Getter of step + * @return the step + */ + public int getStep(){ return this._step;} + + /** + * Setter of the path of the input directory + * @param inputDir String of the input directory + */ + public void setInputDir(String inputDir){ this._input = inputDir; } + + /** + * Getter of the path of the output directory + * @return path + */ + public String getOutputDir(){ return this._output; } + /** + * Setter of the path of the output directory + * @param outputDir String new path for the output directory + */ + public void setOutputDir(String outputDir){ this._output = outputDir;} - * - * @param input - * @param output - * @param chrSize - * @param gauss - * @param resolution - * @param thresholdMax - * @param matrixSize - * @param nbZero - * @param fdr - * @param isProcessed + /** + * Getter of the gaussian blur strength + * @return double gaussian */ - public SIPInter(String input, String output, HashMap chrSize, double gauss, int resolution, - int thresholdMax, int matrixSize, int nbZero, double fdr, boolean isProcessed) { - if(output.endsWith(File.separator) == false) - output = output+File.separator; - if(input.endsWith(File.separator) == false) - input = input+File.separator; - this._output = output; - this._input = input; - this._chrSize = chrSize; - this._gauss = gauss; - this._matrixSize = matrixSize; - this._resolution = resolution; - this._thresholdMaxima = thresholdMax; - this._nbZero = nbZero; - this._fdr = fdr; - this._isProcessed = isProcessed; - } - - - /** - * Save the result file in tabulated file - * - * @param pathFile String path for the results file - * @param first boolean to know idf it is teh first chromo - * @param data - * @throws IOException - */ - public void saveFile(String pathFile, HashMap data, boolean first) throws IOException{ - FDR fdrDetection = new FDR (); - fdrDetection.run(this._fdr, data); - double RFDRcutoff = fdrDetection.getRFDRcutoff(); - double FDRcutoff = fdrDetection.getFDRcutoff(); - boolean supToTen = false; - if(this._isDroso){ - median(data,FDRcutoff); - System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore "); - if(_medianAPReg > 10){ - supToTen = true; - _medianAPReg = _medianAPReg/4; - _medianAP = _medianAP/10; - } - } - else - System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); - BufferedWriter writer; - if(first) writer = new BufferedWriter(new FileWriter(new File(pathFile), true)); - else{ - writer = new BufferedWriter(new FileWriter(new File(pathFile))); - writer.write("chromosome1\tx1\tx2\tchromosome2\ty1\ty2\tcolor\tAPScoreAvg\tProbabilityofEnrichment\tRegAPScoreAvg\tAvg_diffMaxNeihgboor_1\tAvg_diffMaxNeihgboor_2\tavg\tstd\tvalue\n"); - } - - if(data.size()>0){ - Set key = data.keySet(); - Iterator it = key.iterator(); - while (it.hasNext()){ - String name = it.next(); - Loop loop = data.get(name); - ArrayList coord = loop.getCoordinates(); - if(this._isDroso){ - if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > FDRcutoff && loop.getPaScoreAvgdev() > .9 && (loop.getNeigbhoord1() > 1 || loop.getNeigbhoord2() > 1)){ - if(supToTen){ - if(loop.getRegionalPaScoreAvg() >= (_medianAPReg-_medianAPReg*0.7) && loop.getRegionalPaScoreAvg() <= (_medianAPReg*2)&& loop.getPaScoreAvg() <= (_medianAP*2)){ - writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" - +"\t"+loop.getPaScoreAvg()+"\t"+loop.getPaScoreAvgdev()+"\t"+loop.getRegionalPaScoreAvg()+"\t" - +loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" - +loop.getStd()+"\t"+loop.getValue()+"\n"); - } - }else{ - if( loop.getRegionalPaScoreAvg() >= (_medianAPReg-_medianAPReg*0.5) && loop.getRegionalPaScoreAvg() <= (_medianAPReg*2)&& loop.getPaScoreAvg() <= (_medianAP*2)){ - writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" - +"\t"+loop.getPaScoreAvg()+"\t"+loop.getPaScoreAvgdev()+"\t"+loop.getRegionalPaScoreAvg()+"\t" - +loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" - +loop.getStd()+"\t"+loop.getValue()+"\n"); - } - } - } - }else{ - if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > FDRcutoff && loop.getRegionalPaScoreAvg() > RFDRcutoff && loop.getPaScoreAvgdev() > .9){ - writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" - +"\t"+loop.getPaScoreAvg()+"\t"+loop.getPaScoreAvgdev()+"\t"+loop.getRegionalPaScoreAvg()+"\t" - +loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" - +loop.getStd()+"\t"+loop.getValue()+"\n"); - } - } - } - writer.close(); - } - } - - - - /** - * Full the list with file in directory - * @param dir - * @return - * @throws IOException - */ - - public File[] fillList(String dir) throws IOException{ - File folder = new File(dir); - File[] listOfFiles = folder.listFiles(); - return listOfFiles; - } - - - /** - * Test the normalized vector by chromosme - * @param normFile - */ - public HashMap getNormValueFilter(String normFile){ - BufferedReader br; - int lineNumber = 0; - HashMap vector = new HashMap(); - try { - br = new BufferedReader(new FileReader(normFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - if((line.equals("NaN")|| line.equals("NAN") || line.equals("nan") || line.equals("na") || Double.parseDouble(line) < 0.30)){ - vector.put(lineNumber*this._resolution, "plop"); - } - ++lineNumber; - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - } catch (IOException e) { e.printStackTrace();} - return vector; - } - - - /** - * - * @return - */ - private void median(HashMap data, double fdrCutoff){ - Set key = data.keySet(); - Iterator it = key.iterator(); - ArrayList n1 = new ArrayList (); - ArrayList n2 = new ArrayList (); - int nb = 0; - while (it.hasNext()){ - String name = it.next(); - Loop loop = data.get(name); - if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > fdrCutoff && loop.getPaScoreAvgdev() > .9){ - n1.add(loop.getPaScoreAvg()); - n2.add(loop.getRegionalPaScoreAvg()); - nb++; - } - } - if(nb>0){ - n1.sort(Comparator.naturalOrder()); - n2.sort(Comparator.naturalOrder()); - double pos1 = Math.floor((n1.size() - 1.0) / 2.0); - double pos2 = Math.ceil((n1.size() - 1.0) / 2.0); - if (pos1 == pos2 ) _medianAP = n1.get((int)pos1); - else _medianAP = (n1.get((int)pos1) + n1.get((int)pos2)) / 2.0 ; - pos1 = Math.floor((n2.size() - 1.0) / 2.0); - pos2 = Math.ceil((n2.size() - 1.0) / 2.0); - if (pos1 == pos2 ) _medianAPReg = n2.get((int)pos1); - else _medianAPReg = (n2.get((int)pos1) + n2.get((int)pos2)) / 2.0 ; - System.out.println("AP\t"+_medianAP+"\nAPREG\t"+_medianAPReg); - } - } - - - public double getFdr() { return this._fdr; } - public void setFdr(double fdr) { this._fdr = fdr; } - /** - * Getter of the input dir - * @return path of the input dir - */ - public String getInputDir(){ return this._input; } - - /** - * Getter of the matrix size - * - * @return the size of the image - */ - public int getMatrixSize(){ return this._matrixSize; } - - - - /** - * Setter of the path of the input directory - * @param inputDir String of the input directory - */ - public void setInputDir(String inputDir){ this._input = inputDir; } - - /** - * Getter of the path of the output directory - * @return path - */ - public String getOutputDir(){ return this._output; } - - /** - * Setter of the path of the output directory - * @param outputDir - */ - public void setOutputDir(String outputDir){ this._output = outputDir;} - - /** - * Getter of the gaussian blur strength - * @return double gaussian - */ - public double getGauss(){ return this._gauss; } - - /** - * Setter of the gaussian blur strength - * @param gauss double - */ - public void setGauss(double gauss){ this._gauss = gauss; } - - - /** - * Getter of resolution of the bin - * @return - */ - public int getResolution(){ return this._resolution;} - - /** - * Setter of resolution of the bin - * @param resolution - */ - public void setResolution(int resolution){ this._resolution = resolution;} - - /** - * Setter of size of the matrix - * @param size - */ - public void setMatrixSize(int size){ this._matrixSize = size; } - - /** - * Getter of threshold for the detction of the maxima - * @return - */ - public int getThresholdMaxima(){ return _thresholdMaxima;} - /** - * Setter of threshold for the detection of the maxima - * @param thresholdMaxima - */ - public void setThresholdMaxima(int thresholdMaxima) { this._thresholdMaxima = thresholdMaxima;} - - - - - - /** - * Getter of getNbZero - * @return - */ - public int getNbZero(){ return this._nbZero;} - - - public void setNbZero(int nbZero){ this._nbZero = nbZero;} - - - - public boolean isDroso(){return this._isDroso;} - public void setIsDroso(boolean droso){ this._isDroso = droso;} + public double getGauss(){ return this._gauss; } - public HashMap getChrSizeHashMap(){return this._chrSize;} - public void setChrSizeHashMap(HashMap chrSize){this._chrSize = chrSize;} + /** + * Setter of the gaussian blur strength + * @param gauss double + */ + public void setGauss(double gauss){ this._gauss = gauss; } + /** + * Getter of the min filter strength + * @return double strength of the min filter + */ + public double getMin(){ return this._min;} - /** - * - * @return - */ - public boolean isProcessed() { return _isProcessed;} - public void setIsProcessed(boolean isProcessed) { this._isProcessed = isProcessed;} + /** + * Setter of the min filter strength + * @param min double min + */ + public void setMin(double min){ this._min = min;} - /** - * - * @return - */ - public boolean isCooler() { return _isCooler;} - public void setIsCooler(boolean cool) { this._isCooler = cool;} + /** + * Getter of the max filter strength + * @return double max filter + */ + public double getMax(){ return this._max; } - /** - * - * @return - */ - public boolean isGui() { return _isGui;} - public void setIsGui(boolean _isGui) { this._isGui = _isGui;} + /** + * Setter of the min filter strength + * @param max double max + */ + public void setMax(double max){ this._max = max;} + + /** + * Getter % of saturated pixel for the contrast enhancement + * @return double percentage of saturated + */ + public double getSaturatedPixel(){ return this._saturatedPixel; } + + /** + * Setter % of saturated pixel for the contrast enhancement + * @param saturatedPixel double saturatedPixel + */ + public void setSaturatedPixel(double saturatedPixel){ this._saturatedPixel = saturatedPixel; } + + /** + * Getter of resolution of the bin + * @return int resolution of the image + */ + public int getResolution(){ return this._resolution;} + + /** + * Setter of resolution of the bin + * @param resolution int new resolution + */ + public void setResolution(int resolution){ this._resolution = resolution;} + + /** + * Setter of size of the matrix + * @param size int new size of the matrix + */ + public void setMatrixSize(int size){ this._matrixSize = size; } + + /** + * setter step between image + * @param step int step + */ + public void setStep(int step){ this._step = step;} + + /** + * Getter of threshold for the detection of the regional maxima + * @return int threshold + */ + public int getThresholdMaxima(){ return _thresholdMaxima;} + /** + * Setter of threshold for the detection of the maxima + * @param thresholdMaxima int new threshold + */ + public void setThresholdMaxima(int thresholdMaxima) { this._thresholdMaxima = thresholdMaxima;} + + + /** + * Getter of NbZero + * @return int nb of zero + */ + public int getNbZero(){ return this._nbZero;} + + /** + * Setter of nbZero + * @param nbZero int new nb of zero + */ + public void setNbZero(int nbZero){ this._nbZero = nbZero;} + + + + /** + * Getter is isProcessed + * @return boolean + */ + public boolean isProcessed() { return _isProcessed;} + + /** + * setter isProcessed + * @param isProcessed boolean + */ + public void setIsProcessed(boolean isProcessed) { this._isProcessed = isProcessed;} + + /** + *getter is cooler + * @return boolean isCooler + */ + public boolean isCooler() { return _isCooler;} + + /** + * Setter isCooler + * @param cool boolean + */ + public void setIsCooler(boolean cool) { this._isCooler = cool;} + + /** + * getter isGui + * @return boolean + */ + public boolean isGui() { return _isGui;} + + /** + * setter is gui + * @param isGui boolean + */ + public void setIsGui(boolean isGui) { this._isGui = isGui;} + + /** + * getter of _chrSize + * @return HashMap + */ + public HashMap getChrSizeHashMap(){return this._chrSize;} } + From 1d09ef2e291c9409f77e06de99e2d4a735fe1d30 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Tue, 20 Oct 2020 17:42:21 -0400 Subject: [PATCH 05/27] ongoing work on call inter loops --- .../RunnableDetectInterLoops.java | 2 - src/multiProcesing/RunnableDetectLoops.java | 5 +- src/process/CallLoopsInter.java | 77 +++++++++++++++++-- src/process/TupleFileToImage.java | 25 +++--- src/test/TestInter.java | 28 ------- src/utils/FindMaxima.java | 10 ++- 6 files changed, 94 insertions(+), 53 deletions(-) diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/multiProcesing/RunnableDetectInterLoops.java index 6572a4d..99dfe1b 100644 --- a/src/multiProcesing/RunnableDetectInterLoops.java +++ b/src/multiProcesing/RunnableDetectInterLoops.java @@ -35,8 +35,6 @@ public class RunnableDetectInterLoops extends Thread implements Runnable { /** * norn vector table for the chr of interest */ - private HashMap _normVector = new HashMap(); - /** * Construtor, initialize all the variables of interest diff --git a/src/multiProcesing/RunnableDetectLoops.java b/src/multiProcesing/RunnableDetectLoops.java index 72e7124..4fbfd0b 100644 --- a/src/multiProcesing/RunnableDetectLoops.java +++ b/src/multiProcesing/RunnableDetectLoops.java @@ -33,11 +33,12 @@ public class RunnableDetectLoops extends Thread implements Runnable{ /** * Construtor, initialize all the variables of interest * + * * @param chr - * @param callLoops * @param resuFile * @param sip - * @param normVector + * @param normVectorFile + * @param delFile */ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, String normVectorFile, boolean delFile){ this._sip = sip; diff --git a/src/process/CallLoopsInter.java b/src/process/CallLoopsInter.java index 7d9f9c0..32d536c 100644 --- a/src/process/CallLoopsInter.java +++ b/src/process/CallLoopsInter.java @@ -5,19 +5,84 @@ import ij.plugin.filter.GaussianBlur; import ij.process.FloatProcessor; import ij.process.ImageProcessor; +import utils.CoordinatesCorrection; +import utils.FindMaxima; +import utils.Loop; +import utils.SIPInter; -public class CallLoopsInter { +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; - void CallLoopsInter(){ +import static process.TupleFileToImage.readTupleFileInter; - } +public class CallLoopsInter { + private int _matrixSize; + private int _resolution; /** - * Save the image file * - * @param imagePlusInput image to save - * @param pathFile path to save the image + * @param sipInter */ + void CallLoopsInter(SIPInter sipInter){ + _matrixSize = sipInter.getMatrixSize(); + _resolution = sipInter.getResolution(); + } + + /** + * Detect loops methods + * detect the loops at two different resolution, initial resolution + 2 fold bigger + * call the loops first in the smaller resolution + * then making image with bigger resolution and fill no Zero list + * faire un gros for deguelasse por passer les faceteur de grossissement seulement si listDefacteur > 1. + * make and save image at two differents resolution (m_resolution and m_resolution*2) + * if there is a lot pixel at zero in the images adapt the threshold for the maxima detection + * @param fileList + * @param chr + * @param normVector + * @return + * @throws IOException + */ + public HashMap detectLoops(File[] fileList, String chrName1, String chrName2, HashMap normVector) throws IOException{ + File folder = new File(outdir); + File[] listOfFiles = folder.listFiles(); + CoordinatesCorrection coord = new CoordinatesCorrection(); + //System.out.println(outdir+" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + listOfFiles.length); + for (int i = 0; i hloop = coord.imageToGenomeCoordinate(findMaxima.findloopInter(5,img,3) , name[name.length-1]); + Set key = hloop.keySet(); + Iterator it = key.iterator(); + while (it.hasNext()) { + Loop loop = hloop.get(it.next()); + ArrayList coord = loop.getCoordinates(); + System.out.println(loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t"+loop.getChr2()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t0,0,0" + +"\t"+loop.getPaScoreAvg()+"\t"+loop.getRegionalPaScoreAvg()+"\t"+loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" + +loop.getStd()+"\t"+loop.getValue()+"\t"+loop.getNbOfZero()); + } + } + } + } + + /** + * Save the image file + * + * @param imagePlusInput image to save + * @param pathFile path to save the image + */ public ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ GaussianBlur gb = new GaussianBlur(); ImageProcessor ip = imagePlusInput.getProcessor(); diff --git a/src/process/TupleFileToImage.java b/src/process/TupleFileToImage.java index 38508fd..87ee0d4 100644 --- a/src/process/TupleFileToImage.java +++ b/src/process/TupleFileToImage.java @@ -133,23 +133,20 @@ public void correctImage(ImagePlus img){ /** * - * @param file - * @param matrixSize - * @param resolution * @return */ - public static ImagePlus readTupleFileInter(String file, int matrixSize, int resolution){ + public ImagePlus readTupleFileInter(){ System.out.println("plop"); ImagePlus img = new ImagePlus(); BufferedReader br; - FloatProcessor pRaw = new FloatProcessor(matrixSize, matrixSize); - String[] tfile = file.split("_"); + FloatProcessor pRaw = new FloatProcessor(_size, _size); + String[] tfile = _file.split("_"); //4_0_191154275_6_0_171115066 - int numImageX = Integer.parseInt(tfile[tfile.length-5])/(matrixSize*resolution); - int numImageY = Integer.parseInt(tfile[tfile.length-2])/(matrixSize*resolution); + int numImageX = Integer.parseInt(tfile[tfile.length-5])/(_size*_resolution); + int numImageY = Integer.parseInt(tfile[tfile.length-2])/(_size*_resolution); try { pRaw.abs(); - br = new BufferedReader(new FileReader(file)); + br = new BufferedReader(new FileReader(_file)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null){ @@ -162,11 +159,11 @@ public static ImagePlus readTupleFileInter(String file, int matrixSize, int reso if (raw < 0) raw = 0; } - int correctionX = numImageX*matrixSize*resolution; - int correctionY = numImageY*matrixSize*resolution; - int i = (Integer.parseInt(parts[0]) - correctionX)/resolution; - int j = (Integer.parseInt(parts[1]) - correctionY)/resolution; - if(i < matrixSize && j< matrixSize){ + int correctionX = numImageX*_size*_resolution; + int correctionY = numImageY*_size*_resolution; + int i = (Integer.parseInt(parts[0]) - correctionX)/_resolution; + int j = (Integer.parseInt(parts[1]) - correctionY)/_resolution; + if(i < _size && j< _size){ pRaw.setf(i, j, raw); } sb.append(System.lineSeparator()); diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 44c8874..12d2c01 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -42,34 +42,6 @@ public static void main(String[] args) throws IOException, InterruptedException - /* - - File folder = new File(outdir); - File[] listOfFiles = folder.listFiles(); - //System.out.println(outdir+" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + listOfFiles.length); - for (int i = 0; i hloop = imageToGenomeCoordinate(findMaxima.findloopInter(5,img,3) , name[name.length-1]); - Set key = hloop.keySet(); - Iterator it = key.iterator(); - while (it.hasNext()) { - Loop loop = hloop.get(it.next()); - ArrayList coord = loop.getCoordinates(); - System.out.println(loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t"+loop.getChr2()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t0,0,0" - +"\t"+loop.getPaScoreAvg()+"\t"+loop.getRegionalPaScoreAvg()+"\t"+loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" - +loop.getStd()+"\t"+loop.getValue()+"\t"+loop.getNbOfZero()); - } - } - }*/ System.out.println("end"); } diff --git a/src/utils/FindMaxima.java b/src/utils/FindMaxima.java index 4727f42..e8daf43 100644 --- a/src/utils/FindMaxima.java +++ b/src/utils/FindMaxima.java @@ -192,7 +192,15 @@ private void runInter(int nbZero, ImagePlus rawImage, float backgroundValue){ //this.removeMaximaCloseToZero(nbZero,rawImage, backgroundValue); } - + + /** + * + * @param x + * @param y + * @param rawImage + * @param val + * @return + */ private int detectNbOfZero(int x, int y, ImagePlus rawImage, float val){ int w = this._imgResu.getWidth(); int h = this._imgResu.getHeight(); From 8668db5ef8e6ac672a8b642ba33bf59710fd3e7a Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Fri, 6 Nov 2020 18:08:31 -0500 Subject: [PATCH 06/27] add fdr in sip inter, and finalization of the method --- src/multiProcesing/ProcessDetectLoops.java | 31 ++- src/multiProcesing/ProcessDumpData.java | 2 +- .../RunnableDetectInterLoops.java | 52 ++++- src/process/CallLoopsInter.java | 71 +++--- src/process/TupleFileToImage.java | 1 - src/sipMain/Hic_main.java | 10 +- src/test/TestInter.java | 59 ++--- src/utils/CoordinatesCorrection.java | 5 +- src/utils/DecayAnalysis.java | 7 +- src/utils/FDR.java | 6 +- src/utils/FindMaxima.java | 76 ++++--- src/utils/Loop.java | 12 ++ src/utils/PeakAnalysisScore.java | 128 +++++------ src/utils/SIPInter.java | 203 +++++++++++++----- src/utils/SIPObject.java | 2 +- 15 files changed, 403 insertions(+), 262 deletions(-) diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index 21e4cd3..a714da8 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -1,8 +1,10 @@ package multiProcesing; import java.io.File; +import java.util.HashMap; import java.util.Iterator; import gui.Progress; +import process.DumpInterChromosomal; import utils.SIPInter; import utils.SIPObject; @@ -77,20 +79,29 @@ public void go(SIPObject sip,int nbCPU, boolean delImage, String resuFile,String */ public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile, String resName) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); - Iterator chrName = sipInter.getChrSizeHashMap().keySet().iterator(); - if(sipInter.isProcessed()) { - boolean isCool = isProcessedMcool(sipInter.getOutputDir()+resName+File.separator+"normVector"); - sipInter.setIsCooler(isCool); - } - while(chrName.hasNext()){ - String chr = chrName.next(); - RunnableDetectInterLoops task = new RunnableDetectInterLoops(resuFile, chr, sipInter, delImage); - executor.execute(task); + HashMap chrSize = sipInter.getChrSize(); + Object [] chrName = chrSize.keySet().toArray(); + + System.out.println(sipInter.getOutputDir()); + File outDir = new File(sipInter.getOutputDir()); + if (!outDir.exists()) outDir.mkdir(); + for(int i = 0; i < chrName.length;++i){ + String chr1 = chrName[i].toString(); + for(int j = i+1; j < chrName.length;++j){ + String chr2 = chrName[j].toString(); + int size1 = chrSize.get(chr1); + int size2 = chrSize.get(chr2); + System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); + RunnableDetectInterLoops task = new RunnableDetectInterLoops(chr1, chr2, resuFile, sipInter, delImage); + executor.execute(task); + } } + executor.shutdown(); int nb = 0; + if(sipInter.isGui()){ - _p = new Progress(resName+" Loops Detection step",sipInter.getChrSizeHashMap().size()+1); + _p = new Progress("Loop Detection step",sipInter.getChrSize().size()+1); _p._bar.setValue(nb); } while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { diff --git a/src/multiProcesing/ProcessDumpData.java b/src/multiProcesing/ProcessDumpData.java index cb2b2ba..94243b6 100644 --- a/src/multiProcesing/ProcessDumpData.java +++ b/src/multiProcesing/ProcessDumpData.java @@ -105,7 +105,7 @@ public void go(String hicFile, SIPInter sipInter, HashMap chrSiz int nb = 0; if(sipInter.isGui()){ - _p = new Progress("Loop Detection step",sipInter.getChrSizeHashMap().size()+1); + _p = new Progress("Loop Detection step",sipInter.getChrSize().size()+1); _p._bar.setValue(nb); } while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/multiProcesing/RunnableDetectInterLoops.java index 99dfe1b..3ca25cb 100644 --- a/src/multiProcesing/RunnableDetectInterLoops.java +++ b/src/multiProcesing/RunnableDetectInterLoops.java @@ -15,11 +15,11 @@ public class RunnableDetectInterLoops extends Thread implements Runnable { /** * SIP object containing all the parameter for the loops detection */ - private SIPInter _sip; + private SIPInter _sipInter; /** * CallLoops object */ - private CallLoopsInter _callLoops; + private CallLoopsInter _callLoopsInter; /** * String results file */ @@ -27,7 +27,11 @@ public class RunnableDetectInterLoops extends Thread implements Runnable { /** * String name of the chr */ - private String _chr; + private String _chr1; + /** + * + */ + private String _chr2; /** * String name of the chr */ @@ -39,10 +43,11 @@ public class RunnableDetectInterLoops extends Thread implements Runnable { /** * Construtor, initialize all the variables of interest */ - public RunnableDetectInterLoops(String chr, String resuFile, SIPInter sip, boolean delFile) { - this._sip = sip; - this._callLoops = new CallLoopsInter(); - this._chr = chr; + public RunnableDetectInterLoops(String chr1, String chr2, String resuFile, SIPInter sip, boolean delFile) { + this._sipInter = sip; + this._callLoopsInter = new CallLoopsInter(_sipInter); + this._chr1 = chr1; + this._chr2 = chr2; this._resuFile = resuFile; this._delImages = delFile; } @@ -55,6 +60,39 @@ public RunnableDetectInterLoops(String chr, String resuFile, SIPInter sip, bool * txt file with SIPObject via he method saveFile */ public void run() { + String resName = String.valueOf(this._sipInter.getResolution()); + resName = resName.replace("000", "")+"kb"; + String dir = this._sipInter.getOutputDir()+resName+File.separator+_chr1+"_"+_chr2+File.separator; + HashMap data; + if (this._sipInter.isProcessed()) dir = this._sipInter.getInputDir()+resName+File.separator+_chr1+"_"+_chr2+File.separator; + try { + File folder = new File(dir); + File[] listOfFiles = folder.listFiles(); + System.out.println(dir); + if (listOfFiles.length == 0) System.out.println("!!!!!!!!!! dumped directory of chromosome"+this._chr1+"_"+_chr2+"empty"); + else{ + File file = new File(this._resuFile); + /* if(_sipInter.isCooler() == false) { + System.out.println(_normvectorFile+"normVector end loading file: "+_chr+".norm "+resName); + }*/ + data = this._callLoopsInter.detectLoops(listOfFiles,this._chr1, this._chr2); + System.out.println(data.size()+"!!!!!!!!!!!!!!!! "+this._chr1+" "+this._chr2); + synchronized(this) { + if (file.length() == 0) _sipInter.writeResu(this._resuFile,data,false); + else this._sipInter.writeResu(this._resuFile,data,true); + } + folder = new File(dir); + listOfFiles = folder.listFiles(); + if(_delImages){ + System.out.println("Deleting image file for "+_chr1+"_"+_chr2); + for(int i = 0; i < listOfFiles.length;++i) { + String name = listOfFiles[i].toString(); + if(name.contains(".tif")) listOfFiles[i].delete(); + } + } + } + } catch (IOException e1) { e1.printStackTrace();} + System.gc(); } } diff --git a/src/process/CallLoopsInter.java b/src/process/CallLoopsInter.java index 32d536c..fcb0d06 100644 --- a/src/process/CallLoopsInter.java +++ b/src/process/CallLoopsInter.java @@ -5,31 +5,30 @@ import ij.plugin.filter.GaussianBlur; import ij.process.FloatProcessor; import ij.process.ImageProcessor; -import utils.CoordinatesCorrection; -import utils.FindMaxima; -import utils.Loop; -import utils.SIPInter; +import utils.*; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; -import static process.TupleFileToImage.readTupleFileInter; + public class CallLoopsInter { private int _matrixSize; private int _resolution; + private double _noiseTolerance; + private double _gaussian; + /** * * @param sipInter */ - void CallLoopsInter(SIPInter sipInter){ + public CallLoopsInter(SIPInter sipInter){ _matrixSize = sipInter.getMatrixSize(); _resolution = sipInter.getResolution(); + _noiseTolerance= sipInter.getThresholdMaxima(); + _gaussian = sipInter.getGauss(); } /** @@ -40,19 +39,19 @@ void CallLoopsInter(SIPInter sipInter){ * faire un gros for deguelasse por passer les faceteur de grossissement seulement si listDefacteur > 1. * make and save image at two differents resolution (m_resolution and m_resolution*2) * if there is a lot pixel at zero in the images adapt the threshold for the maxima detection + * * @param fileList - * @param chr - * @param normVector + * @param chrName1 + * @param chrName2 * @return * @throws IOException */ - public HashMap detectLoops(File[] fileList, String chrName1, String chrName2, HashMap normVector) throws IOException{ - File folder = new File(outdir); - File[] listOfFiles = folder.listFiles(); + public HashMap detectLoops(File[] fileList, String chrName1, String chrName2){ CoordinatesCorrection coord = new CoordinatesCorrection(); //System.out.println(outdir+" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + listOfFiles.length); - for (int i = 0; i hLoop = new HashMap<> (); + for (int i = 0; i detectLoops(File[] fileList, String chrName1, Strin //System.out.println(imgPath); saveFile(img, imgPath); ImagePlus imageDiff = imgDiff(img,imgPath); - FindMaxima findMaxima = new FindMaxima( imageDiff, chrName1,chrName2, 20, _resolution); - HashMap hloop = coord.imageToGenomeCoordinate(findMaxima.findloopInter(5,img,3) , name[name.length-1]); - Set key = hloop.keySet(); - Iterator it = key.iterator(); - while (it.hasNext()) { - Loop loop = hloop.get(it.next()); - ArrayList coord = loop.getCoordinates(); - System.out.println(loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t"+loop.getChr2()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t0,0,0" - +"\t"+loop.getPaScoreAvg()+"\t"+loop.getRegionalPaScoreAvg()+"\t"+loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" - +loop.getStd()+"\t"+loop.getValue()+"\t"+loop.getNbOfZero()); - } + FindMaxima findMaxima = new FindMaxima( imageDiff, chrName1,chrName2, _noiseTolerance, _resolution,_gaussian); + HashMap temp = findMaxima.findLoopInter(imgPath); + PeakAnalysisScore pas = new PeakAnalysisScore(img,temp); + pas.computeScore(); + coord.setData(hLoop); + coord.imageToGenomeCoordinate(temp,name[name.length-1]); + hLoop = coord.getData(); + //System.out.println(hLoop.size()+" temp "+ temp.size()); } } + return hLoop; } /** @@ -83,23 +80,27 @@ public HashMap detectLoops(File[] fileList, String chrName1, Strin * @param imagePlusInput image to save * @param pathFile path to save the image */ - public ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ + private ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ GaussianBlur gb = new GaussianBlur(); ImageProcessor ip = imagePlusInput.getProcessor(); - gb.blurGaussian(ip, 2); + gb.blurGaussian(ip, _gaussian); FloatProcessor pRaw = new FloatProcessor(ip.getWidth(), ip.getHeight()); - //faire un gaussiane - for(int i = 3; i < ip.getWidth()-3; ++i){ for(int j = 3; j < ip.getWidth()-3; ++j){ float sum = 0; for(int ii = i-3; ii < i+3; ++ii) { - for (int jj = j-3; jj < j+3; ++jj) { - sum = sum+(ip.getf(i,j)- ip.getf(ii,jj)); + for (int jj = j-3; jj < j+3; ++jj){ + if(i!=ii || j!= jj) { + float valueA = ip.getf(i, j); + float valueB = ip.getf(ii, jj); + if (Double.isNaN(ip.getf(i, j))) valueA = 0; + if (Double.isNaN(ip.getf(ii, jj))) valueB = 0; + sum = sum + (valueA - valueB); + } } } //if(sum < 0 ) sum = 0; - pRaw.setf(i,j,sum); + pRaw.setf(i,j,sum/48); } } ImagePlus img = new ImagePlus(); @@ -117,7 +118,7 @@ public ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ * @param imagePlusInput image to save * @param pathFile path to save the image */ - public void saveFile ( ImagePlus imagePlusInput, String pathFile){ + private void saveFile ( ImagePlus imagePlusInput, String pathFile){ FileSaver fileSaver = new FileSaver(imagePlusInput); fileSaver.saveAsTiff(pathFile); } diff --git a/src/process/TupleFileToImage.java b/src/process/TupleFileToImage.java index 87ee0d4..3daf3b8 100644 --- a/src/process/TupleFileToImage.java +++ b/src/process/TupleFileToImage.java @@ -136,7 +136,6 @@ public void correctImage(ImagePlus img){ * @return */ public ImagePlus readTupleFileInter(){ - System.out.println("plop"); ImagePlus img = new ImagePlus(); BufferedReader br; FloatProcessor pRaw = new FloatProcessor(_size, _size); diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index d734404..12e0fdb 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -213,7 +213,7 @@ public static void main(String[] args) throws IOException, InterruptedException } File f = new File(_input); - if(f.exists()==false && _input.startsWith("https")==false){ + if(!f.exists() && !_input.startsWith("https")){ System.out.println(_input+" doesn't existed !!! \n\n"); System.out.println(_doc); return; @@ -231,7 +231,7 @@ public static void main(String[] args) throws IOException, InterruptedException readChrSizeFile(_chrSizeFile); if(_isHic){ f = new File(_juiceBoxTools); - if(f.exists()==false){ + if(!f.exists()){ System.out.println(_juiceBoxTools+" doesn't existed !!! \n\n"); System.out.println(_doc); return; @@ -249,18 +249,18 @@ public static void main(String[] args) throws IOException, InterruptedException System.out.println("########### End of the dump Step"); }else if(_isCool){ f = new File(_cooltools); - if(f.exists()==false){ + if(!f.exists()){ System.out.println(_cooltools+" doesn't existed or wrong path !!! \n\n"); System.out.println(_doc); return; } f = new File(_cooler); - if(f.exists()==false){ + if(!f.exists()){ System.out.println(_cooler+" doesn't existed or wrong path !!! \n\n"); System.out.println(_doc); return; } - if( testTools(_cooltools,0,3,0) == false || testTools(_cooler,0,8,6) == false) { + if(!testTools(_cooltools, 0, 3, 0) || !testTools(_cooler, 0, 8, 6)) { System.out.println( _cooltools +" or" + _cooler+" is not the good version for SIP (it needs cooltools version >= 0.3.0 and cooler version >= 0.8.6) !!! \n\n"); System.out.println(_doc); if(_gui){ diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 12d2c01..a702e95 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -1,13 +1,10 @@ package test; -import multiProcesing.ProcessDumpData; +import multiProcesing.ProcessDetectLoops; import utils.SIPInter; -import java.io.BufferedReader; -import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; public class TestInter { @@ -15,31 +12,27 @@ public class TestInter { public static void main(String[] args) throws IOException, InterruptedException { //String chr = "chr21"; - String input = "/home/plop/Desktop/SIP/GSE104333_Rao-2017-treated_6hr_combined_30.hic"; + String input = "/home/plop/Desktop/testInter/"; String output = "/home/plop/Desktop/testInter/"; - String fileChr = "/home/plop/Desktop/SIP/w_hg19.sizes"; + String fileChr = "/home/plop/Desktop/SIP/testSize.tab"; String juicerTools = "/home/plop/Tools/juicer_tools_1.19.02.jar"; - HashMap chrsize = readChrSizeFile(fileChr); int resolution = 100000; int matrixSize = 500; - int diagSize = 5; - double gauss = 1.5; + double gauss = 1; double min = 2; double max = 2; int nbZero = 6; - String norm = "KR"; - int thresholdMax = 2800; + double thresholdMax = 0.9; double saturatedPixel = 0.01; - ArrayList factor = new ArrayList(); - factor.add(1); - factor.add(2); - factor.add(5); - boolean keepTif = false; - int cpu = 1; - SIPInter sipInter = new SIPInter(output, chrsize, gauss, min, max, resolution, saturatedPixel, thresholdMax, matrixSize, nbZero,keepTif); - ProcessDumpData process = new ProcessDumpData(); - process.go(input,sipInter,chrsize,juicerTools,norm,2); + boolean keepTif = true; + int cpu = 2; + SIPInter sipInter = new SIPInter(input, output, fileChr, gauss, resolution, thresholdMax, matrixSize, nbZero,keepTif,0.025); + //ProcessDumpData process = new ProcessDumpData(); + //process.go(input,sipInter,chrsize,juicerTools,norm,2); + + ProcessDetectLoops detectLoops = new ProcessDetectLoops(); + detectLoops.go(sipInter, 1, false, "/home/plop/Desktop/testInter/loops.txt", "100kb"); System.out.println("end"); @@ -47,30 +40,4 @@ public static void main(String[] args) throws IOException, InterruptedException } - /** - * - * @param chrSizeFile - * @return - * @throws IOException - */ - private static HashMap readChrSizeFile( String chrSizeFile) throws IOException{ - HashMap chrSize = new HashMap(); - - BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - chrSize.put(chr, size); - _chr.add(chr); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - return chrSize; - } - } diff --git a/src/utils/CoordinatesCorrection.java b/src/utils/CoordinatesCorrection.java index 9a2fabf..c8842a6 100644 --- a/src/utils/CoordinatesCorrection.java +++ b/src/utils/CoordinatesCorrection.java @@ -78,7 +78,6 @@ public HashMap imageToGenomeCoordinate(HashMap temp, i */ public HashMap imageToGenomeCoordinate(HashMap temp, String rawImageName) { //4_0_49999999_6_0_49999999.tif - HashMap data = new HashMap<>(); String[] chrCoord = rawImageName.split("_"); int chr1Start = Integer.parseInt(chrCoord[1]); int chr2Start = Integer.parseInt(chrCoord[4]); @@ -99,9 +98,9 @@ public HashMap imageToGenomeCoordinate(HashMap temp, S String newName = loop.getChr() + "\t" + loop.getChr2() + a + "\t" + b; loop.setCoordinates(a, a_end, b, b_end); loop.setName(newName); - data.put(newName, loop); + _data.put(newName, loop); } - return data; + return _data; } /** * getter of m_data diff --git a/src/utils/DecayAnalysis.java b/src/utils/DecayAnalysis.java index 7ff7f32..c933891 100644 --- a/src/utils/DecayAnalysis.java +++ b/src/utils/DecayAnalysis.java @@ -63,8 +63,11 @@ private float computeDiff (int c ){ for(int j = this._y-c ; j <= this._y+c; ++j){ if((i != this._x || j != this._y) && (i-this._x == -c || j-this._y == -c || i-this._x == c || j-this._y == c)){ if(i >=0 && j>= 0 && i < ip.getWidth() && j < ip.getHeight()){ - double a = ip.getf(this._x, this._y)- ip.getf(i, j); - sum+= a; + double valueA = 0; + if(!Double.isNaN(ip.getf(i, j))){ + valueA = ip.getf(i, j); + } + sum+= ip.getf(this._x, this._y)- valueA; ++nb; } } diff --git a/src/utils/FDR.java b/src/utils/FDR.java index 60d95be..a898546 100644 --- a/src/utils/FDR.java +++ b/src/utils/FDR.java @@ -37,11 +37,13 @@ public void run(double fdr,HashMap data){ while (it.hasNext()) { String loopName = it.next(); Loop loop = data.get(loopName); - + + float dubFDR = loop.getPaScoreAvgFDR(); float dubFDR2 = loop.getPaScoreAvgFDR2(); float dubFDR3 = loop.getPaScoreAvgFDR3(); - + + if(dubFDR > 0) myFDRvals.add(dubFDR); if(dubFDR2 > 0) myFDRvals.add(dubFDR2); if(dubFDR3 > 0) myFDRvals.add(dubFDR3); diff --git a/src/utils/FindMaxima.java b/src/utils/FindMaxima.java index e8daf43..f057ded 100644 --- a/src/utils/FindMaxima.java +++ b/src/utils/FindMaxima.java @@ -3,8 +3,10 @@ import java.util.ArrayList; import java.util.HashMap; +import ij.IJ; import ij.ImagePlus; import ij.io.FileSaver; +import ij.plugin.filter.GaussianBlur; import ij.plugin.filter.MaximumFinder; import ij.process.ByteProcessor; import ij.process.ImageProcessor; @@ -33,6 +35,7 @@ public class FindMaxima{ private int _diagSize =-1; /** Resolution of the image in base*/ private int _resolution = -1; + private double _gaussianFilterRadius; /** @@ -61,12 +64,13 @@ public FindMaxima(ImagePlus img, ImagePlus imgFilter, String chr, double noiseTo * @param noiseTolerance * @param resolution */ - public FindMaxima( ImagePlus imgFilter, String chr1,String chr2, double noiseTolerance, int resolution){ + public FindMaxima( ImagePlus imgFilter, String chr1,String chr2, double noiseTolerance, int resolution, double gaussian){ this._imgFilter = imgFilter; this._noiseTolerance = noiseTolerance; this._chr2 = chr2; this._chr = chr1; this._resolution = resolution; + this._gaussianFilterRadius = gaussian; } @@ -113,19 +117,17 @@ public HashMap findloop(int index, int nbZero, ImagePlus raw, float } /** + * @param * - * @param nbZero - * @param raw - * @param val - * @return */ + public HashMap findLoopInter(String pathRaw){ - public HashMap findloopInter( int nbZero, ImagePlus raw, float val){ - runInter(nbZero, raw, val); + ImagePlus raw = IJ.openImage(pathRaw); + ImageProcessor ipFilter = _imgFilter.getProcessor(); + runInter(raw); ArrayList temp = this.getMaxima(); ImageProcessor ipRaw = raw.getProcessor(); HashMap data = new HashMap<>(); - this._imgNorm = raw; //System.out.println("size raw maxima !!!!!!!!!!!!!! "+raw.getTitle()+" "+temp.size()); for(int j = 0; j < temp.size();++j){ String[] parts = temp.get(j).split("\\t"); @@ -134,22 +136,22 @@ public HashMap findloopInter( int nbZero, ImagePlus raw, float val) String name= this._chr+"\t"+this._chr2+"\t"+temp.get(j); float avg = average(x,y); float std = standardDeviation(x,y,avg); - int nbOfZero = detectNbOfZero(x,y,raw,ipRaw.getf(x, y)); - //if(avg > 1.45 && ipRaw.getf(x, y) >= 1.85){ // filter on the loop value and region value + int nbOfZero = detectNbOfZero(x,y,ipRaw.getf(x, y)); + if(nbOfZero <= 3){ // filter on the loop value and region value DecayAnalysis da = new DecayAnalysis(raw,x,y); float n1 =da.getNeighbourhood1(); float n2 =da.getNeighbourhood2(); - //if(n1 < n2 && n1 >= 0.15 && n2 >= 0.25){ // filter on the neighborood for hic datatset + if(n2>n1 && n1 >= 0 && n2 >= 0){ // filter on the neighborood for hic datatset Loop maxima = new Loop(temp.get(j),x,y,this._chr,this._chr2,avg,std,ipRaw.getf(x, y)); + maxima.setValueDiff(ipFilter.getf(x,y)); maxima.setNeigbhoord1(n1); maxima.setNeigbhoord2(n2); maxima.setResolution(this._resolution); maxima.setNbOfZero(nbOfZero); - //System.out.println(_resolution+" "+maxima.getResolution()); maxima.setMatrixSize(raw.getWidth()); data.put(name, maxima); - //} - //} + } + } } //System.out.println("after filter ################# "+raw.getTitle()+" "+data.size()); return data; @@ -165,7 +167,7 @@ public HashMap findloopInter( int nbZero, ImagePlus raw, float val) private void run(int nbZero, ImagePlus rawImage, float backgroundValue){ ImagePlus temp = this._imgFilter.duplicate(); ImageProcessor ip = temp.getProcessor(); - MaximumFinder mf = new MaximumFinder(); + MaximumFinder mf = new MaximumFinder(); ByteProcessor bp = mf.findMaxima(ip, this._noiseTolerance, MaximumFinder.SINGLE_POINTS, true); this._imgResu.setProcessor(bp); this.putLoopLowerTriangle(); @@ -177,18 +179,18 @@ private void run(int nbZero, ImagePlus rawImage, float backgroundValue){ /** * - * @param nbZero - * @param rawImage - * @param backgroundValue */ - private void runInter(int nbZero, ImagePlus rawImage, float backgroundValue){ + private void runInter(ImagePlus rawImage){ ImagePlus temp = this._imgFilter.duplicate(); ImageProcessor ip = temp.getProcessor(); + GaussianBlur gb = new GaussianBlur(); + gb.blurGaussian(ip, this._gaussianFilterRadius); MaximumFinder mf = new MaximumFinder(); ByteProcessor bp = mf.findMaxima(ip, this._noiseTolerance, MaximumFinder.SINGLE_POINTS, true); this._imgResu.setProcessor(bp); + this._imgNorm = rawImage; //this.removedCloseMaxima(); - //this.correctMaxima(); + this.correctMaxima(); //this.removeMaximaCloseToZero(nbZero,rawImage, backgroundValue); } @@ -197,21 +199,23 @@ private void runInter(int nbZero, ImagePlus rawImage, float backgroundValue){ * * @param x * @param y - * @param rawImage * @param val * @return */ - private int detectNbOfZero(int x, int y, ImagePlus rawImage, float val){ - int w = this._imgResu.getWidth(); - int h = this._imgResu.getHeight(); - ImageProcessor ipResu = this._imgResu.getProcessor(); - ImageProcessor ip = rawImage.getProcessor(); - int nbZero = 0; - for(int i = x - 2; i <= x+2; ++i) { - for (int j = y-2; j <= y+2; ++j) { - if(ip.getf(i,j) <= 1) { - nbZero++; - System.out.println("yup"); + private int detectNbOfZero(int x, int y, float val){ + int w = this._imgNorm.getWidth(); + int h = this._imgNorm.getHeight(); + ImageProcessor ip = _imgNorm.getProcessor(); + int nbZero = -1; + if(x >= 3 && x <= w-3 && y >= 3 && y <= h-3) { + nbZero = 0; + for (int i = x - 2; i <= x + 2; ++i) { + for (int j = y - 2; j <= y + 2; ++j) { + if (ip.getf(i, j) <= 1) { + nbZero++; + } else if (Double.isNaN(ip.getf(i, j))) { + nbZero++; + } } } } @@ -341,7 +345,9 @@ private float average(int x, int y){ for(int i = x-1; i <= x+1; ++i){ for(int j = y-1; j <= y+1; ++j){ if(i < ip.getWidth() && i>0 && j < ip.getWidth() && j > 0){ - sum +=ip.getf(i, j); + if( Double.isNaN(ip.getf(i, j))){ + sum +=0; + }else{ sum +=ip.getf(i, j);} ++nb; } } @@ -366,7 +372,9 @@ private float standardDeviation(int x, int y, double avg){ for(int i = x-1; i <= x+1; ++i){ for(int j = y-1; j <= y+1; ++j){ if(i < ip.getWidth() && i>0 && j < ip.getWidth() && j > 0){ - semc += (ip.getf(i, j)-avg)*(ip.getf(i, j)-avg); + if( Double.isNaN(ip.getf(i, j))){ + semc += (0-avg)*(0-avg); + }else{ semc += (ip.getf(i, j)-avg)*(ip.getf(i, j)-avg);} ++nb; } } diff --git a/src/utils/Loop.java b/src/utils/Loop.java index 4627c49..0bb3a22 100644 --- a/src/utils/Loop.java +++ b/src/utils/Loop.java @@ -48,6 +48,8 @@ public class Loop { private float _avg = -1; /** Value of the loop*/ private float _peakValue = -1; + /** Value of the loop*/ + private float _peakValueDiff = -1; /** Standard deviation value of the neighbourhood 9.*/ private float _std = -1; /** FDR score 1*/ @@ -254,6 +256,11 @@ public String loopToStringInter(){ * @return double loop value */ public float getValue(){ return this._peakValue; } + /** + * Getter of the loop(x,y) value + * @return double loop value + */ + public float getValueDiff(){ return this._peakValueDiff; } /** * Getter of the n 8 average value * @return double average of n 8 average @@ -302,6 +309,11 @@ public String loopToStringInter(){ * @return */ public float getPaScoreAvgdev(){ return this._paScoreAvgdev; } + /** + * + * @return + */ + public void setValueDiff(float diff){ this._peakValueDiff = diff; } /** * Setter of the peak analysis loop score diff --git a/src/utils/PeakAnalysisScore.java b/src/utils/PeakAnalysisScore.java index fed9eb8..2ba8bc2 100644 --- a/src/utils/PeakAnalysisScore.java +++ b/src/utils/PeakAnalysisScore.java @@ -50,70 +50,69 @@ public void computeScore(){ float corner = 0; float center = this._ipRaw.getf(x, y); float squareCenterAvg = process3By3SquareAvg(x,y); - - if(x >= 12 && y >= 12 && x < this._imgRaw.getWidth()-12 && y < this._imgRaw.getHeight()-12){ - corner = computeAvgCorner(x,y); - loop.setPaScoreAvg(center/corner); - loop.setRegionalPaScoreAvg(squareCenterAvg/corner); - - float probnum = 0; - float factorial = 1; - int countnumber = (int) (corner); - for (int i = 0; i < countnumber; i++) { - if (i == 0) { - factorial = 1; - }else { - factorial = 1; - for (int j = 1; j<= i; j++) factorial = factorial*j; - } - float tmpprobnum = (float) ((Math.pow(2.718,((center)*-1))*Math.pow((center),i))/factorial); - probnum = probnum + tmpprobnum; - } - loop.setPaScoreAvgdev(1-probnum); + corner = computeAvgCorner(x,y); + loop.setPaScoreAvg(center/corner); + loop.setRegionalPaScoreAvg(squareCenterAvg/corner); - int xFDR = x+10; - int yFDR = y+10; - if(xFDR > this._imgRaw.getWidth()-12 || yFDR > this._imgRaw.getHeight()-12){ - xFDR = x-10; - yFDR = y-10; + float probnum = 0; + float factorial = 1; + int countnumber = (int) (corner); + for (int i = 0; i < countnumber; i++) { + if (i == 0) { + factorial = 1; + }else { + factorial = 1; + for (int j = 1; j<= i; j++) factorial = factorial*j; } - - float centerFDR = this._ipRaw.getf(xFDR,yFDR); - float squareCenterAvgFDR = process3By3SquareAvg(xFDR,yFDR); - loop.setPaScoreAvgFDR(centerFDR/computeAvgCorner(xFDR,yFDR)); - loop.setRegionalPaScoreAvgFDR(squareCenterAvgFDR/computeAvgCorner(xFDR,yFDR)); - - int xFDR2 = x+25; - int yFDR2 = y+25; - if(xFDR2 > this._imgRaw.getWidth()-12 || yFDR2 > this._imgRaw.getHeight()-12){ - xFDR2 = x-25; - yFDR2 = y-25; - if(xFDR2 <= 0) xFDR2 = 13; - if(yFDR2 <= 0) yFDR2 = 13; - } - //System.out.println(xFDR2+" "+yFDR2); - float centerFDR2 = this._ipRaw.getf(xFDR2,yFDR2); - float squareCenterAvgFDR2 = process3By3SquareAvg(xFDR2,yFDR2); - loop.setPaScoreAvgFDR2(centerFDR2/computeAvgCorner(xFDR2,yFDR2)); - loop.setRegionalPaScoreAvgFDR2(squareCenterAvgFDR2/computeAvgCorner(xFDR2,yFDR2)); - - int xFDR3 = x+40; - int yFDR3 = y+40; - if(xFDR3 > this._imgRaw.getWidth()-12 || yFDR3 > this._imgRaw.getHeight()-12){ - xFDR3 = x-40; - yFDR3 = y-40; - if(xFDR3 <= 0) xFDR3 = 13; - if(yFDR3 <= 0) yFDR3 = 13; - } - - float centerFDR3 = this._ipRaw.getf(xFDR3,yFDR3); - float squareCenterAvgFDR3 = process3By3SquareAvg(xFDR3,yFDR3); - loop.setPaScoreAvgFDR3(centerFDR3/computeAvgCorner(xFDR3,yFDR3)); - loop.setRegionalPaScoreAvgFDR3(squareCenterAvgFDR3/computeAvgCorner(xFDR3,yFDR3)); + float tmpprobnum = (float) ((Math.pow(2.718,((center)*-1))*Math.pow((center),i))/factorial); + probnum = probnum + tmpprobnum; + } + loop.setPaScoreAvgdev(1-probnum); + + int xFDR = x+10; + int yFDR = y+10; + if(xFDR > this._imgRaw.getWidth()-12 || yFDR > this._imgRaw.getHeight()-12){ + xFDR = x-10; + yFDR = y-10; + if(xFDR <= 0) xFDR = 13; + if(yFDR <= 0) yFDR = 13; } + + float centerFDR = this._ipRaw.getf(xFDR,yFDR); + float squareCenterAvgFDR = process3By3SquareAvg(xFDR,yFDR); + loop.setPaScoreAvgFDR(centerFDR/computeAvgCorner(xFDR,yFDR)); + loop.setRegionalPaScoreAvgFDR(squareCenterAvgFDR/computeAvgCorner(xFDR,yFDR)); + + int xFDR2 = x+25; + int yFDR2 = y+25; + if(xFDR2 > this._imgRaw.getWidth()-12 || yFDR2 > this._imgRaw.getHeight()-12){ + xFDR2 = x-25; + yFDR2 = y-25; + if(xFDR2 <= 0) xFDR2 = 13; + if(yFDR2 <= 0) yFDR2 = 13; + } + float centerFDR2 = this._ipRaw.getf(xFDR2,yFDR2); + float squareCenterAvgFDR2 = process3By3SquareAvg(xFDR2,yFDR2); + loop.setPaScoreAvgFDR2(centerFDR2/computeAvgCorner(xFDR2,yFDR2)); + loop.setRegionalPaScoreAvgFDR2(squareCenterAvgFDR2/computeAvgCorner(xFDR2,yFDR2)); + + int xFDR3 = x+40; + int yFDR3 = y+40; + if(xFDR3 > this._imgRaw.getWidth()-12 || yFDR3 > this._imgRaw.getHeight()-12){ + xFDR3 = x-40; + yFDR3 = y-40; + if(xFDR3 <= 0) xFDR3 = 13; + if(yFDR3 <= 0) yFDR3 = 13; + } + + float centerFDR3 = this._ipRaw.getf(xFDR3,yFDR3); + float squareCenterAvgFDR3 = process3By3SquareAvg(xFDR3,yFDR3); + loop.setPaScoreAvgFDR3(centerFDR3/computeAvgCorner(xFDR3,yFDR3)); + loop.setRegionalPaScoreAvgFDR3(squareCenterAvgFDR3/computeAvgCorner(xFDR3,yFDR3)); } } - + + /** * compute the avg of5*5 square * @param x int coordinate of the pixel center @@ -123,10 +122,14 @@ public void computeScore(){ private float process3By3SquareAvg(int x, int y){ float sum = 0; int nb = 0; - for(int i = x-2; i <= x+2; ++i){ - for(int j = y-2; j <= y+2; ++j){ + for(int i = x-1; i <= x+1; ++i){ + for(int j = y-1; j <= y+1; ++j){ if(i < this._ipRaw.getWidth() && i>0 && j < this._ipRaw.getWidth() && j > 0){ - sum += this._ipRaw.getf(i,j); + if( Double.isNaN(this._ipRaw.getf(i, j))){ + sum += 0; + }else{ + sum += this._ipRaw.getf(i,j); + } nb++; } } @@ -147,6 +150,7 @@ private float computeAvgCorner(int x, int y){ corner += process3By3SquareAvg(x-10,y+10); corner += process3By3SquareAvg(x+10,y-10); corner += process3By3SquareAvg(x+10,y+10); + //System.out.println(corner+" dans avgCorner"); if( corner == 0) corner = (float) 0.1; return corner/4; } diff --git a/src/utils/SIPInter.java b/src/utils/SIPInter.java index b6b09d4..02d5cec 100644 --- a/src/utils/SIPInter.java +++ b/src/utils/SIPInter.java @@ -19,20 +19,19 @@ public class SIPInter{ private String _output; /** Strength of the gaussian filter*/ private double _gauss; - /** Strength of the min filter*/ - private double _min; - /** Strength of the max filter*/ - private double _max; - /** % of staurated pixel after enhance contrast*/ - private double _saturatedPixel; + + private double _fdr; + private double _medianAP; + private double _medianAPReg; + /** Image size*/ private int _matrixSize; /** Resolution of the bin dump in base*/ private int _resolution; /** Threshold for the maxima detection*/ - private int _thresholdMaxima; + private double _thresholdMaxima; /** HashMap of the chr size, the key = chr name, value = size of chr*/ - private HashMap _chrSize; + private HashMap _chrSize = new HashMap<>(); /** Size of the step to process each chr (step = matrixSize/2)*/ private int _step; /** Number of pixel = 0 allowed around the loop*/ @@ -45,23 +44,131 @@ public class SIPInter{ /** */ private boolean _keepTif; - public SIPInter(String output, HashMap chrsize, double gauss, double min, double max, int resolution, - double saturatedPixel, int thresholdMax, int matrixSize, int nbZero, boolean keepTif) { + /** + * + * constructor for hic file + * + * @param output + * @param chrsize + * @param gauss + * @param resolution + * @param thresholdMax + * @param matrixSize + * @param nbZero + * @param keepTif + * @param fdr + * @throws IOException + */ + public SIPInter(String output,String chrsize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, boolean keepTif,double fdr) throws IOException { this._output = output; - this._chrSize = chrsize; + setChrSize(chrsize); this._gauss = gauss; - this._min = min; - this._max = max; this._resolution = resolution; - this._saturatedPixel = saturatedPixel; + this._thresholdMaxima = thresholdMax; + this._matrixSize = matrixSize; + this._nbZero = nbZero; + this._keepTif = keepTif; + _fdr = fdr; + } + + /** + * constructor for processed data + * + * @param output + * @param chrsize + * @param gauss + * @param resolution + * @param thresholdMax + * @param matrixSize + * @param nbZero + * @param keepTif + */ + public SIPInter(String input,String output,String chrsize, double gauss, int resolution, + double thresholdMax, int matrixSize, int nbZero, boolean keepTif, double fdr) throws IOException { + + this._input = input; + this._output = output; + this._gauss = gauss; + setChrSize(chrsize); + this._resolution = resolution; this._thresholdMaxima = thresholdMax; this._matrixSize = matrixSize; this._nbZero = nbZero; this._keepTif = keepTif; + _fdr = fdr; } + /** + * + * @param pathFile + * @param hLoop + * @param first + * @throws IOException + */ + public void writeResu(String pathFile, HashMap hLoop, boolean first) throws IOException { + FDR fdrDetection = new FDR (); + fdrDetection.run(this._fdr, hLoop); + double RFDRcutoff = fdrDetection.getRFDRcutoff(); + double FDRcutoff = fdrDetection.getFDRcutoff(); + System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); + BufferedWriter writer; + if(first) writer = new BufferedWriter(new FileWriter(new File(pathFile), true)); + else{ + writer = new BufferedWriter(new FileWriter(new File(pathFile))); + writer.write("chromosome1\tx1\tx2\tchromosome2\ty1\ty2\tcolor\tAPScoreAvg\tAPRegScoreAvg\tAvg_diffMaxNeighbour_1\tAvg_diffMaxNeighbour_2\tavg\tstd\tvalue\tvalueDiff\tnbOfZero\tProbabilityofEnrichment\n"); + } + + if(hLoop.size()>0) { + Set key = hLoop.keySet(); + Iterator it = key.iterator(); + while (it.hasNext()) { + Loop loop = hLoop.get(it.next()); + ArrayList coord = loop.getCoordinates(); + if (loop.getPaScoreAvg() > FDRcutoff && loop.getRegionalPaScoreAvg() > RFDRcutoff && loop.getValueDiff() > 1.3 && loop.getValue() >= 8) { + writer.write(loop.getChr() + "\t" + coord.get(0) + "\t" + coord.get(1) + "\t" + loop.getChr2() + "\t" + coord.get(2) + "\t" + coord.get(3) + "\t0,0,0" + + "\t" + loop.getPaScoreAvg() + "\t" + loop.getRegionalPaScoreAvg() + "\t" + loop.getNeigbhoord1() + "\t" + loop.getNeigbhoord2() + "\t" + loop.getAvg() + "\t" + + loop.getStd() + "\t" + loop.getValue() + "\t" +loop.getValueDiff() + "\t" + loop.getNbOfZero() +"\t"+loop.getPaScoreAvgdev()+"\n"); + } + } + } + writer.close(); + } + + /** + * + * @return + */ + private void median(HashMap data, double fdrCutoff){ + Set key = data.keySet(); + Iterator it = key.iterator(); + ArrayList n1 = new ArrayList (); + ArrayList n2 = new ArrayList (); + int nb = 0; + while (it.hasNext()){ + String name = it.next(); + Loop loop = data.get(name); + if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > fdrCutoff && loop.getPaScoreAvgdev() > .9){ + n1.add(loop.getPaScoreAvg()); + n2.add(loop.getRegionalPaScoreAvg()); + nb++; + } + } + if(nb>0){ + n1.sort(Comparator.naturalOrder()); + n2.sort(Comparator.naturalOrder()); + double pos1 = Math.floor((n1.size() - 1.0) / 2.0); + double pos2 = Math.ceil((n1.size() - 1.0) / 2.0); + if (pos1 == pos2 ) _medianAP = n1.get((int)pos1); + else _medianAP = (n1.get((int)pos1) + n1.get((int)pos2)) / 2.0 ; + pos1 = Math.floor((n2.size() - 1.0) / 2.0); + pos2 = Math.ceil((n2.size() - 1.0) / 2.0); + if (pos1 == pos2 ) _medianAPReg = n2.get((int)pos1); + else _medianAPReg = (n2.get((int)pos1) + n2.get((int)pos2)) / 2.0 ; + // System.out.println("AP\t"+_medianAP+"\nAPREG\t"+_medianAPReg); + } + } /** * Getter of the input dir @@ -113,41 +220,6 @@ public SIPInter(String output, HashMap chrsize, double gauss, d public void setGauss(double gauss){ this._gauss = gauss; } - /** - * Getter of the min filter strength - * @return double strength of the min filter - */ - public double getMin(){ return this._min;} - - /** - * Setter of the min filter strength - * @param min double min - */ - public void setMin(double min){ this._min = min;} - - /** - * Getter of the max filter strength - * @return double max filter - */ - public double getMax(){ return this._max; } - - /** - * Setter of the min filter strength - * @param max double max - */ - public void setMax(double max){ this._max = max;} - - /** - * Getter % of saturated pixel for the contrast enhancement - * @return double percentage of saturated - */ - public double getSaturatedPixel(){ return this._saturatedPixel; } - - /** - * Setter % of saturated pixel for the contrast enhancement - * @param saturatedPixel double saturatedPixel - */ - public void setSaturatedPixel(double saturatedPixel){ this._saturatedPixel = saturatedPixel; } /** * Getter of resolution of the bin @@ -177,7 +249,7 @@ public SIPInter(String output, HashMap chrsize, double gauss, d * Getter of threshold for the detection of the regional maxima * @return int threshold */ - public int getThresholdMaxima(){ return _thresholdMaxima;} + public double getThresholdMaxima(){ return _thresholdMaxima;} /** * Setter of threshold for the detection of the maxima * @param thresholdMaxima int new threshold @@ -235,11 +307,36 @@ public SIPInter(String output, HashMap chrsize, double gauss, d */ public void setIsGui(boolean isGui) { this._isGui = isGui;} + /** - * getter of _chrSize - * @return HashMap + * + * @param chrSizeFile + * @return + * @throws IOException */ - public HashMap getChrSizeHashMap(){return this._chrSize;} + public void setChrSize(String chrSizeFile) throws IOException{ + BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null){ + sb.append(line); + String[] parts = line.split("\\t"); + String chr = parts[0]; + int size = Integer.parseInt(parts[1]); + _chrSize.put(chr, size); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + br.close(); + } + + /** + * \ + * @return + */ + public HashMap getChrSize() { + return _chrSize; + } } diff --git a/src/utils/SIPObject.java b/src/utils/SIPObject.java index c9a0536..4271143 100644 --- a/src/utils/SIPObject.java +++ b/src/utils/SIPObject.java @@ -222,7 +222,7 @@ public void saveFile(String pathFile, HashMap data, boolean first) } } }else{ - if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > FDRcutoff && loop.getRegionalPaScoreAvg() > RFDRcutoff && loop.getPaScoreAvgdev() > .9){ + if(loop.getPaScoreAvg() > FDRcutoff && loop.getRegionalPaScoreAvg() > RFDRcutoff && loop.getPaScoreAvgdev() > .9){ writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" +"\t"+loop.getPaScoreAvg()+"\t"+loop.getPaScoreAvgdev()+"\t"+loop.getRegionalPaScoreAvg()+"\t" +loop.getNeigbhoord1()+"\t"+loop.getNeigbhoord2()+"\t"+loop.getAvg()+"\t" From 641ddfa0d63966eab2b0fdd2c99c9da0346b8719 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Fri, 6 Nov 2020 22:07:28 -0500 Subject: [PATCH 07/27] add comment in most of the classes --- src/multiProcesing/ProcessCoolerDumpData.java | 28 +- src/multiProcesing/ProcessDetectLoops.java | 37 ++- .../RunnableDetectInterLoops.java | 41 ++- src/multiProcesing/RunnableDetectLoops.java | 40 +-- .../RunnableDumpDataCooler.java | 40 +-- src/multiProcesing/RunnableDumpDataHiC.java | 40 +-- .../RunnableDumpInterChromoData.java | 9 +- src/process/CallLoops.java | 30 +- src/process/CallLoopsInter.java | 32 +- src/process/CoolerDumpData.java | 54 ++-- src/process/DumpData.java | 52 ++-- src/process/DumpInterChromosomal.java | 46 ++- src/process/MultiResProcess.java | 121 ++++---- src/process/TupleFileToImage.java | 41 +-- src/test/TestInter.java | 2 +- src/utils/CoolerExpected.java | 79 ++--- src/utils/CoordinatesCorrection.java | 10 +- src/utils/FDR.java | 84 +++--- src/utils/FilterLoops.java | 5 +- src/utils/SIPInter.java | 139 ++++----- src/utils/SIPObject.java | 280 ++++++++++-------- 21 files changed, 628 insertions(+), 582 deletions(-) diff --git a/src/multiProcesing/ProcessCoolerDumpData.java b/src/multiProcesing/ProcessCoolerDumpData.java index ea3028e..2cd5460 100644 --- a/src/multiProcesing/ProcessCoolerDumpData.java +++ b/src/multiProcesing/ProcessCoolerDumpData.java @@ -26,26 +26,31 @@ public class ProcessCoolerDumpData { private Progress _p; /** - * + * Constructor */ public ProcessCoolerDumpData(){ } /** - * * run the processing on different cpu, if all cpu are running, take break else run a new one. - * - * @param hicFile - * @param sip - * @param chrSize - * @param juiceBoxTools - * @param normJuiceBox - * @param nbCPU - * @throws InterruptedException + * run the processing on different cpu, if all cpu are running, take break else run a new one. + *for each chromosome the normalized data and expected data will be dump via cooler and cooltool. + * the SIP are produce in this step allowing later, the creation of the images and the loops calling step. + * + * if gui is true a progress bar will pop up. + * + * + * @param coolTools String coolTools path + * @param cooler String cooler path + * @param sip SIPObject + * @param coolFile path mcool file + * @param chrSize hashMap chr name => chrSize + * @param nbCPU number of cpu + * @throws InterruptedException exception */ public void go(String coolTools, String cooler, SIPObject sip, String coolFile, HashMap chrSize,int nbCPU) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); Iterator chrName = chrSize.keySet().iterator(); File outDir = new File(sip.getOutputDir()); - if (outDir.exists()==false) outDir.mkdir(); + if (!outDir.exists()) outDir.mkdir(); ArrayList listFactor = sip.getListFactor(); for(int indexFact = 0; indexFact < listFactor.size(); ++indexFact) { @@ -88,6 +93,5 @@ public void go(String coolTools, String cooler, SIPObject sip, String coolFile, if(name.contains(".expected")) listOfFiles[i].delete(); } if(sip.isGui()) _p.dispose(); - } } diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index a714da8..d23b3a4 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -4,7 +4,6 @@ import java.util.Iterator; import gui.Progress; -import process.DumpInterChromosomal; import utils.SIPInter; import utils.SIPObject; @@ -14,8 +13,8 @@ /** - * multi thread class - * Construct all the RunnableDetectLoops Object and run them sequencily with the available processors + * multi thread class for the SIP loop calling step + * * * @author axel poulet * @@ -28,7 +27,17 @@ public class ProcessDetectLoops{ /** */ public ProcessDetectLoops(){ } - + + /** + * multiprocessing method for SIP intra chromosomal interaction + * + * @param sip SIPObject + * @param nbCPU nb of cpu + * @param delImage boolean if true del all the tif file + * @param resuFile path to results file + * @param resName name of the resolution used + * @throws InterruptedException exception + */ public void go(SIPObject sip,int nbCPU, boolean delImage, String resuFile,String resName) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); Iterator chrName = sip.getChrSizeHashMap().keySet().iterator(); @@ -69,15 +78,15 @@ public void go(SIPObject sip,int nbCPU, boolean delImage, String resuFile,String } /** - * - * @param sipInter - * @param nbCPU - * @param delImage - * @param resuFile - * @param resName - * @throws InterruptedException + * multiprocessing for sip on inter-chromosomal interaction + * for each couple of chromosome, RunnableDetectInterLoop is call. + * @param sipInter SIPInter object + * @param nbCPU number of cpu + * @param delImage boolean if true del all the tif file + * @param resuFile path to results file + * @throws InterruptedException exception */ - public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile, String resName) throws InterruptedException { + public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); HashMap chrSize = sipInter.getChrSize(); Object [] chrName = chrSize.keySet().toArray(); @@ -115,8 +124,8 @@ public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile, } /** * - * @param dirToTest - * @return + * @param dirToTest path to test if it is existing + * @return boolean */ private boolean isProcessedMcool(String dirToTest) { File test = new File (dirToTest); diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/multiProcesing/RunnableDetectInterLoops.java index 3ca25cb..9f2c193 100644 --- a/src/multiProcesing/RunnableDetectInterLoops.java +++ b/src/multiProcesing/RunnableDetectInterLoops.java @@ -9,39 +9,34 @@ import java.io.IOException; import java.util.HashMap; - +/** + * runnable class for inter loops detection + * + */ public class RunnableDetectInterLoops extends Thread implements Runnable { - /** - * SIP object containing all the parameter for the loops detection - */ + /*** SIP object containing all the parameter for the loops detection */ private SIPInter _sipInter; - /** - * CallLoops object - */ + /** CallLoops object */ private CallLoopsInter _callLoopsInter; - /** - * String results file - */ + /** String results file */ private String _resuFile; - /** - * String name of the chr - */ + /** String name of the chr1 */ private String _chr1; - /** - * - */ + /** String chr name 2 */ private String _chr2; - /** - * String name of the chr - */ + /**String name of the chr*/ private boolean _delImages = true; - /** - * norn vector table for the chr of interest - */ + /** - * Construtor, initialize all the variables of interest + * Construtor, initialize all the variables of interest + * + * @param chr1 chr1 name + * @param chr2 chr2 name + * @param resuFile path output file + * @param sip SIPInter object + * @param delFile boolean if true delete all tif file. */ public RunnableDetectInterLoops(String chr1, String chr2, String resuFile, SIPInter sip, boolean delFile) { this._sipInter = sip; diff --git a/src/multiProcesing/RunnableDetectLoops.java b/src/multiProcesing/RunnableDetectLoops.java index 4fbfd0b..8208c85 100644 --- a/src/multiProcesing/RunnableDetectLoops.java +++ b/src/multiProcesing/RunnableDetectLoops.java @@ -7,7 +7,7 @@ import java.util.HashMap; /** - * Runnable class for loops detcetion + * Runnable class for loops detection * * @author axel poulet * @@ -25,20 +25,20 @@ public class RunnableDetectLoops extends Thread implements Runnable{ private boolean _delImages = true; /** norn vector table for the chr of interest*/ private HashMap _normVector = new HashMap (); - /** */ - private String _normvectorFile; + /** path of Normalized vector from juicer tools dump for each chr by SIP*/ + private String _normVectorFile; /** - * Construtor, initialize all the variables of interest + * Constructor, initialize all the variables needed for runnableDetectLoop, for hic file * * - * @param chr - * @param resuFile - * @param sip - * @param normVectorFile - * @param delFile + * @param chr String chromosome name + * @param resuFile path to the result file + * @param sip SIPObject + * @param normVectorFile path to normalized vector + * @param delFile boolean if true delete all the tif file at the end of the process */ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, String normVectorFile, boolean delFile){ this._sip = sip; @@ -47,15 +47,16 @@ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, String n this._resuFile = resuFile; this._normVector = sip.getNormValueFilter(normVectorFile); this._delImages = delFile; - this._normvectorFile = normVectorFile; + this._normVectorFile = normVectorFile; } /** + * Constructor, initialize all the variables needed for runnableDetectLoop, for mcool file * - * @param chr - * @param resuFile - * @param sip - * @param delFile + * @param chr String chromosome name + * @param resuFile path to the result file + * @param sip SIPObject + * @param delFile boolean if true delete all the tif file at the end of the process */ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, boolean delFile){ this._sip = sip; @@ -77,20 +78,23 @@ public void run(){ HashMap data = new HashMap (); if (this._sip.isProcessed()) dir = this._sip.getInputDir()+resName+File.separator+this._chr+File.separator; try { - File[] listOfFiles = _sip.fillList(dir); + File folder = new File(dir); + File[] listOfFiles = folder.listFiles(); + System.out.println(dir); if (listOfFiles.length == 0) System.out.println("!!!!!!!!!! dumped directory of chromosome"+this._chr+" empty"); else{ File file = new File(this._resuFile); - if(_sip.isCooler() == false) { - System.out.println(_normvectorFile+"normVector end loading file: "+_chr+".norm "+resName); + if(!_sip.isCooler()) { + System.out.println(_normVectorFile +"normVector end loading file: "+_chr+".norm "+resName); } data = this._callLoops.detectLoops(listOfFiles,this._chr,this._normVector); synchronized(this) { if (file.length() == 0) _sip.saveFile(this._resuFile,data,false); else this._sip.saveFile(this._resuFile,data, true); } - listOfFiles = _sip.fillList(dir); + folder = new File(dir); + listOfFiles = folder.listFiles(); if(_delImages){ System.out.println("Deleting image file for "+_chr); for(int i = 0; i < listOfFiles.length;++i) { diff --git a/src/multiProcesing/RunnableDumpDataCooler.java b/src/multiProcesing/RunnableDumpDataCooler.java index 194e7d8..ccb455b 100644 --- a/src/multiProcesing/RunnableDumpDataCooler.java +++ b/src/multiProcesing/RunnableDumpDataCooler.java @@ -14,33 +14,34 @@ */ public class RunnableDumpDataCooler extends Thread implements Runnable{ /**String: path where save the dump data */ - private String _outdir =""; + private String _outdir ; /**String: name of the chr*/ - private String _chrName = ""; + private String _chrName; /**int: chr size */ - private int _chrSize = 0; + private int _chrSize; /** DumpData object run juicertoolbox.jar*/ private CoolerDumpData _coolerDumpData; /**int: bin resolution*/ - private int _res = 0; + private int _res; /**int: image Size */ - private int _matrixSize = 0; + private int _matrixSize; /**int: size of the step to run a chr */ - private int _step = 0; - /** */ + private int _step; + /** List of integer for multi-resolution loop calling*/ private ArrayList _listFactor; /** * Constructor, initialize the variables of interest * - * @param outdir - * @param chrName - * @param chrSize - * @param dumpData - * @param res - * @param matrixSize - * @param step + * @param outdir string path outdir + * @param chrName string chr name + * @param chrSize int chr size + * @param dumpData CoolerDumpData Object + * @param res bin size + * @param matrixSize image size + * @param step step between each image + * @param listFactor List of integer for multi-resolution loop calling */ public RunnableDumpDataCooler (String outdir, String chrName, int chrSize, CoolerDumpData dumpData,int res, int matrixSize, int step, ArrayList listFactor){ this._outdir = outdir; @@ -54,7 +55,8 @@ public RunnableDumpDataCooler (String outdir, String chrName, int chrSize, Coole } /** - * Dump teh data by chr + * Dump the data by chr for mcool data + * using cooler and cooltools */ public void run(){ boolean coolerTools; @@ -73,11 +75,11 @@ public void run(){ _coolerDumpData.setExpected(lExpected); String outdir = this._outdir+File.separator+nameRes+File.separator+this._chrName+File.separator; File file = new File(outdir); - if (file.exists()==false) file.mkdirs(); + if (!file.exists()) file.mkdirs(); int step = this._step*res; int j = matrixSize*res; String name = outdir+this._chrName+"_0_"+j+".txt"; - if (file.exists()==false) file.mkdir(); + if (!file.exists()) file.mkdir(); System.out.println("start dump "+this._chrName+" size "+this._chrSize+" res "+ nameRes); if(j > this._chrSize) j = this._chrSize; for(int i = 0 ; j-1 <= this._chrSize; i+=step,j+=step){ @@ -86,7 +88,7 @@ public void run(){ name = outdir+this._chrName+"_"+i+"_"+end+".txt"; System.out.println("start dump "+this._chrName+" size "+this._chrSize+" dump "+dump+" res "+ nameRes); coolerTools = this._coolerDumpData.dumpObservedMExpected(dump,name,res); - if (coolerTools == false){ + if (!coolerTools){ System.out.print(dump+" "+"\n"+coolerTools+"\n"); System.exit(0); } @@ -97,7 +99,7 @@ public void run(){ name = outdir+this._chrName+"_"+i+"_"+j+".txt"; System.out.println("start dump "+this._chrName+" size "+this._chrSize+" dump "+dump+" res "+ nameRes); coolerTools = this._coolerDumpData.dumpObservedMExpected(dump,name,res); - if (coolerTools == false){ + if (!coolerTools){ System.out.print(dump+" "+"\n"+coolerTools+"\n"); System.exit(0); } diff --git a/src/multiProcesing/RunnableDumpDataHiC.java b/src/multiProcesing/RunnableDumpDataHiC.java index f4b8b90..189a4d7 100644 --- a/src/multiProcesing/RunnableDumpDataHiC.java +++ b/src/multiProcesing/RunnableDumpDataHiC.java @@ -10,40 +10,41 @@ * The data are dumped by chr and by windows size, with user's parameters choose. * * two sorts of file file will be created one for the raw value with the observed minus expected value and also with the diatnce normalized value. - * Then the "norm" vector is also dump in an other deirectory. + * Then the "norm" vector is also dump in an other directory. * * @author axel poulet * */ public class RunnableDumpDataHiC extends Thread implements Runnable{ /**String: path where save the dump data */ - private String _outdir =""; + private String _outdir; /**String: name of the chr*/ - private String _chrName = ""; + private String _chrName; /**int: chr size */ - private int _chrSize = 0; + private int _chrSize; /** DumpData object run juicertoolbox.jar*/ private DumpData _dumpData; /**int: bin resolution*/ - private int _res = 0; + private int _res; /**int: image Size */ - private int _matrixSize = 0; + private int _matrixSize; /**int: size of the step to run a chr */ - private int _step = 0; - /** */ + private int _step ; + /** List of integer for multi-resolution loop calling*/ private ArrayList _listFactor; /** * Constructor, initialize the variables of interest - * - * @param outdir - * @param chrName - * @param chrSize - * @param dumpData - * @param res - * @param matrixSize - * @param step + * + * @param outdir string path outdir + * @param chrName string chr name + * @param chrSize int chr size + * @param dumpData CoolerDumpData Object + * @param res bin size + * @param matrixSize image size + * @param step step between each image + * @param listFactor List of integer for multi-resolution loop calling */ public RunnableDumpDataHiC (String outdir, String chrName, int chrSize, DumpData dumpData,int res, int matrixSize, int step, ArrayList listFactor){ this._outdir = outdir; @@ -57,7 +58,8 @@ public RunnableDumpDataHiC (String outdir, String chrName, int chrSize, DumpData } /** - * Dump teh data by chr + * Dump th data by chr for hic file + * using juicer tools */ public void run(){ boolean juicerTools; @@ -70,7 +72,7 @@ public void run(){ nameRes = nameRes+"kb"; String outdir = this._outdir+nameRes+File.separator+this._chrName+File.separator; File file = new File(outdir); - if (file.exists()==false) file.mkdirs(); + if (!file.exists()) file.mkdirs(); int step = this._step*res; int j = matrixSize*res; String test = this._chrName+":0:"+j; @@ -78,7 +80,7 @@ public void run(){ this._dumpData.getExpected(test,name,res); String normOutput = this._outdir+nameRes+File.separator+"normVector"; file = new File(normOutput); - if (file.exists()==false) file.mkdir(); + if (!file.exists()) file.mkdir(); try { this._dumpData.getNormVector(this._chrName,normOutput+File.separator+this._chrName+".norm",res); System.out.println("start dump "+this._chrName+" size "+this._chrSize+" res "+ nameRes); diff --git a/src/multiProcesing/RunnableDumpInterChromoData.java b/src/multiProcesing/RunnableDumpInterChromoData.java index 232a77c..fa03ec5 100644 --- a/src/multiProcesing/RunnableDumpInterChromoData.java +++ b/src/multiProcesing/RunnableDumpInterChromoData.java @@ -10,14 +10,21 @@ * */ public class RunnableDumpInterChromoData extends Thread implements Runnable{ - + /** path outdir */ private String _outDir; + /** chr1 name */ private String _chr1; + /** chr2 name*/ private String _chr2; + /** size chr1*/ private int _sizeChr1; + /** size chr2 */ private int _sizeChr2; + /** Object DumpInterChromosomal*/ private DumpInterChromosomal _dumpInter; + /** bin size*/ private int _resolution; + /** image size*/ private int _matrixSize; /** diff --git a/src/process/CallLoops.java b/src/process/CallLoops.java index 7ea46d4..32783e8 100644 --- a/src/process/CallLoops.java +++ b/src/process/CallLoops.java @@ -31,10 +31,10 @@ public class CallLoops { private double _min; /** Strength of the max filter*/ private double _max; - /** % of staurated pixel after enhance contrast*/ + /** % of saturated pixel after enhance contrast*/ private double _saturatedPixel; /** Image size*/ - private int _matrixSize = 0; + private int _matrixSize; /** Resolution of the bin dump in base*/ private int _resolution; /** Threshold for the maxima detection*/ @@ -48,8 +48,9 @@ public class CallLoops { /** struturing element for the MM method used (MorpholibJ)*/ private Strel _strel = Strel.Shape.SQUARE.fromRadius(40); /** image background value*/ - private float _backgroudValue = (float) 0.25; - private boolean _isCooler = false; + private float _backgroudValue; + /** boolean if true => mcool file in input */ + private boolean _isCooler; /** * Constructor @@ -64,10 +65,11 @@ public CallLoops(SIPObject sip){ this._matrixSize = sip.getMatrixSize(); this._resolution = sip.getResolution(); this._thresholdMaxima = sip.getThresholdMaxima(); - this._diagSize = sip.getDiagSize(); + this._diagSize = sip.getDiagonalSize(); this._step = sip.getStep(); this._nbZero = sip.getNbZero(); this._isCooler = sip.isCooler(); + _backgroudValue = (float) 0.25; //System.out.println("gauss:"+this._gauss+" min:"+this._min+" max:"+_max+" sat:"+_saturatedPixel+ //" matrix:"+_matrixSize+" res:"+_resolution+" thresh:"+_thresholdMaxima+" diag:"+_diagSize+ //" step:"+_step+" nbZero:"+_nbZero); @@ -81,11 +83,11 @@ public CallLoops(SIPObject sip){ * faire un gros for deguelasse por passer les faceteur de grossissement seulement si listDefacteur > 1. * make and save image at two differents resolution (m_resolution and m_resolution*2) * if there is a lot pixel at zero in the images adapt the threshold for the maxima detection - * @param fileList - * @param chr - * @param normVector - * @return - * @throws IOException + * @param fileList list of File + * @param chr chr name + * @param normVector hashMap normVector containing biased coordinate + * @return HashMap loop name => Loop Object + * @throws IOException exception */ public HashMap detectLoops(File[] fileList, String chr,HashMap normVector) throws IOException{ CoordinatesCorrection coord = new CoordinatesCorrection(); @@ -153,11 +155,11 @@ private void imageProcessing(ImagePlus imgFilter, String fileName, ImageProcessi /** - * Make Image + * Make Image from tuple file give in input via the TupleFileToImage Object * * - * @param readFile - * @return + * @param readFile TupleFileToImage object + * @return ImagePlus */ private ImagePlus doImage(TupleFileToImage readFile){ String file = readFile.getInputFile(); @@ -175,7 +177,7 @@ private ImagePlus doImage(TupleFileToImage readFile){ * @param imagePlusInput image to save * @param pathFile path to save the image */ - public void saveFile ( ImagePlus imagePlusInput, String pathFile){ + private void saveFile ( ImagePlus imagePlusInput, String pathFile){ FileSaver fileSaver = new FileSaver(imagePlusInput); fileSaver.saveAsTiff(pathFile); } diff --git a/src/process/CallLoopsInter.java b/src/process/CallLoopsInter.java index fcb0d06..64210ab 100644 --- a/src/process/CallLoopsInter.java +++ b/src/process/CallLoopsInter.java @@ -33,18 +33,12 @@ public CallLoopsInter(SIPInter sipInter){ /** * Detect loops methods - * detect the loops at two different resolution, initial resolution + 2 fold bigger - * call the loops first in the smaller resolution - * then making image with bigger resolution and fill no Zero list - * faire un gros for deguelasse por passer les faceteur de grossissement seulement si listDefacteur > 1. - * make and save image at two differents resolution (m_resolution and m_resolution*2) - * if there is a lot pixel at zero in the images adapt the threshold for the maxima detection * - * @param fileList - * @param chrName1 - * @param chrName2 - * @return - * @throws IOException + * @param fileList list with tuple file + * @param chrName1 name of chr 1 + * @param chrName2 name of chr 2 + * @return HashMap name loop => Loop Object + * @throws IOException exception */ public HashMap detectLoops(File[] fileList, String chrName1, String chrName2){ CoordinatesCorrection coord = new CoordinatesCorrection(); @@ -74,12 +68,15 @@ public HashMap detectLoops(File[] fileList, String chrName1, Strin return hLoop; } - /** - * Save the image file - * - * @param imagePlusInput image to save - * @param pathFile path to save the image - */ + /** + * Create and save the diff image. + * for each pixel compute the new value computing the average subtraction between the pixel of interest and all + * pixel inside the neighbor 3 + * + * @param imagePlusInput imagePlus raw + * @param pathFile path to the imagePlus raw + * @return the diff ImagePlus + */ private ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ GaussianBlur gb = new GaussianBlur(); ImageProcessor ip = imagePlusInput.getProcessor(); @@ -99,7 +96,6 @@ private ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ } } } - //if(sum < 0 ) sum = 0; pRaw.setf(i,j,sum/48); } } diff --git a/src/process/CoolerDumpData.java b/src/process/CoolerDumpData.java index 9e8a354..0f14b70 100644 --- a/src/process/CoolerDumpData.java +++ b/src/process/CoolerDumpData.java @@ -12,6 +12,12 @@ import java.nio.file.Paths; import java.util.ArrayList; +/** + * dump data contained in mcool file via cooler tools + * + * https://github.com/open2c/cooler + * Abdennur, N., and Mirny, L. (2019). Cooler: scalable storage for Hi-C data and other genomically labeled arrays. Bioinformatics. doi: 10.1093/bioinformatics/btz540. + */ public class CoolerDumpData { @@ -20,20 +26,18 @@ public class CoolerDumpData { /** String for the log*/ private String _log = ""; /** path to the hic file or url link*/ - private String _coolFile = ""; + private String _coolFile; /** List of doucle to stock the expected vector*/ private ArrayList _lExpected = new ArrayList(); + /** path to cooler tools*/ + private String _cooler ; + - private String _cooler = ""; - - /** * Constructor of this class to iniatilise the different variables - * - * @param juiceboxTools: String: path of juicertoolsBox - * @param hicFile: String: path to the HiC file - * @param norm: String: type of normalisation - * @param resolution: int: resolution of the bins + * + * @param cooler path to cooler bin + * @param coolFile path of mcool file */ public CoolerDumpData(String cooler, String coolFile) { this._coolFile = coolFile; @@ -44,8 +48,8 @@ public CoolerDumpData(String cooler, String coolFile) { * * @param chr: String for the name of teh chromosome * @param output: String path of the output - * @return - * @throws IOException + * @return boolean + * @throws IOException exception */ public boolean dumpObservedMExpected(String chr, String output, int resolution) throws IOException{ int exitValue=1; @@ -62,8 +66,7 @@ public boolean dumpObservedMExpected(String chr, String output, int resolution) new ReturnFlux(process.getErrorStream()).start(); exitValue=process.waitFor(); } - catch (IOException e) { e.printStackTrace();} - catch (InterruptedException e) {e.printStackTrace();} + catch (IOException | InterruptedException e) { e.printStackTrace();} if(_logError!=""){ System.out.println(_logError); System.exit(0); @@ -79,7 +82,8 @@ public boolean dumpObservedMExpected(String chr, String output, int resolution) * * @param obs: String path with the file of the observed value * @param chr: name of the chr - * @throws IOException + * @param resolution resolution of interest + * @throws IOException exception */ private void observedMExpected(String obs, String chr, int resolution) throws IOException{ BufferedReader br = Files.newBufferedReader(Paths.get(obs), StandardCharsets.UTF_8); @@ -100,21 +104,15 @@ private void observedMExpected(String obs, String chr, int resolution) throws IO writer.close(); br.close(); } - - public void setExpected( ArrayList lExpected) {this._lExpected = lExpected;} /** - * getter of the logerror file if necessary - * - * @return return the String with the error - */ - public String getLogError(){ return this._logError;} - - /** - * getter of the log info if necessary - * @return return a String with the log info + * setter for expected vector + * + * @param lExpected list of expected value */ - public String getLog(){ return this._log;} + public void setExpected( ArrayList lExpected) {this._lExpected = lExpected;} + + /** * Class to run command line in java * @author axel poulet @@ -130,7 +128,7 @@ public class ReturnFlux extends Thread { * @param flux * flux to redirect */ - public ReturnFlux(InputStream flux){this._flux = flux; } + private ReturnFlux(InputStream flux){this._flux = flux; } /** * @@ -141,7 +139,7 @@ public void run(){ BufferedReader br = new BufferedReader(reader); String line=null; while ( (line = br.readLine()) != null) { - if(line.contains("WARN")== false) _logError = _logError+line+"\n"; + if(!line.contains("WARN")) _logError = _logError+line+"\n"; } } catch (IOException ioe){ diff --git a/src/process/DumpData.java b/src/process/DumpData.java index 7c9b505..a15e98b 100644 --- a/src/process/DumpData.java +++ b/src/process/DumpData.java @@ -36,11 +36,11 @@ public class DumpData { /** String for the log*/ private String _log = ""; /** String => normalisation to dump the data (NONE, KR, VC, VC_SQRT or NONE)*/ - private String _normalisation= ""; + private String _normalisation; /** path to the hic file or url link*/ - private String _hicFile = ""; + private String _hicFile; /** path to juicer_toolsbox.jars*/ - private String _juiceBoxTools = ""; + private String _juiceBoxTools ; /** List of doucle to stock the expected vector*/ private ArrayList _lExpected = new ArrayList(); @@ -49,7 +49,7 @@ public class DumpData { /** * Constructor of this class to iniatilise the different variables * - * @param juiceboxTools: String: path of juicertoolsBox + * @param juiceboxTools: String: path of juicertools * @param hicFile: String: path to the HiC file * @param norm: String: type of normalisation */ @@ -64,8 +64,9 @@ public DumpData(String juiceboxTools,String hicFile, String norm) { * * @param chr: String for the name of teh chromosome * @param output: String path of the output - * @return - * @throws IOException + * @param resolution resolutionn of interest + * @return boolean + * @throws IOException exception */ public boolean dumpObservedMExpected(String chr, String output, int resolution) throws IOException{ int exitValue=1; @@ -80,8 +81,7 @@ public boolean dumpObservedMExpected(String chr, String output, int resolution) new ReturnFlux(process.getErrorStream()).start(); exitValue=process.waitFor(); } - catch (IOException e) { e.printStackTrace();} - catch (InterruptedException e) {e.printStackTrace();} + catch (IOException | InterruptedException e) { e.printStackTrace();} observedMExpected(obs,output,resolution); if(_logError.contains("Exception")) { System.out.println(_logError); @@ -97,7 +97,8 @@ public boolean dumpObservedMExpected(String chr, String output, int resolution) * * @param obs: String path with the file of the observed value * @param chr: name of the chr - * @throws IOException + * @param resolution resolution of interest + * @throws IOException exception */ private void observedMExpected(String obs, String chr, int resolution) throws IOException{ BufferedReader br = Files.newBufferedReader(Paths.get(obs), StandardCharsets.UTF_8); @@ -117,26 +118,14 @@ private void observedMExpected(String obs, String chr, int resolution) throws IO br.close(); } - - /** - * getter of the logerror file if necessary - * - * @return return the String with the error - */ - public String getLogError(){ return this._logError;} - - /** - * getter of the log info if necessary - * @return return a String with the log info - */ - public String getLog(){ return this._log;} - + /** * getter of the expected matrix. * * @param chr: String name of the chromosme * @param output: path to the output - * @return + * @param resolution resolution of interest + * @return boolean */ public boolean getExpected(String chr,String output,int resolution){ int exitValue=1; @@ -175,9 +164,10 @@ public boolean getExpected(String chr,String output,int resolution){ * * @param chr: String name of the chromosme * @param output: path to the output - * @return - * @throws IOException - * @throws InterruptedException + * @param resolution resolution of interest + * @return boolean + * @throws IOException exception + * @throws InterruptedException exception */ public boolean getNormVector(String chr,String output,int resolution) throws IOException, InterruptedException{ int exitValue=1; @@ -189,7 +179,7 @@ public boolean getNormVector(String chr,String output,int resolution) throws IOE new ReturnFlux(process.getErrorStream()).start(); process.getOutputStream(); exitValue=process.waitFor(); - if(_logError!="" && _logError.contains("Exception") == false){ + if(_logError!="" && !_logError.contains("Exception")){ System.out.println("VC vector not find, SIP is using "+this._normalisation+" for "+ chr+"\n"+_logError); runtime = Runtime.getRuntime(); _logError =""; @@ -231,7 +221,7 @@ public class ReturnFlux extends Thread { * @param flux * flux to redirect */ - public ReturnFlux(InputStream flux){this._flux = flux; } + private ReturnFlux(InputStream flux){this._flux = flux; } /** * @@ -240,9 +230,9 @@ public void run(){ try { InputStreamReader reader = new InputStreamReader(this._flux); BufferedReader br = new BufferedReader(reader); - String line=null; + String line; while ( (line = br.readLine()) != null) { - if(line.contains("WARN")== false && line.contains("INFO")== false) _logError = _logError+line+"\n"; + if(!line.contains("WARN") && !line.contains("INFO")) _logError = _logError+line+"\n"; } } catch (IOException ioe){ diff --git a/src/process/DumpInterChromosomal.java b/src/process/DumpInterChromosomal.java index c640208..93de278 100644 --- a/src/process/DumpInterChromosomal.java +++ b/src/process/DumpInterChromosomal.java @@ -6,21 +6,42 @@ import java.io.InputStreamReader; /** + * Class aims to dump the data of the hic file. this class need juicer_toolbox.jar to obtain the raw data and does the 2D images which will represent the HiC matrix. + * If some error is detected a file log is created for that. + * At the end this class a file by step is created (coordinate1 coordinate2 hic_value). The file created if the oMe option is chose the subtraction Observed-Expected + * is done to obtain the value of the interaction between two bins. + * If observed is used the value will be the observed. + * + * You can also chosse the option of the normalisation for the hic matrix, the different normalisations are these one available in juicertoolnox.jar + * (https://github.com/theaidenlab/juicer/wiki). + * + * eg of commad line use : dump observed KR https://hicfiles.s3.amazonaws.com/hiseq/gm12878/in-situ/combined.hic 1:20480000:40960000 1:20480000:40960000 BP 10000 combined_10Kb.txt + * + * Neva C. Durand, Muhammad S. Shamim, Ido Machol, Suhas S. P. Rao, Miriam H. Huntley, Eric S. Lander, and Erez Lieberman Aiden. "Juicer provides a + * one-click system for analyzing loop-resolution Hi-C experiments." Cell Systems 3(1), 2016. + * + * @author axel poulet * */ public class DumpInterChromosomal { + /** path of juiceBox */ private String _juiceBoxTools; + /** path of the hic file*/ private String _hicFile; + /** normalization method name*/ private String _normalisation; + /** log*/ private String _log = ""; + /** logError*/ private String _logError = ""; /** + *Constructor * - * @param juiceboxTools - * @param hicFile - * @param norm + * @param juiceboxTools path to juicer tools + * @param hicFile path to the hic file + * @param norm normalization methode used */ public DumpInterChromosomal(String juiceboxTools,String hicFile, String norm) { this._juiceBoxTools = juiceboxTools; @@ -31,12 +52,12 @@ public DumpInterChromosomal(String juiceboxTools,String hicFile, String norm) { /** * - * @param chr1 - * @param chr2 - * @param obs - * @param resolution - * @return - * @throws IOException + * @param chr1 string containing name and coordinate of interest eg: chr2+":"+startChr2+":"+end2 + * @param chr2 string containing name and coordinate of interest eg: chr2+":"+startChr2+":"+end2 + * @param obs string path output observed create + * @param resolution bin resolution + * @return boolean + * @throws IOException exception */ public boolean dumpObserved(String chr1, String chr2, String obs, int resolution) throws IOException { int exitValue=1; @@ -51,8 +72,7 @@ public boolean dumpObserved(String chr1, String chr2, String obs, int resolution new DumpInterChromosomal.ReturnFlux(process.getErrorStream()).start(); exitValue=process.waitFor(); } - catch (IOException e) { e.printStackTrace();} - catch (InterruptedException e) {e.printStackTrace();} + catch (IOException | InterruptedException e) { e.printStackTrace();} if(_logError.contains("Exception")) { System.out.println(_logError); @@ -76,7 +96,7 @@ public class ReturnFlux extends Thread { * @param flux * flux to redirect */ - public ReturnFlux(InputStream flux){this._flux = flux; } + private ReturnFlux(InputStream flux){this._flux = flux; } /** * @@ -87,7 +107,7 @@ public void run(){ BufferedReader br = new BufferedReader(reader); String line=null; while ( (line = br.readLine()) != null) { - if(line.contains("WARN")== false && line.contains("INFO")== false) _logError = _logError+line+"\n"; + if(!line.contains("WARN") && !line.contains("INFO")) _logError = _logError+line+"\n"; } } catch (IOException ioe){ diff --git a/src/process/MultiResProcess.java b/src/process/MultiResProcess.java index 2c511ff..e975de1 100644 --- a/src/process/MultiResProcess.java +++ b/src/process/MultiResProcess.java @@ -21,22 +21,20 @@ import utils.SIPObject; /** - * + * Class allowing the multi resolution loop calling + * * @author axel poulet * */ public class MultiResProcess { + /** SIP object*/ private SIPObject _sip; - /** - * - */ + /** number of cpu */ private int _nbCpu; - /** - * - */ + /** boolean delImage*/ private boolean _delImage; - + /** doc */ private String _doc = ("#SIP Version 1 run with java 8\n" + "\nUsage:\n" + "\thic [options]\n" @@ -75,14 +73,16 @@ public class MultiResProcess { + "M. Jordan Rowley\n" + "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu"); - + /** path to chr size file*/ private String _chrFile; + /** - * - * @param sip - * @param cpu - * @param delImage - * @param chrSizeFile + * Constructor + * + * @param sip SIPObject + * @param cpu number of cpu + * @param delImage delete image boolean + * @param chrSizeFile path of chrSize file */ public MultiResProcess(SIPObject sip, int cpu, boolean delImage, String chrSizeFile) { this._nbCpu = cpu; @@ -92,17 +92,20 @@ public MultiResProcess(SIPObject sip, int cpu, boolean delImage, String chrSizeF } /** - * @throws InterruptedException - * @throws IOException + * + * for each resolution used run the same process to otain the loop at the resolution of interest + * at each resolution the input parameters will be adapted to the resolution used + * @throws InterruptedException exception + * @throws IOException exception * */ public void run() throws InterruptedException, IOException{ ArrayList listFactor = this._sip.getListFactor(); ArrayList listOfFile = new ArrayList(); File outDir = new File(_sip.getOutputDir()); - if (outDir.exists()==false) outDir.mkdir(); + if (!outDir.exists()) outDir.mkdir(); if (_sip.isProcessed()){ - if(this.testDir()==false){ + if(!this.testDir()){ if(_sip.isGui()) { JOptionPane.showMessageDialog(null,"Resolution problem", "Enable to find all the directories needed for SIP (-factor option)", JOptionPane.ERROR_MESSAGE); } @@ -111,6 +114,7 @@ public void run() throws InterruptedException, IOException{ System.exit(0); } } + for(int indexFact = 0; indexFact < listFactor.size(); ++indexFact) { int res = this._sip.getResolution()*listFactor.get(indexFact); String resName = String.valueOf(res); @@ -133,7 +137,7 @@ public void run() throws InterruptedException, IOException{ } sipTmp.setChrSizeHashMap(this._sip.getChrSizeHashMap()); sipTmp.setIsGui(_sip.isGui()); - sipTmp.setDiagSize(this._sip.getDiagSize()); + sipTmp.setDiagonalSize(this._sip.getDiagonalSize()); sipTmp.setGauss(this._sip.getGauss()/listFactor.get(indexFact)); sipTmp.setMatrixSize((int)(this._sip.getMatrixSize()/listFactor.get(indexFact))); sipTmp.setResolution(res); @@ -159,8 +163,8 @@ public void run() throws InterruptedException, IOException{ } /** - * - * @return + * test the data organization + * @return boolean if yes the dir of interest is existing */ private boolean testDir(){ String input = _sip.getInputDir(); @@ -170,7 +174,7 @@ private boolean testDir(){ String resName = String.valueOf(res); resName = resName.replace("000", "")+"kb"; File inputDir = new File(input+resName); - if(inputDir.exists()== false) { + if(!inputDir.exists()) { return false; } } @@ -178,17 +182,19 @@ private boolean testDir(){ } /** - * - * @param listOfFile - * @throws IOException + * merge loops from different resolution + * test if loops are present at different resolution if yes keep this one at smaller resolution + * + * @param listOfFile list of of llops file + * @throws IOException exception */ private void mergedFile(ArrayList listOfFile) throws IOException{ - HashMap chrsize = readChrIndex(this._chrFile); - Set key = chrsize.keySet(); - ArrayList > data = new ArrayList >(); + HashMap chrSize = readChrIndex(this._chrFile); + Set key = chrSize.keySet(); + ArrayList > arrayListLoop = new ArrayList >(); for (int i = 0; i < key.size();++i) { - HashMap plop = new HashMap(); - data.add(plop); + HashMap loopHashMap = new HashMap(); + arrayListLoop.add(loopHashMap); } BufferedReader br = new BufferedReader(new FileReader(listOfFile.get(0))); @@ -201,10 +207,10 @@ private void mergedFile(ArrayList listOfFile) throws IOException{ sb.append(line); Loop loop = new Loop(line); String chr = loop.getChr(); - int index = chrsize.get(chr); - HashMap plop = data.get(index); - plop.put(line, loop); - data.set(index, plop); + int index = chrSize.get(chr); + HashMap loopHashMap = arrayListLoop.get(index); + loopHashMap.put(line, loop); + arrayListLoop.set(index, loopHashMap); sb.append(System.lineSeparator()); line = br.readLine(); } @@ -219,11 +225,11 @@ private void mergedFile(ArrayList listOfFile) throws IOException{ while (line != null){ Loop loop = new Loop(line); String chr = loop.getChr(); - int index = chrsize.get(chr); - HashMap plop = data.get(index); - if(compareLoop(plop,loop)){ - plop.put(line,loop); - data.set(index, plop); + int index = chrSize.get(chr); + HashMap loopHashMap = arrayListLoop.get(index); + if(compareLoop(loopHashMap,loop)){ + loopHashMap.put(line,loop); + arrayListLoop.set(index, loopHashMap); } sb.append(System.lineSeparator()); line = br.readLine(); @@ -234,9 +240,9 @@ private void mergedFile(ArrayList listOfFile) throws IOException{ BufferedWriter writer; writer = new BufferedWriter(new FileWriter(new File(_sip.getOutputDir()+"finalLoops.txt"))); writer.write(title+"\n"); - for (int i = 0; i < data.size();++i){ - HashMap plop = data.get(i); - Set keyBis = plop.keySet(); + for (int i = 0; i < arrayListLoop.size();++i){ + HashMap loopHashMap = arrayListLoop.get(i); + Set keyBis = loopHashMap.keySet(); List output = keyBis.stream().collect(Collectors.toList()); for (int j = 0; j < output.size();++j){ writer.write(output.get(j)+"\n"); @@ -247,24 +253,25 @@ private void mergedFile(ArrayList listOfFile) throws IOException{ /** - * - * @param plop - * @param a - * @return + * test if the loop is existing at other resolution, if yes keep it if it is the smaller reolution + * + * @param loopHashMap hashmap loop name => Loop object + * @param loopOfInterest Loop to test + * @return boolean true or false */ - private boolean compareLoop(HashMap plop, Loop a) { - Set key = plop.keySet(); + private boolean compareLoop(HashMap loopHashMap, Loop loopOfInterest) { + Set key = loopHashMap.keySet(); Iterator it = key.iterator(); while (it.hasNext()){ String loopName = it.next(); - Loop loop = plop.get(loopName); + Loop loop = loopHashMap.get(loopName); int xEnd = loop.getCoordinates().get(1); int yEnd = loop.getCoordinates().get(3); - int xtest = a.getCoordinates().get(0); - int xtestEnd = a.getCoordinates().get(1); + int xtest = loopOfInterest.getCoordinates().get(0); + int xtestEnd = loopOfInterest.getCoordinates().get(1); int res = xtestEnd-xtest; - int ytest = a.getCoordinates().get(2); - int ytestEnd = a.getCoordinates().get(3); + int ytest = loopOfInterest.getCoordinates().get(2); + int ytestEnd = loopOfInterest.getCoordinates().get(3); xtest = xtest-res*2; xtestEnd = xtestEnd+res*2; ytest = ytest-res*2; @@ -278,10 +285,10 @@ private boolean compareLoop(HashMap plop, Loop a) { /** - * - * @param chrSizeFile - * @return - * @throws IOException + * Read chr index file and return HashMap of chr name and size + * @param chrSizeFile path to the chr size file + * @return hashMap chrName => chrSize + * @throws IOException exception */ private HashMap readChrIndex( String chrSizeFile) throws IOException{ HashMap chrSize = new HashMap(); diff --git a/src/process/TupleFileToImage.java b/src/process/TupleFileToImage.java index 3daf3b8..ef115f0 100644 --- a/src/process/TupleFileToImage.java +++ b/src/process/TupleFileToImage.java @@ -23,17 +23,13 @@ public class TupleFileToImage { /** Image results */ private ImagePlus _imgNorm = new ImagePlus(); /** Path of the tuple file*/ - private String _file = ""; + private String _file; /** Size of the matrix*/ - private int _size = 0 ; + private int _size; /** Resolution of the image in base*/ - private int _resolution = 0 ; + private int _resolution; /** Step to process the whole chromosme*/ private int _step ; - /** Image value average*/ - private float _avg = 0; - /** Image standard deviation */ - private float _std = 0; /** number of pixe == 0 */ private int _noZeroPixel = 0; @@ -53,9 +49,8 @@ public TupleFileToImage(String fileMatrix, int size, int resolution){ /** - * Method to make the image with an input tuple file return the image results - * - * @return ImagePlus results + * Method to make the image with an input tuple file from intra chromosomal process + * */ public void readTupleFile(){ BufferedReader br; @@ -119,21 +114,23 @@ public void correctImage(ImagePlus img){ } } } - _avg = sum/_noZeroPixel; - _std = std(_avg,img); + /** Image value average*/ + float _avg = sum / _noZeroPixel; + /** Image standard deviation */ + float _std = std(_avg, img); for(int i = 0; i < ip.getWidth(); ++i){ for(int j = 0; j < ip.getWidth(); ++j){ float a = ip.getf(i, j); - if (Math.abs(j-i) <= 2 && a >= _avg+_std*2) - ip.setf(i,j,_avg); + if (Math.abs(j-i) <= 2 && a >= _avg + _std *2) + ip.setf(i,j, _avg); } } img.setProcessor(ip); } /** - * - * @return + * Method to make the image with an input tuple file from inter chromosomal process + * @return ImagePlus */ public ImagePlus readTupleFileInter(){ ImagePlus img = new ImagePlus(); @@ -213,15 +210,5 @@ private float std(float mean,ImagePlus img){ * @return ImagePlus normalized image */ public ImagePlus getNormImage(){return this._imgNorm;} - - /** - * setter for the raw Image - * @param img ImagePlus - */ - public void setRawImage(ImagePlus img){this._img = img;} - /** - * setter of the normalized image - * @param img ImagePLus - */ - public void setNormImage(ImagePlus img){this._imgNorm = img;} + } \ No newline at end of file diff --git a/src/test/TestInter.java b/src/test/TestInter.java index a702e95..19c4718 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -32,7 +32,7 @@ public static void main(String[] args) throws IOException, InterruptedException //process.go(input,sipInter,chrsize,juicerTools,norm,2); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(sipInter, 1, false, "/home/plop/Desktop/testInter/loops.txt", "100kb"); + detectLoops.go(sipInter, 1, false, "/home/plop/Desktop/testInter/loops.txt"); System.out.println("end"); diff --git a/src/utils/CoolerExpected.java b/src/utils/CoolerExpected.java index 190676e..e880b13 100644 --- a/src/utils/CoolerExpected.java +++ b/src/utils/CoolerExpected.java @@ -10,6 +10,9 @@ import java.util.ArrayList; import java.util.HashMap; +/** + * + */ public class CoolerExpected { /** String to stock the error if need of juicerbox_tools*/ @@ -17,16 +20,28 @@ public class CoolerExpected { /** String for the log*/ private String _log = ""; /** path to the hic file or url link*/ - private String _coolFile = ""; + private String _coolFile; /** List of doucle to stock the expected vector*/ - private int _resolution = 0; - private int _imgSize = 0; + private int _resolution ; + /** */ + private int _imgSize; + /** */ private String _expected; - private String _coolTools = ""; + /** */ + private String _coolTools; + /** */ private HashMap> _hashExpected = new HashMap>(); + /** */ private int _cpu; - - + + /** + * + * @param cooltools + * @param coolFile + * @param resolution + * @param imageSize + * @param cpu + */ public CoolerExpected(String cooltools, String coolFile, int resolution, int imageSize, int cpu){ _coolTools = cooltools; this._resolution = resolution; @@ -34,15 +49,20 @@ public CoolerExpected(String cooltools, String coolFile, int resolution, int ima this._coolFile = coolFile+"::/resolutions/"+this._resolution; _cpu = cpu; } - + + /** + * + * @param expectedFile + * @param imageSize + */ public CoolerExpected(String expectedFile, int imageSize){ this._imgSize = imageSize; this._expected = expectedFile; } + /** - * - * @param output - * @param resolution + * + * @param expected * @return */ public boolean dumpExpected(String expected){ @@ -83,9 +103,12 @@ public boolean dumpExpected(String expected){ return exitValue==0; } - - - + + + /** + * + * @throws IOException + */ public void parseExpectedFile() throws IOException { BufferedReader br = Files.newBufferedReader(Paths.get(_expected), StandardCharsets.UTF_8); String line = br.readLine(); @@ -122,34 +145,16 @@ public void parseExpectedFile() throws IOException { /** * getter of the expected matrix. * - * @param chr: String name of the chromosme - * @param output: path to the output - * @throws IOException + * @param chr: String name of the chromosome + * @return arrayList of double => vector of expected value + * @throws IOException exception */ public ArrayList getExpected(String chr) throws IOException{ return this._hashExpected.get(chr); } - - - /** - * getter of the logerror file if necessary - * - * @return return the String with the error - */ - public String getLogError(){ return this._logError;} - - /** - * getter of the log info if necessary - * @return return a String with the log info - */ - public String getLog(){ return this._log;} - /** - * Class to run command line in java - * @author axel poulet - * - */ + public class ReturnFlux extends Thread { /** Flux to redirect */ @@ -160,7 +165,7 @@ public class ReturnFlux extends Thread { * @param flux * flux to redirect */ - public ReturnFlux(InputStream flux){this._flux = flux; } + private ReturnFlux(InputStream flux){this._flux = flux; } /** * @@ -171,7 +176,7 @@ public void run(){ BufferedReader br = new BufferedReader(reader); String line=null; while ( (line = br.readLine()) != null) { - if(line.contains("WARN")== false) _logError = _logError+line+"\n"; + if(!line.contains("WARN")) _logError = _logError+line+"\n"; } } catch (IOException ioe){ diff --git a/src/utils/CoordinatesCorrection.java b/src/utils/CoordinatesCorrection.java index c8842a6..3937464 100644 --- a/src/utils/CoordinatesCorrection.java +++ b/src/utils/CoordinatesCorrection.java @@ -51,7 +51,7 @@ public HashMap imageToGenomeCoordinate(HashMap temp, i String newName = loop.getChr()+"\t"+a+"\t"+b; if(a!=b && Math.abs(a-b) > diagSize){ if (x > 1 && y > 1 && y < imageSize-2 && x < imageSize-2){ - if(this._data.containsKey(newName) == false){ + if(!this._data.containsKey(newName)){ loop.setCoordinates(a, a_end, b, b_end); loop.setName(newName); //System.out.println(newName+" "+resolution+" "+step+" "+index+" "+x); @@ -72,9 +72,9 @@ public HashMap imageToGenomeCoordinate(HashMap temp, i /** * For loop inter chromosomal - * @param temp - * @param rawImageName - * @return + * @param temp hashMap name loop > loop object + * @param rawImageName raw image name + * @return HashMAp with new coordinate */ public HashMap imageToGenomeCoordinate(HashMap temp, String rawImageName) { //4_0_49999999_6_0_49999999.tif @@ -110,7 +110,7 @@ public HashMap imageToGenomeCoordinate(HashMap temp, S /** * setter of m_data - * @param data + * @param data setter loops hashMAp */ public void setData(HashMap data){ this._data = data;} } \ No newline at end of file diff --git a/src/utils/FDR.java b/src/utils/FDR.java index a898546..31e577e 100644 --- a/src/utils/FDR.java +++ b/src/utils/FDR.java @@ -8,77 +8,85 @@ import java.util.Set; /** - * - * @author m. jordan rowley and axel poulet + * + * Compute the cut off for AP and Regional AP score for loops gave in input + * + * @author axel poulet and m. jordan rowley * */ public class FDR { - /** */ - private double _RFDRcutoff = 10000; - /** */ - private double _FDRcutoff = 10000; - + /** double regional fdr cutoff */ + private double _RFDRCutoff = 10000; + /** double fdr cutoff */ + private double _FDRCutoff = 10000; + /** fdr value*/ + private double _fdr; + /** hashmap of loop loopName=> Loop object*/ + private HashMap _data; + /** - * + * Constructor + * @param fdr fdr value use to compute the two cutoff + * @param data loops data */ - public FDR(){} + public FDR(double fdr,HashMap data){ + this._fdr = fdr; + this._data = data; + } /** - * - * @param fdr - * @param data + * */ - public void run(double fdr,HashMap data){ - Set key = data.keySet(); + public void run(){ + Set key = _data.keySet(); Iterator it = key.iterator(); - List myFDRvals = new ArrayList(); - List myRFDRvals = new ArrayList(); + List myFDRValues = new ArrayList(); + List myRFDRValues = new ArrayList(); while (it.hasNext()) { String loopName = it.next(); - Loop loop = data.get(loopName); - + Loop loop = _data.get(loopName); float dubFDR = loop.getPaScoreAvgFDR(); float dubFDR2 = loop.getPaScoreAvgFDR2(); float dubFDR3 = loop.getPaScoreAvgFDR3(); - if(dubFDR > 0) myFDRvals.add(dubFDR); - if(dubFDR2 > 0) myFDRvals.add(dubFDR2); - if(dubFDR3 > 0) myFDRvals.add(dubFDR3); + if(dubFDR > 0) myFDRValues.add(dubFDR); + if(dubFDR2 > 0) myFDRValues.add(dubFDR2); + if(dubFDR3 > 0) myFDRValues.add(dubFDR3); float dubRFDR = loop.getRegionalPaScoreAvgFDR(); float dubRFDR2 = loop.getRegionalPaScoreAvgFDR2(); float dubRFDR3 = loop.getRegionalPaScoreAvgFDR3(); - if(dubRFDR > 0) myRFDRvals.add(dubRFDR); - if(dubRFDR2 > 0) myRFDRvals.add(dubRFDR2); - if(dubRFDR3 > 0) myRFDRvals.add(dubRFDR3); + if(dubRFDR > 0) myRFDRValues.add(dubRFDR); + if(dubRFDR2 > 0) myRFDRValues.add(dubRFDR2); + if(dubRFDR3 > 0) myRFDRValues.add(dubRFDR3); } - Collections.sort(myFDRvals); - int topFDRs = (int)(myFDRvals.size()*fdr); + Collections.sort(myFDRValues); + int topFDRs = (int)(myFDRValues.size()*_fdr); if(topFDRs != 0){ - List topFDRlist = new ArrayList(myFDRvals.subList(myFDRvals.size() -topFDRs, myFDRvals.size() -(topFDRs-1))); - this._FDRcutoff = topFDRlist.get(0); - Collections.sort(myRFDRvals); - int topRFDRs = (int)(myRFDRvals.size()*fdr); - List topRFDRlist = new ArrayList(myRFDRvals.subList(myRFDRvals.size() -topRFDRs, myRFDRvals.size() -(topRFDRs-1))); - this._RFDRcutoff = topRFDRlist.get(0); + List topFDRList = new ArrayList(myFDRValues.subList(myFDRValues.size() -topFDRs, myFDRValues.size() -(topFDRs-1))); + this._FDRCutoff = topFDRList.get(0); + Collections.sort(myRFDRValues); + int topRFDRs = (int)(myRFDRValues.size()*_fdr); + List topRFDRList = new ArrayList(myRFDRValues.subList(myRFDRValues.size() -topRFDRs, myRFDRValues.size() -(topRFDRs-1))); + this._RFDRCutoff = topRFDRList.get(0); } } /** - * - * @return + * getter of regional fdr cutoff + * @return regional fdr cutoff */ - public double getRFDRcutoff() { return _RFDRcutoff; } + public double getRFDRCutoff() { return _RFDRCutoff; } /** - * - * @return + * getter of regional fdr cutoff + * @return fdr cutoff */ - public double getFDRcutoff() { return _FDRcutoff; } + public double getFDRCutoff() { return _FDRCutoff; } } diff --git a/src/utils/FilterLoops.java b/src/utils/FilterLoops.java index 2bd3403..cf0b961 100644 --- a/src/utils/FilterLoops.java +++ b/src/utils/FilterLoops.java @@ -16,9 +16,8 @@ public class FilterLoops { /** - * Constructor - * @param resolution - * @param normVector + * Constructor + * @param resolution loop resolution */ public FilterLoops(int resolution){ this._resolution = resolution; diff --git a/src/utils/SIPInter.java b/src/utils/SIPInter.java index 02d5cec..055d034 100644 --- a/src/utils/SIPInter.java +++ b/src/utils/SIPInter.java @@ -19,11 +19,8 @@ public class SIPInter{ private String _output; /** Strength of the gaussian filter*/ private double _gauss; - + /** double fdr value choose by the user*/ private double _fdr; - private double _medianAP; - private double _medianAPReg; - /** Image size*/ private int _matrixSize; /** Resolution of the bin dump in base*/ @@ -40,6 +37,7 @@ public class SIPInter{ private boolean _isProcessed; /** if is gui analysis*/ private boolean _isGui; + /** if data set is mcool format*/ private boolean _isCooler; /** */ private boolean _keepTif; @@ -48,16 +46,16 @@ public class SIPInter{ * * constructor for hic file * - * @param output - * @param chrsize - * @param gauss - * @param resolution - * @param thresholdMax - * @param matrixSize - * @param nbZero - * @param keepTif - * @param fdr - * @throws IOException + * @param output output path + * @param chrsize chr size path + * @param gauss gaussian filter strength + * @param resolution bins size + * @param thresholdMax threshold value for loops detection + * @param matrixSize image size + * @param nbZero nb of zero allowed around a loop + * @param keepTif true to keep image creat by SIP + * @param fdr fdr value for the final loops filter + * @throws IOException exception */ public SIPInter(String output,String chrsize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, boolean keepTif,double fdr) throws IOException { @@ -75,14 +73,17 @@ public SIPInter(String output,String chrsize, double gauss, int resolution, dou /** * constructor for processed data * - * @param output - * @param chrsize - * @param gauss - * @param resolution - * @param thresholdMax - * @param matrixSize - * @param nbZero - * @param keepTif + * @param input input file with SIP file + * @param output output path + * @param chrsize chr size path + * @param gauss gaussian filter strength + * @param resolution bins size + * @param thresholdMax threshold value for loops detection + * @param matrixSize image size + * @param nbZero nb of zero allowed around a loop + * @param keepTif true to keep image creat by SIP + * @param fdr fdr value for the final loops filter + * @throws IOException exception */ public SIPInter(String input,String output,String chrsize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, boolean keepTif, double fdr) throws IOException { @@ -101,17 +102,17 @@ public SIPInter(String input,String output,String chrsize, double gauss, int res } /** - * - * @param pathFile - * @param hLoop - * @param first - * @throws IOException + * Write detected loops after filtering via the fdr value + * @param pathFile path for the output file + * @param hLoop hashmap loopsName => Loop object + * @param first boolean if true it is the first results so need to write the header + * @throws IOException exception */ public void writeResu(String pathFile, HashMap hLoop, boolean first) throws IOException { - FDR fdrDetection = new FDR (); - fdrDetection.run(this._fdr, hLoop); - double RFDRcutoff = fdrDetection.getRFDRcutoff(); - double FDRcutoff = fdrDetection.getFDRcutoff(); + FDR fdrDetection = new FDR (this._fdr, hLoop); + fdrDetection.run(); + double RFDRcutoff = fdrDetection.getRFDRCutoff(); + double FDRcutoff = fdrDetection.getFDRCutoff(); System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); BufferedWriter writer; if(first) writer = new BufferedWriter(new FileWriter(new File(pathFile), true)); @@ -136,39 +137,7 @@ public void writeResu(String pathFile, HashMap hLoop, boolean first writer.close(); } - /** - * - * @return - */ - private void median(HashMap data, double fdrCutoff){ - Set key = data.keySet(); - Iterator it = key.iterator(); - ArrayList n1 = new ArrayList (); - ArrayList n2 = new ArrayList (); - int nb = 0; - while (it.hasNext()){ - String name = it.next(); - Loop loop = data.get(name); - if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > fdrCutoff && loop.getPaScoreAvgdev() > .9){ - n1.add(loop.getPaScoreAvg()); - n2.add(loop.getRegionalPaScoreAvg()); - nb++; - } - } - if(nb>0){ - n1.sort(Comparator.naturalOrder()); - n2.sort(Comparator.naturalOrder()); - double pos1 = Math.floor((n1.size() - 1.0) / 2.0); - double pos2 = Math.ceil((n1.size() - 1.0) / 2.0); - if (pos1 == pos2 ) _medianAP = n1.get((int)pos1); - else _medianAP = (n1.get((int)pos1) + n1.get((int)pos2)) / 2.0 ; - pos1 = Math.floor((n2.size() - 1.0) / 2.0); - pos2 = Math.ceil((n2.size() - 1.0) / 2.0); - if (pos1 == pos2 ) _medianAPReg = n2.get((int)pos1); - else _medianAPReg = (n2.get((int)pos1) + n2.get((int)pos2)) / 2.0 ; - // System.out.println("AP\t"+_medianAP+"\nAPREG\t"+_medianAPReg); - } - } + /** * Getter of the input dir @@ -308,35 +277,41 @@ private void median(HashMap data, double fdrCutoff){ public void setIsGui(boolean isGui) { this._isGui = isGui;} + /** + * Initialize chrSize hashMap * - * @param chrSizeFile - * @return - * @throws IOException + * @param chrSizeFile path to the chrFile */ - public void setChrSize(String chrSizeFile) throws IOException{ - BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - _chrSize.put(chr, size); - sb.append(System.lineSeparator()); - line = br.readLine(); + public void setChrSize(String chrSizeFile) { + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(chrSizeFile)); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null){ + sb.append(line); + String[] parts = line.split("\\t"); + String chr = parts[0]; + int size = Integer.parseInt(parts[1]); + _chrSize.put(chr, size); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + br.close(); + } catch (IOException e) { + e.printStackTrace(); } - br.close(); } /** - * \ - * @return + * getter chrSize + * @return hashMap of chrName => size */ public HashMap getChrSize() { return _chrSize; } + } diff --git a/src/utils/SIPObject.java b/src/utils/SIPObject.java index 4271143..84e0e12 100644 --- a/src/utils/SIPObject.java +++ b/src/utils/SIPObject.java @@ -48,7 +48,7 @@ public class SIPObject { /** HashMap of the chr size, the key = chr name, value = size of chr*/ private HashMap _chrSize = new HashMap(); /** Diage size to removed maxima close to diagonal*/ - private int _diagSize; + private int _diagonalSize; /** Size of the step to process each chr (step = matrixSize/2)*/ private int _step; /** Number of pixel = 0 allowed around the loop*/ @@ -61,42 +61,46 @@ public class SIPObject { private boolean _isProcessed = false; /** if is gui analysis*/ private boolean _isGui = false; - /** if rfdr*/ + /** if true regional fdr will be not used*/ private boolean _isDroso = false; + /** median of loop AP score */ private double _medianAP = 0; + /** median of loop regional AP score */ private double _medianAPReg = 0; + /** true is mcool input*/ private boolean _isCooler = false; - //private HashMap _normVector = new HashMap(); - - - public SIPObject() { - - } + + /** - * SIPObject constructor + * + */ + public SIPObject() { } + + /** + * SIPObject constructor for hic or mcool file * * - * @param output - * @param chrSize - * @param gauss - * @param min - * @param max - * @param resolution - * @param saturatedPixel - * @param thresholdMax - * @param diagSize - * @param matrixSize - * @param nbZero - * @param listFactor - * @param fdr - * @param isProcessed - * @param rfdr + * @param output path file with the file created by the first step of SIP + * @param chrSize hashMap name chr => chr size + * @param gauss gaussian filter strength + * @param min minimum filter strength + * @param max maximum filter strength + * @param resolution bin size + * @param saturatedPixel percentage of saturated pixel for image histogram normalization + * @param thresholdMax threshold for loop detection with findMaxima + * @param diagonalSize size of the diagonal, where the value will be not use + * @param matrixSize size of the image + * @param nbZero number of zero allowed around loops + * @param listFactor multi resolution calling loops used this list of factor + * @param fdr fdr value for final loops filtering + * @param isProcessed true if processed SIP data input else false + * @param rFDR false if it isn't drosophila input */ public SIPObject(String output, HashMap chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, int thresholdMax, - int diagSize, int matrixSize, int nbZero,ArrayList listFactor, - double fdr, boolean isProcessed, boolean rfdr) { - if(output.endsWith(File.separator) == false) + int diagonalSize, int matrixSize, int nbZero,ArrayList listFactor, + double fdr, boolean isProcessed, boolean rFDR) { + if(!output.endsWith(File.separator)) output = output+File.separator; this._output = output; this._input = output; @@ -108,41 +112,42 @@ public SIPObject(String output, HashMap chrSize, double gauss, this._resolution = resolution; this._saturatedPixel = saturatedPixel; this._thresholdMaxima = thresholdMax; - this._diagSize = diagSize; + this._diagonalSize = diagonalSize; this._step = matrixSize/2; this._nbZero = nbZero; this._listFactor = listFactor; this._fdr = fdr; this._isProcessed = isProcessed; - this._isDroso = rfdr; + this._isDroso = rFDR; } /** - * SIPObject constructor - * @param input - * @param output - * @param chrSize - * @param gauss - * @param min - * @param max - * @param resolution - * @param saturatedPixel - * @param thresholdMax - * @param diagSize - * @param matrixSize - * @param nbZero - * @param listFactor - * @param fdr - * @param isProcessed - * @param rfdr + * SIPObject constructor for processed SIP data + * + * @param input path file with the file created by the first step of SIP + * @param output path file for the results + * @param chrSize hashMap name chr => chr size + * @param gauss gaussian filter strength + * @param min minimum filter strength + * @param max maximum filter strength + * @param resolution bin size + * @param saturatedPixel percentage of saturated pixel for image histogram normalization + * @param thresholdMax threshold for loop detection with findMaxima + * @param diagonalSize size of the diagonal, where the value will be not use + * @param matrixSize size of the image + * @param nbZero number of zero allowed around loops + * @param listFactor multi resolution calling loops used this list of factor + * @param fdr fdr value for final loops filtering + * @param isProcessed true if processed SIP data input else false + * @param rFDR false if it isn't drosophila input */ public SIPObject(String input, String output, HashMap chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, int thresholdMax, - int diagSize, int matrixSize, int nbZero,ArrayList listFactor, - double fdr, boolean isProcessed, boolean rfdr) { - if(output.endsWith(File.separator) == false) + int diagonalSize, int matrixSize, int nbZero,ArrayList listFactor, + double fdr, boolean isProcessed, boolean rFDR) { + if(!output.endsWith(File.separator)) output = output+File.separator; - if(input.endsWith(File.separator) == false) + if(!input.endsWith(File.separator)) input = input+File.separator; this._output = output; this._input = input; @@ -154,13 +159,13 @@ public SIPObject(String input, String output, HashMap chrSize, this._resolution = resolution; this._saturatedPixel = saturatedPixel; this._thresholdMaxima = thresholdMax; - this._diagSize = diagSize; + this._diagonalSize = diagonalSize; this._step = matrixSize/2; this._nbZero = nbZero; this._listFactor = listFactor; this._fdr = fdr; this._isProcessed = isProcessed; - this._isDroso = rfdr; + this._isDroso = rFDR; } @@ -169,14 +174,14 @@ public SIPObject(String input, String output, HashMap chrSize, * * @param pathFile String path for the results file * @param first boolean to know idf it is teh first chromo - * @param data - * @throws IOException + * @param data hashMap loop name => Loop object + * @throws IOException exception */ public void saveFile(String pathFile, HashMap data, boolean first) throws IOException{ - FDR fdrDetection = new FDR (); - fdrDetection.run(this._fdr, data); - double RFDRcutoff = fdrDetection.getRFDRcutoff(); - double FDRcutoff = fdrDetection.getFDRcutoff(); + FDR fdrDetection = new FDR (this._fdr, data); + fdrDetection.run(); + double RFDRcutoff = fdrDetection.getRFDRCutoff(); + double FDRcutoff = fdrDetection.getFDRCutoff(); boolean supToTen = false; if(this._isDroso){ median(data,FDRcutoff); @@ -204,7 +209,7 @@ public void saveFile(String pathFile, HashMap data, boolean first) Loop loop = data.get(name); ArrayList coord = loop.getCoordinates(); if(this._isDroso){ - if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > FDRcutoff && loop.getPaScoreAvgdev() > .9 && (loop.getNeigbhoord1() > 1 || loop.getNeigbhoord2() > 1)){ + if(loop.getPaScoreAvg() > FDRcutoff && loop.getPaScoreAvgdev() > .9 && (loop.getNeigbhoord1() > 1 || loop.getNeigbhoord2() > 1)){ if(supToTen){ if(loop.getRegionalPaScoreAvg() >= (_medianAPReg-_medianAPReg*0.7) && loop.getRegionalPaScoreAvg() <= (_medianAPReg*2)&& loop.getPaScoreAvg() <= (_medianAP*2)){ writer.write(loop.getChr()+"\t"+coord.get(2)+"\t"+coord.get(3)+"\t"+loop.getChr()+"\t"+coord.get(0)+"\t"+coord.get(1)+"\t0,0,0" @@ -234,25 +239,12 @@ public void saveFile(String pathFile, HashMap data, boolean first) } } - - - /** - * Full the list with file in directory - * @param dir - * @return - * @throws IOException - */ - - public File[] fillList(String dir) throws IOException{ - File folder = new File(dir); - File[] listOfFiles = folder.listFiles(); - return listOfFiles; - } - /** - * Test the normalized vector by chromosme - * @param normFile + * Test the normalized vector by chromosome and return a hashMap with biased coordinate. + * if loops is detected around this region in theis hashMap the loop will be deleted + * + * @param normFile normalized file */ public HashMap getNormValueFilter(String normFile){ BufferedReader br; @@ -276,10 +268,12 @@ public HashMap getNormValueFilter(String normFile){ return vector; } - + /** - * - * @return + * compute median of pa score and regional pa score for a set of loops + * + * @param data hashMap loops name=> Loop object + * @param fdrCutoff fdr cutoff */ private void median(HashMap data, double fdrCutoff){ Set key = data.keySet(); @@ -290,7 +284,7 @@ private void median(HashMap data, double fdrCutoff){ while (it.hasNext()){ String name = it.next(); Loop loop = data.get(name); - if(loop.getPaScoreAvg()> 1.2 && loop.getPaScoreAvg() > 1 && loop.getPaScoreAvg() > fdrCutoff && loop.getPaScoreAvgdev() > .9){ + if(loop.getPaScoreAvg() > fdrCutoff && loop.getPaScoreAvgdev() > .9){ n1.add(loop.getPaScoreAvg()); n2.add(loop.getRegionalPaScoreAvg()); nb++; @@ -310,10 +304,19 @@ private void median(HashMap data, double fdrCutoff){ System.out.println("AP\t"+_medianAP+"\nAPREG\t"+_medianAPReg); } } - - - public double getFdr() { return this._fdr; } - public void setFdr(double fdr) { this._fdr = fdr; } + + /** + * getter of fdr parameter + * @return fdr value + */ + public double getFdr() { return this._fdr; } + + /** + * setter of fdr value + * @param fdr new fdr value + * + */ + public void setFdr(double fdr) { this._fdr = fdr; } /** * Getter of the input dir * @return path of the input dir @@ -322,7 +325,6 @@ private void median(HashMap data, double fdrCutoff){ /** * Getter of the matrix size - * * @return the size of the image */ public int getMatrixSize(){ return this._matrixSize; } @@ -348,32 +350,32 @@ private void median(HashMap data, double fdrCutoff){ /** * Setter of the path of the output directory - * @param outputDir + * @param outputDir path of output directory */ public void setOutputDir(String outputDir){ this._output = outputDir;} /** * Getter of the gaussian blur strength - * @return double gaussian + * @return double gaussian filter strength */ public double getGauss(){ return this._gauss; } /** * Setter of the gaussian blur strength - * @param gauss double + * @param gauss new gaussian filter strength */ public void setGauss(double gauss){ this._gauss = gauss; } /** - * Getter of diagSize - * @return + * Getter of diagonalSize + * @return integer size of diagonal */ - public int getDiagSize(){ return this._diagSize;} + public int getDiagonalSize(){ return this._diagonalSize;} /** * Setter of the diagonal size - * @param diagSize int of the size of the diagonal + * @param diagonalSize int of the size of the diagonal */ - public void setDiagSize(int diagSize){ this._diagSize = diagSize; } + public void setDiagonalSize(int diagonalSize){ this._diagonalSize = diagonalSize; } /** * Getter of the min filter strength @@ -383,7 +385,7 @@ private void median(HashMap data, double fdrCutoff){ /** * Setter of the min filter strength - * @param min + * @param min new filter min strength */ public void setMin(double min){ this._min = min;} @@ -395,37 +397,37 @@ private void median(HashMap data, double fdrCutoff){ /** * Setter of the min filter strength - * @param max + * @param max double max filter */ public void setMax(double max){ this._max = max;} /** * Getter % of saturated pixel for the contrast enhancement - * @return double percentage of saturated + * @return double percentage of saturated pixel */ public double getSaturatedPixel(){ return this._saturatedPixel; } /** * Setter % of saturated pixel for the contrast enhancement - * @param saturatedPixel + * @param saturatedPixel double percentage of saturated pixel */ public void setSaturatedPixel(double saturatedPixel){ this._saturatedPixel = saturatedPixel; } /** * Getter of resolution of the bin - * @return + * @return bin size */ public int getResolution(){ return this._resolution;} /** * Setter of resolution of the bin - * @param resolution + * @param resolution bin size */ public void setResolution(int resolution){ this._resolution = resolution;} /** * Setter of size of the matrix - * @param size + * @param size image size */ public void setMatrixSize(int size){ this._matrixSize = size; } @@ -436,62 +438,96 @@ private void median(HashMap data, double fdrCutoff){ public void setStep(int step){ this._step = step;} /** - * Getter of threshold for the detction of the maxima - * @return + * Getter of threshold for the loop detection + * @return threshold */ public int getThresholdMaxima(){ return _thresholdMaxima;} /** * Setter of threshold for the detection of the maxima - * @param thresholdMaxima + * @param thresholdMaxima threshold */ public void setThresholdMaxima(int thresholdMaxima) { this._thresholdMaxima = thresholdMaxima;} - - - /** * Getter of getNbZero - * @return + * @return int nb of zero allowed around the loops */ public int getNbZero(){ return this._nbZero;} - + /** + * setter of nb of zero + * @param nbZero int nb of zero allowed around the loops + */ public void setNbZero(int nbZero){ this._nbZero = nbZero;} /** - * - * @return + * Getter of list of integer for multi resolution loop calling + * @return list of integer */ public ArrayList getListFactor() {return this._listFactor;} - public void setListFactor(ArrayList listFactor) {this._listFactor = listFactor;} - + + /** + * boolean isDroso + * @return boolean + */ public boolean isDroso(){return this._isDroso;} + + /** + * setter + * @param droso boolean + */ public void setIsDroso(boolean droso){ this._isDroso = droso;} - - public HashMap getChrSizeHashMap(){return this._chrSize;} - public void setChrSizeHashMap(HashMap chrSize){this._chrSize = chrSize;} - + /** + * getter of chrSize hashMap + * @return hashMap chr name => chr size + */ + public HashMap getChrSizeHashMap(){return this._chrSize;} /** - * - * @return + * setter + * @param chrSize hashMap chr name => chr size + */ + public void setChrSizeHashMap(HashMap chrSize){this._chrSize = chrSize;} + + /** + * getter boolean isProcessed + * true input is SIP processed dat + * @return boolean */ public boolean isProcessed() { return _isProcessed;} + + /** + * setter boolean isProcessed + * @param isProcessed boolean + */ public void setIsProcessed(boolean isProcessed) { this._isProcessed = isProcessed;} /** - * - * @return + * getter isCooler + * true: input is mcool dataset + * @return boolean */ public boolean isCooler() { return _isCooler;} + + /** + * setter isCooler + * @param cool boolean + */ public void setIsCooler(boolean cool) { this._isCooler = cool;} /** - * - * @return + * getter isGui + * true: program run with GUI + * @return boolean */ public boolean isGui() { return _isGui;} + + /** + * setter isGui + * @param _isGui boolean + */ + public void setIsGui(boolean _isGui) { this._isGui = _isGui;} } \ No newline at end of file From 4d31108a448fc397dcf8d8bad99ff1f019d3eb12 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Mon, 9 Nov 2020 18:02:02 -0500 Subject: [PATCH 08/27] start changing the global main, start re write SIPObject class. --- .../CoolerDumpData.java | 2 +- .../CoolerExpected.java | 2 +- src/{process => dumpProcessing}/DumpData.java | 2 +- .../DumpInterChromosomal.java | 2 +- src/{process => loops}/CallLoops.java | 17 +- src/{process => loops}/CallLoopsInter.java | 8 +- src/{utils => loops}/FilterLoops.java | 2 +- src/{utils => loops}/Loop.java | 59 +--- src/multiProcesing/ProcessCoolerDumpData.java | 12 +- src/multiProcesing/ProcessDetectLoops.java | 12 +- src/multiProcesing/ProcessDumpData.java | 20 +- .../RunnableDetectInterLoops.java | 8 +- src/multiProcesing/RunnableDetectLoops.java | 18 +- .../RunnableDumpDataCooler.java | 4 +- src/multiProcesing/RunnableDumpDataHiC.java | 2 +- .../RunnableDumpInterChromoData.java | 2 +- src/process/HiC.java | 4 + src/process/MCool.java | 6 + src/process/Processed.java | 18 + src/{utils => sip}/SIPInter.java | 54 +-- .../SIPObject.java => sip/SIPIntra.java} | 244 ++----------- src/sip/SIPObject.java | 327 ++++++++++++++++++ src/sipMain/Hic_main.java | 121 ++----- src/test/TestCallLoopsHicFile.java | 36 +- src/test/TestCallLoopsProcessedFile.java | 36 +- src/test/TestCoolFormat.java | 37 +- src/test/TestGui.java | 38 +- src/test/TestInter.java | 2 +- src/test/TestMergeLoops.java | 2 +- src/utils/CoordinatesCorrection.java | 4 +- src/utils/FDR.java | 4 +- src/utils/FindMaxima.java | 103 +++--- src/utils/ImageProcessingMethod.java | 29 +- src/{process => utils}/MultiResProcess.java | 56 +-- src/utils/PeakAnalysisScore.java | 3 +- src/{process => utils}/TupleFileToImage.java | 2 +- 36 files changed, 596 insertions(+), 702 deletions(-) rename src/{process => dumpProcessing}/CoolerDumpData.java (99%) rename src/{utils => dumpProcessing}/CoolerExpected.java (99%) rename src/{process => dumpProcessing}/DumpData.java (99%) rename src/{process => dumpProcessing}/DumpInterChromosomal.java (99%) rename src/{process => loops}/CallLoops.java (95%) rename src/{process => loops}/CallLoopsInter.java (96%) rename src/{utils => loops}/FilterLoops.java (99%) rename src/{utils => loops}/Loop.java (87%) create mode 100644 src/process/HiC.java create mode 100644 src/process/MCool.java create mode 100644 src/process/Processed.java rename src/{utils => sip}/SIPInter.java (85%) rename src/{utils/SIPObject.java => sip/SIPIntra.java} (63%) create mode 100644 src/sip/SIPObject.java rename src/{process => utils}/MultiResProcess.java (73%) rename src/{process => utils}/TupleFileToImage.java (99%) diff --git a/src/process/CoolerDumpData.java b/src/dumpProcessing/CoolerDumpData.java similarity index 99% rename from src/process/CoolerDumpData.java rename to src/dumpProcessing/CoolerDumpData.java index 0f14b70..b81b8f0 100644 --- a/src/process/CoolerDumpData.java +++ b/src/dumpProcessing/CoolerDumpData.java @@ -1,4 +1,4 @@ -package process; +package dumpProcessing; import java.io.BufferedReader; import java.io.BufferedWriter; diff --git a/src/utils/CoolerExpected.java b/src/dumpProcessing/CoolerExpected.java similarity index 99% rename from src/utils/CoolerExpected.java rename to src/dumpProcessing/CoolerExpected.java index e880b13..229ad60 100644 --- a/src/utils/CoolerExpected.java +++ b/src/dumpProcessing/CoolerExpected.java @@ -1,4 +1,4 @@ -package utils; +package dumpProcessing; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/process/DumpData.java b/src/dumpProcessing/DumpData.java similarity index 99% rename from src/process/DumpData.java rename to src/dumpProcessing/DumpData.java index a15e98b..a299e72 100644 --- a/src/process/DumpData.java +++ b/src/dumpProcessing/DumpData.java @@ -1,4 +1,4 @@ -package process; +package dumpProcessing; import java.io.BufferedReader; import java.io.BufferedWriter; diff --git a/src/process/DumpInterChromosomal.java b/src/dumpProcessing/DumpInterChromosomal.java similarity index 99% rename from src/process/DumpInterChromosomal.java rename to src/dumpProcessing/DumpInterChromosomal.java index 93de278..636b00e 100644 --- a/src/process/DumpInterChromosomal.java +++ b/src/dumpProcessing/DumpInterChromosomal.java @@ -1,4 +1,4 @@ -package process; +package dumpProcessing; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/process/CallLoops.java b/src/loops/CallLoops.java similarity index 95% rename from src/process/CallLoops.java rename to src/loops/CallLoops.java index 32783e8..f4e48d7 100644 --- a/src/process/CallLoops.java +++ b/src/loops/CallLoops.java @@ -1,4 +1,4 @@ -package process; +package loops; import java.io.File; import java.io.IOException; @@ -9,13 +9,8 @@ import ij.io.FileSaver; import inra.ijpb.morphology.Morphology; import inra.ijpb.morphology.Strel; -import utils.CoordinatesCorrection; -import utils.FilterLoops; -import utils.FindMaxima; -import utils.SIPObject; -import utils.ImageProcessingMethod; -import utils.Loop; -import utils.PeakAnalysisScore; +import sip.SIPIntra; +import utils.*; /** * Class with all the methods to call the reginal maxima in the images and filter and write the output loops file list @@ -38,7 +33,7 @@ public class CallLoops { /** Resolution of the bin dump in base*/ private int _resolution; /** Threshold for the maxima detection*/ - private int _thresholdMaxima; + private double _thresholdMaxima; /** Diage size to removed maxima close to diagonal*/ private int _diagSize; /** Size of the step to process each chr (step = matrixSize/2)*/ @@ -57,7 +52,7 @@ public class CallLoops { * * @param sip SIPOject */ - public CallLoops(SIPObject sip){ + public CallLoops(SIPIntra sip){ this._gauss = sip.getGauss(); this._min = sip.getMin(); this._max= sip.getMax(); @@ -106,7 +101,7 @@ public HashMap detectLoops(File[] fileList, String chr,HashMap getCoordinates(){ return listCoord; } - /** - * - * @return - */ - public float getRegionalPaScoreMed(){ return this._regPaScoreMed; } - /** - * - * @param m_RpaScore - */ - public void setRegionalPaScoreMed(float m_RpaScore){ this._regPaScoreMed = m_RpaScore; } /** * Getter of regional peak analysis score @@ -404,11 +366,6 @@ public ArrayList getCoordinates(){ */ public String getChr2(){ return this._chr2; } - /** - * Setter of the avg of th n 8 - * @param avg double - */ - public void setAvg(float avg) { this._avg=avg; } /** * diff --git a/src/multiProcesing/ProcessCoolerDumpData.java b/src/multiProcesing/ProcessCoolerDumpData.java index 2cd5460..0458845 100644 --- a/src/multiProcesing/ProcessCoolerDumpData.java +++ b/src/multiProcesing/ProcessCoolerDumpData.java @@ -9,9 +9,9 @@ import java.util.concurrent.TimeUnit; import gui.Progress; -import process.CoolerDumpData; -import utils.CoolerExpected; -import utils.SIPObject; +import dumpProcessing.CoolerDumpData; +import dumpProcessing.CoolerExpected; +import sip.SIPIntra; /** * multi thread class dumping the data via juicertoolsbox.jar @@ -40,13 +40,13 @@ public ProcessCoolerDumpData(){ } * * @param coolTools String coolTools path * @param cooler String cooler path - * @param sip SIPObject + * @param sip SIPIntra * @param coolFile path mcool file - * @param chrSize hashMap chr name => chrSize * @param nbCPU number of cpu * @throws InterruptedException exception */ - public void go(String coolTools, String cooler, SIPObject sip, String coolFile, HashMap chrSize,int nbCPU) throws InterruptedException { + public void go(String coolTools, String cooler, SIPIntra sip, String coolFile, int nbCPU) throws InterruptedException { + HashMap chrSize= sip.getChrSizeHashMap(); ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); Iterator chrName = chrSize.keySet().iterator(); File outDir = new File(sip.getOutputDir()); diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index d23b3a4..6217072 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -4,8 +4,8 @@ import java.util.Iterator; import gui.Progress; -import utils.SIPInter; -import utils.SIPObject; +import sip.SIPInter; +import sip.SIPIntra; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; @@ -31,14 +31,14 @@ public ProcessDetectLoops(){ } /** * multiprocessing method for SIP intra chromosomal interaction * - * @param sip SIPObject + * @param sip SIPIntra * @param nbCPU nb of cpu * @param delImage boolean if true del all the tif file * @param resuFile path to results file * @param resName name of the resolution used * @throws InterruptedException exception */ - public void go(SIPObject sip,int nbCPU, boolean delImage, String resuFile,String resName) throws InterruptedException { + public void go(SIPIntra sip, int nbCPU, boolean delImage, String resuFile, String resName) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); Iterator chrName = sip.getChrSizeHashMap().keySet().iterator(); if(sip.isProcessed()) { @@ -88,7 +88,7 @@ public void go(SIPObject sip,int nbCPU, boolean delImage, String resuFile,String */ public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); - HashMap chrSize = sipInter.getChrSize(); + HashMap chrSize = sipInter.getChrSizeHashMap(); Object [] chrName = chrSize.keySet().toArray(); System.out.println(sipInter.getOutputDir()); @@ -110,7 +110,7 @@ public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile) int nb = 0; if(sipInter.isGui()){ - _p = new Progress("Loop Detection step",sipInter.getChrSize().size()+1); + _p = new Progress("Loop Detection step",sipInter.getChrSizeHashMap().size()+1); _p._bar.setValue(nb); } while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { diff --git a/src/multiProcesing/ProcessDumpData.java b/src/multiProcesing/ProcessDumpData.java index 94243b6..ed32e56 100644 --- a/src/multiProcesing/ProcessDumpData.java +++ b/src/multiProcesing/ProcessDumpData.java @@ -8,10 +8,10 @@ import java.util.concurrent.TimeUnit; import gui.Progress; -import process.DumpData; -import process.DumpInterChromosomal; -import utils.SIPInter; -import utils.SIPObject; +import dumpProcessing.DumpData; +import dumpProcessing.DumpInterChromosomal; +import sip.SIPInter; +import sip.SIPIntra; /** @@ -35,14 +35,14 @@ public ProcessDumpData(){ } * run SiP for intra chr loops * * @param hicFile Sting input file path - * @param sip SIPObject with all the paramters needed - * @param chrSize HashMap Name and size of chr + * @param sip SIPIntra with all the paramters needed * @param juiceBoxTools juicerTools.jar path * @param normJuiceBox String normalization method * @param nbCPU int nb cpu * @throws InterruptedException exception */ - public void go(String hicFile, SIPObject sip, HashMap chrSize, String juiceBoxTools, String normJuiceBox,int nbCPU) throws InterruptedException { + public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJuiceBox, int nbCPU) throws InterruptedException { + HashMap chrSize = sip.getChrSizeHashMap(); ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); Iterator chrName = chrSize.keySet().iterator(); File outDir = new File(sip.getOutputDir()); @@ -74,14 +74,14 @@ public void go(String hicFile, SIPObject sip, HashMap chrSize, S * * @param hicFile Sting input file path * @param sipInter SIPInter object with all the parameters needed - * @param chrSize HashMap Name and size of chr * @param juiceBoxTools juicerTools.jar path * @param normJuiceBox String normalization method * @param nbCPU int nb cpu * @throws InterruptedException exception */ - public void go(String hicFile, SIPInter sipInter, HashMap chrSize, String juiceBoxTools, String normJuiceBox, int nbCPU) throws InterruptedException { + public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String normJuiceBox, int nbCPU) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + HashMap chrSize = sipInter.getChrSizeHashMap(); Object [] chrName = chrSize.keySet().toArray(); System.out.println(sipInter.getOutputDir()); @@ -105,7 +105,7 @@ public void go(String hicFile, SIPInter sipInter, HashMap chrSiz int nb = 0; if(sipInter.isGui()){ - _p = new Progress("Loop Detection step",sipInter.getChrSize().size()+1); + _p = new Progress("Loop Detection step",sipInter.getChrSizeHashMap().size()+1); _p._bar.setValue(nb); } while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/multiProcesing/RunnableDetectInterLoops.java index 9f2c193..56c5a5d 100644 --- a/src/multiProcesing/RunnableDetectInterLoops.java +++ b/src/multiProcesing/RunnableDetectInterLoops.java @@ -1,8 +1,8 @@ package multiProcesing; -import process.CallLoopsInter; -import utils.Loop; -import utils.SIPInter; +import loops.CallLoopsInter; +import loops.Loop; +import sip.SIPInter; import java.io.File; @@ -52,7 +52,7 @@ public RunnableDetectInterLoops(String chr1, String chr2, String resuFile, SIPIn /** * Run all the process for loops detection by chr using the objet CallLoops and then save loops in - * txt file with SIPObject via he method saveFile + * txt file with SIPIntra via he method saveFile */ public void run() { String resName = String.valueOf(this._sipInter.getResolution()); diff --git a/src/multiProcesing/RunnableDetectLoops.java b/src/multiProcesing/RunnableDetectLoops.java index 8208c85..6335e4b 100644 --- a/src/multiProcesing/RunnableDetectLoops.java +++ b/src/multiProcesing/RunnableDetectLoops.java @@ -1,7 +1,7 @@ package multiProcesing; -import process.CallLoops; -import utils.SIPObject; -import utils.Loop; +import loops.CallLoops; +import sip.SIPIntra; +import loops.Loop; import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -14,7 +14,7 @@ */ public class RunnableDetectLoops extends Thread implements Runnable{ /** SIP object containing all the parameter for the loops detection*/ - private SIPObject _sip; + private SIPIntra _sip; /** CallLoops object */ private CallLoops _callLoops; /** String results file*/ @@ -36,11 +36,11 @@ public class RunnableDetectLoops extends Thread implements Runnable{ * * @param chr String chromosome name * @param resuFile path to the result file - * @param sip SIPObject + * @param sip SIPIntra * @param normVectorFile path to normalized vector * @param delFile boolean if true delete all the tif file at the end of the process */ - public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, String normVectorFile, boolean delFile){ + public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, String normVectorFile, boolean delFile){ this._sip = sip; this._callLoops = new CallLoops(sip); this._chr= chr; @@ -55,10 +55,10 @@ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, String n * * @param chr String chromosome name * @param resuFile path to the result file - * @param sip SIPObject + * @param sip SIPIntra * @param delFile boolean if true delete all the tif file at the end of the process */ - public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, boolean delFile){ + public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, boolean delFile){ this._sip = sip; this._callLoops = new CallLoops(sip); this._chr= chr; @@ -68,7 +68,7 @@ public RunnableDetectLoops (String chr, String resuFile, SIPObject sip, boolean /** * Run all the process for loops detection by chr using the objet CallLoops and then save loops in - * txt file with SIPObject via he method saveFile + * txt file with SIPIntra via he method saveFile * */ public void run(){ diff --git a/src/multiProcesing/RunnableDumpDataCooler.java b/src/multiProcesing/RunnableDumpDataCooler.java index ccb455b..659620e 100644 --- a/src/multiProcesing/RunnableDumpDataCooler.java +++ b/src/multiProcesing/RunnableDumpDataCooler.java @@ -4,8 +4,8 @@ import java.io.IOException; import java.util.ArrayList; -import process.CoolerDumpData; -import utils.CoolerExpected; +import dumpProcessing.CoolerDumpData; +import dumpProcessing.CoolerExpected; /** * diff --git a/src/multiProcesing/RunnableDumpDataHiC.java b/src/multiProcesing/RunnableDumpDataHiC.java index 189a4d7..6d09c83 100644 --- a/src/multiProcesing/RunnableDumpDataHiC.java +++ b/src/multiProcesing/RunnableDumpDataHiC.java @@ -1,5 +1,5 @@ package multiProcesing; -import process.DumpData; +import dumpProcessing.DumpData; import java.io.File; import java.io.IOException; diff --git a/src/multiProcesing/RunnableDumpInterChromoData.java b/src/multiProcesing/RunnableDumpInterChromoData.java index fa03ec5..5f12686 100644 --- a/src/multiProcesing/RunnableDumpInterChromoData.java +++ b/src/multiProcesing/RunnableDumpInterChromoData.java @@ -1,6 +1,6 @@ package multiProcesing; -import process.DumpInterChromosomal; +import dumpProcessing.DumpInterChromosomal; import java.io.File; import java.io.IOException; diff --git a/src/process/HiC.java b/src/process/HiC.java new file mode 100644 index 0000000..af79ad5 --- /dev/null +++ b/src/process/HiC.java @@ -0,0 +1,4 @@ +package process; + +public class HiC { +} diff --git a/src/process/MCool.java b/src/process/MCool.java new file mode 100644 index 0000000..80513d0 --- /dev/null +++ b/src/process/MCool.java @@ -0,0 +1,6 @@ +package process; + +public class MCool { + + +} diff --git a/src/process/Processed.java b/src/process/Processed.java new file mode 100644 index 0000000..a91b77c --- /dev/null +++ b/src/process/Processed.java @@ -0,0 +1,18 @@ +package process; + +import gui.GuiAnalysis; + +public class Processed { + + + public Processed(String args[]){ + + + } + + public Processed(GuiAnalysis gui){ + + + } + +} diff --git a/src/utils/SIPInter.java b/src/sip/SIPInter.java similarity index 85% rename from src/utils/SIPInter.java rename to src/sip/SIPInter.java index 055d034..d0dcf3d 100644 --- a/src/utils/SIPInter.java +++ b/src/sip/SIPInter.java @@ -1,4 +1,7 @@ -package utils; +package sip; + +import utils.FDR; +import loops.Loop; import java.io.*; import java.util.*; @@ -10,7 +13,7 @@ * */ -public class SIPInter{ +public class SIPInter extends SIPObject { /** String path of the input data*/ @@ -58,16 +61,8 @@ public class SIPInter{ * @throws IOException exception */ public SIPInter(String output,String chrsize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, boolean keepTif,double fdr) throws IOException { + super(output, gauss, resolution, thresholdMax,matrixSize, nbZero, fdr, keepTif,chrsize) ; - this._output = output; - setChrSize(chrsize); - this._gauss = gauss; - this._resolution = resolution; - this._thresholdMaxima = thresholdMax; - this._matrixSize = matrixSize; - this._nbZero = nbZero; - this._keepTif = keepTif; - _fdr = fdr; } /** @@ -108,7 +103,7 @@ public SIPInter(String input,String output,String chrsize, double gauss, int res * @param first boolean if true it is the first results so need to write the header * @throws IOException exception */ - public void writeResu(String pathFile, HashMap hLoop, boolean first) throws IOException { + public void writeResu(String pathFile, HashMap hLoop, boolean first) throws IOException { FDR fdrDetection = new FDR (this._fdr, hLoop); fdrDetection.run(); double RFDRcutoff = fdrDetection.getRFDRCutoff(); @@ -277,41 +272,6 @@ public void writeResu(String pathFile, HashMap hLoop, boolean first public void setIsGui(boolean isGui) { this._isGui = isGui;} - - /** - * Initialize chrSize hashMap - * - * @param chrSizeFile path to the chrFile - */ - public void setChrSize(String chrSizeFile) { - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - _chrSize.put(chr, size); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * getter chrSize - * @return hashMap of chrName => size - */ - public HashMap getChrSize() { - return _chrSize; - } - } diff --git a/src/utils/SIPObject.java b/src/sip/SIPIntra.java similarity index 63% rename from src/utils/SIPObject.java rename to src/sip/SIPIntra.java index 84e0e12..0454ada 100644 --- a/src/utils/SIPObject.java +++ b/src/sip/SIPIntra.java @@ -1,4 +1,7 @@ -package utils; +package sip; + +import utils.FDR; +import loops.Loop; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -26,62 +29,38 @@ * @author axel poulet * */ -public class SIPObject { - /** String path of the input data*/ - private String _input; - /** Path of the output file*/ - private String _output; - /** Strength of the gaussian filter*/ - private double _gauss; - /** Strength of the min filter*/ +public class SIPIntra extends SIPObject { + private double _min; /** Strength of the max filter*/ private double _max; /** % of staurated pixel after enhance contrast*/ private double _saturatedPixel; - /** Image size*/ - private int _matrixSize = 0; - /** Resolution of the bin dump in base*/ - private int _resolution; - /** Threshold for the maxima detection*/ - private int _thresholdMaxima; - /** HashMap of the chr size, the key = chr name, value = size of chr*/ - private HashMap _chrSize = new HashMap(); + /** Diage size to removed maxima close to diagonal*/ private int _diagonalSize; /** Size of the step to process each chr (step = matrixSize/2)*/ private int _step; - /** Number of pixel = 0 allowed around the loop*/ - private int _nbZero = -1; /** list of the image resolution to find loop*/ private ArrayList _listFactor = new ArrayList(); - /** fdr value */ - private double _fdr; - /** is processed booelan*/ - private boolean _isProcessed = false; - /** if is gui analysis*/ - private boolean _isGui = false; /** if true regional fdr will be not used*/ private boolean _isDroso = false; /** median of loop AP score */ private double _medianAP = 0; /** median of loop regional AP score */ private double _medianAPReg = 0; - /** true is mcool input*/ - private boolean _isCooler = false; /** * */ - public SIPObject() { } + public SIPIntra() { } /** - * SIPObject constructor for hic or mcool file + * SIPIntra constructor for hic or mcool file * * * @param output path file with the file created by the first step of SIP - * @param chrSize hashMap name chr => chr size * @param gauss gaussian filter strength * @param min minimum filter strength * @param max maximum filter strength @@ -96,33 +75,26 @@ public SIPObject() { } * @param isProcessed true if processed SIP data input else false * @param rFDR false if it isn't drosophila input */ - public SIPObject(String output, HashMap chrSize, double gauss, double min, - double max, int resolution, double saturatedPixel, int thresholdMax, - int diagonalSize, int matrixSize, int nbZero,ArrayList listFactor, - double fdr, boolean isProcessed, boolean rFDR) { - if(!output.endsWith(File.separator)) - output = output+File.separator; - this._output = output; - this._input = output; - this._chrSize = chrSize; - this._gauss = gauss; + public SIPIntra(String output, String chrFile, double gauss, double min, + double max, int resolution, double saturatedPixel, int thresholdMax, + int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, + double fdr, boolean isProcessed, boolean rFDR) { + + super( output, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrFile); + + + this._min = min; this._max = max; - this._matrixSize = matrixSize; - this._resolution = resolution; this._saturatedPixel = saturatedPixel; - this._thresholdMaxima = thresholdMax; this._diagonalSize = diagonalSize; this._step = matrixSize/2; - this._nbZero = nbZero; this._listFactor = listFactor; - this._fdr = fdr; - this._isProcessed = isProcessed; this._isDroso = rFDR; } /** - * SIPObject constructor for processed SIP data + * SIPIntra constructor for processed SIP data * * @param input path file with the file created by the first step of SIP * @param output path file for the results @@ -141,30 +113,21 @@ public SIPObject(String output, HashMap chrSize, double gauss, * @param isProcessed true if processed SIP data input else false * @param rFDR false if it isn't drosophila input */ - public SIPObject(String input, String output, HashMap chrSize, double gauss, double min, - double max, int resolution, double saturatedPixel, int thresholdMax, - int diagonalSize, int matrixSize, int nbZero,ArrayList listFactor, - double fdr, boolean isProcessed, boolean rFDR) { - if(!output.endsWith(File.separator)) - output = output+File.separator; - if(!input.endsWith(File.separator)) - input = input+File.separator; - this._output = output; - this._input = input; - this._chrSize = chrSize; - this._gauss = gauss; + public SIPIntra(String input, String output, String chrSize, double gauss, double min, + double max, int resolution, double saturatedPixel, int thresholdMax, + int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, + double fdr, boolean isProcessed, boolean rFDR) { + + super( output, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize); + + this._min = min; this._max = max; - this._matrixSize = matrixSize; - this._resolution = resolution; this._saturatedPixel = saturatedPixel; - this._thresholdMaxima = thresholdMax; this._diagonalSize = diagonalSize; this._step = matrixSize/2; - this._nbZero = nbZero; this._listFactor = listFactor; - this._fdr = fdr; - this._isProcessed = isProcessed; + this._listFactor = listFactor; this._isDroso = rFDR; } @@ -177,15 +140,17 @@ public SIPObject(String input, String output, HashMap chrSize, * @param data hashMap loop name => Loop object * @throws IOException exception */ - public void saveFile(String pathFile, HashMap data, boolean first) throws IOException{ - FDR fdrDetection = new FDR (this._fdr, data); + public void saveFile(String pathFile, HashMap data, boolean first) throws IOException{ + double fdr = this.getFdr(); + FDR fdrDetection = new FDR (fdr, data); + fdrDetection.run(); double RFDRcutoff = fdrDetection.getRFDRCutoff(); double FDRcutoff = fdrDetection.getFDRCutoff(); boolean supToTen = false; if(this._isDroso){ median(data,FDRcutoff); - System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore "); + System.out.println("Filtering value at "+fdr+" FDR is "+FDRcutoff+" APscore "); if(_medianAPReg > 10){ supToTen = true; _medianAPReg = _medianAPReg/4; @@ -193,7 +158,7 @@ public void saveFile(String pathFile, HashMap data, boolean first) } } else - System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); + System.out.println("Filtering value at "+fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); BufferedWriter writer; if(first) writer = new BufferedWriter(new FileWriter(new File(pathFile), true)); else{ @@ -257,7 +222,7 @@ public HashMap getNormValueFilter(String normFile){ while (line != null){ sb.append(line); if((line.equals("NaN")|| line.equals("NAN") || line.equals("nan") || line.equals("na") || Double.parseDouble(line) < 0.30)){ - vector.put(lineNumber*this._resolution, "plop"); + vector.put(lineNumber*this.getResolution(), "plop"); } ++lineNumber; sb.append(System.lineSeparator()); @@ -305,30 +270,6 @@ private void median(HashMap data, double fdrCutoff){ } } - /** - * getter of fdr parameter - * @return fdr value - */ - public double getFdr() { return this._fdr; } - - /** - * setter of fdr value - * @param fdr new fdr value - * - */ - public void setFdr(double fdr) { this._fdr = fdr; } - /** - * Getter of the input dir - * @return path of the input dir - */ - public String getInputDir(){ return this._input; } - - /** - * Getter of the matrix size - * @return the size of the image - */ - public int getMatrixSize(){ return this._matrixSize; } - /** * Getter of step @@ -336,35 +277,7 @@ private void median(HashMap data, double fdrCutoff){ */ public int getStep(){ return this._step;} - /** - * Setter of the path of the input directory - * @param inputDir String of the input directory - */ - public void setInputDir(String inputDir){ this._input = inputDir; } - - /** - * Getter of the path of the output directory - * @return path - */ - public String getOutputDir(){ return this._output; } - - /** - * Setter of the path of the output directory - * @param outputDir path of output directory - */ - public void setOutputDir(String outputDir){ this._output = outputDir;} - /** - * Getter of the gaussian blur strength - * @return double gaussian filter strength - */ - public double getGauss(){ return this._gauss; } - - /** - * Setter of the gaussian blur strength - * @param gauss new gaussian filter strength - */ - public void setGauss(double gauss){ this._gauss = gauss; } /** * Getter of diagonalSize @@ -413,23 +326,7 @@ private void median(HashMap data, double fdrCutoff){ */ public void setSaturatedPixel(double saturatedPixel){ this._saturatedPixel = saturatedPixel; } - /** - * Getter of resolution of the bin - * @return bin size - */ - public int getResolution(){ return this._resolution;} - - /** - * Setter of resolution of the bin - * @param resolution bin size - */ - public void setResolution(int resolution){ this._resolution = resolution;} - /** - * Setter of size of the matrix - * @param size image size - */ - public void setMatrixSize(int size){ this._matrixSize = size; } /** * setter step between image @@ -437,30 +334,7 @@ private void median(HashMap data, double fdrCutoff){ */ public void setStep(int step){ this._step = step;} - /** - * Getter of threshold for the loop detection - * @return threshold - */ - public int getThresholdMaxima(){ return _thresholdMaxima;} - /** - * Setter of threshold for the detection of the maxima - * @param thresholdMaxima threshold - */ - public void setThresholdMaxima(int thresholdMaxima) { this._thresholdMaxima = thresholdMaxima;} - - /** - * Getter of getNbZero - * @return int nb of zero allowed around the loops - */ - public int getNbZero(){ return this._nbZero;} - - /** - * setter of nb of zero - * @param nbZero int nb of zero allowed around the loops - */ - public void setNbZero(int nbZero){ this._nbZero = nbZero;} - /** * Getter of list of integer for multi resolution loop calling * @return list of integer @@ -479,55 +353,9 @@ private void median(HashMap data, double fdrCutoff){ */ public void setIsDroso(boolean droso){ this._isDroso = droso;} - /** - * getter of chrSize hashMap - * @return hashMap chr name => chr size - */ - public HashMap getChrSizeHashMap(){return this._chrSize;} - /** - * setter - * @param chrSize hashMap chr name => chr size - */ - public void setChrSizeHashMap(HashMap chrSize){this._chrSize = chrSize;} - - /** - * getter boolean isProcessed - * true input is SIP processed dat - * @return boolean - */ - public boolean isProcessed() { return _isProcessed;} - - /** - * setter boolean isProcessed - * @param isProcessed boolean - */ - public void setIsProcessed(boolean isProcessed) { this._isProcessed = isProcessed;} - - /** - * getter isCooler - * true: input is mcool dataset - * @return boolean - */ - public boolean isCooler() { return _isCooler;} - /** - * setter isCooler - * @param cool boolean - */ - public void setIsCooler(boolean cool) { this._isCooler = cool;} - - /** - * getter isGui - * true: program run with GUI - * @return boolean - */ - public boolean isGui() { return _isGui;} - /** - * setter isGui - * @param _isGui boolean - */ + - public void setIsGui(boolean _isGui) { this._isGui = _isGui;} } \ No newline at end of file diff --git a/src/sip/SIPObject.java b/src/sip/SIPObject.java new file mode 100644 index 0000000..f2b1998 --- /dev/null +++ b/src/sip/SIPObject.java @@ -0,0 +1,327 @@ +package sip; + + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; + +/** + * Analyse and detect a whole genome HiC with .hic file or already processed data. + * The class is used for the observed and oMe method. + * + * + * @author axel poulet + * + */ +public class SIPObject { + + + /** String path of the input data*/ + private String _input; + /** Path of the output file*/ + private String _output; + /** Strength of the gaussian filter*/ + private double _gauss; + /** double fdr value choose by the user*/ + private double _fdr; + /** Image size*/ + private int _matrixSize; + /** Resolution of the bin dump in base*/ + private int _resolution; + /** Threshold for the maxima detection*/ + private double _thresholdMaxima; + /** Number of pixel = 0 allowed around the loop*/ + private int _nbZero; + /** is processed booelan*/ + private boolean _isProcessed; + /** if is gui analysis*/ + private boolean _isGui; + /** if data set is mcool format*/ + private boolean _isCooler; + /** */ + private boolean _keepTif; + /** HashMap of the chr size, the key = chr name, value = size of chr*/ + private HashMap _chrSizeHashMap = new HashMap(); + /** */ + private String _chrSizeFile; + + /** + * + * @param input + * @param output + * @param gauss + * @param resolution + * @param thresholdMax + * @param matrixSize + * @param nbZero + * @param fdr + */ + public SIPObject (String input, String output, double gauss, int resolution, int thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile){ + if(!output.endsWith(File.separator)) output = output+File.separator; + if(!input.endsWith(File.separator)) input = input+File.separator; + this._input = input; + this._output = output; + this._gauss = gauss; + this._resolution = resolution; + this._thresholdMaxima = thresholdMax; + this._matrixSize = matrixSize; + this._nbZero = nbZero; + this._fdr = fdr; + this._chrSizeFile = chrSizeFile; + setChrSize(this._chrSizeFile); + } + + /** + * + * @param output + * @param gauss + * @param resolution + * @param thresholdMax + * @param matrixSize + * @param nbZero + * @param fdr + * @param keepTif + */ + public SIPObject ( String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr,boolean keepTif, String chrSizeFile ){ + + this._output = output; + this._gauss = gauss; + this._resolution = resolution; + this._thresholdMaxima = thresholdMax; + this._matrixSize = matrixSize; + this._nbZero = nbZero; + this._keepTif = keepTif; + _fdr = fdr; + this._chrSizeFile = chrSizeFile; + setChrSize(this._chrSizeFile); + + + + } + + public SIPObject(){ + + } + + + /** + * getter of fdr parameter + * @return fdr value + */ + public double getFdr() { return this._fdr; } + + /** + * setter of fdr value + * @param fdr new fdr value + * + */ + public void setFdr(double fdr) { this._fdr = fdr; } + /** + * Getter of the input dir + * @return path of the input dir + */ + public String getInputDir(){ return this._input; } + + /** + * Getter of the matrix size + * @return the size of the image + */ + public int getMatrixSize(){ return this._matrixSize; } + + /** + * Setter of the path of the input directory + * @param inputDir String of the input directory + */ + public void setInputDir(String inputDir){ this._input = inputDir; } + + /** + * Getter of the path of the output directory + * @return path + */ + public String getOutputDir(){ return this._output; } + + /** + * Setter of the path of the output directory + * @param outputDir path of output directory + */ + public void setOutputDir(String outputDir){ this._output = outputDir;} + + /** + * Getter of the gaussian blur strength + * @return double gaussian filter strength + */ + public double getGauss(){ return this._gauss; } + + /** + * Setter of the gaussian blur strength + * @param gauss new gaussian filter strength + */ + public void setGauss(double gauss){ this._gauss = gauss; } + + /** + * Getter of resolution of the bin + * @return bin size + */ + public int getResolution(){ return this._resolution;} + + /** + * Setter of resolution of the bin + * @param resolution bin size + */ + public void setResolution(int resolution){ this._resolution = resolution;} + + /** + * Setter of size of the matrix + * @param size image size + */ + public void setMatrixSize(int size){ this._matrixSize = size; } + + /** + * Getter of threshold for the loop detection + * @return threshold + */ + public double getThresholdMaxima(){ return _thresholdMaxima;} + /** + * Setter of threshold for the detection of the maxima + * @param thresholdMaxima threshold + */ + public void setThresholdMaxima(double thresholdMaxima) { this._thresholdMaxima = thresholdMaxima;} + + /** + * Getter of getNbZero + * @return int nb of zero allowed around the loops + */ + public int getNbZero(){ return this._nbZero;} + + /** + * setter of nb of zero + * @param nbZero int nb of zero allowed around the loops + */ + public void setNbZero(int nbZero){ this._nbZero = nbZero;} + + /** + * getter boolean isProcessed + * true input is SIP processed dat + * @return boolean + */ + public boolean isProcessed() { return _isProcessed;} + + /** + * setter boolean isProcessed + * @param isProcessed boolean + */ + public void setIsProcessed(boolean isProcessed) { this._isProcessed = isProcessed;} + + /** + * getter isCooler + * true: input is mcool dataset + * @return boolean + */ + public boolean isCooler() { return _isCooler;} + + /** + * setter isCooler + * @param cool boolean + */ + public void setIsCooler(boolean cool) { this._isCooler = cool;} + + /** + * getter isGui + * true: program run with GUI + * @return boolean + */ + public boolean isGui() { return _isGui;} + + /** + * setter isGui + * @param _isGui boolean + */ + + public void setIsGui(boolean _isGui) { this._isGui = _isGui;} + + + public static void docError (){ + String doc = ("#SIP Version 1 run with java 8\n" + + "\nUsage:\n" + + "\thic [options]\n" + + "\tcool [options]\n" + + "\tprocessed [options]\n" + + "\nParameters:\n" + + "\t chrSizeFile: path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1)\n" + + "\t-res: resolution in bp (default 5000 bp)\n" + + "\t-mat: matrix size to use for each chunk of the chromosome (default 2000 bins)\n" + + "\t-d: diagonal size in bins, remove the maxima found at this size (eg: a size of 2 at 5000 bp resolution removes all maxima" + + " detected at a distance inferior or equal to 10kb) (default 6 bins).\n" + + "\t-g: Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1.5)\n" + + "\t-cpu: Number of CPU used for SIP processing (default 1)\n" + + "\t-factor: Multiple resolutions can be specified using:\n" + + "\t\t-factor 1: run only for the input res (default)\n" + + "\t\t-factor 2: res and res*2\n" + + "\t\t-factor 3: res and res*5\n" + + "\t\t-factor 4: res, res*2 and res*5\n" + + "\t-max: Maximum filter: increases the region of high intensity (default 2)\n" + + "\t-min: Minimum filter: removes the isolated high value (default 2)\n" + + "\t-sat: % of saturated pixel: enhances the contrast in the image (default 0.01)\n" + + "\t-t Threshold for loops detection (default 2800)\n" + + "\t-nbZero: number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6)\n" + + "\t-norm: (default KR)\n" + + "\t-del: true or false, whether not to delete tif files used for loop detection (default true)\n" + + "\t-fdr: Empirical FDR value for filtering based on random sites (default 0.01)\n" + + "\t-isDroso: default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n" + + "\t-h, --help print help\n" + + "\nCommand line eg:\n" + + "\tjava -jar SIP_HiC.jar processed inputDirectory pathToChromosome.size OutputDir .... paramaters\n" + + "\tjava -jar SIP_HiC.jar hic inputDirectory pathToChromosome.size OutputDir juicer_tools.jar\n" + + "\nAuthors:\n" + + "Axel Poulet\n" + + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" + + "\tNew Haven, CT 06511, USA\n" + + "M. Jordan Rowley\n" + + "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" + + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu"); + + System.out.println(doc); + } + + /** + * getter of chrSize hashMap + * @return hashMap chr name => chr size + */ + public HashMap getChrSizeHashMap(){return this._chrSizeHashMap;} + + + /** + * getter of chrSize hashMap + * @return hashMap chr name => chr size + */ + public void setChrSizeHashMap(HashMap chrSize){this._chrSizeHashMap = chrSize;} + + /** + * Initialize chrSize hashMap + * + * @param chrSizeFile path to the chrFile + */ + public void setChrSize(String chrSizeFile) { + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(chrSizeFile)); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null){ + sb.append(line); + String[] parts = line.split("\\t"); + String chr = parts[0]; + int size = Integer.parseInt(parts[1]); + _chrSizeHashMap.put(chr, size); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 12e0fdb..00cc669 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -2,21 +2,19 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; -import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.HashMap; import javax.swing.JOptionPane; import gui.GuiAnalysis; import multiProcesing.ProcessCoolerDumpData; import multiProcesing.ProcessDumpData; -import process.MultiResProcess; -import utils.SIPObject; +import utils.MultiResProcess; +import sip.SIPIntra; /** * @@ -71,7 +69,7 @@ public class Hic_main { /** if true run only image Processing step*/ private static boolean _isProcessed = false; /** hash map stocking in key the name of the chr and in value the size*/ - private static HashMap _chrSize = new HashMap(); +// private static HashMap _chrSize = new HashMap(); /** path to the chromosome size file */ private static String _chrSizeFile; /**boolean is true supress all the image created*/ @@ -83,45 +81,8 @@ public class Hic_main { /**boolean is true supress all the image created*/ private static boolean _gui = false; private static String _logError = ""; - /**String for the documentation*/ - private static String _doc = ("#SIP Version 1 run with java 8\n" - + "\nUsage:\n" - + "\thic [options]\n" - + "\tcool [options]\n" - + "\tprocessed [options]\n" - + "\nParameters:\n" - + "\t chrSizeFile: path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1)\n" - + "\t-res: resolution in bp (default 5000 bp)\n" - + "\t-mat: matrix size to use for each chunk of the chromosome (default 2000 bins)\n" - + "\t-d: diagonal size in bins, remove the maxima found at this size (eg: a size of 2 at 5000 bp resolution removes all maxima" - + " detected at a distance inferior or equal to 10kb) (default 6 bins).\n" - + "\t-g: Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1.5)\n" - + "\t-cpu: Number of CPU used for SIP processing (default 1)\n" - + "\t-factor: Multiple resolutions can be specified using:\n" - + "\t\t-factor 1: run only for the input res (default)\n" - + "\t\t-factor 2: res and res*2\n" - + "\t\t-factor 3: res and res*5\n" - + "\t\t-factor 4: res, res*2 and res*5\n" - + "\t-max: Maximum filter: increases the region of high intensity (default 2)\n" - + "\t-min: Minimum filter: removes the isolated high value (default 2)\n" - + "\t-sat: % of saturated pixel: enhances the contrast in the image (default 0.01)\n" - + "\t-t Threshold for loops detection (default 2800)\n" - + "\t-nbZero: number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6)\n" - + "\t-norm: (default KR)\n" - + "\t-del: true or false, whether not to delete tif files used for loop detection (default true)\n" - + "\t-fdr: Empirical FDR value for filtering based on random sites (default 0.01)\n" - + "\t-isDroso: default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n" - + "\t-h, --help print help\n" - + "\nCommand line eg:\n" - + "\tjava -jar SIP_HiC.jar processed inputDirectory pathToChromosome.size OutputDir .... paramaters\n" - + "\tjava -jar SIP_HiC.jar hic inputDirectory pathToChromosome.size OutputDir juicer_tools.jar\n" - + "\nAuthors:\n" - + "Axel Poulet\n" - + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" - + "\tNew Haven, CT 06511, USA\n" - + "M. Jordan Rowley\n" - + "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" - + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu"); + + /** * Main function to run all the process, can be run with gui or in command line. @@ -129,14 +90,14 @@ public class Hic_main { * With zero parameter only java -jar SIP.jar => gui * With more than 5 paramter => command line mode * - * @param args - * @throws IOException - * @throws InterruptedException + * @param args table with parameters for command line + * @throws IOException exception + * @throws InterruptedException exception */ public static void main(String[] args) throws IOException, InterruptedException { _factor.add(1); if (args.length >= 1 && args.length < 4){ - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); }else if(args.length >= 4){ if (args[0].equals("hic") || args[0].equals("processed") || args[0].equals("cool")){ @@ -160,7 +121,7 @@ public static void main(String[] args) throws IOException, InterruptedException } }else{ System.out.println(args[0]+" not defined\n"); - System.out.println(_doc); + SIPIntra.docError(); return; } @@ -215,25 +176,24 @@ public static void main(String[] args) throws IOException, InterruptedException if(!f.exists() && !_input.startsWith("https")){ System.out.println(_input+" doesn't existed !!! \n\n"); - System.out.println(_doc); + SIPIntra.docError(); return; } f = new File(_chrSizeFile); - if(f.exists()==false ){ + if(!f.exists()){ System.out.println(_chrSizeFile+" doesn't existed !!! \n\n"); - System.out.println(_doc); + SIPIntra.docError(); return; } - SIPObject sip; - readChrSizeFile(_chrSizeFile); + SIPIntra sip; if(_isHic){ f = new File(_juiceBoxTools); if(!f.exists()){ System.out.println(_juiceBoxTools+" doesn't existed !!! \n\n"); - System.out.println(_doc); + SIPIntra.docError(); return; } System.out.println("hic mode: \n"+ "input: "+_input+"\n"+ "output: "+_output+"\n"+ "juiceBox: "+_juiceBoxTools+"\n"+ "norm: "+ _juiceBoXNormalisation+"\n" @@ -241,28 +201,28 @@ public static void main(String[] args) throws IOException, InterruptedException + "saturated pixel: "+_saturatedPixel+"\n"+ "threshold: "+_thresholdMax+"\n"+ "number of zero :"+_nbZero+"\n"+ "factor "+ _factOption+"\n"+ "fdr "+_fdr+"\n" + "del "+_delImages+"\n"+ "cpu "+ _cpu+"\n-isDroso "+_isDroso+"\n"); - sip = new SIPObject(_output, _chrSize, _gauss, _min, _max, _resolution, _saturatedPixel, + sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); sip.setIsGui(_gui); ProcessDumpData processDumpData = new ProcessDumpData(); - processDumpData.go(_input, sip, _chrSize, _juiceBoxTools, _juiceBoXNormalisation, _cpu); + processDumpData.go(_input, sip, _juiceBoxTools, _juiceBoXNormalisation, _cpu); System.out.println("########### End of the dump Step"); }else if(_isCool){ f = new File(_cooltools); if(!f.exists()){ System.out.println(_cooltools+" doesn't existed or wrong path !!! \n\n"); - System.out.println(_doc); + SIPIntra.docError(); return; } f = new File(_cooler); if(!f.exists()){ System.out.println(_cooler+" doesn't existed or wrong path !!! \n\n"); - System.out.println(_doc); + SIPIntra.docError(); return; } if(!testTools(_cooltools, 0, 3, 0) || !testTools(_cooler, 0, 8, 6)) { System.out.println( _cooltools +" or" + _cooler+" is not the good version for SIP (it needs cooltools version >= 0.3.0 and cooler version >= 0.8.6) !!! \n\n"); - System.out.println(_doc); + SIPIntra.docError(); if(_gui){ JOptionPane.showMessageDialog(null, "Error SIP program", _cooltools +" or" + _cooler+" is not the good version for SIP (it needs cooltools version >= 0.3.0 and cooler version >= 0.8.6) !!!" , JOptionPane.ERROR_MESSAGE); @@ -273,11 +233,11 @@ public static void main(String[] args) throws IOException, InterruptedException + "gauss: "+_gauss+"\n"+ "min: "+_min+"\n"+ "max: "+_max+"\n"+ "matrix size: "+_matrixSize+"\n"+ "diag size: "+_diagSize+"\n"+ "resolution: "+_resolution+"\n" + "saturated pixel: "+_saturatedPixel+"\n"+ "threshold: "+_thresholdMax+"\n"+ "number of zero :"+_nbZero+"\n"+ "factor "+ _factOption+"\n"+ "fdr "+_fdr+"\n" + "del "+_delImages+"\n"+ "cpu "+ _cpu+"\n-isDroso "+_isDroso+"\n"); - sip = new SIPObject(_output, _chrSize, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); + sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); sip.setIsCooler(_isCool); ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); - processDumpData.go(_cooltools, _cooler, sip, _input, _chrSize,_cpu); + processDumpData.go(_cooltools, _cooler, sip, _input, _cpu); }else{ System.out.println("processed mode:\n"+ "input: "+_input+"\n"+ "output: "+_output+"\n"+ "juiceBox: "+_juiceBoxTools+"\n" @@ -286,7 +246,7 @@ public static void main(String[] args) throws IOException, InterruptedException + "isHic: "+_isHic+"\n" + "isProcessed: "+_isProcessed+"\n"+ "number of zero:"+_nbZero+"\n"+ "factor "+ _factOption+"\n"+ "fdr "+_fdr+ "\n" + "del "+_delImages+"\n"+"cpu "+ _cpu+"\n-isDroso "+_isDroso+"\n"); - sip = new SIPObject(_input,_output, _chrSize, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, + sip = new SIPIntra(_input,_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero,_factor,_fdr,_isProcessed, _isDroso); sip.setIsGui(_gui); } @@ -319,28 +279,7 @@ public static void main(String[] args) throws IOException, InterruptedException } System.out.println("End of SIP loops are available in "+_output); } - - /** - * Run the input file and stock the info of name chr and their size in hashmap - * @param chrSizeFile path chr size file - * @throws IOException if file does't exist - */ - private static void readChrSizeFile( String chrSizeFile) throws IOException{ - BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - _chrSize.put(chr, size); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - } - + /** * -res: resolution in bases (default 5000 bases) * -mat: matrix size in bins (default 2000 bins) @@ -386,7 +325,7 @@ else if(a == 4){ catch(NumberFormatException e){ returnError("-cpu",args[i+1],"int");} if(_cpu > Runtime.getRuntime().availableProcessors() || _cpu <= 0){ System.out.println("the number of CPU "+ _cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); } }else if(args[i].equals("-nbZero")){ @@ -417,7 +356,7 @@ else if(a == 4){ _juiceBoXNormalisation = args[i+1]; }else{ System.out.println("-norm = "+args[i+1]+", not defined\n"); - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); } }else if(args[i].equals("-del")){ @@ -427,7 +366,7 @@ else if(args[i+1].equals("false") || args[i+1].equals("F") || args[i+1].equals(" _delImages = false; else{ System.out.println("-del = "+args[i+1]+", not defined\n"); - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); } }else if(args[i].equals("-isDroso")){ @@ -437,12 +376,12 @@ else if(args[i+1].equals("false") || args[i+1].equals("F") || args[i+1].equals(" _isDroso = false; else{ System.out.println("-_isDroso = "+args[i+1]+", not defined\n"); - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); } }else{ System.out.println(args[i]+" doesn't existed\n"); - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); } } @@ -458,7 +397,7 @@ else if(args[i+1].equals("false") || args[i+1].equals("F") || args[i+1].equals(" */ private static void returnError(String param, String value, String type){ System.out.println(param+" has to be an integer "+value+" can't be convert in "+type+"\n"); - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); } diff --git a/src/test/TestCallLoopsHicFile.java b/src/test/TestCallLoopsHicFile.java index 20da776..4cac389 100644 --- a/src/test/TestCallLoopsHicFile.java +++ b/src/test/TestCallLoopsHicFile.java @@ -1,17 +1,14 @@ package test; import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.HashMap; import multiProcesing.ProcessDumpData; -import process.MultiResProcess; -import utils.SIPObject; - +import utils.MultiResProcess; +import sip.SIPIntra; /** @@ -42,7 +39,6 @@ public static void main(String[] args) throws IOException, InterruptedException //readChrSizeFile("/home/plop/Documents/Genome/HumanGenomeHg19/hg19_withoutChr.sizes"); //chrsize = readChrSizeFile("/home/plop/Documents/Genome/mammals/HumanGenomeHg19/chr1.size"); String fileChr = "/home/plop/Desktop/SIP/Erics/hg19_chromSizes.txt"; - HashMap chrsize = readChrSizeFile(fileChr); String juiceBoxTools = "/home/plop/Tools/juicer_tools_1.19.02.jar"; int matrixSize = 2000; int resolution = 10000; @@ -78,10 +74,10 @@ public static void main(String[] args) throws IOException, InterruptedException File file = new File(output); if (file.exists()==false){file.mkdir();} - SIPObject sip = new SIPObject(output, chrsize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,keepTif,false); + SIPIntra sip = new SIPIntra(output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,keepTif,false); sip.setIsGui(false); ProcessDumpData processDumpData = new ProcessDumpData(); - processDumpData.go(input, sip, chrsize, juiceBoxTools, juiceBoXNormalisation,cpu); + processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation,cpu); MultiResProcess multi = new MultiResProcess(sip, cpu, keepTif,fileChr); multi.run(); @@ -92,29 +88,7 @@ public static void main(String[] args) throws IOException, InterruptedException //System.out.println("End "+testTools(cooltools,0,3,0)); } - /** - * - * @param chrSizeFile - * @throws IOException - */ - @SuppressWarnings("unused") - private static HashMap readChrSizeFile( String chrSizeFile) throws IOException{ - HashMap chrSize = new HashMap(); - BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - chrSize.put(chr, size); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - return chrSize; - } + public static boolean testTools(String pathTools, int first, int second, int third) { Runtime runtime = Runtime.getRuntime(); diff --git a/src/test/TestCallLoopsProcessedFile.java b/src/test/TestCallLoopsProcessedFile.java index 72e989e..254540d 100644 --- a/src/test/TestCallLoopsProcessedFile.java +++ b/src/test/TestCallLoopsProcessedFile.java @@ -1,12 +1,9 @@ package test; -import java.io.BufferedReader; -import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; -import process.MultiResProcess; -import utils.SIPObject; +import utils.MultiResProcess; +import sip.SIPIntra; /** * Test of calling loops on processed files @@ -41,8 +38,7 @@ public static void main(String[] args) throws IOException, InterruptedException //factor.add(5); //SIP_HiC_v1.3.6.jar hic SIP/Kc_allcombined.hic SIP/armsizes.txt SIP/Droso/ ../Tools/juicer_tools_1.13.02.jar String chrSizeFile = "/home/plop/Desktop/w_hg19.sizes"; - HashMap chrsize = readChrSizeFile(chrSizeFile); - SIPObject sip = new SIPObject(input,output, chrsize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,true,false); + SIPIntra sip = new SIPIntra(input,output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,true,false); sip.setIsGui(false); int cpu = 2; System.out.println("Processed Data\n"); @@ -67,28 +63,4 @@ public static void main(String[] args) throws IOException, InterruptedException System.out.println("End"); } - /** - * - * @param chrSizeFile - * @return - * @throws IOException - */ - private static HashMap readChrSizeFile( String chrSizeFile) throws IOException{ - HashMap chrSize = new HashMap(); - BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - - chrSize.put(chr, size); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - return chrSize; - } -} +} diff --git a/src/test/TestCoolFormat.java b/src/test/TestCoolFormat.java index 21a84e2..d7adc60 100644 --- a/src/test/TestCoolFormat.java +++ b/src/test/TestCoolFormat.java @@ -1,13 +1,10 @@ package test; -import java.io.BufferedReader; -import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; -import process.MultiResProcess; -import utils.SIPObject; +import utils.MultiResProcess; +import sip.SIPIntra; @SuppressWarnings("unused") public class TestCoolFormat { @@ -20,7 +17,7 @@ public static void main(String[] args) throws IOException, InterruptedException String fileChr = "/home/plop/Desktop/w_hg19.sizes"; String cooler = "/home/plop/anaconda3/bin/cooler"; String cooltools = "/home/plop/anaconda3/bin/cooltools"; - HashMap chrsize = readChrSizeFile(fileChr); + int resolution = 5000; int matrixSize = 2000; //CoolerExpected expected = new CoolerExpected(input, resolution, matrixSize); @@ -45,14 +42,14 @@ public static void main(String[] args) throws IOException, InterruptedException boolean keepTif = false; int cpu = 1; - SIPObject sip = new SIPObject(input,output, chrsize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03,keepTif,false); + SIPIntra sip = new SIPIntra(input,output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03,keepTif,false); sip.setIsGui(false); sip.setIsCooler(true); sip.setIsProcessed(true); //ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); - // go(String coolTools, String cooler, SIPObject sip, String coolFile, HashMap chrSize,int nbCPU) + // go(String coolTools, String cooler, SIPIntra sip, String coolFile, HashMap chrSize,int nbCPU) //processDumpData.go(cooltools, cooler, sip, input, chrsize,2); MultiResProcess multi = new MultiResProcess(sip, cpu, keepTif,fileChr); multi.run(); @@ -61,27 +58,5 @@ public static void main(String[] args) throws IOException, InterruptedException } - /** - * - * @param chrSizeFile - * @return - * @throws IOException - */ - private static HashMap readChrSizeFile( String chrSizeFile) throws IOException{ - HashMap chrSize = new HashMap(); - BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - chrSize.put(chr, size); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - return chrSize; - } + } diff --git a/src/test/TestGui.java b/src/test/TestGui.java index 47d1df6..5b4d223 100644 --- a/src/test/TestGui.java +++ b/src/test/TestGui.java @@ -1,14 +1,11 @@ package test; -import java.io.BufferedReader; -import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import gui.GuiAnalysis; import multiProcesing.ProcessDumpData; -import utils.SIPObject; +import sip.SIPIntra; /** @@ -25,7 +22,7 @@ public class TestGui { * @throws InterruptedException */ public static void main(String[] args) throws IOException, InterruptedException{ - SIPObject sip ; + SIPIntra sip ; GuiAnalysis gui = new GuiAnalysis(); while( gui.isShowing()){ try {Thread.sleep(1);} @@ -55,22 +52,22 @@ public static void main(String[] args) throws IOException, InterruptedException{ ArrayList factor = new ArrayList(); factor.add(1); //factor.add(2); - HashMap chrSize = readChrSizeFile(gui.getChrSizeFile()); + String chrSize = gui.getChrSizeFile(); if(gui.isProcessed()==false){ System.out.println("hic mode:\ninput: "+input+"\noutput: "+output+"\njuiceBox: "+juiceBoxTools+"\nnorm: "+ juiceBoXNormalisation+"\ngauss: "+gauss+"\n" + "min: "+min+"\nmax: "+max+"\nmatrix size: "+matrixSize+"\ndiag size: "+diagSize+"\nresolution: "+resolution+"\nsaturated pixel: "+saturatedPixel +"\nthreshold: "+thresholdMax+"\n number of zero:"+nbZero+"\n "); - sip = new SIPObject(output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,gui.isProcessed(),false); + sip = new SIPIntra(output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,gui.isProcessed(),false); sip.setIsGui(true); ProcessDumpData processDumpData = new ProcessDumpData(); - processDumpData.go(input, sip, chrSize, juiceBoxTools, juiceBoXNormalisation,gui.getNbCpu()); + processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation,gui.getNbCpu()); }else{ System.out.println("processed mode:\ninput: "+input+"\noutput: "+output+"\njuiceBox: "+juiceBoxTools+"\nnorm: "+ juiceBoXNormalisation+"\ngauss: "+gauss +"\nmin: "+min+"\nmax: "+max+"\nmatrix size: "+matrixSize+"\ndiag size: "+diagSize+"\nresolution: "+resolution+"\nsaturated pixel: "+saturatedPixel +"\nthreshold: "+thresholdMax+"\nisHic: "+isHic+"\nisProcessed: "+isProcessed+"\n number of zero:" +nbZero+"\n"); - sip = new SIPObject(input,output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,gui.isProcessed(),false); + sip = new SIPIntra(input,output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,gui.isProcessed(),false); sip.setIsGui(true); } @@ -79,27 +76,4 @@ public static void main(String[] args) throws IOException, InterruptedException{ } } - - /** - * Run the input file and stock the info of name chr and their size in hashmap - * @param chrSizeFile path chr size file - * @throws IOException if file does't exist - */ - private static HashMap readChrSizeFile( String chrSizeFile) throws IOException{ - HashMap m_chrSize = new HashMap(); - BufferedReader br = new BufferedReader(new FileReader(chrSizeFile)); - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null){ - sb.append(line); - String[] parts = line.split("\\t"); - String chr = parts[0]; - int size = Integer.parseInt(parts[1]); - m_chrSize.put(chr, size); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - br.close(); - return m_chrSize; - } } \ No newline at end of file diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 19c4718..72b08ce 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -1,7 +1,7 @@ package test; import multiProcesing.ProcessDetectLoops; -import utils.SIPInter; +import sip.SIPInter; import java.io.IOException; import java.util.ArrayList; diff --git a/src/test/TestMergeLoops.java b/src/test/TestMergeLoops.java index a60faf7..eb4408e 100644 --- a/src/test/TestMergeLoops.java +++ b/src/test/TestMergeLoops.java @@ -13,7 +13,7 @@ import java.util.Set; import java.util.stream.Collectors; -import utils.Loop; +import loops.Loop; public class TestMergeLoops { diff --git a/src/utils/CoordinatesCorrection.java b/src/utils/CoordinatesCorrection.java index 3937464..eb5630b 100644 --- a/src/utils/CoordinatesCorrection.java +++ b/src/utils/CoordinatesCorrection.java @@ -1,5 +1,7 @@ package utils; +import loops.Loop; + import java.util.HashMap; import java.util.Iterator; import java.util.Set; @@ -16,7 +18,7 @@ public class CoordinatesCorrection { /** HashMap of the loops with new coordinates*/ - private HashMap _data = new HashMap(); + private HashMap _data = new HashMap(); /** * diff --git a/src/utils/FDR.java b/src/utils/FDR.java index 31e577e..59251f8 100644 --- a/src/utils/FDR.java +++ b/src/utils/FDR.java @@ -1,5 +1,7 @@ package utils; +import loops.Loop; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -22,7 +24,7 @@ public class FDR { /** fdr value*/ private double _fdr; /** hashmap of loop loopName=> Loop object*/ - private HashMap _data; + private HashMap _data; /** * Constructor diff --git a/src/utils/FindMaxima.java b/src/utils/FindMaxima.java index f057ded..7d60901 100644 --- a/src/utils/FindMaxima.java +++ b/src/utils/FindMaxima.java @@ -10,6 +10,7 @@ import ij.plugin.filter.MaximumFinder; import ij.process.ByteProcessor; import ij.process.ImageProcessor; +import loops.Loop; /** * Detection of regional maxima in image. Return the HashMap, the loop can be corrected. @@ -30,64 +31,73 @@ public class FindMaxima{ /** binary image pixel white = the maxima detected*/ private ImagePlus _imgResu = new ImagePlus(); /** threshold for the imageJ class MaximumFinder, this class is call to detecte the maxima */ - private double _noiseTolerance =-1; + private double _thresholdMaxima; /** diagonal size in bin*/ - private int _diagSize =-1; + private int _diagonalSize; /** Resolution of the image in base*/ - private int _resolution = -1; - private double _gaussianFilterRadius; + private int _resolution; + /** gaussian Filter strength*/ + private double _gaussian; /** - * Constructor of FindMaxima + * Constructor of FindMaxima for intra chromosomal method + * * @param img ImagePlus raw image * @param imgFilter ImagePlus filtered image * @param chr String chromosome - * @param noiseTolerance double threshold to detect maxima - * @param diag int the size of the diagonal + * @param thresholdMaxima double threshold to detect maxima + * @param diagonalSize int the size of the diagonal * @param resolution int size of the pixel in base */ - public FindMaxima(ImagePlus img, ImagePlus imgFilter, String chr, double noiseTolerance, int diag, int resolution){ + public FindMaxima(ImagePlus img, ImagePlus imgFilter, String chr, double thresholdMaxima, int diagonalSize, int resolution){ this._imgNorm = img; this._imgFilter = imgFilter; - this._noiseTolerance = noiseTolerance; + this._thresholdMaxima = thresholdMaxima; this._chr = chr; - this._diagSize = diag; + this._diagonalSize = diagonalSize; this._resolution = resolution; } /** - * - * @param imgFilter - * @param chr1 - * @param chr2 - * @param noiseTolerance - * @param resolution + * Constructor of FindMaxima for inter chromosomal method + * @param imgDiff ImagePlus image diff + * @param chr1 chr1 name + * @param chr2 chr2 name + * @param thresholdMaxima double threshold to detect maxima + * @param resolution int size of the pixel in base + * @param gaussian gaussian filter strength */ - public FindMaxima( ImagePlus imgFilter, String chr1,String chr2, double noiseTolerance, int resolution, double gaussian){ - this._imgFilter = imgFilter; - this._noiseTolerance = noiseTolerance; + public FindMaxima( ImagePlus imgDiff, String chr1,String chr2, double thresholdMaxima, int resolution, double gaussian){ + this._imgFilter = imgDiff; + this._thresholdMaxima = thresholdMaxima; this._chr2 = chr2; this._chr = chr1; this._resolution = resolution; - this._gaussianFilterRadius = gaussian; + this._gaussian = gaussian; } /** + * findLoop for intra chromosomal interaction + * call ImageJ findMaxima method + * filter loops with low value in oMe image and normalize image + * if the loops didn't possess a decay => suppress + * Loop correction: => avoid overlapping loops, correct also the coordinate if higher value pixel is in the loops + * neighbor * - * @param index - * @param nbZero - * @param raw - * @param val - * @return + * @param index image index + * @param nbZero nb zeor allowe around the loop + * @param raw ImagePlus raw image + * @param val value used as min in the image + * @return HashMap loop loop name => Loop object */ - public HashMap findloop(int index, int nbZero, ImagePlus raw, float val){ + public HashMap findloop(int index, int nbZero, ImagePlus raw, float val){ run(nbZero, raw, val); ArrayList temp = this.getMaxima(); ImageProcessor ipN = this._imgNorm.getProcessor(); - HashMap data = new HashMap(); + HashMap data = new HashMap(); //System.out.println("size raw maxima !!!!!!!!!!!!!! "+raw.getTitle()+" "+temp.size()); for(int j = 0; j < temp.size();++j){ String[] parts = temp.get(j).split("\\t"); @@ -99,14 +109,14 @@ public HashMap findloop(int index, int nbZero, ImagePlus raw, float if(avg > 1.45 && ipN.getf(x, y) >= 1.85){ // filter on the loop value and region value DecayAnalysis da = new DecayAnalysis(this._imgNorm,x,y); float n1 =da.getNeighbourhood1(); - float n2 =da.getNeighbourhood2(); + float n2 =da.getNeighbourhood2(); if(n1 < n2 && n1 >= 0.15 && n2 >= 0.25){ // filter on the neighborood for hic datatset Loop maxima = new Loop(temp.get(j),x,y,this._chr,avg,std,ipN.getf(x, y)); maxima.setNeigbhoord1(n1); maxima.setNeigbhoord2(n2); maxima.setResolution(this._resolution); //System.out.println(_resolution+" "+maxima.getResolution()); - maxima.setDiagSize(this._diagSize); + maxima.setDiagSize(this._diagonalSize); maxima.setMatrixSize(this._imgNorm.getWidth()); data.put(name, maxima); } @@ -117,8 +127,14 @@ public HashMap findloop(int index, int nbZero, ImagePlus raw, float } /** - * @param - * + * findLoop for inter chromosomal interaction + * call ImageJ findMaxima method + * filter loops with more than the nb of zero allowed in its neighbor + * if the loops didn't possess a decay => suppress + * Loop correction: correct also the coordinate if higher value pixel is in the loops + * neighbor + * @param pathRaw path to the raw image + * @return HashMap loop loop name => Loop object */ public HashMap findLoopInter(String pathRaw){ @@ -156,7 +172,7 @@ public HashMap findLoopInter(String pathRaw){ //System.out.println("after filter ################# "+raw.getTitle()+" "+data.size()); return data; } - + /** * Detect maxima with the oMe or observed methods, call the different methods * to detect the maxima and correct them. @@ -168,7 +184,7 @@ private void run(int nbZero, ImagePlus rawImage, float backgroundValue){ ImagePlus temp = this._imgFilter.duplicate(); ImageProcessor ip = temp.getProcessor(); MaximumFinder mf = new MaximumFinder(); - ByteProcessor bp = mf.findMaxima(ip, this._noiseTolerance, MaximumFinder.SINGLE_POINTS, true); + ByteProcessor bp = mf.findMaxima(ip, this._thresholdMaxima, MaximumFinder.SINGLE_POINTS, true); this._imgResu.setProcessor(bp); this.putLoopLowerTriangle(); this.removedCloseMaxima(); @@ -178,20 +194,20 @@ private void run(int nbZero, ImagePlus rawImage, float backgroundValue){ /** - * + * Detect maxima with the oMe or observed methods, call the different methods + * to detect the maxima and correct them. + * @param rawImage ImagePlus raw image */ private void runInter(ImagePlus rawImage){ ImagePlus temp = this._imgFilter.duplicate(); ImageProcessor ip = temp.getProcessor(); GaussianBlur gb = new GaussianBlur(); - gb.blurGaussian(ip, this._gaussianFilterRadius); + gb.blurGaussian(ip, this._gaussian); MaximumFinder mf = new MaximumFinder(); - ByteProcessor bp = mf.findMaxima(ip, this._noiseTolerance, MaximumFinder.SINGLE_POINTS, true); + ByteProcessor bp = mf.findMaxima(ip, this._thresholdMaxima, MaximumFinder.SINGLE_POINTS, true); this._imgResu.setProcessor(bp); this._imgNorm = rawImage; - //this.removedCloseMaxima(); this.correctMaxima(); - //this.removeMaximaCloseToZero(nbZero,rawImage, backgroundValue); } @@ -232,6 +248,9 @@ public static void saveFile ( ImagePlus imagePlusInput, String pathFile){ fileSaver.saveAsTiff(pathFile); } + /** + * + */ private void putLoopLowerTriangle() { ImageProcessor ipMaxima = this._imgResu.getProcessor(); int w = ipMaxima.getWidth(); @@ -402,7 +421,7 @@ private void removeMaximaCloseToZero(int nbZero,ImagePlus rawImage, float val){ for(int j= 2;j< h-2;++j){ if(ipResu.getPixel(i, j) > 0){ int thresh = nbZero; - if (j-i <= this._diagSize+2) + if (j-i <= this._diagonalSize +2) thresh = thresh+1; int nb = 0; for(int ii = i-2; ii <= i+2; ++ii){ @@ -420,10 +439,4 @@ private void removeMaximaCloseToZero(int nbZero,ImagePlus rawImage, float val){ } this._imgResu.setProcessor(ipResu); } - - /** - * Setter of the noise tolerance parameter - * @param n int the value of the new noiseTolerance - */ - public void setNoiseTolerance( int n){ this._noiseTolerance = n;} } diff --git a/src/utils/ImageProcessingMethod.java b/src/utils/ImageProcessingMethod.java index b02388e..bd1ee88 100644 --- a/src/utils/ImageProcessingMethod.java +++ b/src/utils/ImageProcessingMethod.java @@ -73,30 +73,11 @@ public void enhanceContrast(double saturatedPixel){ public void runMin(double min){ this._rF.rank(this._ip, min, RankFilters.MIN); } - - - /** - * White "tophat" method to enhance the light structure - * - */ - public void topHat(){ - GaussianBlur gb = new GaussianBlur(); - gb.blurGaussian(this._ip, this._gaussianFilterRadius); - this._rF.rank(this._ip, this._minFilterRadius, RankFilters.MIN); - this._rF.rank(this._ip, this._maxFilterRadius, RankFilters.MAX); - this._rF.rank(this._ip, this._maxFilterRadius, RankFilters.MAX); - this._rF.rank(this._ip, this._minFilterRadius, RankFilters.MIN); - } - - /** - * Getter of the image filtered - * @return ImagePlus image filtered - */ - public ImagePlus getImg(){ return _img;} + /** * Setter of the raw image - * @param _img raw Image + * @param img raw Image */ public void setImg(ImagePlus img){ this._img = img;} @@ -112,9 +93,9 @@ public void runGaussian() { /** * - * @param m_min + * @param max max filter strength */ - public void runMax(double m_max) { - _rF.rank(_ip, m_max, RankFilters.MAX); + public void runMax(double max) { + _rF.rank(_ip, max, RankFilters.MAX); } } diff --git a/src/process/MultiResProcess.java b/src/utils/MultiResProcess.java similarity index 73% rename from src/process/MultiResProcess.java rename to src/utils/MultiResProcess.java index e975de1..5adf555 100644 --- a/src/process/MultiResProcess.java +++ b/src/utils/MultiResProcess.java @@ -1,4 +1,4 @@ -package process; +package utils; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -17,8 +17,8 @@ import multiProcesing.ProcessDetectLoops; -import utils.Loop; -import utils.SIPObject; +import loops.Loop; +import sip.SIPIntra; /** * Class allowing the multi resolution loop calling @@ -29,62 +29,24 @@ public class MultiResProcess { /** SIP object*/ - private SIPObject _sip; + private SIPIntra _sip; /** number of cpu */ private int _nbCpu; /** boolean delImage*/ private boolean _delImage; - /** doc */ - private String _doc = ("#SIP Version 1 run with java 8\n" - + "\nUsage:\n" - + "\thic [options]\n" - + "\tcool [options]\n" - + "\tprocessed [options]\n" - + "\nParameters:\n" - + "\t chrSizeFile: path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1)\n" - + "\t-res: resolution in bp (default 5000 bp)\n" - + "\t-mat: matrix size to use for each chunk of the chromosome (default 2000 bins)\n" - + "\t-d: diagonal size in bins, remove the maxima found at this size (eg: a size of 2 at 5000 bp resolution removes all maxima" - + " detected at a distance inferior or equal to 10kb) (default 6 bins).\n" - + "\t-g: Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1.5)\n" - + "\t-cpu: Number of CPU used for SIP processing (default 1)\n" - + "\t-factor: Multiple resolutions can be specified using:\n" - + "\t\t-factor 1: run only for the input res (default)\n" - + "\t\t-factor 2: res and res*2\n" - + "\t\t-factor 3: res and res*5\n" - + "\t\t-factor 4: res, res*2 and res*5\n" - + "\t-max: Maximum filter: increases the region of high intensity (default 2)\n" - + "\t-min: Minimum filter: removes the isolated high value (default 2)\n" - + "\t-sat: % of saturated pixel: enhances the contrast in the image (default 0.01)\n" - + "\t-t Threshold for loops detection (default 2800)\n" - + "\t-nbZero: number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6)\n" - + "\t-norm: (default KR)\n" - + "\t-del: true or false, whether not to delete tif files used for loop detection (default true)\n" - + "\t-fdr: Empirical FDR value for filtering based on random sites (default 0.01)\n" - + "\t-isDroso: default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n" - + "\t-h, --help print help\n" - + "\nCommand line eg:\n" - + "\tjava -jar SIP_HiC.jar processed inputDirectory pathToChromosome.size OutputDir .... paramaters\n" - + "\tjava -jar SIP_HiC.jar hic inputDirectory pathToChromosome.size OutputDir juicer_tools.jar\n" - + "\nAuthors:\n" - + "Axel Poulet\n" - + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" - + "\tNew Haven, CT 06511, USA\n" - + "M. Jordan Rowley\n" - + "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" - + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu"); + /** path to chr size file*/ private String _chrFile; /** * Constructor * - * @param sip SIPObject + * @param sip SIPIntra * @param cpu number of cpu * @param delImage delete image boolean * @param chrSizeFile path of chrSize file */ - public MultiResProcess(SIPObject sip, int cpu, boolean delImage, String chrSizeFile) { + public MultiResProcess(SIPIntra sip, int cpu, boolean delImage, String chrSizeFile) { this._nbCpu = cpu; this._sip = sip; this._delImage = delImage; @@ -110,7 +72,7 @@ public void run() throws InterruptedException, IOException{ JOptionPane.showMessageDialog(null,"Resolution problem", "Enable to find all the directories needed for SIP (-factor option)", JOptionPane.ERROR_MESSAGE); } System.out.println("!!!! It is missing one or several directories for factor paramter\n"); - System.out.println(_doc); + SIPIntra.docError(); System.exit(0); } } @@ -124,7 +86,7 @@ public void run() throws InterruptedException, IOException{ File file = new File(resuFile); if(file.exists()) file.delete(); - SIPObject sipTmp = new SIPObject (); + SIPIntra sipTmp = new SIPIntra(); if(indexFact == 0) { ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); processDetectloops.go(this._sip, this._nbCpu,this._delImage,resuFile,resName); diff --git a/src/utils/PeakAnalysisScore.java b/src/utils/PeakAnalysisScore.java index 2ba8bc2..c95c6b4 100644 --- a/src/utils/PeakAnalysisScore.java +++ b/src/utils/PeakAnalysisScore.java @@ -6,6 +6,7 @@ import java.util.Set; import ij.ImagePlus; import ij.process.ImageProcessor; +import loops.Loop; /** * Peak analysis score. @@ -17,7 +18,7 @@ public class PeakAnalysisScore { /** Raw image of the matrix*/ private ImagePlus _imgRaw = new ImagePlus(); /** HashMap of object loops*/ - private HashMap _data = new HashMap(); + private HashMap _data = new HashMap(); /** ImageProcessor of the raw ImagePlus*/ private ImageProcessor _ipRaw; diff --git a/src/process/TupleFileToImage.java b/src/utils/TupleFileToImage.java similarity index 99% rename from src/process/TupleFileToImage.java rename to src/utils/TupleFileToImage.java index ef115f0..73f88e8 100644 --- a/src/process/TupleFileToImage.java +++ b/src/utils/TupleFileToImage.java @@ -1,4 +1,4 @@ -package process; +package utils; import java.io.BufferedReader; import java.io.FileReader; From db9e970a00da63a59f8e5f13ded366d63845dde8 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Thu, 12 Nov 2020 19:56:42 -0500 Subject: [PATCH 09/27] adding apache common CLI method to parse the commande line argument and simplify the main class. --- SIP.iml | 1 + pom.xml | 7 +- src/cli/CLIOptionHiC.java | 48 ++++++ src/cli/CLIOptionMCool.java | 53 ++++++ src/cli/CLISipOption.java | 151 +++++++++++++++++ src/process/HiC.java | 12 ++ src/process/MCool.java | 6 + src/sip/SIPInter.java | 199 ++--------------------- src/sip/SIPIntra.java | 10 +- src/sip/SIPObject.java | 14 +- src/sipMain/Hic_main.java | 38 +++-- src/test/TestCallLoopsProcessedFile.java | 4 +- src/test/TestCoolFormat.java | 4 +- src/test/TestGui.java | 4 +- src/test/TestInter.java | 5 +- 15 files changed, 338 insertions(+), 218 deletions(-) create mode 100644 src/cli/CLIOptionHiC.java create mode 100644 src/cli/CLIOptionMCool.java create mode 100644 src/cli/CLISipOption.java diff --git a/SIP.iml b/SIP.iml index a705397..08d1edd 100644 --- a/SIP.iml +++ b/SIP.iml @@ -21,5 +21,6 @@ + \ No newline at end of file diff --git a/pom.xml b/pom.xml index bd7720d..92d9698 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,12 @@ MorphoLibJ_ 1.4.0 - + + + commons-cli + commons-cli + 1.4 + diff --git a/src/cli/CLIOptionHiC.java b/src/cli/CLIOptionHiC.java new file mode 100644 index 0000000..40ce368 --- /dev/null +++ b/src/cli/CLIOptionHiC.java @@ -0,0 +1,48 @@ +package cli; + +import org.apache.commons.cli.*; + +public class CLIOptionHiC extends CLISipOption{ + + /** */ + private CommandLine _commandLine; + + public CLIOptionHiC(String [] args)throws Exception{ + super(args); + HelpFormatter formatter ; + CommandLineParser parser= new DefaultParser(); + CommandLine cmd = this._cmd; + + this._options.addOption(Option.builder("j").longOpt("juicerTool").required() + .type(String.class).desc("Path to juicerTool.jar\n").numberOfArgs(1).build()); + + this._options.addOption(Option.builder("n").longOpt("norm").required() + .type(String.class).desc(" (default KR)\n").numberOfArgs(1).build()); + + + + String typeOfLoop = cmd.getOptionValue("tl"); + if(typeOfLoop.equals("inter")){ + this.addInterChange(); + }else{ + this.addIntraParam(); + } + try { + _commandLine = parser.parse(this._options, args); + } + catch (ParseException exp){ + System.out.println(exp.getMessage()+"\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + } + + + /** + * + * @return + */ + public CommandLine getCommandLine() { + return _commandLine; + } +} diff --git a/src/cli/CLIOptionMCool.java b/src/cli/CLIOptionMCool.java new file mode 100644 index 0000000..64f5ead --- /dev/null +++ b/src/cli/CLIOptionMCool.java @@ -0,0 +1,53 @@ +package cli; + +import org.apache.commons.cli.*; + +/** + * + */ +public class CLIOptionMCool extends CLISipOption{ + /** */ + private CommandLine _commandLine; + /** + * + * @param args + * @throws Exception + */ + public CLIOptionMCool (String [] args)throws Exception{ + super(args); + HelpFormatter formatter ; + CommandLineParser parser= new DefaultParser(); + CommandLine cmd = this._cmd; + String typeOfLoop = cmd.getOptionValue("tl"); + this._options.addOption(Option.builder("cooltools").longOpt("cooltools").required() + .type(String.class).desc("Path to cooltools bin\n").numberOfArgs(1).build()); + + this._options.addOption(Option.builder("cooler").longOpt("cooler").required() + .type(String.class).desc("Path to cooler bin\n").numberOfArgs(1).build()); + + + if(typeOfLoop.equals("inter")){ + this.addInterChange(); + }else{ + this.addIntraParam(); + } + try { + _commandLine = parser.parse(this._options, args); + } + catch (ParseException exp){ + System.out.println(exp.getMessage()+"\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + } + + /** + * + * @return + */ + public CommandLine getCommandLine() { + return _commandLine; + } + +} diff --git a/src/cli/CLISipOption.java b/src/cli/CLISipOption.java new file mode 100644 index 0000000..12b6682 --- /dev/null +++ b/src/cli/CLISipOption.java @@ -0,0 +1,151 @@ +package cli; +import org.apache.commons.cli.*; + +public class CLISipOption { + + Options _options= new Options(); + CommandLine _cmd; + + private Option _inputFolder= Option.builder("i").longOpt("input").required() + .type(String.class).desc("Path to input .hic, .mcool or SIP folder containing processed data\n") + .numberOfArgs(1).build(); + private Option _outputFolder= Option.builder("o").longOpt("output").required() + .type(String.class).desc("Path to output folder for SIP's files \n") + .numberOfArgs(1).build(); + private Option _chrSize = Option.builder("c").longOpt("chrSize").required() + .type(String.class).desc("Path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1).\n") + .numberOfArgs(1).build(); + private Option _resolution = Option.builder("r").longOpt("resolution") + .type(Number.class).desc("Resolution in bp (default 5000 bp)\n") + .numberOfArgs(1).build(); + private Option _sizeImage = Option.builder("m").longOpt("matrix") + .type(Number.class).desc("Matrix size to use for each chunk of the chromosome (default 2000 bins)\n") + .numberOfArgs(1).build(); + private Option _cpu = Option.builder("cpu") + .type(Number.class).desc("Number of CPU used for SIP processing (default 1)\n") + .numberOfArgs(1).build(); + private Option _gaussianStrength = Option.builder("g").longOpt("gaussian") + .type(Number.class).desc("Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1.5)\n") + .numberOfArgs(1).build(); + private Option _threshold = Option.builder("t").longOpt("threshold") + .type(Number.class).desc("Threshold for loops detection (default 2800)\n") + .numberOfArgs(1).build(); + private Option _nbZero = Option.builder("nbZero") + .type(Number.class).desc("Number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6)\n") + .numberOfArgs(1).build(); + private Option _fdr = Option.builder("fdr") + .type(Number.class).desc("Empirical FDR value for filtering based on random sites (default 0.01)\n") + .numberOfArgs(1).build(); + private Option _deleteImage = Option.builder("d").longOpt("delete") + .type(boolean.class).desc("Delete tif files used for loop detection (default true)\n") + .build(); + private Option _interOrIntra = Option.builder("lt").longOpt("loopsType").required() + .type(String.class).desc("(inter or intra), call loops inter chromosomal or intra chromosomal loops\n") + .build(); + private Option _isDroso = Option.builder("isDroso") + .type(boolean.class).desc("Default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n") + .build(); + private Option _diagonal = Option.builder("d").longOpt("diagonal") + .type(Number.class).desc("diagonal size in bins, remove the maxima found at this size (eg: a size of 2 at 5000 bp resolution removes all maxima\n" + + " detected at a distance inferior or equal to 10kb) (default 6 bins).\n") + .numberOfArgs(1).build(); + private Option _factor = Option.builder("f").longOpt("factor") + .type(Number.class).desc(" Multiple resolutions can be specified using:\n" + + "\t\t-factor 1: run only for the input res (default)\n" + + "\t\t-factor 2: res and res*2\n" + + "\t\t-factor 3: res and res*5\n" + + "\t\t-factor 4: res, res*2 and res*5\n") + .numberOfArgs(1).build(); + + private Option _min = Option.builder("min").longOpt("minimum") + .type(Number.class).desc("Minimum filter strength (default 2)\n") + .numberOfArgs(1).build(); + private Option _max = Option.builder("max").longOpt("maximum") + .type(Number.class).desc("Maximum filter strength (default 2)\n") + .numberOfArgs(1).build(); + private Option _saturated = Option.builder("sat").longOpt("saturated") + .type(Number.class).desc("% of saturated pixel: enhances the contrast in the image (default 0.01)\n") + .numberOfArgs(1).build(); + + private static String _Jversion ="1.6.1"; + /** + * + * @param args + * @throws Exception + */ + public CLISipOption(String[] args)throws Exception { + CommandLineParser parser= new DefaultParser(); + + this._options.addOption(_inputFolder); + this._options.addOption(_outputFolder); + this._options.addOption(_chrSize); + this._options.addOption(_resolution); + this._options.addOption(_deleteImage); + this._options.addOption(_fdr); + this._options.addOption(_nbZero); + this._options.addOption(_sizeImage); + this._options.addOption(_cpu); + this._options.addOption(_gaussianStrength); + this._options.addOption(_threshold); + this._options.addOption(_interOrIntra); + try { + _cmd = parser.parse(this._options, args); + } + catch (ParseException exp){ + System.out.println(exp.getMessage()+"\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + } + + /** + * + * @return + */ + public static String getHelperInfos() { + return "More details :\n" + + "java -jar SIPHiC"+_Jversion+".jar hic --help \n" + + "or \n"+ + "java -jar NucleusJ_2-"+_Jversion+".jar cool -h or --help\n"+ + "or \n" + + "java -jar NucleusJ_2-"+_Jversion+".jar cool -h or --help \n" + + "\n\nCommand line eg:\n" + + "\tjava -jar SIP_HiC.jar hic [options]\n" + + "\tjava -jar SIP_HiC.jar cool [options]\n" + + "\tjava -jar SIP_HiC.jar processed [options]\n" + + "\nAuthors:\n" + + "Axel Poulet\n" + + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" + + "\tNew Haven, CT 06511, USA\n" + + "\nM. Jordan Rowley\n" + + "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" + + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"; + } + + + + /** + * + */ + public void addInterChange(){ + this._gaussianStrength.setDescription("Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1)\n"); + this._fdr.setDescription("Empirical FDR value for filtering based on random sites (default 0.025)\n"); + this._resolution.setDescription("Resolution in bp (default 100000 bp)\n"); + this._sizeImage.setDescription("Matrix size to use for each chunk of the chromosome (default 500 bins)\n"); + this._threshold.setDescription("Threshold for loops detection (default 0.9)\n"); + } + + + /** + * + */ + public void addIntraParam(){ + this._options.addOption(_diagonal); + this._options.addOption(_factor); + this._options.addOption(_max); + this._options.addOption(_min); + this._options.addOption(_saturated); + this._options.addOption(_isDroso); + } + +} diff --git a/src/process/HiC.java b/src/process/HiC.java index af79ad5..b939d02 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -1,4 +1,16 @@ package process; + + public class HiC { + + private String [] _args; + + public HiC(String args []){ + _args = args; + + } + + + } diff --git a/src/process/MCool.java b/src/process/MCool.java index 80513d0..e22b816 100644 --- a/src/process/MCool.java +++ b/src/process/MCool.java @@ -2,5 +2,11 @@ public class MCool { + private String [] _args; + + public MCool(String args []) { + _args = args; + } + } diff --git a/src/sip/SIPInter.java b/src/sip/SIPInter.java index d0dcf3d..8b65598 100644 --- a/src/sip/SIPInter.java +++ b/src/sip/SIPInter.java @@ -16,41 +16,12 @@ public class SIPInter extends SIPObject { - /** String path of the input data*/ - private String _input; - /** Path of the output file*/ - private String _output; - /** Strength of the gaussian filter*/ - private double _gauss; - /** double fdr value choose by the user*/ - private double _fdr; - /** Image size*/ - private int _matrixSize; - /** Resolution of the bin dump in base*/ - private int _resolution; - /** Threshold for the maxima detection*/ - private double _thresholdMaxima; - /** HashMap of the chr size, the key = chr name, value = size of chr*/ - private HashMap _chrSize = new HashMap<>(); - /** Size of the step to process each chr (step = matrixSize/2)*/ - private int _step; - /** Number of pixel = 0 allowed around the loop*/ - private int _nbZero; - /** is processed booelan*/ - private boolean _isProcessed; - /** if is gui analysis*/ - private boolean _isGui; - /** if data set is mcool format*/ - private boolean _isCooler; - /** */ - private boolean _keepTif; - /** * * constructor for hic file * * @param output output path - * @param chrsize chr size path + * @param chrSize chr size path * @param gauss gaussian filter strength * @param resolution bins size * @param thresholdMax threshold value for loops detection @@ -60,8 +31,8 @@ public class SIPInter extends SIPObject { * @param fdr fdr value for the final loops filter * @throws IOException exception */ - public SIPInter(String output,String chrsize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, boolean keepTif,double fdr) throws IOException { - super(output, gauss, resolution, thresholdMax,matrixSize, nbZero, fdr, keepTif,chrsize) ; + public SIPInter(String output,String chrSize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, boolean keepTif,double fdr) throws IOException { + super(output, gauss, resolution, thresholdMax,matrixSize, nbZero, fdr, keepTif,chrSize) ; } @@ -70,7 +41,7 @@ public SIPInter(String output,String chrsize, double gauss, int resolution, dou * * @param input input file with SIP file * @param output output path - * @param chrsize chr size path + * @param chrSize chr size path * @param gauss gaussian filter strength * @param resolution bins size * @param thresholdMax threshold value for loops detection @@ -80,19 +51,11 @@ public SIPInter(String output,String chrsize, double gauss, int resolution, dou * @param fdr fdr value for the final loops filter * @throws IOException exception */ - public SIPInter(String input,String output,String chrsize, double gauss, int resolution, - double thresholdMax, int matrixSize, int nbZero, boolean keepTif, double fdr) throws IOException { + public SIPInter(String input,String output,String chrSize, double gauss, int resolution, + double thresholdMax, int matrixSize, int nbZero, boolean keepTif, double fdr){ + + super(input, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize); - this._input = input; - this._output = output; - this._gauss = gauss; - setChrSize(chrsize); - this._resolution = resolution; - this._thresholdMaxima = thresholdMax; - this._matrixSize = matrixSize; - this._nbZero = nbZero; - this._keepTif = keepTif; - _fdr = fdr; } @@ -104,11 +67,12 @@ public SIPInter(String input,String output,String chrsize, double gauss, int res * @throws IOException exception */ public void writeResu(String pathFile, HashMap hLoop, boolean first) throws IOException { - FDR fdrDetection = new FDR (this._fdr, hLoop); + double fdr = this.getFdr(); + FDR fdrDetection = new FDR (fdr, hLoop); fdrDetection.run(); double RFDRcutoff = fdrDetection.getRFDRCutoff(); double FDRcutoff = fdrDetection.getFDRCutoff(); - System.out.println("Filtering value at "+this._fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); + System.out.println("Filtering value at "+fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); BufferedWriter writer; if(first) writer = new BufferedWriter(new FileWriter(new File(pathFile), true)); else{ @@ -131,147 +95,6 @@ public void writeResu(String pathFile, HashMap hLoop, boolean firs } writer.close(); } - - - - /** - * Getter of the input dir - * @return path of the input dir - */ - public String getInputDir(){ return this._input; } - - /** - * Getter of the matrix size - * @return the size of the image - */ - public int getMatrixSize(){ return this._matrixSize; } - - - /** - * Getter of step - * @return the step - */ - public int getStep(){ return this._step;} - - /** - * Setter of the path of the input directory - * @param inputDir String of the input directory - */ - public void setInputDir(String inputDir){ this._input = inputDir; } - - /** - * Getter of the path of the output directory - * @return path - */ - public String getOutputDir(){ return this._output; } - - /** - * Setter of the path of the output directory - * @param outputDir String new path for the output directory - */ - public void setOutputDir(String outputDir){ this._output = outputDir;} - - /** - * Getter of the gaussian blur strength - * @return double gaussian - */ - public double getGauss(){ return this._gauss; } - - /** - * Setter of the gaussian blur strength - * @param gauss double - */ - public void setGauss(double gauss){ this._gauss = gauss; } - - - - /** - * Getter of resolution of the bin - * @return int resolution of the image - */ - public int getResolution(){ return this._resolution;} - - /** - * Setter of resolution of the bin - * @param resolution int new resolution - */ - public void setResolution(int resolution){ this._resolution = resolution;} - - /** - * Setter of size of the matrix - * @param size int new size of the matrix - */ - public void setMatrixSize(int size){ this._matrixSize = size; } - - /** - * setter step between image - * @param step int step - */ - public void setStep(int step){ this._step = step;} - - /** - * Getter of threshold for the detection of the regional maxima - * @return int threshold - */ - public double getThresholdMaxima(){ return _thresholdMaxima;} - /** - * Setter of threshold for the detection of the maxima - * @param thresholdMaxima int new threshold - */ - public void setThresholdMaxima(int thresholdMaxima) { this._thresholdMaxima = thresholdMaxima;} - - - /** - * Getter of NbZero - * @return int nb of zero - */ - public int getNbZero(){ return this._nbZero;} - - /** - * Setter of nbZero - * @param nbZero int new nb of zero - */ - public void setNbZero(int nbZero){ this._nbZero = nbZero;} - - - - /** - * Getter is isProcessed - * @return boolean - */ - public boolean isProcessed() { return _isProcessed;} - - /** - * setter isProcessed - * @param isProcessed boolean - */ - public void setIsProcessed(boolean isProcessed) { this._isProcessed = isProcessed;} - - /** - *getter is cooler - * @return boolean isCooler - */ - public boolean isCooler() { return _isCooler;} - - /** - * Setter isCooler - * @param cool boolean - */ - public void setIsCooler(boolean cool) { this._isCooler = cool;} - - /** - * getter isGui - * @return boolean - */ - public boolean isGui() { return _isGui;} - - /** - * setter is gui - * @param isGui boolean - */ - public void setIsGui(boolean isGui) { this._isGui = isGui;} - - } diff --git a/src/sip/SIPIntra.java b/src/sip/SIPIntra.java index 0454ada..1c63615 100644 --- a/src/sip/SIPIntra.java +++ b/src/sip/SIPIntra.java @@ -36,7 +36,6 @@ public class SIPIntra extends SIPObject { private double _max; /** % of staurated pixel after enhance contrast*/ private double _saturatedPixel; - /** Diage size to removed maxima close to diagonal*/ private int _diagonalSize; /** Size of the step to process each chr (step = matrixSize/2)*/ @@ -110,15 +109,13 @@ public SIPIntra(String output, String chrFile, double gauss, double min, * @param nbZero number of zero allowed around loops * @param listFactor multi resolution calling loops used this list of factor * @param fdr fdr value for final loops filtering - * @param isProcessed true if processed SIP data input else false - * @param rFDR false if it isn't drosophila input */ public SIPIntra(String input, String output, String chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, int thresholdMax, int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, - double fdr, boolean isProcessed, boolean rFDR) { + double fdr) { - super( output, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize); + super( input, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize); this._min = min; @@ -127,8 +124,7 @@ public SIPIntra(String input, String output, String chrSize, double gauss, doubl this._diagonalSize = diagonalSize; this._step = matrixSize/2; this._listFactor = listFactor; - this._listFactor = listFactor; - this._isDroso = rFDR; + } diff --git a/src/sip/SIPObject.java b/src/sip/SIPObject.java index f2b1998..a9f97cc 100644 --- a/src/sip/SIPObject.java +++ b/src/sip/SIPObject.java @@ -58,7 +58,7 @@ public class SIPObject { * @param nbZero * @param fdr */ - public SIPObject (String input, String output, double gauss, int resolution, int thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile){ + public SIPObject (String input, String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile){ if(!output.endsWith(File.separator)) output = output+File.separator; if(!input.endsWith(File.separator)) input = input+File.separator; this._input = input; @@ -272,8 +272,9 @@ public static void docError (){ + "\t-isDroso: default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n" + "\t-h, --help print help\n" + "\nCommand line eg:\n" - + "\tjava -jar SIP_HiC.jar processed inputDirectory pathToChromosome.size OutputDir .... paramaters\n" - + "\tjava -jar SIP_HiC.jar hic inputDirectory pathToChromosome.size OutputDir juicer_tools.jar\n" + + "\tjava -jar SIP_HiC.jar hic [options]\n" + + "\tjava -jar SIP_HiC.jar cool [options]\n" + + "\tjava -jar SIP_HiC.jar processed [options]\n" + "\nAuthors:\n" + "Axel Poulet\n" + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" @@ -324,4 +325,11 @@ public void setChrSize(String chrSizeFile) { } } + /** + * + * @param keepTif + */ + public void setIsKeepTif(boolean keepTif) { + this._keepTif = keepTif; + } } diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 00cc669..4ef1bfc 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -10,9 +10,13 @@ import javax.swing.JOptionPane; +import cli.CLISipOption; import gui.GuiAnalysis; import multiProcesing.ProcessCoolerDumpData; import multiProcesing.ProcessDumpData; +import process.HiC; +import process.MCool; +import process.Processed; import utils.MultiResProcess; import sip.SIPIntra; @@ -95,13 +99,24 @@ public class Hic_main { * @throws InterruptedException exception */ public static void main(String[] args) throws IOException, InterruptedException { + + + _factor.add(1); - if (args.length >= 1 && args.length < 4){ - SIPIntra.docError(); - System.exit(0); - }else if(args.length >= 4){ - if (args[0].equals("hic") || args[0].equals("processed") || args[0].equals("cool")){ - _input = args[1]; + if(args.length >= 1) { + if (args[0].equals("hic")) { + HiC hic = new HiC(args); + + } else if (args[0].equals("processed")) { + Processed processed = new Processed(args); + } else if (args[0].equals("cool")) { + MCool mCool = new MCool(args); + + } else { + System.out.println(CLISipOption.getHelperInfos()); + } + } +/* _input = args[1]; _output = args[3]; _chrSizeFile = args[2]; if (args[0].equals("hic")){ @@ -119,11 +134,6 @@ public static void main(String[] args) throws IOException, InterruptedException _cooltools = args[4]; readOption(args,6); } - }else{ - System.out.println(args[0]+" not defined\n"); - SIPIntra.docError(); - return; - } }else{////////////////////////////////////////GUI parameter initialisation GuiAnalysis gui = new GuiAnalysis(); @@ -247,7 +257,9 @@ public static void main(String[] args) throws IOException, InterruptedException + "del "+_delImages+"\n"+"cpu "+ _cpu+"\n-isDroso "+_isDroso+"\n"); sip = new SIPIntra(_input,_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, - _diagSize, _matrixSize, _nbZero,_factor,_fdr,_isProcessed, _isDroso); + _diagSize, _matrixSize, _nbZero,_factor,_fdr); + sip.setIsDroso(_isDroso); + sip.setIsProcessed(_isProcessed); sip.setIsGui(_gui); } System.out.println("Start loop detction step"); @@ -277,7 +289,7 @@ public static void main(String[] args) throws IOException, InterruptedException if(_gui){ JOptionPane.showMessageDialog(null,"Results available: "+_output , "End of SIP program", JOptionPane.INFORMATION_MESSAGE); } - System.out.println("End of SIP loops are available in "+_output); + System.out.println("End of SIP loops are available in "+_output);*/ } /** diff --git a/src/test/TestCallLoopsProcessedFile.java b/src/test/TestCallLoopsProcessedFile.java index 254540d..03a723d 100644 --- a/src/test/TestCallLoopsProcessedFile.java +++ b/src/test/TestCallLoopsProcessedFile.java @@ -38,8 +38,10 @@ public static void main(String[] args) throws IOException, InterruptedException //factor.add(5); //SIP_HiC_v1.3.6.jar hic SIP/Kc_allcombined.hic SIP/armsizes.txt SIP/Droso/ ../Tools/juicer_tools_1.13.02.jar String chrSizeFile = "/home/plop/Desktop/w_hg19.sizes"; - SIPIntra sip = new SIPIntra(input,output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,true,false); + SIPIntra sip = new SIPIntra(input,output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01); sip.setIsGui(false); + sip.setIsDroso(false); + sip.setIsProcessed(true); int cpu = 2; System.out.println("Processed Data\n"); System.out.println("input "+input+"\n" diff --git a/src/test/TestCoolFormat.java b/src/test/TestCoolFormat.java index d7adc60..0daf1a3 100644 --- a/src/test/TestCoolFormat.java +++ b/src/test/TestCoolFormat.java @@ -42,10 +42,12 @@ public static void main(String[] args) throws IOException, InterruptedException boolean keepTif = false; int cpu = 1; - SIPIntra sip = new SIPIntra(input,output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03,keepTif,false); + SIPIntra sip = new SIPIntra(input,output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03); sip.setIsGui(false); sip.setIsCooler(true); sip.setIsProcessed(true); + sip.setIsDroso(false); + sip.setIsKeepTif(keepTif); //ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); diff --git a/src/test/TestGui.java b/src/test/TestGui.java index 5b4d223..757c1e6 100644 --- a/src/test/TestGui.java +++ b/src/test/TestGui.java @@ -67,7 +67,9 @@ public static void main(String[] args) throws IOException, InterruptedException{ +"\nmin: "+min+"\nmax: "+max+"\nmatrix size: "+matrixSize+"\ndiag size: "+diagSize+"\nresolution: "+resolution+"\nsaturated pixel: "+saturatedPixel +"\nthreshold: "+thresholdMax+"\nisHic: "+isHic+"\nisProcessed: "+isProcessed+"\n number of zero:" +nbZero+"\n"); - sip = new SIPIntra(input,output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,gui.isProcessed(),false); + sip = new SIPIntra(input,output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01); + sip.setIsDroso(false); + sip.setIsProcessed(gui.isProcessed()); sip.setIsGui(true); } diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 72b08ce..4abd1e5 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -19,11 +19,10 @@ public static void main(String[] args) throws IOException, InterruptedException int resolution = 100000; int matrixSize = 500; double gauss = 1; - double min = 2; - double max = 2; + int nbZero = 6; double thresholdMax = 0.9; - double saturatedPixel = 0.01; + boolean keepTif = true; int cpu = 2; From 7fe7621f334865f6c9d4ec56cdb97abf488e8486 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Thu, 12 Nov 2020 21:14:02 -0500 Subject: [PATCH 10/27] Starting the classes in process package to link the main, CLI and SIP process --- src/process/HiC.java | 85 +++++++++++++++++++++++++++++++++++++-- src/sipMain/Hic_main.java | 3 +- 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/src/process/HiC.java b/src/process/HiC.java index b939d02..2bcfc28 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -1,14 +1,93 @@ package process; +import cli.CLIOptionHiC; +import multiProcesing.ProcessDumpData; +import org.apache.commons.cli.CommandLine; +import sip.SIPIntra; +import utils.MultiResProcess; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; public class HiC { - private String [] _args; - public HiC(String args []){ - _args = args; + private CommandLine _cmd; + + public HiC(String args []) throws Exception { + + String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); + CLIOptionHiC cli = new CLIOptionHiC(argsSubset); + _cmd = cli.getCommandLine(); + + + } + + /** + * + * Normalisation method to dump the the data with hic method (KR,NONE.VC,VC_SQRT) + * + */ + public void run() throws IOException, InterruptedException { + + String input = _cmd.getOptionValue("input"); + String output = _cmd.getOptionValue("output"); + String juiceBoxTools = ""; + String juiceBoXNormalisation = "KR"; + double gauss = 1.5; + int matrixSize = 2000; + double min = 2.0; + double max = 2.0; + int thresholdMax = 2800; + int nbZero = 6; + String chrSizeFile = _cmd.getOptionValue("output");; + boolean delImages = true; + int cpu = 1; + double fdr = 0.01; + + + int diagSize = 6; + int resolution = 5000; + double saturatedPixel = 0.01; + boolean isHic = true; + boolean isCool = false; + boolean isDroso = false; + ArrayList factor = new ArrayList(); + String factOption = "1"; + boolean isProcessed = false; + + + + boolean _gui = false; + + File f = new File(juiceBoxTools); + if(!f.exists()){ + System.out.println(juiceBoxTools+" doesn't existed !!! \n\n"); + // Mettre help ici + return; + } + + System.out.println("hic mode: \n"+ "input: "+input+"\n"+ "output: "+output+"\n"+ "juiceBox: "+juiceBoxTools+"\n"+ "norm: "+ juiceBoXNormalisation+"\n" + + "gauss: "+gauss+"\n"+ "min: "+min+"\n"+ "max: "+max+"\n"+ "matrix size: "+matrixSize+"\n"+ "diag size: "+diagSize+"\n"+ "resolution: "+resolution+"\n" + + "saturated pixel: "+saturatedPixel+"\n"+ "threshold: "+thresholdMax+"\n"+ "number of zero :"+nbZero+"\n"+ "factor "+ factOption+"\n"+ "fdr "+fdr+"\n" + + "del "+delImages+"\n"+ "cpu "+ cpu+"\n-isDroso "+isDroso+"\n"); + + SIPIntra sip = new SIPIntra(output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, + thresholdMax,diagSize, matrixSize, nbZero, factor,fdr, isProcessed,isDroso); + sip.setIsGui(_gui); + ProcessDumpData processDumpData = new ProcessDumpData(); + processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation, cpu); + System.out.println("########### End of the dump Step"); + MultiResProcess multi = new MultiResProcess(sip, cpu, delImages, chrSizeFile); + multi.run(); + System.out.println("###########End loop detction step"); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(output+File.separator+"parameters.txt"))); } diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 4ef1bfc..52e2202 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -98,7 +98,7 @@ public class Hic_main { * @throws IOException exception * @throws InterruptedException exception */ - public static void main(String[] args) throws IOException, InterruptedException { + public static void main(String[] args) throws Exception { @@ -106,6 +106,7 @@ public static void main(String[] args) throws IOException, InterruptedException if(args.length >= 1) { if (args[0].equals("hic")) { HiC hic = new HiC(args); + hic.run(); } else if (args[0].equals("processed")) { Processed processed = new Processed(args); From c8a1bbbbc84c8ebd9e947ef781ea98246db2d416 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Fri, 13 Nov 2020 12:27:44 -0500 Subject: [PATCH 11/27] work ongoing on hic file analysis --- src/cli/CLIOptionHiC.java | 2 +- src/cli/CLISipOption.java | 45 +++++++++++++--- src/process/HiC.java | 110 +++++++++++++++++++++++++++++++------- 3 files changed, 131 insertions(+), 26 deletions(-) diff --git a/src/cli/CLIOptionHiC.java b/src/cli/CLIOptionHiC.java index 40ce368..d533d84 100644 --- a/src/cli/CLIOptionHiC.java +++ b/src/cli/CLIOptionHiC.java @@ -16,7 +16,7 @@ public CLIOptionHiC(String [] args)throws Exception{ this._options.addOption(Option.builder("j").longOpt("juicerTool").required() .type(String.class).desc("Path to juicerTool.jar\n").numberOfArgs(1).build()); - this._options.addOption(Option.builder("n").longOpt("norm").required() + this._options.addOption(Option.builder("n").longOpt("norm") .type(String.class).desc(" (default KR)\n").numberOfArgs(1).build()); diff --git a/src/cli/CLISipOption.java b/src/cli/CLISipOption.java index 12b6682..2f6cf2e 100644 --- a/src/cli/CLISipOption.java +++ b/src/cli/CLISipOption.java @@ -1,6 +1,8 @@ package cli; import org.apache.commons.cli.*; +import java.io.File; + public class CLISipOption { Options _options= new Options(); @@ -90,12 +92,43 @@ public CLISipOption(String[] args)throws Exception { this._options.addOption(_interOrIntra); try { _cmd = parser.parse(this._options, args); + } catch (ParseException exp){ System.out.println(exp.getMessage()+"\n"); System.out.println(getHelperInfos()); System.exit(1); } + this.testParam(); + } + + private void testParam(){ + String input = _cmd.getOptionValue("input"); + String output = _cmd.getOptionValue("output"); + String chrSizeFile = _cmd.getOptionValue("chrSize"); + File file = new File(input); + + if(!file.exists() && !input.startsWith("https")){ + System.out.println("-i "+input+"doesn't existed !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + file = new File(output); + if(!file.exists()){ + System.out.println("-o "+output+"doesn't existed !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + file = new File(chrSizeFile); + if(!file.exists()){ + System.out.println("-c "+chrSizeFile+"doesn't existed !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + String inter ; } /** @@ -106,13 +139,13 @@ public static String getHelperInfos() { return "More details :\n" + "java -jar SIPHiC"+_Jversion+".jar hic --help \n" + "or \n"+ - "java -jar NucleusJ_2-"+_Jversion+".jar cool -h or --help\n"+ + "java -jar SIPHiC-"+_Jversion+".jar cool -h or --help\n"+ "or \n" + - "java -jar NucleusJ_2-"+_Jversion+".jar cool -h or --help \n" + + "java -jar SIPHiC-"+_Jversion+".jar processed -h or --help \n" + "\n\nCommand line eg:\n" + - "\tjava -jar SIP_HiC.jar hic [options]\n" + - "\tjava -jar SIP_HiC.jar cool [options]\n" + - "\tjava -jar SIP_HiC.jar processed [options]\n" + + "\tjava -jar SIP_HiC.jar hic -i hicFile -c chrSizeFile -o Output -j juicerTool [options]\n" + + "\tjava -jar SIP_HiC.jar cool -i mcoolFile -c chrSizeFile -o Output -cooltools cooltoolsPath -cooler coolerPath [options]\n" + + "\tjava -jar SIP_HiC.jar processed -i PathDirectoryWithProcessedData -c chrSizeFile -o Output [options]\n" + "\nAuthors:\n" + "Axel Poulet\n" + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" + @@ -120,7 +153,7 @@ public static String getHelperInfos() { "\nM. Jordan Rowley\n" + "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"; - } + } diff --git a/src/process/HiC.java b/src/process/HiC.java index 2bcfc28..c82cc38 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -24,8 +24,6 @@ public HiC(String args []) throws Exception { String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); CLIOptionHiC cli = new CLIOptionHiC(argsSubset); _cmd = cli.getCommandLine(); - - } /** @@ -35,27 +33,101 @@ public HiC(String args []) throws Exception { */ public void run() throws IOException, InterruptedException { - String input = _cmd.getOptionValue("input"); - String output = _cmd.getOptionValue("output"); - String juiceBoxTools = ""; - String juiceBoXNormalisation = "KR"; - double gauss = 1.5; - int matrixSize = 2000; + /* Param spe intra chromosomal loop*/ double min = 2.0; double max = 2.0; - int thresholdMax = 2800; + int diagSize = 6; + double saturatedPixel = 0.01; + /* end spe intra */ + + /* common */ + String input = _cmd.getOptionValue("input"); + String output = _cmd.getOptionValue("output"); + String juicerTool = _cmd.getOptionValue("juicerTool"); + String interOrIntra = _cmd.getOptionValue("lt"); + String chrSizeFile = _cmd.getOptionValue("chrSize"); + + String juicerNorm = "KR"; + if (_cmd.hasOption("norm")) { + juicerNorm = _cmd.getOptionValue("norm"); + if (!juicerNorm.equals("KR") && !juicerNorm.equals("NONE") && !juicerNorm.equals("VC") && !juicerNorm.equals("VC_SQRT")) { + System.out.println("-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); + //helper hic + System.exit(0); + } + } + int nbZero = 6; - String chrSizeFile = _cmd.getOptionValue("output");; + if (_cmd.hasOption("nbZero")) { + nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); + if (nbZero > 24|| nbZero < 0) { + System.out.println("\n-nbZero"+ nbZero+" value invalid: choose an integer value between 0 and 24\n"); + //erreur mettre l'aide et stopper le prog. + + System.exit(0); + } + } + boolean delImages = true; + if (_cmd.hasOption("delete")) delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + int cpu = 1; - double fdr = 0.01; + if (_cmd.hasOption("cpu")){ + cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); + if(cpu > Runtime.getRuntime().availableProcessors() || cpu <= 0){ + System.out.println("\nThe number of CPU "+ cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + System.exit(0); + } + } + ; + /* end common */ - int diagSize = 6; + + /* common with modif*/ + double gauss = 1.5; + int matrixSize = 2000; + int thresholdMax = 2800; + double fdr = 0.01; int resolution = 5000; - double saturatedPixel = 0.01; - boolean isHic = true; - boolean isCool = false; + /* end common with modif*/ + + + if(interOrIntra.equals("intra")){ + if(_cmd.hasOption("min")) { + min = Double.parseDouble(_cmd.getOptionValue("min")); + if(min < 0){ + System.out.println("\n-min"+ min+": this parameter need to be >= 0\n"); + System.exit(0); + } + } + + if(_cmd.hasOption("max")) { + max = Double.parseDouble(_cmd.getOptionValue("max")); + if(max < 0){ + System.out.println("\n-max"+ max+": this parameter need to be >= 0\n"); + + System.exit(0); + } + } + + if(_cmd.hasOption("diagonal")) { + diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if(diagSize < 0){ + System.out.println("\n-d"+ diagSize+": this parameter need to be >= 0\n"); + + System.exit(0); + } + } + + + + saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); + + } + + + boolean isDroso = false; ArrayList factor = new ArrayList(); String factOption = "1"; @@ -65,14 +137,14 @@ public void run() throws IOException, InterruptedException { boolean _gui = false; - File f = new File(juiceBoxTools); + File f = new File(juicerTool); if(!f.exists()){ - System.out.println(juiceBoxTools+" doesn't existed !!! \n\n"); + System.out.println(juicerTool+" doesn't existed !!! \n\n"); // Mettre help ici return; } - System.out.println("hic mode: \n"+ "input: "+input+"\n"+ "output: "+output+"\n"+ "juiceBox: "+juiceBoxTools+"\n"+ "norm: "+ juiceBoXNormalisation+"\n" + System.out.println("hic mode: \n"+ "input: "+input+"\n"+ "output: "+output+"\n"+ "juiceBox: "+juicerTool+"\n"+ "norm: "+ juicerNorm+"\n" + "gauss: "+gauss+"\n"+ "min: "+min+"\n"+ "max: "+max+"\n"+ "matrix size: "+matrixSize+"\n"+ "diag size: "+diagSize+"\n"+ "resolution: "+resolution+"\n" + "saturated pixel: "+saturatedPixel+"\n"+ "threshold: "+thresholdMax+"\n"+ "number of zero :"+nbZero+"\n"+ "factor "+ factOption+"\n"+ "fdr "+fdr+"\n" + "del "+delImages+"\n"+ "cpu "+ cpu+"\n-isDroso "+isDroso+"\n"); @@ -81,7 +153,7 @@ public void run() throws IOException, InterruptedException { thresholdMax,diagSize, matrixSize, nbZero, factor,fdr, isProcessed,isDroso); sip.setIsGui(_gui); ProcessDumpData processDumpData = new ProcessDumpData(); - processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation, cpu); + processDumpData.go(input, sip, juicerTool, juicerNorm, cpu); System.out.println("########### End of the dump Step"); MultiResProcess multi = new MultiResProcess(sip, cpu, delImages, chrSizeFile); From 47701ccef156d237c5618e5d78552d84460ffb1c Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Fri, 13 Nov 2020 21:06:45 -0500 Subject: [PATCH 12/27] work ongoing on hic file analysis --- src/cli/CLIOptionHiC.java | 26 +++ src/cli/CLISipOption.java | 43 +++- src/process/HiC.java | 282 +++++++++++++++--------- src/process/OptionalParamaterCheck.java | 76 +++++++ src/sip/SIPIntra.java | 4 +- 5 files changed, 308 insertions(+), 123 deletions(-) create mode 100644 src/process/OptionalParamaterCheck.java diff --git a/src/cli/CLIOptionHiC.java b/src/cli/CLIOptionHiC.java index d533d84..f903722 100644 --- a/src/cli/CLIOptionHiC.java +++ b/src/cli/CLIOptionHiC.java @@ -2,6 +2,8 @@ import org.apache.commons.cli.*; +import java.io.File; + public class CLIOptionHiC extends CLISipOption{ /** */ @@ -29,14 +31,38 @@ public CLIOptionHiC(String [] args)throws Exception{ } try { _commandLine = parser.parse(this._options, args); + testParam(); } catch (ParseException exp){ System.out.println(exp.getMessage()+"\n"); System.out.println(getHelperInfos()); System.exit(1); } + } + private void testParam(){ + + + + if (_cmd.hasOption("norm")) { + String juicerNorm = _cmd.getOptionValue("norm"); + if (!juicerNorm.equals("KR") && !juicerNorm.equals("NONE") && !juicerNorm.equals("VC") && !juicerNorm.equals("VC_SQRT")) { + System.out.println("-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); + //helper hic + System.exit(0); + } + } + + String juicerTools = _cmd.getOptionValue("juicerTool"); + File file = new File(juicerTools); + if(!file.exists()){ + System.out.println("-j "+juicerTools+" => this file doesn't existed !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + } /** * diff --git a/src/cli/CLISipOption.java b/src/cli/CLISipOption.java index 2f6cf2e..5a3841f 100644 --- a/src/cli/CLISipOption.java +++ b/src/cli/CLISipOption.java @@ -20,7 +20,7 @@ public class CLISipOption { private Option _resolution = Option.builder("r").longOpt("resolution") .type(Number.class).desc("Resolution in bp (default 5000 bp)\n") .numberOfArgs(1).build(); - private Option _sizeImage = Option.builder("m").longOpt("matrix") + private Option _sizeImage = Option.builder("ms").longOpt("matrixSize") .type(Number.class).desc("Matrix size to use for each chunk of the chromosome (default 2000 bins)\n") .numberOfArgs(1).build(); private Option _cpu = Option.builder("cpu") @@ -77,10 +77,13 @@ public class CLISipOption { */ public CLISipOption(String[] args)throws Exception { CommandLineParser parser= new DefaultParser(); - + /*required parameters*/ this._options.addOption(_inputFolder); this._options.addOption(_outputFolder); this._options.addOption(_chrSize); + this._options.addOption(_interOrIntra); + + /*optional parameters*/ this._options.addOption(_resolution); this._options.addOption(_deleteImage); this._options.addOption(_fdr); @@ -89,9 +92,10 @@ public CLISipOption(String[] args)throws Exception { this._options.addOption(_cpu); this._options.addOption(_gaussianStrength); this._options.addOption(_threshold); - this._options.addOption(_interOrIntra); + try { _cmd = parser.parse(this._options, args); + this.testParam(); } catch (ParseException exp){ @@ -99,9 +103,11 @@ public CLISipOption(String[] args)throws Exception { System.out.println(getHelperInfos()); System.exit(1); } - this.testParam(); } + /** + * + */ private void testParam(){ String input = _cmd.getOptionValue("input"); String output = _cmd.getOptionValue("output"); @@ -109,26 +115,41 @@ private void testParam(){ File file = new File(input); if(!file.exists() && !input.startsWith("https")){ - System.out.println("-i "+input+"doesn't existed !!! \n\n"); + System.out.println("-i "+input+" => this file doesn't existed !!! \n\n"); System.out.println(getHelperInfos()); System.exit(1); } file = new File(output); if(!file.exists()){ - System.out.println("-o "+output+"doesn't existed !!! \n\n"); + System.out.println("-o "+output+" => this file doesn't existed !!! \n\n"); System.out.println(getHelperInfos()); System.exit(1); } file = new File(chrSizeFile); if(!file.exists()){ - System.out.println("-c "+chrSizeFile+"doesn't existed !!! \n\n"); + System.out.println("-c "+chrSizeFile+" => this file doesn't existed !!! \n\n"); System.out.println(getHelperInfos()); System.exit(1); } - String inter ; + String inter = _cmd.getOptionValue("tl"); + if(!inter.equals("inter") && !inter.equals("intra")){ + System.out.println("-tl "+inter+", wrong value, choose inter or intra !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + if(_cmd.hasOption("resolution")){ + int res = Integer.parseInt(_cmd.getOptionValue("resolution")); + if(res <= 0 ){ + System.out.println("-r "+res+", resolution need to be a >= 0 !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + + } + } } /** @@ -143,9 +164,9 @@ public static String getHelperInfos() { "or \n" + "java -jar SIPHiC-"+_Jversion+".jar processed -h or --help \n" + "\n\nCommand line eg:\n" + - "\tjava -jar SIP_HiC.jar hic -i hicFile -c chrSizeFile -o Output -j juicerTool [options]\n" + - "\tjava -jar SIP_HiC.jar cool -i mcoolFile -c chrSizeFile -o Output -cooltools cooltoolsPath -cooler coolerPath [options]\n" + - "\tjava -jar SIP_HiC.jar processed -i PathDirectoryWithProcessedData -c chrSizeFile -o Output [options]\n" + + "\tjava -jar SIP_HiC.jar hic -i hicFile -c chrSizeFile -o Output -j juicerTool -tl inter [options]\n" + + "\tjava -jar SIP_HiC.jar cool -i mcoolFile -c chrSizeFile -o Output -cooltools cooltoolsPath -cooler coolerPath -tl inter [options]\n" + + "\tjava -jar SIP_HiC.jar processed -i PathDirectoryWithProcessedData -c chrSizeFile -o Output -tl inter [options]\n" + "\nAuthors:\n" + "Axel Poulet\n" + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" + diff --git a/src/process/HiC.java b/src/process/HiC.java index c82cc38..6e2e4fb 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -2,8 +2,11 @@ import cli.CLIOptionHiC; +import gui.GuiAnalysis; +import multiProcesing.ProcessDetectLoops; import multiProcesing.ProcessDumpData; import org.apache.commons.cli.CommandLine; +import sip.SIPInter; import sip.SIPIntra; import utils.MultiResProcess; @@ -16,16 +19,57 @@ public class HiC { - - private CommandLine _cmd; - + private String _log; + /** */ + private SIPIntra _sipIntra; + /** */ + private SIPInter _sipInter; + /** */ + private CommandLine _cmd; + + /** */ + private String _input; + /** */ + private String _output; + /** */ + private String _juicerTool; + /** */ + private String _interOrIntra; + /** */ + private String _chrSizeFile; + /** */ + private String _juicerNorm = "KR"; + /** */ + private int _nbZero = 6; + /** */ + private boolean _delImages = true; + + private int _cpu =1; + + private boolean _gui; + + private int _factor = 1; + + private GuiAnalysis _guiAnalysis; + /** + * + * @param args + * @throws Exception + */ public HiC(String args []) throws Exception { - + _gui = false; String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); CLIOptionHiC cli = new CLIOptionHiC(argsSubset); _cmd = cli.getCommandLine(); + OptionalParamaterCheck opt = new OptionalParamaterCheck(_cmd); + opt.testOptionalParametersValueCommons(); + opt.testOptionalParametersValueIntra(); } + public HiC(GuiAnalysis guiAnalysis ) throws Exception { + _gui = true; + _guiAnalysis = guiAnalysis; + } /** * * Normalisation method to dump the the data with hic method (KR,NONE.VC,VC_SQRT) @@ -33,133 +77,151 @@ public HiC(String args []) throws Exception { */ public void run() throws IOException, InterruptedException { - /* Param spe intra chromosomal loop*/ - double min = 2.0; - double max = 2.0; - int diagSize = 6; - double saturatedPixel = 0.01; - /* end spe intra */ - - /* common */ - String input = _cmd.getOptionValue("input"); - String output = _cmd.getOptionValue("output"); - String juicerTool = _cmd.getOptionValue("juicerTool"); - String interOrIntra = _cmd.getOptionValue("lt"); - String chrSizeFile = _cmd.getOptionValue("chrSize"); - - String juicerNorm = "KR"; - if (_cmd.hasOption("norm")) { - juicerNorm = _cmd.getOptionValue("norm"); - if (!juicerNorm.equals("KR") && !juicerNorm.equals("NONE") && !juicerNorm.equals("VC") && !juicerNorm.equals("VC_SQRT")) { - System.out.println("-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); - //helper hic - System.exit(0); - } + if(_gui) { + }else {/* common required parameters*/ + _input = _cmd.getOptionValue("input"); + _output = _cmd.getOptionValue("output"); + _juicerTool = _cmd.getOptionValue("juicerTool"); + _interOrIntra = _cmd.getOptionValue("lt"); + _chrSizeFile = _cmd.getOptionValue("chrSize"); + /* common optional parameters */ + if (_cmd.hasOption("norm")) + _juicerNorm = _cmd.getOptionValue("norm"); + if (_cmd.hasOption("nbZero")) + _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); + if (_cmd.hasOption("delete")) + _delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + + if (_cmd.hasOption("cpu")) + _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } - int nbZero = 6; - if (_cmd.hasOption("nbZero")) { - nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); - if (nbZero > 24|| nbZero < 0) { - System.out.println("\n-nbZero"+ nbZero+" value invalid: choose an integer value between 0 and 24\n"); - //erreur mettre l'aide et stopper le prog. + _log = _output+File.separator+"log.txt"; - System.exit(0); - } - } + ProcessDumpData processDumpData = new ProcessDumpData(); - boolean delImages = true; - if (_cmd.hasOption("delete")) delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + if(_interOrIntra.equals("intra")){ + /* Param spe intra chromosomal loop*/ + this.setSipIntra(); + _sipIntra.setIsGui(_gui); + + + String allParam = "SIPHiC hic: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "juiceBox: "+_juicerTool+"\n"+ + "norm: "+_juicerNorm+"\n" + + "inter or intra chromosomal: "+_interOrIntra+"\n" + + "gauss: "+this._sipIntra.getGauss()+"\n"+ + "min: "+this._sipIntra.getMin()+"\n"+ + "max: "+this._sipIntra.getMax()+"\n"+ + "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ + "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ + "resolution: "+this._sipIntra.getResolution()+"\n"+ + "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ + "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ + "number of zero: "+this._nbZero+"\n"+ + "factor: "+ _factor+"\n"+ + "fdr: "+this._sipIntra.getFdr()+"\n"+ + "delete images: "+_delImages+"\n"+ + "cpu: "+ _cpu+"\n" + + "isDroso: "+this._sipIntra.isDroso()+"\n"; + + System.out.println("########### Starting dump Step inter chromosomal interactions"); + + processDumpData.go(_input, _sipIntra, _juicerTool, _juicerNorm, _cpu); + System.out.println("########### End of the dump step\n"); + + System.out.println("########### Start loop detection\n"); + MultiResProcess multi = new MultiResProcess(_sipIntra, _cpu, _delImages, _chrSizeFile); + multi.run(); + System.out.println("###########End loop detection step\n"); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); + writer.write(allParam); + + + }else{ + setSipInter(); + _sipInter.setIsGui(_gui); + + String allParam = "SIPHiC hic: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "juiceBox: "+_juicerTool+"\n"+ + "norm: "+_juicerNorm+"\n" + + "inter or intra chromosomal: "+_interOrIntra+"\n" + + "gauss: "+this._sipInter.getGauss()+"\n"+ + "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ + "resolution: "+this._sipInter.getResolution()+"\n"+ + "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ + "number of zero :"+_nbZero+"\n"+ + "fdr "+this._sipInter.getFdr()+"\n"+ + "delete images "+_delImages+"\n"+ + "cpu "+ _cpu+"\n"; + processDumpData.go(_input,_sipInter,_juicerTool,_juicerNorm,_cpu); + + ProcessDetectLoops detectLoops = new ProcessDetectLoops(); + detectLoops.go(_sipInter, _cpu, _delImages, "/home/plop/Desktop/testInter/loops.txt"); + } - int cpu = 1; - if (_cmd.hasOption("cpu")){ - cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); - if(cpu > Runtime.getRuntime().availableProcessors() || cpu <= 0){ - System.out.println("\nThe number of CPU "+ cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); - System.exit(0); - } - } - ; - /* end common */ + } - /* common with modif*/ + /** + * + * + */ + private void setSipIntra(){ + double min = 2.0; + double max = 2.0; double gauss = 1.5; int matrixSize = 2000; - int thresholdMax = 2800; + double thresholdMax = 2800; double fdr = 0.01; int resolution = 5000; - /* end common with modif*/ - - - if(interOrIntra.equals("intra")){ - if(_cmd.hasOption("min")) { - min = Double.parseDouble(_cmd.getOptionValue("min")); - if(min < 0){ - System.out.println("\n-min"+ min+": this parameter need to be >= 0\n"); - System.exit(0); - } - } - - if(_cmd.hasOption("max")) { - max = Double.parseDouble(_cmd.getOptionValue("max")); - if(max < 0){ - System.out.println("\n-max"+ max+": this parameter need to be >= 0\n"); - - System.exit(0); - } - } - - if(_cmd.hasOption("diagonal")) { - diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); - if(diagSize < 0){ - System.out.println("\n-d"+ diagSize+": this parameter need to be >= 0\n"); - - System.exit(0); - } - } - - - - saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); - - } - - - + int diagSize = 6; + double saturatedPixel = 0.01; boolean isDroso = false; ArrayList factor = new ArrayList(); - String factOption = "1"; - boolean isProcessed = false; + factor.add(1); + if(_gui){ + }else{ - boolean _gui = false; + if(_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); + if(_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if(_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if(_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); + if(_cmd.hasOption("gaussian")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("gaussian")); - File f = new File(juicerTool); - if(!f.exists()){ - System.out.println(juicerTool+" doesn't existed !!! \n\n"); - // Mettre help ici - return; - } + if(_cmd.hasOption("factor")) { + _factor= Integer.parseInt(_cmd.getOptionValue("factor")); + if(_factor == 2){ factor.add(2);} + else if(_factor == 4){ + factor.add(2); + factor.add(5); + }else{ factor.add(5);} + } - System.out.println("hic mode: \n"+ "input: "+input+"\n"+ "output: "+output+"\n"+ "juiceBox: "+juicerTool+"\n"+ "norm: "+ juicerNorm+"\n" - + "gauss: "+gauss+"\n"+ "min: "+min+"\n"+ "max: "+max+"\n"+ "matrix size: "+matrixSize+"\n"+ "diag size: "+diagSize+"\n"+ "resolution: "+resolution+"\n" - + "saturated pixel: "+saturatedPixel+"\n"+ "threshold: "+thresholdMax+"\n"+ "number of zero :"+nbZero+"\n"+ "factor "+ factOption+"\n"+ "fdr "+fdr+"\n" - + "del "+delImages+"\n"+ "cpu "+ cpu+"\n-isDroso "+isDroso+"\n"); + _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, + thresholdMax, diagSize, matrixSize, _nbZero, factor, fdr, false, isDroso); + } - SIPIntra sip = new SIPIntra(output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, - thresholdMax,diagSize, matrixSize, nbZero, factor,fdr, isProcessed,isDroso); - sip.setIsGui(_gui); - ProcessDumpData processDumpData = new ProcessDumpData(); - processDumpData.go(input, sip, juicerTool, juicerNorm, cpu); - System.out.println("########### End of the dump Step"); + } - MultiResProcess multi = new MultiResProcess(sip, cpu, delImages, chrSizeFile); - multi.run(); - System.out.println("###########End loop detction step"); - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(output+File.separator+"parameters.txt"))); + /** + * + * + */ + private void setSipInter(){ + double gauss = 1; + int matrixSize = 500; + double thresholdMax = 0.01; + double fdr = 0.025; + int resolution = 100000; + _sipInter = new SIPInter(_input, _output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, _delImages, fdr); } diff --git a/src/process/OptionalParamaterCheck.java b/src/process/OptionalParamaterCheck.java new file mode 100644 index 0000000..f1b0e7e --- /dev/null +++ b/src/process/OptionalParamaterCheck.java @@ -0,0 +1,76 @@ +package process; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.HelpFormatter; + +public class OptionalParamaterCheck { + + private CommandLine _cmd; + + /** + * + * @param commandLine + */ + public OptionalParamaterCheck(CommandLine commandLine){ + _cmd = commandLine; + } + + + public void testOptionalParametersValueCommons(){ + + int nbZero = 6; + if (_cmd.hasOption("nbZero")) { + nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); + if (nbZero > 24|| nbZero < 0) { + System.out.println("\n-nbZero"+ nbZero+" value invalid: choose an integer value between 0 and 24\n"); + //erreur mettre l'aide et stopper le prog. + + System.exit(0); + } + } + + boolean delImages = true; + if (_cmd.hasOption("delete")) delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + + int cpu = 1; + if (_cmd.hasOption("cpu")){ + cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); + if(cpu > Runtime.getRuntime().availableProcessors() || cpu <= 0){ + System.out.println("\nThe number of CPU "+ cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + + System.exit(0); + } + } + + } + public void testOptionalParametersValueIntra(){ + + if(_cmd.hasOption("min")) { + double min = Double.parseDouble(_cmd.getOptionValue("min")); + if(min < 0){ + System.out.println("\n-min"+ min+": this parameter need to be >= 0\n"); + //trouver commande sortir l'aide propre + System.exit(0); + } + } + + if(_cmd.hasOption("max")) { + double max = Double.parseDouble(_cmd.getOptionValue("max")); + if(max < 0){ + System.out.println("\n-max"+ max+": this parameter need to be >= 0\n"); + + System.exit(0); + } + } + + if(_cmd.hasOption("diagonal")) { + int diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if (diagSize < 0) { + System.out.println("\n-d" + diagSize + ": this parameter need to be >= 0\n"); + + System.exit(0); + } + } + } + +} diff --git a/src/sip/SIPIntra.java b/src/sip/SIPIntra.java index 1c63615..1bfdc10 100644 --- a/src/sip/SIPIntra.java +++ b/src/sip/SIPIntra.java @@ -75,7 +75,7 @@ public SIPIntra() { } * @param rFDR false if it isn't drosophila input */ public SIPIntra(String output, String chrFile, double gauss, double min, - double max, int resolution, double saturatedPixel, int thresholdMax, + double max, int resolution, double saturatedPixel, double thresholdMax, int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, double fdr, boolean isProcessed, boolean rFDR) { @@ -111,7 +111,7 @@ public SIPIntra(String output, String chrFile, double gauss, double min, * @param fdr fdr value for final loops filtering */ public SIPIntra(String input, String output, String chrSize, double gauss, double min, - double max, int resolution, double saturatedPixel, int thresholdMax, + double max, int resolution, double saturatedPixel, double thresholdMax, int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, double fdr) { From 169db61f607db207a354ffac8f7f8c387df80b1f Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Sat, 14 Nov 2020 17:16:31 -0500 Subject: [PATCH 13/27] work ongoing on hic file analysis, modification of GUI to add the inter parameters and manage the GUI on function of the option. --- src/gui/GuiAnalysis.java | 312 +++++++++++++++++++++++++------------- src/process/HiC.java | 191 ++++++++++++++--------- src/sipMain/Hic_main.java | 39 +++-- src/test/TestGui.java | 8 +- 4 files changed, 359 insertions(+), 191 deletions(-) diff --git a/src/gui/GuiAnalysis.java b/src/gui/GuiAnalysis.java index 2b623d9..9da0289 100644 --- a/src/gui/GuiAnalysis.java +++ b/src/gui/GuiAnalysis.java @@ -33,9 +33,9 @@ public class GuiAnalysis extends JFrame{ /** */ private Container _container; /** */ - private JButton _jbWorkDir = new JButton("Output directory"); + private JButton _jbOutputDir = new JButton("Output directory"); /** */ - private JButton _jbRawData = new JButton("Data (.hic, .mcool or SIP)"); + private JButton _jbInputDir = new JButton("Data (.hic, .mcool or SIP)"); /** */ private JButton _jbChrSize = new JButton("Chr size file"); /** */ @@ -82,6 +82,15 @@ public class GuiAnalysis extends JFrame{ private JRadioButton _jrbVC = new JRadioButton("VC"); /** */ private JRadioButton _jrbVC_sqrt = new JRadioButton("VC SQRT"); + + /** */ + private ButtonGroup _bIntraOrInter = new ButtonGroup(); + /** */ + private JRadioButton _jrbIntra = new JRadioButton("Intra"); + /** */ + private JRadioButton _jrbInter = new JRadioButton("Inter"); + + /** */ private JFormattedTextField _jtfMatrixSize = new JFormattedTextField(Number.class); /** */ @@ -95,11 +104,11 @@ public class GuiAnalysis extends JFrame{ /** */ private JFormattedTextField _jtfMax = new JFormattedTextField(Number.class); /** */ - private JFormattedTextField _jtfEnhanceContrast = new JFormattedTextField(Number.class); + private JFormattedTextField _jtfSaturatedPixel = new JFormattedTextField(Number.class); /** */ private JFormattedTextField _jtfNbZero = new JFormattedTextField(Number.class); /** */ - private JFormattedTextField _jtfNoiseTolerance = new JFormattedTextField(Number.class); + private JFormattedTextField _jtfThresholdMaxima = new JFormattedTextField(Number.class); /** */ private boolean _start = false; /** */ @@ -234,7 +243,7 @@ GridBagConstraints.NONE, new Insets(110, 160, 0, 0), 0, 0 label.setFont(new java.awt.Font("arial",2,11)); this._container.add(label, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(133, 20, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(138, 20, 0, 0), 0, 0 )); this._bNorm.add(this._jrbNone); @@ -247,59 +256,59 @@ GridBagConstraints.NONE, new Insets(133, 20, 0, 0), 0, 0 this._jrbVC_sqrt.setFont(new java.awt.Font("arial",2,11)); this._container.add(this._jrbNone,new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(130, 220, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(135, 220, 0, 0), 0, 0 )); this._container.add(this._jrbKR,new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE,new Insets(130, 290, 0, 0), 0, 0 + GridBagConstraints.NONE,new Insets(135, 290, 0, 0), 0, 0 )); this._container.add(this._jrbVC, new GridBagConstraints( 0,1, 0, 0, 0.0, 0.0,GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(130, 340, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(135, 340, 0, 0), 0, 0 )); this._container.add(this._jrbVC_sqrt, new GridBagConstraints( 0,1, 0, 0, 0.0, 0.0,GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(130, 390, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(135, 390, 0, 0), 0, 0 )); this._jrbKR.setSelected(true); ///////////////////////////////////////////////////////////////////////// label = new JLabel(); - label.setText("Data and Output directories : "); + label.setText("Input and Output directories : "); label.setFont(new java.awt.Font("arial",1,12)); this._container.add( label, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(150, 10, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(155, 10, 0, 0), 0, 0 )); - this._jbRawData.setPreferredSize(new java.awt.Dimension(150, 21)); - this._jbRawData.setFont(new java.awt.Font("arial",2,10)); - this._container.add ( this._jbRawData, new GridBagConstraints( + this._jbInputDir.setPreferredSize(new java.awt.Dimension(150, 21)); + this._jbInputDir.setFont(new java.awt.Font("arial",2,10)); + this._container.add ( this._jbInputDir, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(165, 20, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(175, 20, 0, 0), 0, 0 )); this._jtfRawData.setPreferredSize(new java.awt.Dimension(280, 21)); this._jtfRawData.setFont(new java.awt.Font("arial",2,10)); this._container.add(this._jtfRawData, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(165, 190, 0, 0),0, 0 + GridBagConstraints.NONE, new Insets(175, 190, 0, 0),0, 0 )); - this._jbWorkDir.setPreferredSize(new java.awt.Dimension(150, 21)); - this._jbWorkDir.setFont(new java.awt.Font("arial",2,10)); - this._container.add(this._jbWorkDir, new GridBagConstraints( + this._jbOutputDir.setPreferredSize(new java.awt.Dimension(150, 21)); + this._jbOutputDir.setFont(new java.awt.Font("arial",2,10)); + this._container.add(this._jbOutputDir, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0,GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(195, 20, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(205, 20, 0, 0), 0, 0 )); this._jtfWorkDir.setPreferredSize(new java.awt.Dimension(280, 21)); this._jtfWorkDir.setFont(new java.awt.Font("arial",2,10)); this._container.add( this._jtfWorkDir, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(195, 190, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(205, 190, 0, 0), 0, 0 )); ////////////////////////////////////// @@ -308,7 +317,7 @@ GridBagConstraints.NONE, new Insets(195, 190, 0, 0), 0, 0 label.setFont(new java.awt.Font("arial",1,12)); this._container.add (label, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(225, 10, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(235, 10, 0, 0), 0, 0 )); this._container.setLayout (gridBagLayout); label = new JLabel(); @@ -316,29 +325,29 @@ GridBagConstraints.NONE, new Insets(225, 10, 0, 0), 0, 0 label.setFont(new java.awt.Font("arial",2,11)); this._container.add( label, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(245, 20, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(258, 20, 0, 0), 0, 0 )); this._jtfMatrixSize.setText("2000"); this._jtfMatrixSize.setPreferredSize(new java.awt.Dimension(60, 21)); this._jtfMatrixSize.setFont(new java.awt.Font("arial",2,11)); this._container.add( this._jtfMatrixSize, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(243, 170, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(260, 170, 0, 0), 0, 0 )); this._container.setLayout (gridBagLayout); label = new JLabel(); - label.setText("Diag size (in bins):"); + label.setText("Diagonal size (in bins):"); label.setFont(new java.awt.Font("arial",2,11)); this._container.add(label, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(270, 20, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(283, 20, 0, 0), 0, 0 )); this._jtfDiagSize.setText("5"); this._jtfDiagSize.setPreferredSize(new java.awt.Dimension(60, 21)); this._jtfDiagSize.setFont(new java.awt.Font("arial",2,11)); this._container.add( this._jtfDiagSize, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(268, 170, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(285, 170, 0, 0), 0, 0 )); label = new JLabel(); @@ -346,7 +355,7 @@ GridBagConstraints.NONE, new Insets(268, 170, 0, 0), 0, 0 label.setFont(new java.awt.Font("arial",2,11)); this._container.add( label, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(295, 20, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(308, 20, 0, 0), 0, 0 )); this._jtfResolution.setText("5000"); @@ -354,24 +363,25 @@ GridBagConstraints.NONE, new Insets(295, 20, 0, 0), 0, 0 this._jtfResolution.setFont(new java.awt.Font("arial",2,11)); this._container.add( this._jtfResolution, new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(293, 170, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(310, 170, 0, 0), 0, 0 )); label = new JLabel(); - label.setText(" Multi resolution loop calling:"); + label.setText("Multi resolution loop calling:"); + label.setFont(new java.awt.Font("arial",1,12)); this._container.add(label,new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(225, 250, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(235, 250, 0, 0), 0, 0 )); this._checkbox2.setFont(new java.awt.Font("arial",2,12)); this._container.add(this._checkbox2,new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(250, 300, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(260, 300, 0, 0), 0, 0 )); this._checkbox5.setFont(new java.awt.Font("arial",2,12)); this._container.add(this._checkbox5,new GridBagConstraints( 0, 1, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE,new Insets(270, 300, 0, 0), 0, 0 + GridBagConstraints.NONE,new Insets(280, 300, 0, 0), 0, 0 )); //////////////////////////////////////////////////////////////////////////////// @@ -432,10 +442,10 @@ GridBagConstraints.NONE, new Insets(127, 150, 0, 0), 0, 0 GridBagConstraints.NONE, new Insets(130, 230, 0, 0), 0, 0 )); - this._jtfNoiseTolerance.setText("2800"); - this._jtfNoiseTolerance.setPreferredSize(new java.awt.Dimension(60, 21)); - this._jtfNoiseTolerance.setFont(new java.awt.Font("arial",2,11)); - this._container.add( this._jtfNoiseTolerance, new GridBagConstraints( + this._jtfThresholdMaxima.setText("2800"); + this._jtfThresholdMaxima.setPreferredSize(new java.awt.Dimension(60, 21)); + this._jtfThresholdMaxima.setFont(new java.awt.Font("arial",2,11)); + this._container.add( this._jtfThresholdMaxima, new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(127, 430, 0, 0), 0, 0 )); @@ -473,17 +483,17 @@ GridBagConstraints.NONE, new Insets(157, 350, 0, 0), 0, 0 )); label = new JLabel(); - label.setText("% of satured pixel:"); + label.setText("% of saturated pixel:"); label.setFont(new java.awt.Font("arial",2,11)); this._container.add( label, new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(190, 20, 0, 0), 0, 0 )); - this._jtfEnhanceContrast.setText("0.01"); - this._jtfEnhanceContrast.setPreferredSize(new java.awt.Dimension(60, 21)); - this._jtfEnhanceContrast.setFont(new java.awt.Font("arial",2,11)); - this._container.add( this._jtfEnhanceContrast, new GridBagConstraints( + this._jtfSaturatedPixel.setText("0.01"); + this._jtfSaturatedPixel.setPreferredSize(new java.awt.Dimension(60, 21)); + this._jtfSaturatedPixel.setFont(new java.awt.Font("arial",2,11)); + this._container.add( this._jtfSaturatedPixel, new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(187, 150, 0, 0), 0, 0 )); @@ -521,24 +531,48 @@ GridBagConstraints.NONE, new Insets(217, 350, 0, 0), 0, 0 )); label = new JLabel(); - label.setText("If is droso or like droso HiC map:"); + label.setText("If it is D. mel or like D. mel HiC map:"); label.setFont(new java.awt.Font("arial",1,12)); this._container.add(label, new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(250, 10, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(245, 10, 0, 0), 0, 0 )); this._jCbIsDroso.setFont(new java.awt.Font("arial",2,11)); this._container.add(this._jCbIsDroso,new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE,new Insets(268, 20, 0, 0), 0, 0 + GridBagConstraints.NONE,new Insets(242, 230, 0, 0), 0, 0 )); - + + + label = new JLabel(); + label.setText("Type of loops (inter or intra chromosomal):"); + label.setFont(new java.awt.Font("arial",1,12)); + this._container.add(label, new GridBagConstraints( + 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, + GridBagConstraints.NONE, new Insets(285, 10, 0, 0), 0, 0 + )); + + this._bIntraOrInter.add(this._jrbInter); + this._bIntraOrInter.add(this._jrbIntra); + this._jrbInter.setFont(new java.awt.Font("arial",2,12)); + this._jrbIntra.setFont(new java.awt.Font("arial",2,12)); + + this._container.add(this._jrbIntra,new GridBagConstraints( + 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, + GridBagConstraints.NONE, new Insets(282, 270, 0, 0), 0, 0 + )); + this._container.add(this._jrbInter,new GridBagConstraints( + 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, + GridBagConstraints.NONE,new Insets(282, 340, 0, 0), 0, 0 + )); + this._jrbIntra.setSelected(true); + this._checkboxDeleteTif.setFont(new java.awt.Font("arial",1,12)); this._container.add(this._checkboxDeleteTif,new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE,new Insets(330, 10, 0, 0), 0, 0 + GridBagConstraints.NONE,new Insets(325, 260, 0, 0), 0, 0 )); label = new JLabel(); @@ -546,14 +580,14 @@ GridBagConstraints.NONE,new Insets(330, 10, 0, 0), 0, 0 label.setFont(new java.awt.Font("arial",1,12)); this._container.add( label, new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(300, 10, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(330, 10, 0, 0), 0, 0 )); this._jtfCpu.setText("1"); this._jtfCpu.setPreferredSize(new java.awt.Dimension(60, 21)); this._container.add( this._jtfCpu, new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(298, 140, 0, 0), 0, 0 + GridBagConstraints.NONE, new Insets(328, 140, 0, 0), 0, 0 )); this._jbStart.setPreferredSize(new java.awt.Dimension(120, 21)); @@ -572,8 +606,10 @@ GridBagConstraints.NONE,new Insets(365, 10, 0, 0), 0, 0 this._jrbHic.addActionListener(hic); this._jrbProcessed.addActionListener(hic); this._jrbCool.addActionListener(hic); + this._jrbInter.addActionListener(hic); + this._jrbIntra.addActionListener(hic); WorkDirectoryListener wdListener = new WorkDirectoryListener(); - this._jbWorkDir.addActionListener(wdListener); + this._jbOutputDir.addActionListener(wdListener); FileListener chr = new FileListener(this._jtfChrSize); this._jbChrSize.addActionListener(chr); FileListener juice = new FileListener(this._jtfBoxTools); @@ -583,7 +619,7 @@ GridBagConstraints.NONE,new Insets(365, 10, 0, 0), 0, 0 FileListener cooltools = new FileListener(this._jtfCoolTools); this._jbCoolTools.addActionListener(cooltools); RawDataDirectoryListener ddListener = new RawDataDirectoryListener(this,this._jtfRawData); - this._jbRawData.addActionListener(ddListener); + this._jbInputDir.addActionListener(ddListener); QuitListener quitListener = new QuitListener(this); this._jbQuit.addActionListener(quitListener); StartListener startListener = new StartListener(this); @@ -649,8 +685,8 @@ public double getMin(){ * * @return double */ - public double getEnhanceSignal(){ - String x = this._jtfEnhanceContrast.getText(); + public double getSaturatedPixell(){ + String x = this._jtfSaturatedPixel.getText(); return Double.parseDouble(x.replaceAll(",", ".")); } @@ -670,8 +706,8 @@ public int getFactorChoice(){ * threshold for the regional maxima detection * @return int */ - public int getNoiseTolerance(){ - String x = this._jtfNoiseTolerance.getText(); + public int getThresholdMaxima(){ + String x = this._jtfThresholdMaxima.getText(); return Integer.parseInt(x.replaceAll(",", ".")); } /** @@ -703,7 +739,7 @@ public int getDiagSize(){ * getter of the input path (hic file or SIP) * @return String input path */ - public String getRawDataDir(){ return this._jtfRawData.getText();} + public String getInput(){ return this._jtfRawData.getText();} /** * getter of the chrSize file path @@ -715,7 +751,7 @@ public int getDiagSize(){ * getter of the juicerToolsBox.jar path * @return String path */ - public String getJuiceBox(){ return this._jtfBoxTools.getText();} + public String getJuicerTool(){ return this._jtfBoxTools.getText();} /** * getter of the juicerToolsBox.jar path @@ -751,6 +787,16 @@ public int getDiagSize(){ * @return */ public boolean isHic(){ return this._jrbHic.isSelected();} + /** + * + * @return + */ + public boolean isInter(){ return this._jrbInter.isSelected();} + /** + * + * @return + */ + public boolean isIntra(){ return this._jrbIntra.isSelected();} /** * @@ -824,57 +870,111 @@ class RBHicListener implements ActionListener{ * @param gui */ public RBHicListener (GuiAnalysis gui){ _gui = gui; } - + + /** + * + */ + private void changeInter(){ + _gui._jtfThresholdMaxima.setText("0.01"); + _gui._jtfFdr.setText("0.025"); + _gui._jtfResolution.setText("100000"); + _gui._jtfMatrixSize.setText("500"); + _gui._jtfGaussian.setText("1"); + _gui._jtfMax.setEditable(false); + _gui._jtfMin.setEditable(false); + _gui._jtfSaturatedPixel.setEditable(false); + _gui._jtfDiagSize.setEditable(false); + _gui._jtfSaturatedPixel.setEditable(false); + _gui._checkbox2.setEnabled(false); + _gui._checkbox5.setEnabled(false); + _gui._jCbIsDroso.setEnabled(false); + } + + /** + * + */ + private void changeIntra(){ + _gui._jtfThresholdMaxima.setText("2800"); + _gui._jtfFdr.setText("0.001"); + _gui._jtfResolution.setText("5000"); + _gui._jtfMatrixSize.setText("2000"); + _gui._jtfGaussian.setText("1.5"); + _gui._jtfMax.setEditable(true); + _gui._jtfMin.setEditable(true); + _gui._jtfSaturatedPixel.setEditable(true); + _gui._jtfDiagSize.setEditable(true); + _gui._jtfSaturatedPixel.setEditable(true); + _gui._checkbox2.setEnabled(true); + _gui._checkbox5.setEnabled(true); + _gui._jCbIsDroso.setEnabled(true); + } + + /** + * + */ + private void changeHic(){ + _gui._jrbInter.setEnabled(true); + _gui._jrbIntra.setEnabled(true); + if(_gui.isIntra())changeIntra(); + else if(_gui.isInter()) changeInter(); + _gui._jrbVC_sqrt.setEnabled(true); + _gui._jrbVC.setEnabled(true); + _gui._jrbNone.setEnabled(true); + _gui._jrbKR.setEnabled(true); + _gui._jtfBoxTools.setEnabled(true); + _gui._jbBoxTools.setEnabled(true); + _gui._jtfCoolTools.setEnabled(false); + _gui._jbCoolTools.setEnabled(false); + _gui._jtfCooler.setEnabled(false); + _gui._jbCooler.setEnabled(false); + } + + private void changeProcessed(){ + _gui._jrbInter.setEnabled(true); + _gui._jrbIntra.setEnabled(true); + if(_gui.isIntra())changeIntra(); + else if(_gui.isInter()) changeInter(); + _gui._jrbVC_sqrt.setEnabled(false); + _gui._jrbVC.setEnabled(false); + _gui._jrbNone.setEnabled(false); + _gui._jrbKR.setEnabled(false); + _gui._jtfBoxTools.setEnabled(false); + _gui._jbBoxTools.setEnabled(false); + _gui._jtfCoolTools.setEnabled(false); + _gui._jbCoolTools.setEnabled(false); + _gui._jtfCooler.setEnabled(false); + _gui._jbCooler.setEnabled(false); + } + + private void changeCool(){ + _gui._jrbIntra.isSelected(); + _gui._jrbInter.setEnabled(false); + _gui._jrbIntra.setEnabled(false); + + changeIntra(); + _gui._jrbVC_sqrt.setEnabled(false); + _gui._jrbVC.setEnabled(false); + _gui._jrbNone.setEnabled(false); + _gui._jrbKR.setEnabled(false); + _gui._jtfBoxTools.setEnabled(false); + _gui._jbBoxTools.setEnabled(false); + _gui._jtfCoolTools.setEnabled(true); + _gui._jbCoolTools.setEnabled(true); + _gui._jtfCooler.setEnabled(true); + _gui._jbCooler.setEnabled(true); + } + /** * manage the access of the different gui element on function of the paramter choose */ public void actionPerformed(ActionEvent actionEvent){ - if (_gui.isHic()){ - _gui._jrbVC_sqrt.setEnabled(true); - _gui._jrbVC.setEnabled(true); - _gui._jrbNone.setEnabled(true); - _gui._jrbKR.setEnabled(true); - _gui._jtfBoxTools.setEnabled(true); - _gui._jbBoxTools.setEnabled(true); - _gui._jtfMax.setEditable(true); - _gui._jtfMin.setEditable(true); - _gui._jtfEnhanceContrast.setEditable(true); - _gui._jtfCoolTools.setEnabled(false); - _gui._jbCoolTools.setEnabled(false); - _gui._jtfCooler.setEnabled(false); - _gui._jbCooler.setEnabled(false); - }else if(_gui.isProcessed()){ - _gui._jrbVC_sqrt.setEnabled(false); - _gui._jrbVC.setEnabled(false); - _gui._jrbNone.setEnabled(false); - _gui._jrbKR.setEnabled(false); - _gui._jtfBoxTools.setEnabled(false); - _gui._jbBoxTools.setEnabled(false); - _gui._jtfCoolTools.setEnabled(false); - _gui._jbCoolTools.setEnabled(false); - _gui._jtfCooler.setEnabled(false); - _gui._jbCooler.setEnabled(false); - _gui._jtfMax.setEditable(true); - _gui._jtfNbZero.setEnabled(true); - _gui._jtfMin.setEditable(true); - _gui._jtfEnhanceContrast.setEditable(true); - }else if(_gui.isCool()){ - _gui._jrbVC_sqrt.setEnabled(false); - _gui._jrbVC.setEnabled(false); - _gui._jrbNone.setEnabled(false); - _gui._jrbKR.setEnabled(false); - _gui._jtfBoxTools.setEnabled(false); - _gui._jbBoxTools.setEnabled(false); - _gui._jtfCoolTools.setEnabled(true); - _gui._jbCoolTools.setEnabled(true); - _gui._jtfCooler.setEnabled(true); - _gui._jbCooler.setEnabled(true); - _gui._jtfMax.setEditable(true); - _gui._jtfNbZero.setEnabled(true); - _gui._jtfMin.setEditable(true); - _gui._jtfEnhanceContrast.setEditable(true); - - } + if (_gui.isHic()) { + changeHic(); + }else if(_gui.isProcessed()){ + changeProcessed(); + }else if(_gui.isCool()) { + changeCool(); + } } } @@ -907,11 +1007,11 @@ public void actionPerformed(ActionEvent actionEvent){ null,"You did not choose a Juicer_box_tools.jar path", "Error", JOptionPane.ERROR_MESSAGE ); - }else if(_gui._jtfDiagSize.getText().matches("[a-zA-Z]") || _gui._jtfEnhanceContrast.getText().matches("[a-zA-Z]") || + }else if(_gui._jtfDiagSize.getText().matches("[a-zA-Z]") || _gui._jtfSaturatedPixel.getText().matches("[a-zA-Z]") || _gui._jtfGaussian.getText().matches("[a-zA-Z]") || _gui._jtfMatrixSize.getText().matches("[a-zA-Z]") || _gui._jtfMax.getText().matches("[a-zA-Z]") || _gui._jtfMin.getText().matches("[a-zA-Z]") || _gui._jtfResolution.getText().matches("[a-zA-Z]") || _gui._jtfNbZero.getText().matches("[a-zA-Z]") || - _gui._jtfNoiseTolerance.getText().matches("[a-zA-Z]")|| _gui._jtfCpu.getText().matches("[a-zA-Z]")){ + _gui._jtfThresholdMaxima.getText().matches("[a-zA-Z]")|| _gui._jtfCpu.getText().matches("[a-zA-Z]")){ JOptionPane.showMessageDialog( null, "some alphabetic character detected in integer or float paramters", "Error", JOptionPane.ERROR_MESSAGE diff --git a/src/process/HiC.java b/src/process/HiC.java index 6e2e4fb..976c3fa 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -17,10 +17,11 @@ import java.util.ArrayList; import java.util.Arrays; +/** + * + */ public class HiC { - - private String _log; - /** */ + /** */ private SIPIntra _sipIntra; /** */ private SIPInter _sipInter; @@ -32,10 +33,6 @@ public class HiC { /** */ private String _output; /** */ - private String _juicerTool; - /** */ - private String _interOrIntra; - /** */ private String _chrSizeFile; /** */ private String _juicerNorm = "KR"; @@ -43,32 +40,45 @@ public class HiC { private int _nbZero = 6; /** */ private boolean _delImages = true; - + /** */ private int _cpu =1; + /** */ + private boolean _isGui; + /** */ + private int _factorParam = 1; + /** */ + private GuiAnalysis _guiAnalysis; - private boolean _gui; - - private int _factor = 1; + String _log; - private GuiAnalysis _guiAnalysis; /** * * @param args * @throws Exception */ public HiC(String args []) throws Exception { - _gui = false; + _isGui = false; String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); CLIOptionHiC cli = new CLIOptionHiC(argsSubset); _cmd = cli.getCommandLine(); OptionalParamaterCheck opt = new OptionalParamaterCheck(_cmd); opt.testOptionalParametersValueCommons(); opt.testOptionalParametersValueIntra(); + _input = _cmd.getOptionValue("input"); + _output = _cmd.getOptionValue("output"); + _log = _output+File.separator+"log.txt"; } - public HiC(GuiAnalysis guiAnalysis ) throws Exception { - _gui = true; + /** + * + * @param guiAnalysis + */ + public HiC(GuiAnalysis guiAnalysis ){ + _isGui = true; _guiAnalysis = guiAnalysis; + _input = this._guiAnalysis.getInput(); + _output = this._guiAnalysis.getOutputDir(); + _log = _output+File.separator+"log.txt"; } /** * @@ -76,42 +86,48 @@ public HiC(GuiAnalysis guiAnalysis ) throws Exception { * */ public void run() throws IOException, InterruptedException { + String juicerTool; + String interOrIntra; + String allParam; + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); + ProcessDumpData processDumpData = new ProcessDumpData(); - if(_gui) { - }else {/* common required parameters*/ - _input = _cmd.getOptionValue("input"); - _output = _cmd.getOptionValue("output"); - _juicerTool = _cmd.getOptionValue("juicerTool"); - _interOrIntra = _cmd.getOptionValue("lt"); + if(_isGui) { + juicerTool = this._guiAnalysis.getJuicerTool(); + if(this._guiAnalysis.isInter()) interOrIntra = "inter"; + else interOrIntra = "intra"; + _chrSizeFile = this._guiAnalysis.getChrSizeFile(); + if(this._guiAnalysis.isNONE()) _juicerNorm = "NONE"; + else if (this._guiAnalysis.isVC()) _juicerNorm = "VC"; + else if (this._guiAnalysis.isVC_SQRT()) _juicerNorm = "VC_SQRT"; + _nbZero = this._guiAnalysis.getNbZero(); + _delImages = this._guiAnalysis.isDeletTif(); + _cpu = this._guiAnalysis.getNbCpu(); + }else { + /* common required parameters*/ + juicerTool = _cmd.getOptionValue("juicerTool"); + interOrIntra = _cmd.getOptionValue("lt"); _chrSizeFile = _cmd.getOptionValue("chrSize"); /* common optional parameters */ - if (_cmd.hasOption("norm")) - _juicerNorm = _cmd.getOptionValue("norm"); - if (_cmd.hasOption("nbZero")) - _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); - if (_cmd.hasOption("delete")) - _delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); - - if (_cmd.hasOption("cpu")) - _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); + if (_cmd.hasOption("norm")) _juicerNorm = _cmd.getOptionValue("norm"); + if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); + if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } - _log = _output+File.separator+"log.txt"; - ProcessDumpData processDumpData = new ProcessDumpData(); - if(_interOrIntra.equals("intra")){ + if(interOrIntra.equals("intra")){ /* Param spe intra chromosomal loop*/ this.setSipIntra(); - _sipIntra.setIsGui(_gui); - + _sipIntra.setIsGui(_isGui); - String allParam = "SIPHiC hic: \n" + + allParam = "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ - "juiceBox: "+_juicerTool+"\n"+ + "juiceBox: "+juicerTool+"\n"+ "norm: "+_juicerNorm+"\n" + - "inter or intra chromosomal: "+_interOrIntra+"\n" + + "inter or intra chromosomal: "+interOrIntra+"\n" + "gauss: "+this._sipIntra.getGauss()+"\n"+ "min: "+this._sipIntra.getMin()+"\n"+ "max: "+this._sipIntra.getMax()+"\n"+ @@ -121,7 +137,7 @@ public void run() throws IOException, InterruptedException { "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ "number of zero: "+this._nbZero+"\n"+ - "factor: "+ _factor+"\n"+ + "factor: "+ _factorParam +"\n"+ "fdr: "+this._sipIntra.getFdr()+"\n"+ "delete images: "+_delImages+"\n"+ "cpu: "+ _cpu+"\n" + @@ -129,27 +145,24 @@ public void run() throws IOException, InterruptedException { System.out.println("########### Starting dump Step inter chromosomal interactions"); - processDumpData.go(_input, _sipIntra, _juicerTool, _juicerNorm, _cpu); + processDumpData.go(_input, _sipIntra, juicerTool, _juicerNorm, _cpu); System.out.println("########### End of the dump step\n"); System.out.println("########### Start loop detection\n"); MultiResProcess multi = new MultiResProcess(_sipIntra, _cpu, _delImages, _chrSizeFile); multi.run(); System.out.println("###########End loop detection step\n"); - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); - writer.write(allParam); - }else{ - setSipInter(); - _sipInter.setIsGui(_gui); + this.setSipInter(); + _sipInter.setIsGui(_isGui); - String allParam = "SIPHiC hic: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "juiceBox: "+_juicerTool+"\n"+ + allParam = "SIPHiC hic: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "juiceBox: "+juicerTool+"\n"+ "norm: "+_juicerNorm+"\n" + - "inter or intra chromosomal: "+_interOrIntra+"\n" + + "inter or intra chromosomal: "+interOrIntra+"\n" + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ "resolution: "+this._sipInter.getResolution()+"\n"+ @@ -158,11 +171,15 @@ public void run() throws IOException, InterruptedException { "fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ "cpu "+ _cpu+"\n"; - processDumpData.go(_input,_sipInter,_juicerTool,_juicerNorm,_cpu); + processDumpData.go(_input,_sipInter,juicerTool,_juicerNorm,_cpu); + + String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(_sipInter, _cpu, _delImages, "/home/plop/Desktop/testInter/loops.txt"); + detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); + } + writer.write(allParam); } @@ -186,28 +203,46 @@ private void setSipIntra(){ ArrayList factor = new ArrayList(); factor.add(1); - if(_gui){ - - }else{ - - if(_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); - if(_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); - if(_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); - if(_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); - if(_cmd.hasOption("gaussian")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("gaussian")); - - if(_cmd.hasOption("factor")) { - _factor= Integer.parseInt(_cmd.getOptionValue("factor")); - if(_factor == 2){ factor.add(2);} - else if(_factor == 4){ + if(_isGui){ + min = this._guiAnalysis.getMin(); + max = this._guiAnalysis.getMax(); + gauss = this._guiAnalysis.getGaussian(); + matrixSize = this._guiAnalysis.getMatrixSize(); + thresholdMax = this._guiAnalysis.getThresholdMaxima(); + fdr = this._guiAnalysis.getFDR(); + resolution = this._guiAnalysis.getResolution(); + diagSize = this._guiAnalysis.getDiagSize(); + saturatedPixel = this._guiAnalysis.getSaturatedPixell(); + isDroso= this._guiAnalysis.isDroso(); + + if(this._guiAnalysis.getFactorChoice() == 2) factor.add(2); + else if(this._guiAnalysis.getFactorChoice() == 4){ + factor.add(2); + factor.add(5); + }else if(this._guiAnalysis.getFactorChoice() == 3) factor.add(5); + }else { + if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); + if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); + if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); + if (_cmd.hasOption("factor")) { + _factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); + if (_factorParam == 2) factor.add(2); + else if (_factorParam == 4) { factor.add(2); factor.add(5); - }else{ factor.add(5);} - } + } else factor.add(5); + } + } _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, _nbZero, factor, fdr, false, isDroso); - } } @@ -221,9 +256,21 @@ private void setSipInter(){ double thresholdMax = 0.01; double fdr = 0.025; int resolution = 100000; - _sipInter = new SIPInter(_input, _output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, _delImages, fdr); - } - + if(_isGui){ + gauss = this._guiAnalysis.getGaussian(); + matrixSize = this._guiAnalysis.getMatrixSize(); + thresholdMax = this._guiAnalysis.getThresholdMaxima(); + fdr = this._guiAnalysis.getFDR(); + resolution = this._guiAnalysis.getResolution(); + }else{ + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + } + _sipInter = new SIPInter(_input, _output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, _delImages, fdr); + } } diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 52e2202..8fa2b52 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -100,23 +100,44 @@ public class Hic_main { */ public static void main(String[] args) throws Exception { + /*CLI */ - - _factor.add(1); if(args.length >= 1) { if (args[0].equals("hic")) { HiC hic = new HiC(args); hic.run(); - } else if (args[0].equals("processed")) { + }else if (args[0].equals("processed")) { Processed processed = new Processed(args); - } else if (args[0].equals("cool")) { + }else if (args[0].equals("cool")) { MCool mCool = new MCool(args); - } else { + }else { System.out.println(CLISipOption.getHelperInfos()); } } + /*GUI */ + else{ + GuiAnalysis gui = new GuiAnalysis(); + while( gui.isShowing()){ + try {Thread.sleep(1);} + catch (InterruptedException e) {e.printStackTrace();} + } + if (gui.isStart()){ + if(gui.isHic()) { + HiC hic = new HiC(gui); + hic.run(); + }else if(gui.isCool()){ + + }else if(gui.isProcessed()){ + + } + }else { + System.out.println("SIP closed: if you want the help: -h"); + return; + } + } + /* _input = args[1]; _output = args[3]; _chrSizeFile = args[2]; @@ -147,7 +168,7 @@ public static void main(String[] args) throws Exception { _isCool = gui.isCool(); _chrSizeFile = gui.getChrSizeFile(); _output = gui.getOutputDir(); - _input = gui.getRawDataDir(); + _input = gui.getInput(); _matrixSize = gui.getMatrixSize(); _diagSize = gui.getDiagSize(); _resolution = gui.getResolution(); @@ -157,8 +178,8 @@ public static void main(String[] args) throws Exception { _min = gui.getMin(); _isDroso= gui.isDroso(); _nbZero = gui.getNbZero(); - _saturatedPixel = gui.getEnhanceSignal(); - _thresholdMax = gui.getNoiseTolerance(); + _saturatedPixel = gui.getSaturatedPixell(); + _thresholdMax = gui.getThresholdMaxima(); _fdr = gui.getFDR(); _cpu = gui.getNbCpu(); if(gui.getFactorChoice() == 2){ @@ -171,7 +192,7 @@ public static void main(String[] args) throws Exception { } _isHic = gui.isHic(); _isProcessed = gui.isProcessed(); - _juiceBoxTools = gui.getJuiceBox(); + _juiceBoxTools = gui.getJuicerTool(); _cooltools = gui.getCooltools(); _cooler = gui.getCooler(); diff --git a/src/test/TestGui.java b/src/test/TestGui.java index 757c1e6..e319a7f 100644 --- a/src/test/TestGui.java +++ b/src/test/TestGui.java @@ -31,18 +31,18 @@ public static void main(String[] args) throws IOException, InterruptedException{ if (gui.isStart()){ System.out.println("test"); String output = gui.getOutputDir(); - String input = gui.getRawDataDir(); + String input = gui.getInput(); int matrixSize = gui.getMatrixSize(); int diagSize = gui.getDiagSize(); int resolution = gui.getResolution(); double gauss = gui.getGaussian(); double max = gui.getMax(); double min = gui.getMin(); - double saturatedPixel = gui.getEnhanceSignal(); - int thresholdMax = gui.getNoiseTolerance(); + double saturatedPixel = gui.getSaturatedPixell(); + int thresholdMax = gui.getThresholdMaxima(); boolean isHic = gui.isHic(); boolean isProcessed = gui.isProcessed(); - String juiceBoxTools = gui.getJuiceBox(); + String juiceBoxTools = gui.getJuicerTool(); String juiceBoXNormalisation = "KR"; if(gui.isNONE()) juiceBoXNormalisation = "NONE"; else if (gui.isVC()) juiceBoXNormalisation = "VC"; From e4c0b474848aa314e5f14e77bbe64be52c0f24f9 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Mon, 16 Nov 2020 08:02:44 -0500 Subject: [PATCH 14/27] Start class testing the parameters value before running the process --- src/cli/CLIOptionHiC.java | 23 ----- src/cli/CLISipOption.java | 75 +++++---------- src/process/HiC.java | 34 +++---- src/process/OptionalParamaterCheck.java | 76 --------------- src/process/ParametersCheck.java | 123 ++++++++++++++++++++++++ 5 files changed, 164 insertions(+), 167 deletions(-) delete mode 100644 src/process/OptionalParamaterCheck.java create mode 100644 src/process/ParametersCheck.java diff --git a/src/cli/CLIOptionHiC.java b/src/cli/CLIOptionHiC.java index f903722..20b05a7 100644 --- a/src/cli/CLIOptionHiC.java +++ b/src/cli/CLIOptionHiC.java @@ -31,7 +31,6 @@ public CLIOptionHiC(String [] args)throws Exception{ } try { _commandLine = parser.parse(this._options, args); - testParam(); } catch (ParseException exp){ System.out.println(exp.getMessage()+"\n"); @@ -41,28 +40,6 @@ public CLIOptionHiC(String [] args)throws Exception{ } - private void testParam(){ - - - - if (_cmd.hasOption("norm")) { - String juicerNorm = _cmd.getOptionValue("norm"); - if (!juicerNorm.equals("KR") && !juicerNorm.equals("NONE") && !juicerNorm.equals("VC") && !juicerNorm.equals("VC_SQRT")) { - System.out.println("-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); - //helper hic - System.exit(0); - } - } - - String juicerTools = _cmd.getOptionValue("juicerTool"); - File file = new File(juicerTools); - if(!file.exists()){ - System.out.println("-j "+juicerTools+" => this file doesn't existed !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - } /** * diff --git a/src/cli/CLISipOption.java b/src/cli/CLISipOption.java index 5a3841f..4b07354 100644 --- a/src/cli/CLISipOption.java +++ b/src/cli/CLISipOption.java @@ -1,56 +1,73 @@ package cli; import org.apache.commons.cli.*; -import java.io.File; - +/** + * + */ public class CLISipOption { + /** */ Options _options= new Options(); + /** */ CommandLine _cmd; - + /** */ private Option _inputFolder= Option.builder("i").longOpt("input").required() .type(String.class).desc("Path to input .hic, .mcool or SIP folder containing processed data\n") .numberOfArgs(1).build(); + /** */ private Option _outputFolder= Option.builder("o").longOpt("output").required() .type(String.class).desc("Path to output folder for SIP's files \n") .numberOfArgs(1).build(); + /** */ private Option _chrSize = Option.builder("c").longOpt("chrSize").required() .type(String.class).desc("Path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1).\n") .numberOfArgs(1).build(); + /** */ private Option _resolution = Option.builder("r").longOpt("resolution") .type(Number.class).desc("Resolution in bp (default 5000 bp)\n") .numberOfArgs(1).build(); + /** */ private Option _sizeImage = Option.builder("ms").longOpt("matrixSize") .type(Number.class).desc("Matrix size to use for each chunk of the chromosome (default 2000 bins)\n") .numberOfArgs(1).build(); + /** */ private Option _cpu = Option.builder("cpu") .type(Number.class).desc("Number of CPU used for SIP processing (default 1)\n") .numberOfArgs(1).build(); + /** */ private Option _gaussianStrength = Option.builder("g").longOpt("gaussian") .type(Number.class).desc("Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1.5)\n") .numberOfArgs(1).build(); + /** */ private Option _threshold = Option.builder("t").longOpt("threshold") .type(Number.class).desc("Threshold for loops detection (default 2800)\n") .numberOfArgs(1).build(); + /** */ private Option _nbZero = Option.builder("nbZero") .type(Number.class).desc("Number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6)\n") .numberOfArgs(1).build(); + /** */ private Option _fdr = Option.builder("fdr") .type(Number.class).desc("Empirical FDR value for filtering based on random sites (default 0.01)\n") .numberOfArgs(1).build(); + /** */ private Option _deleteImage = Option.builder("d").longOpt("delete") .type(boolean.class).desc("Delete tif files used for loop detection (default true)\n") .build(); + /** */ private Option _interOrIntra = Option.builder("lt").longOpt("loopsType").required() .type(String.class).desc("(inter or intra), call loops inter chromosomal or intra chromosomal loops\n") .build(); + /** */ private Option _isDroso = Option.builder("isDroso") .type(boolean.class).desc("Default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n") .build(); + /** */ private Option _diagonal = Option.builder("d").longOpt("diagonal") .type(Number.class).desc("diagonal size in bins, remove the maxima found at this size (eg: a size of 2 at 5000 bp resolution removes all maxima\n" + " detected at a distance inferior or equal to 10kb) (default 6 bins).\n") .numberOfArgs(1).build(); + /** */ private Option _factor = Option.builder("f").longOpt("factor") .type(Number.class).desc(" Multiple resolutions can be specified using:\n" + "\t\t-factor 1: run only for the input res (default)\n" + @@ -59,16 +76,20 @@ public class CLISipOption { "\t\t-factor 4: res, res*2 and res*5\n") .numberOfArgs(1).build(); + /** */ private Option _min = Option.builder("min").longOpt("minimum") .type(Number.class).desc("Minimum filter strength (default 2)\n") .numberOfArgs(1).build(); + /** */ private Option _max = Option.builder("max").longOpt("maximum") .type(Number.class).desc("Maximum filter strength (default 2)\n") .numberOfArgs(1).build(); + /** */ private Option _saturated = Option.builder("sat").longOpt("saturated") .type(Number.class).desc("% of saturated pixel: enhances the contrast in the image (default 0.01)\n") .numberOfArgs(1).build(); + /** */ private static String _Jversion ="1.6.1"; /** * @@ -95,8 +116,6 @@ public CLISipOption(String[] args)throws Exception { try { _cmd = parser.parse(this._options, args); - this.testParam(); - } catch (ParseException exp){ System.out.println(exp.getMessage()+"\n"); @@ -105,52 +124,6 @@ public CLISipOption(String[] args)throws Exception { } } - /** - * - */ - private void testParam(){ - String input = _cmd.getOptionValue("input"); - String output = _cmd.getOptionValue("output"); - String chrSizeFile = _cmd.getOptionValue("chrSize"); - File file = new File(input); - - if(!file.exists() && !input.startsWith("https")){ - System.out.println("-i "+input+" => this file doesn't existed !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - file = new File(output); - if(!file.exists()){ - System.out.println("-o "+output+" => this file doesn't existed !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - file = new File(chrSizeFile); - if(!file.exists()){ - System.out.println("-c "+chrSizeFile+" => this file doesn't existed !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - String inter = _cmd.getOptionValue("tl"); - if(!inter.equals("inter") && !inter.equals("intra")){ - System.out.println("-tl "+inter+", wrong value, choose inter or intra !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - if(_cmd.hasOption("resolution")){ - int res = Integer.parseInt(_cmd.getOptionValue("resolution")); - if(res <= 0 ){ - System.out.println("-r "+res+", resolution need to be a >= 0 !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - - } - } - } /** * diff --git a/src/process/HiC.java b/src/process/HiC.java index 976c3fa..ce70c96 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -34,8 +34,7 @@ public class HiC { private String _output; /** */ private String _chrSizeFile; - /** */ - private String _juicerNorm = "KR"; + /** */ private int _nbZero = 6; /** */ @@ -49,6 +48,7 @@ public class HiC { /** */ private GuiAnalysis _guiAnalysis; + String _log; /** @@ -61,9 +61,6 @@ public HiC(String args []) throws Exception { String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); CLIOptionHiC cli = new CLIOptionHiC(argsSubset); _cmd = cli.getCommandLine(); - OptionalParamaterCheck opt = new OptionalParamaterCheck(_cmd); - opt.testOptionalParametersValueCommons(); - opt.testOptionalParametersValueIntra(); _input = _cmd.getOptionValue("input"); _output = _cmd.getOptionValue("output"); _log = _output+File.separator+"log.txt"; @@ -89,6 +86,7 @@ public void run() throws IOException, InterruptedException { String juicerTool; String interOrIntra; String allParam; + String juicerNorm = "KR"; BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); ProcessDumpData processDumpData = new ProcessDumpData(); @@ -97,9 +95,9 @@ public void run() throws IOException, InterruptedException { if(this._guiAnalysis.isInter()) interOrIntra = "inter"; else interOrIntra = "intra"; _chrSizeFile = this._guiAnalysis.getChrSizeFile(); - if(this._guiAnalysis.isNONE()) _juicerNorm = "NONE"; - else if (this._guiAnalysis.isVC()) _juicerNorm = "VC"; - else if (this._guiAnalysis.isVC_SQRT()) _juicerNorm = "VC_SQRT"; + if(this._guiAnalysis.isNONE()) juicerNorm = "NONE"; + else if (this._guiAnalysis.isVC()) juicerNorm = "VC"; + else if (this._guiAnalysis.isVC_SQRT()) juicerNorm = "VC_SQRT"; _nbZero = this._guiAnalysis.getNbZero(); _delImages = this._guiAnalysis.isDeletTif(); _cpu = this._guiAnalysis.getNbCpu(); @@ -109,13 +107,13 @@ public void run() throws IOException, InterruptedException { interOrIntra = _cmd.getOptionValue("lt"); _chrSizeFile = _cmd.getOptionValue("chrSize"); /* common optional parameters */ - if (_cmd.hasOption("norm")) _juicerNorm = _cmd.getOptionValue("norm"); + if (_cmd.hasOption("norm")) juicerNorm = _cmd.getOptionValue("norm"); if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } - - + ParametersCheck paramaterCheck = new ParametersCheck(_input, _output, _chrSizeFile, interOrIntra); + paramaterCheck.testHiCOption(juicerTool, juicerNorm); if(interOrIntra.equals("intra")){ /* Param spe intra chromosomal loop*/ @@ -126,7 +124,7 @@ public void run() throws IOException, InterruptedException { "input: "+_input+"\n" + "output: "+_output+"\n"+ "juiceBox: "+juicerTool+"\n"+ - "norm: "+_juicerNorm+"\n" + + "norm: "+juicerNorm+"\n" + "inter or intra chromosomal: "+interOrIntra+"\n" + "gauss: "+this._sipIntra.getGauss()+"\n"+ "min: "+this._sipIntra.getMin()+"\n"+ @@ -145,7 +143,8 @@ public void run() throws IOException, InterruptedException { System.out.println("########### Starting dump Step inter chromosomal interactions"); - processDumpData.go(_input, _sipIntra, juicerTool, _juicerNorm, _cpu); + paramaterCheck.testCommonParametersValidity(_sipIntra); + processDumpData.go(_input, _sipIntra, juicerTool, juicerNorm, _cpu); System.out.println("########### End of the dump step\n"); System.out.println("########### Start loop detection\n"); @@ -161,7 +160,7 @@ public void run() throws IOException, InterruptedException { "input: "+_input+"\n" + "output: "+_output+"\n"+ "juiceBox: "+juicerTool+"\n"+ - "norm: "+_juicerNorm+"\n" + + "norm: "+juicerNorm+"\n" + "inter or intra chromosomal: "+interOrIntra+"\n" + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ @@ -171,7 +170,7 @@ public void run() throws IOException, InterruptedException { "fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ "cpu "+ _cpu+"\n"; - processDumpData.go(_input,_sipInter,juicerTool,_juicerNorm,_cpu); + processDumpData.go(_input,_sipInter,juicerTool,juicerNorm,_cpu); String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; @@ -250,7 +249,7 @@ else if (_factorParam == 4) { * * */ - private void setSipInter(){ + private void setSipInter() throws IOException { double gauss = 1; int matrixSize = 500; double thresholdMax = 0.01; @@ -271,6 +270,7 @@ private void setSipInter(){ if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); } - _sipInter = new SIPInter(_input, _output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, _delImages, fdr); + _sipInter = new SIPInter(_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, _delImages, fdr); + } } diff --git a/src/process/OptionalParamaterCheck.java b/src/process/OptionalParamaterCheck.java deleted file mode 100644 index f1b0e7e..0000000 --- a/src/process/OptionalParamaterCheck.java +++ /dev/null @@ -1,76 +0,0 @@ -package process; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.HelpFormatter; - -public class OptionalParamaterCheck { - - private CommandLine _cmd; - - /** - * - * @param commandLine - */ - public OptionalParamaterCheck(CommandLine commandLine){ - _cmd = commandLine; - } - - - public void testOptionalParametersValueCommons(){ - - int nbZero = 6; - if (_cmd.hasOption("nbZero")) { - nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); - if (nbZero > 24|| nbZero < 0) { - System.out.println("\n-nbZero"+ nbZero+" value invalid: choose an integer value between 0 and 24\n"); - //erreur mettre l'aide et stopper le prog. - - System.exit(0); - } - } - - boolean delImages = true; - if (_cmd.hasOption("delete")) delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); - - int cpu = 1; - if (_cmd.hasOption("cpu")){ - cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); - if(cpu > Runtime.getRuntime().availableProcessors() || cpu <= 0){ - System.out.println("\nThe number of CPU "+ cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); - - System.exit(0); - } - } - - } - public void testOptionalParametersValueIntra(){ - - if(_cmd.hasOption("min")) { - double min = Double.parseDouble(_cmd.getOptionValue("min")); - if(min < 0){ - System.out.println("\n-min"+ min+": this parameter need to be >= 0\n"); - //trouver commande sortir l'aide propre - System.exit(0); - } - } - - if(_cmd.hasOption("max")) { - double max = Double.parseDouble(_cmd.getOptionValue("max")); - if(max < 0){ - System.out.println("\n-max"+ max+": this parameter need to be >= 0\n"); - - System.exit(0); - } - } - - if(_cmd.hasOption("diagonal")) { - int diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); - if (diagSize < 0) { - System.out.println("\n-d" + diagSize + ": this parameter need to be >= 0\n"); - - System.exit(0); - } - } - } - -} diff --git a/src/process/ParametersCheck.java b/src/process/ParametersCheck.java new file mode 100644 index 0000000..8a2aba8 --- /dev/null +++ b/src/process/ParametersCheck.java @@ -0,0 +1,123 @@ +package process; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.HelpFormatter; +import sip.SIPIntra; +import sip.SIPObject; + +import java.io.File; + +import static cli.CLISipOption.getHelperInfos; + +public class ParametersCheck { + + private SIPIntra _sipIntra; + + private SIPIntra _sipInter; + + /** + * + * @param input + * @param output + * @param chrSizeFile + * @param interOrIntra + */ + public ParametersCheck(String input, String output, String chrSizeFile, String interOrIntra){ + File file = new File(input); + + if(!file.exists() && !input.startsWith("https")){ + System.out.println("-i "+input+" => this file doesn't existed !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + file = new File(output); + + if(!file.exists()){ + System.out.println("-i "+output+" => this file doesn't existed !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + file = new File(chrSizeFile); + if(!file.exists()){ + System.out.println("-i "+chrSizeFile+" => this file doesn't existed !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + if(!interOrIntra.equals("inter") && !interOrIntra.equals("intra")){ + System.out.println("-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + } + + /** + * + */ + public void testCommonParametersValidity(SIPObject sip){ + + + /*if(_cmd.hasOption("resolution")){ + int res = Integer.parseInt(_cmd.getOptionValue("resolution")); + if(res <= 0 ){ + System.out.println("-r "+res+", resolution need to be a >= 0 !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + + } + } + + int nbZero = sip.getNbZero(); + if (nbZero > 24|| nbZero < 0) { + System.out.println("\n-nbZero"+ nbZero+" value invalid: choose an integer value between 0 and 24\n"); + //erreur mettre l'aide et stopper le prog. + + System.exit(0); + } + + + boolean delImages = true; + if (_cmd.hasOption("delete")) delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + + int cpu = 1; + if (_cmd.hasOption("cpu")){ + cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); + if(cpu > Runtime.getRuntime().availableProcessors() || cpu <= 0){ + System.out.println("\nThe number of CPU "+ cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + + System.exit(0); + } + } + */ + } + + /** + * + */ + public void testHiCOption(String juicerTool, String juicerNorm){ + + if (!juicerNorm.equals("KR") && !juicerNorm.equals("NONE") && !juicerNorm.equals("VC") && !juicerNorm.equals("VC_SQRT")) { + System.out.println("-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); + //helper hic + System.exit(0); + } + + + File file = new File(juicerTool); + if(!file.exists()){ + System.out.println("-j "+juicerTool+" => this file doesn't existed !!! \n\n"); + //helper hic + System.exit(0); + } + } + + /** + * + */ + public void testCoolOption() { + + } + +} From 6c25167451c81b4bbeb7e8a3fc61db2effe89cd2 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Tue, 17 Nov 2020 20:19:35 -0500 Subject: [PATCH 15/27] Correction of HiC class (split long method) Start class testing the parameters value before running the process add cpu and delImage in SIPObject constructor, and propagate the change in different class --- src/gui/GuiAnalysis.java | 2 +- src/multiProcesing/ProcessCoolerDumpData.java | 7 +- src/multiProcesing/ProcessDetectLoops.java | 12 +- src/multiProcesing/ProcessDumpData.java | 10 +- .../RunnableDetectInterLoops.java | 8 +- src/multiProcesing/RunnableDetectLoops.java | 14 +- src/process/HiC.java | 313 ++++++++++-------- src/process/ParametersCheck.java | 72 ++-- src/sip/SIPInter.java | 11 +- src/sip/SIPIntra.java | 14 +- src/sip/SIPObject.java | 41 ++- src/sipMain/Hic_main.java | 2 +- src/test/TestCallLoopsHicFile.java | 6 +- src/test/TestCallLoopsProcessedFile.java | 6 +- src/test/TestCoolFormat.java | 10 +- src/test/TestGui.java | 11 +- src/test/TestInter.java | 2 +- src/utils/MultiResProcess.java | 44 +-- 18 files changed, 333 insertions(+), 252 deletions(-) diff --git a/src/gui/GuiAnalysis.java b/src/gui/GuiAnalysis.java index 9da0289..1e8d22b 100644 --- a/src/gui/GuiAnalysis.java +++ b/src/gui/GuiAnalysis.java @@ -685,7 +685,7 @@ public double getMin(){ * * @return double */ - public double getSaturatedPixell(){ + public double getSaturatedPixel(){ String x = this._jtfSaturatedPixel.getText(); return Double.parseDouble(x.replaceAll(",", ".")); } diff --git a/src/multiProcesing/ProcessCoolerDumpData.java b/src/multiProcesing/ProcessCoolerDumpData.java index 0458845..b3c4dac 100644 --- a/src/multiProcesing/ProcessCoolerDumpData.java +++ b/src/multiProcesing/ProcessCoolerDumpData.java @@ -42,12 +42,11 @@ public ProcessCoolerDumpData(){ } * @param cooler String cooler path * @param sip SIPIntra * @param coolFile path mcool file - * @param nbCPU number of cpu * @throws InterruptedException exception */ - public void go(String coolTools, String cooler, SIPIntra sip, String coolFile, int nbCPU) throws InterruptedException { + public void go(String coolTools, String cooler, SIPIntra sip, String coolFile) throws InterruptedException { HashMap chrSize= sip.getChrSizeHashMap(); - ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sip.getCpu()); Iterator chrName = chrSize.keySet().iterator(); File outDir = new File(sip.getOutputDir()); if (!outDir.exists()) outDir.mkdir(); @@ -57,7 +56,7 @@ public void go(String coolTools, String cooler, SIPIntra sip, String coolFile, int res = sip.getResolution()*listFactor.get(indexFact); int matrixSize = sip.getMatrixSize()/listFactor.get(indexFact); - CoolerExpected expected = new CoolerExpected(coolTools,coolFile, res, matrixSize, nbCPU); + CoolerExpected expected = new CoolerExpected(coolTools,coolFile, res, matrixSize,sip.getCpu()); String nameRes = String.valueOf(res); nameRes = nameRes.replace("000", ""); nameRes = nameRes+"kb"; diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index 6217072..7f7e447 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -32,14 +32,12 @@ public ProcessDetectLoops(){ } * multiprocessing method for SIP intra chromosomal interaction * * @param sip SIPIntra - * @param nbCPU nb of cpu - * @param delImage boolean if true del all the tif file * @param resuFile path to results file * @param resName name of the resolution used * @throws InterruptedException exception */ - public void go(SIPIntra sip, int nbCPU, boolean delImage, String resuFile, String resName) throws InterruptedException { - ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + public void go(SIPIntra sip, String resuFile, String resName) throws InterruptedException { + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sip.getCpu()); Iterator chrName = sip.getChrSizeHashMap().keySet().iterator(); if(sip.isProcessed()) { boolean isCool = isProcessedMcool(sip.getOutputDir()+resName+File.separator+"normVector"); @@ -49,7 +47,7 @@ public void go(SIPIntra sip, int nbCPU, boolean delImage, String resuFile, Strin while(chrName.hasNext()){ String chr = chrName.next(); if(sip.isCooler()){ - RunnableDetectLoops task = new RunnableDetectLoops(chr, resuFile, sip, delImage); + RunnableDetectLoops task = new RunnableDetectLoops(chr, resuFile, sip); executor.execute(task); }else { @@ -57,7 +55,7 @@ public void go(SIPIntra sip, int nbCPU, boolean delImage, String resuFile, Strin if (sip.isProcessed()){ normFile = sip.getInputDir()+resName+File.separator+"normVector"+File.separator+chr+".norm"; } - RunnableDetectLoops task = new RunnableDetectLoops(chr, resuFile, sip,normFile, delImage); + RunnableDetectLoops task = new RunnableDetectLoops(chr, resuFile, sip,normFile); executor.execute(task); } } @@ -101,7 +99,7 @@ public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile) int size1 = chrSize.get(chr1); int size2 = chrSize.get(chr2); System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); - RunnableDetectInterLoops task = new RunnableDetectInterLoops(chr1, chr2, resuFile, sipInter, delImage); + RunnableDetectInterLoops task = new RunnableDetectInterLoops(chr1, chr2, resuFile, sipInter); executor.execute(task); } } diff --git a/src/multiProcesing/ProcessDumpData.java b/src/multiProcesing/ProcessDumpData.java index ed32e56..4fd769c 100644 --- a/src/multiProcesing/ProcessDumpData.java +++ b/src/multiProcesing/ProcessDumpData.java @@ -38,12 +38,11 @@ public ProcessDumpData(){ } * @param sip SIPIntra with all the paramters needed * @param juiceBoxTools juicerTools.jar path * @param normJuiceBox String normalization method - * @param nbCPU int nb cpu * @throws InterruptedException exception */ - public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJuiceBox, int nbCPU) throws InterruptedException { + public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJuiceBox) throws InterruptedException { HashMap chrSize = sip.getChrSizeHashMap(); - ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sip.getCpu()); Iterator chrName = chrSize.keySet().iterator(); File outDir = new File(sip.getOutputDir()); if (!outDir.exists()) outDir.mkdir(); @@ -76,11 +75,10 @@ public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJu * @param sipInter SIPInter object with all the parameters needed * @param juiceBoxTools juicerTools.jar path * @param normJuiceBox String normalization method - * @param nbCPU int nb cpu * @throws InterruptedException exception */ - public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String normJuiceBox, int nbCPU) throws InterruptedException { - ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String normJuiceBox) throws InterruptedException { + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); HashMap chrSize = sipInter.getChrSizeHashMap(); Object [] chrName = chrSize.keySet().toArray(); diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/multiProcesing/RunnableDetectInterLoops.java index 56c5a5d..93f5ffc 100644 --- a/src/multiProcesing/RunnableDetectInterLoops.java +++ b/src/multiProcesing/RunnableDetectInterLoops.java @@ -25,8 +25,6 @@ public class RunnableDetectInterLoops extends Thread implements Runnable { private String _chr1; /** String chr name 2 */ private String _chr2; - /**String name of the chr*/ - private boolean _delImages = true; /** @@ -36,15 +34,13 @@ public class RunnableDetectInterLoops extends Thread implements Runnable { * @param chr2 chr2 name * @param resuFile path output file * @param sip SIPInter object - * @param delFile boolean if true delete all tif file. */ - public RunnableDetectInterLoops(String chr1, String chr2, String resuFile, SIPInter sip, boolean delFile) { + public RunnableDetectInterLoops(String chr1, String chr2, String resuFile, SIPInter sip) { this._sipInter = sip; this._callLoopsInter = new CallLoopsInter(_sipInter); this._chr1 = chr1; this._chr2 = chr2; this._resuFile = resuFile; - this._delImages = delFile; } @@ -78,7 +74,7 @@ public void run() { } folder = new File(dir); listOfFiles = folder.listFiles(); - if(_delImages){ + if(_sipInter.isDelImage()){ System.out.println("Deleting image file for "+_chr1+"_"+_chr2); for(int i = 0; i < listOfFiles.length;++i) { String name = listOfFiles[i].toString(); diff --git a/src/multiProcesing/RunnableDetectLoops.java b/src/multiProcesing/RunnableDetectLoops.java index 6335e4b..55b6408 100644 --- a/src/multiProcesing/RunnableDetectLoops.java +++ b/src/multiProcesing/RunnableDetectLoops.java @@ -21,8 +21,6 @@ public class RunnableDetectLoops extends Thread implements Runnable{ private String _resuFile; /** String name of the chr*/ private String _chr; - /** String name of the chr*/ - private boolean _delImages = true; /** norn vector table for the chr of interest*/ private HashMap _normVector = new HashMap (); /** path of Normalized vector from juicer tools dump for each chr by SIP*/ @@ -38,15 +36,14 @@ public class RunnableDetectLoops extends Thread implements Runnable{ * @param resuFile path to the result file * @param sip SIPIntra * @param normVectorFile path to normalized vector - * @param delFile boolean if true delete all the tif file at the end of the process + * */ - public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, String normVectorFile, boolean delFile){ + public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, String normVectorFile){ this._sip = sip; this._callLoops = new CallLoops(sip); this._chr= chr; this._resuFile = resuFile; this._normVector = sip.getNormValueFilter(normVectorFile); - this._delImages = delFile; this._normVectorFile = normVectorFile; } @@ -56,14 +53,13 @@ public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, String no * @param chr String chromosome name * @param resuFile path to the result file * @param sip SIPIntra - * @param delFile boolean if true delete all the tif file at the end of the process + * */ - public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, boolean delFile){ + public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip){ this._sip = sip; this._callLoops = new CallLoops(sip); this._chr= chr; this._resuFile = resuFile; - this._delImages = delFile; } /** @@ -95,7 +91,7 @@ public void run(){ } folder = new File(dir); listOfFiles = folder.listFiles(); - if(_delImages){ + if(_sip.isDelImage()){ System.out.println("Deleting image file for "+_chr); for(int i = 0; i < listOfFiles.length;++i) { String name = listOfFiles[i].toString(); diff --git a/src/process/HiC.java b/src/process/HiC.java index ce70c96..0c5fae9 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -36,19 +36,26 @@ public class HiC { private String _chrSizeFile; /** */ - private int _nbZero = 6; + private int _nbZero; /** */ - private boolean _delImages = true; + private boolean _delImages; /** */ - private int _cpu =1; + private int _cpu; /** */ private boolean _isGui; /** */ - private int _factorParam = 1; + private int _factorParam; /** */ private GuiAnalysis _guiAnalysis; - - + /** */ + private String _juicerTool; + /** */ + private String _interOrIntra; + /** */ + private ParametersCheck _parameterCheck; + /** */ + private String _juicerNorm; + /** */ String _log; /** @@ -64,6 +71,11 @@ public HiC(String args []) throws Exception { _input = _cmd.getOptionValue("input"); _output = _cmd.getOptionValue("output"); _log = _output+File.separator+"log.txt"; + _juicerNorm = "KR"; + _delImages = true; + _nbZero = 6; + _cpu = 1; + _factorParam = 1; } /** @@ -76,119 +88,157 @@ public HiC(GuiAnalysis guiAnalysis ){ _input = this._guiAnalysis.getInput(); _output = this._guiAnalysis.getOutputDir(); _log = _output+File.separator+"log.txt"; + _juicerNorm = "KR"; + _delImages = true; + _nbZero = 6; + _cpu = 1; + _factorParam = 1; } /** * * Normalisation method to dump the the data with hic method (KR,NONE.VC,VC_SQRT) * + * + * @throws IOException + * @throws InterruptedException */ public void run() throws IOException, InterruptedException { - String juicerTool; - String interOrIntra; + String allParam; - String juicerNorm = "KR"; + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); - ProcessDumpData processDumpData = new ProcessDumpData(); if(_isGui) { - juicerTool = this._guiAnalysis.getJuicerTool(); - if(this._guiAnalysis.isInter()) interOrIntra = "inter"; - else interOrIntra = "intra"; + _juicerTool = this._guiAnalysis.getJuicerTool(); + if(this._guiAnalysis.isInter()) _interOrIntra = "inter"; + else _interOrIntra = "intra"; _chrSizeFile = this._guiAnalysis.getChrSizeFile(); - if(this._guiAnalysis.isNONE()) juicerNorm = "NONE"; - else if (this._guiAnalysis.isVC()) juicerNorm = "VC"; - else if (this._guiAnalysis.isVC_SQRT()) juicerNorm = "VC_SQRT"; + if(this._guiAnalysis.isNONE()) _juicerNorm = "NONE"; + else if (this._guiAnalysis.isVC()) _juicerNorm = "VC"; + else if (this._guiAnalysis.isVC_SQRT()) _juicerNorm = "VC_SQRT"; _nbZero = this._guiAnalysis.getNbZero(); _delImages = this._guiAnalysis.isDeletTif(); _cpu = this._guiAnalysis.getNbCpu(); }else { /* common required parameters*/ - juicerTool = _cmd.getOptionValue("juicerTool"); - interOrIntra = _cmd.getOptionValue("lt"); + _juicerTool = _cmd.getOptionValue("_juicerTool"); + _interOrIntra = _cmd.getOptionValue("lt"); _chrSizeFile = _cmd.getOptionValue("chrSize"); /* common optional parameters */ - if (_cmd.hasOption("norm")) juicerNorm = _cmd.getOptionValue("norm"); + if (_cmd.hasOption("norm")) _juicerNorm = _cmd.getOptionValue("norm"); if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } - ParametersCheck paramaterCheck = new ParametersCheck(_input, _output, _chrSizeFile, interOrIntra); - paramaterCheck.testHiCOption(juicerTool, juicerNorm); - - if(interOrIntra.equals("intra")){ - /* Param spe intra chromosomal loop*/ - this.setSipIntra(); - _sipIntra.setIsGui(_isGui); - - allParam = "SIPHiC hic: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "juiceBox: "+juicerTool+"\n"+ - "norm: "+juicerNorm+"\n" + - "inter or intra chromosomal: "+interOrIntra+"\n" + - "gauss: "+this._sipIntra.getGauss()+"\n"+ - "min: "+this._sipIntra.getMin()+"\n"+ - "max: "+this._sipIntra.getMax()+"\n"+ - "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ - "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ - "resolution: "+this._sipIntra.getResolution()+"\n"+ - "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ - "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ - "number of zero: "+this._nbZero+"\n"+ - "factor: "+ _factorParam +"\n"+ - "fdr: "+this._sipIntra.getFdr()+"\n"+ - "delete images: "+_delImages+"\n"+ - "cpu: "+ _cpu+"\n" + - "isDroso: "+this._sipIntra.isDroso()+"\n"; - - System.out.println("########### Starting dump Step inter chromosomal interactions"); - - paramaterCheck.testCommonParametersValidity(_sipIntra); - processDumpData.go(_input, _sipIntra, juicerTool, juicerNorm, _cpu); - System.out.println("########### End of the dump step\n"); - - System.out.println("########### Start loop detection\n"); - MultiResProcess multi = new MultiResProcess(_sipIntra, _cpu, _delImages, _chrSizeFile); - multi.run(); - System.out.println("###########End loop detection step\n"); + _parameterCheck = new ParametersCheck(_input, _output, _chrSizeFile, _interOrIntra); + _parameterCheck.testHiCOption(_juicerTool, _juicerNorm); - }else{ - this.setSipInter(); - _sipInter.setIsGui(_isGui); + if(_interOrIntra.equals("intra")) + allParam = runIntra(); + else + allParam = runInter(); - allParam = "SIPHiC hic: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "juiceBox: "+juicerTool+"\n"+ - "norm: "+juicerNorm+"\n" + - "inter or intra chromosomal: "+interOrIntra+"\n" + - "gauss: "+this._sipInter.getGauss()+"\n"+ - "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ - "resolution: "+this._sipInter.getResolution()+"\n"+ - "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ - "number of zero :"+_nbZero+"\n"+ - "fdr "+this._sipInter.getFdr()+"\n"+ - "delete images "+_delImages+"\n"+ - "cpu "+ _cpu+"\n"; - processDumpData.go(_input,_sipInter,juicerTool,juicerNorm,_cpu); - - String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; - - ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); - } writer.write(allParam); } + /** + * + * @return + * @throws IOException + * @throws InterruptedException + */ + private String runIntra() throws IOException, InterruptedException { + /* Param spe intra chromosomal loop*/ + if(_isGui) + this.setSipIntraGUI(); + else + this.setSipIntraCLI(); + + _sipIntra.setIsGui(_isGui); + _sipIntra.setIsProcessed(false); + _sipIntra.setIsCooler(false); + + ProcessDumpData processDumpData = new ProcessDumpData(); + String allParam = "SIPHiC hic: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "juiceBox: "+ _juicerTool +"\n"+ + "norm: "+ _juicerNorm +"\n" + + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipIntra.getGauss()+"\n"+ + "min: "+this._sipIntra.getMin()+"\n"+ + "max: "+this._sipIntra.getMax()+"\n"+ + "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ + "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ + "resolution: "+this._sipIntra.getResolution()+"\n"+ + "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ + "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ + "number of zero: "+this._nbZero+"\n"+ + "factor: "+ _factorParam +"\n"+ + "fdr: "+this._sipIntra.getFdr()+"\n"+ + "delete images: "+_delImages+"\n"+ + "cpu: "+ _cpu+"\n" + + "isDroso: "+this._sipIntra.isDroso()+"\n"; + + System.out.println("########### Starting dump Step inter chromosomal interactions"); + + _parameterCheck.optionalParametersValidity(_sipIntra); + processDumpData.go(_input, _sipIntra, _juicerTool, _juicerNorm); + System.out.println("########### End of the dump step\n"); + + System.out.println("########### Start loop detection\n"); + MultiResProcess multi = new MultiResProcess(_sipIntra, _chrSizeFile); + multi.run(); + System.out.println("###########End loop detection step\n"); + return allParam; + } + /** * + * @throws IOException + */ + private String runInter() throws IOException, InterruptedException { + ProcessDumpData processDumpData = new ProcessDumpData(); + + this.setSipInter(); + _sipInter.setIsGui(_isGui); + _sipIntra.setIsProcessed(false); + _sipIntra.setIsCooler(false); + + String allParam = "SIPHiC hic: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "juiceBox: "+ _juicerTool +"\n"+ + "norm: "+ _juicerNorm +"\n" + + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipInter.getGauss()+"\n"+ + "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ + "resolution: "+this._sipInter.getResolution()+"\n"+ + "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ + "number of zero :"+_nbZero+"\n"+ + "fdr "+this._sipInter.getFdr()+"\n"+ + "delete images "+_delImages+"\n"+ + "cpu "+ _cpu+"\n"; + processDumpData.go(_input,_sipInter, _juicerTool, _juicerNorm); + + String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; + + ProcessDetectLoops detectLoops = new ProcessDetectLoops(); + detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); + + return allParam; + + } + + + /** * */ - private void setSipIntra(){ + private void setSipIntraCLI(){ double min = 2.0; double max = 2.0; double gauss = 1.5; @@ -202,46 +252,49 @@ private void setSipIntra(){ ArrayList factor = new ArrayList(); factor.add(1); - if(_isGui){ - min = this._guiAnalysis.getMin(); - max = this._guiAnalysis.getMax(); - gauss = this._guiAnalysis.getGaussian(); - matrixSize = this._guiAnalysis.getMatrixSize(); - thresholdMax = this._guiAnalysis.getThresholdMaxima(); - fdr = this._guiAnalysis.getFDR(); - resolution = this._guiAnalysis.getResolution(); - diagSize = this._guiAnalysis.getDiagSize(); - saturatedPixel = this._guiAnalysis.getSaturatedPixell(); - isDroso= this._guiAnalysis.isDroso(); - - if(this._guiAnalysis.getFactorChoice() == 2) factor.add(2); - else if(this._guiAnalysis.getFactorChoice() == 4){ + if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); + if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); + if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); + if (_cmd.hasOption("factor")) { + _factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); + if (_factorParam == 2) factor.add(2); + else if (_factorParam == 4) { factor.add(2); factor.add(5); - }else if(this._guiAnalysis.getFactorChoice() == 3) factor.add(5); - }else { - if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); - if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); - if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); - if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); - if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); - if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); - if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); - if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); - if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); - if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); - if (_cmd.hasOption("factor")) { - _factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); - if (_factorParam == 2) factor.add(2); - else if (_factorParam == 4) { - factor.add(2); - factor.add(5); - } else factor.add(5); - - } + } else factor.add(5); + } - _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, - thresholdMax, diagSize, matrixSize, _nbZero, factor, fdr, false, isDroso); + _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, + thresholdMax, diagSize, matrixSize, _nbZero, factor, fdr, isDroso,_delImages, _cpu); + + } + /** + * + * + */ + private void setSipIntraGUI(){ + + ArrayList factor = new ArrayList(); + factor.add(1); + + if(this._guiAnalysis.getFactorChoice() == 2) factor.add(2); + else if(this._guiAnalysis.getFactorChoice() == 4){ + factor.add(2); + factor.add(5); + }else if(this._guiAnalysis.getFactorChoice() == 3) factor.add(5); + + _sipIntra = new SIPIntra(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getMin(), + _guiAnalysis.getMax(), _guiAnalysis.getResolution(), _guiAnalysis.getSaturatedPixel(), + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getDiagSize(), _guiAnalysis.getMatrixSize(), + _nbZero, factor, _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); + } @@ -250,27 +303,25 @@ else if (_factorParam == 4) { * */ private void setSipInter() throws IOException { - double gauss = 1; - int matrixSize = 500; - double thresholdMax = 0.01; - double fdr = 0.025; - int resolution = 100000; + if(_isGui){ - gauss = this._guiAnalysis.getGaussian(); - matrixSize = this._guiAnalysis.getMatrixSize(); - thresholdMax = this._guiAnalysis.getThresholdMaxima(); - fdr = this._guiAnalysis.getFDR(); - resolution = this._guiAnalysis.getResolution(); + _sipInter = new SIPInter(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getMatrixSize(), _nbZero, _guiAnalysis.getFDR(), _delImages,_cpu); }else{ + double gauss = 1; + int matrixSize = 500; + double thresholdMax = 0.01; + double fdr = 0.025; + int resolution = 100000; if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + _sipInter = new SIPInter(_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, fdr, _delImages,_cpu); } - _sipInter = new SIPInter(_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, _delImages, fdr); } } diff --git a/src/process/ParametersCheck.java b/src/process/ParametersCheck.java index 8a2aba8..fd03e74 100644 --- a/src/process/ParametersCheck.java +++ b/src/process/ParametersCheck.java @@ -2,6 +2,7 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; +import sip.SIPInter; import sip.SIPIntra; import sip.SIPObject; @@ -56,41 +57,49 @@ public ParametersCheck(String input, String output, String chrSizeFile, String i /** * */ - public void testCommonParametersValidity(SIPObject sip){ + public void optionalParametersValidity(SIPObject sip){ - - /*if(_cmd.hasOption("resolution")){ - int res = Integer.parseInt(_cmd.getOptionValue("resolution")); - if(res <= 0 ){ - System.out.println("-r "+res+", resolution need to be a >= 0 !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - - } + if(sip.getResolution() <= 0 ){ + System.out.println("-r "+sip.getResolution()+", resolution need to be a >= 0 !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); } - int nbZero = sip.getNbZero(); - if (nbZero > 24|| nbZero < 0) { - System.out.println("\n-nbZero"+ nbZero+" value invalid: choose an integer value between 0 and 24\n"); - //erreur mettre l'aide et stopper le prog. + if (sip.getNbZero() > 24|| sip.getNbZero() < 0) { + System.out.println("\n-nbZero"+ sip.getNbZero() +" value invalid: choose an integer value between 0 and 24\n"); + //erreur mettre l'aide et stopper le prog. System.exit(0); } + if(sip.getCpu() > Runtime.getRuntime().availableProcessors() || sip.getCpu() <= 0){ + System.out.println("\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + System.exit(0); + } - boolean delImages = true; - if (_cmd.hasOption("delete")) delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + if(sip.getFdr() < 0 ){ + System.out.println("-fdr "+sip.getFdr()+", fdr need to be a >= 0 !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } - int cpu = 1; - if (_cmd.hasOption("cpu")){ - cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); - if(cpu > Runtime.getRuntime().availableProcessors() || cpu <= 0){ - System.out.println("\nThe number of CPU "+ cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + if(sip.getMatrixSize() < 0 ){ + System.out.println("-ms "+sip.getMatrixSize()+", matrix size need to be a > 0 !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } - System.exit(0); - } + if(sip.getGauss() < 0 ){ + System.out.println("-g "+sip.getGauss()+", gaussian strength filter need to be a > 0 !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); + } + + if(sip.getThresholdMaxima() < 0 ){ + System.out.println("-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); + System.out.println(getHelperInfos()); + System.exit(1); } - */ } /** @@ -113,6 +122,21 @@ public void testHiCOption(String juicerTool, String juicerNorm){ } } + /** + * + */ + public void speOption(SIPIntra sipIntra){ + + } + + /** + * + */ + public void speOption(SIPInter sipInter){ + + + } + /** * */ diff --git a/src/sip/SIPInter.java b/src/sip/SIPInter.java index 8b65598..deddfd6 100644 --- a/src/sip/SIPInter.java +++ b/src/sip/SIPInter.java @@ -27,12 +27,12 @@ public class SIPInter extends SIPObject { * @param thresholdMax threshold value for loops detection * @param matrixSize image size * @param nbZero nb of zero allowed around a loop - * @param keepTif true to keep image creat by SIP * @param fdr fdr value for the final loops filter * @throws IOException exception */ - public SIPInter(String output,String chrSize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, boolean keepTif,double fdr) throws IOException { - super(output, gauss, resolution, thresholdMax,matrixSize, nbZero, fdr, keepTif,chrSize) ; + public SIPInter(String output,String chrSize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero,double fdr, + boolean delTif, int cpu) throws IOException { + super(output, gauss, resolution, thresholdMax,matrixSize, nbZero, fdr,chrSize, delTif, cpu) ; } @@ -47,14 +47,13 @@ public SIPInter(String output,String chrSize, double gauss, int resolution, dou * @param thresholdMax threshold value for loops detection * @param matrixSize image size * @param nbZero nb of zero allowed around a loop - * @param keepTif true to keep image creat by SIP * @param fdr fdr value for the final loops filter * @throws IOException exception */ public SIPInter(String input,String output,String chrSize, double gauss, int resolution, - double thresholdMax, int matrixSize, int nbZero, boolean keepTif, double fdr){ + double thresholdMax, int matrixSize, int nbZero, double fdr, boolean delTif, int cpu){ - super(input, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize); + super(input, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize, delTif, cpu); } diff --git a/src/sip/SIPIntra.java b/src/sip/SIPIntra.java index 1bfdc10..a7b130e 100644 --- a/src/sip/SIPIntra.java +++ b/src/sip/SIPIntra.java @@ -71,15 +71,14 @@ public SIPIntra() { } * @param nbZero number of zero allowed around loops * @param listFactor multi resolution calling loops used this list of factor * @param fdr fdr value for final loops filtering - * @param isProcessed true if processed SIP data input else false - * @param rFDR false if it isn't drosophila input + * @param isDroso false if it isn't drosophila input */ public SIPIntra(String output, String chrFile, double gauss, double min, double max, int resolution, double saturatedPixel, double thresholdMax, int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, - double fdr, boolean isProcessed, boolean rFDR) { + double fdr, boolean isDroso, boolean delImage, int cpu) { - super( output, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrFile); + super( output, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrFile, delImage, cpu); @@ -89,7 +88,7 @@ public SIPIntra(String output, String chrFile, double gauss, double min, this._diagonalSize = diagonalSize; this._step = matrixSize/2; this._listFactor = listFactor; - this._isDroso = rFDR; + this._isDroso = isDroso; } /** @@ -113,9 +112,9 @@ public SIPIntra(String output, String chrFile, double gauss, double min, public SIPIntra(String input, String output, String chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, double thresholdMax, int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, - double fdr) { + double fdr, boolean isDroso, boolean delImage, int cpu) { - super( input, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize); + super( input, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize, delImage,cpu ); this._min = min; @@ -124,6 +123,7 @@ public SIPIntra(String input, String output, String chrSize, double gauss, doubl this._diagonalSize = diagonalSize; this._step = matrixSize/2; this._listFactor = listFactor; + this._isDroso = isDroso; } diff --git a/src/sip/SIPObject.java b/src/sip/SIPObject.java index a9f97cc..a092e1c 100644 --- a/src/sip/SIPObject.java +++ b/src/sip/SIPObject.java @@ -41,11 +41,12 @@ public class SIPObject { /** if data set is mcool format*/ private boolean _isCooler; /** */ - private boolean _keepTif; + private boolean _delImage; /** HashMap of the chr size, the key = chr name, value = size of chr*/ private HashMap _chrSizeHashMap = new HashMap(); /** */ private String _chrSizeFile; + private int _cpu; /** * @@ -58,7 +59,8 @@ public class SIPObject { * @param nbZero * @param fdr */ - public SIPObject (String input, String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile){ + public SIPObject (String input, String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile, + boolean delTif, int cpu){ if(!output.endsWith(File.separator)) output = output+File.separator; if(!input.endsWith(File.separator)) input = input+File.separator; this._input = input; @@ -71,6 +73,8 @@ public SIPObject (String input, String output, double gauss, int resolution, dou this._fdr = fdr; this._chrSizeFile = chrSizeFile; setChrSize(this._chrSizeFile); + this._delImage = delTif; + this._cpu = cpu; } /** @@ -82,9 +86,9 @@ public SIPObject (String input, String output, double gauss, int resolution, dou * @param matrixSize * @param nbZero * @param fdr - * @param keepTif */ - public SIPObject ( String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr,boolean keepTif, String chrSizeFile ){ + public SIPObject ( String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile, + boolean delTif, int cpu){ this._output = output; this._gauss = gauss; @@ -92,10 +96,11 @@ public SIPObject ( String output, double gauss, int resolution, double threshold this._thresholdMaxima = thresholdMax; this._matrixSize = matrixSize; this._nbZero = nbZero; - this._keepTif = keepTif; _fdr = fdr; this._chrSizeFile = chrSizeFile; setChrSize(this._chrSizeFile); + this._delImage = delTif; + this._cpu = cpu; @@ -106,6 +111,27 @@ public SIPObject(){ } + /** + * getter of cpu parameter + * @return nb of cpu + */ + public String getChrSizeFile() { return this._chrSizeFile; } + + /** + * getter of cpu parameter + * @return nb of cpu + */ + public int getCpu() { return this._cpu; } + + /** + * setter of cpu number + * @param cpu number + * + */ + public void setCpu(int cpu) { this._cpu = cpu; } + + + /** * getter of fdr parameter * @return fdr value @@ -329,7 +355,8 @@ public void setChrSize(String chrSizeFile) { * * @param keepTif */ - public void setIsKeepTif(boolean keepTif) { - this._keepTif = keepTif; + public void setDelImage(boolean keepTif) { + this._delImage = keepTif; } + public boolean isDelImage() { return _delImage; } } diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 8fa2b52..aa75716 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -178,7 +178,7 @@ public static void main(String[] args) throws Exception { _min = gui.getMin(); _isDroso= gui.isDroso(); _nbZero = gui.getNbZero(); - _saturatedPixel = gui.getSaturatedPixell(); + _saturatedPixel = gui.getSaturatedPixel(); _thresholdMax = gui.getThresholdMaxima(); _fdr = gui.getFDR(); _cpu = gui.getNbCpu(); diff --git a/src/test/TestCallLoopsHicFile.java b/src/test/TestCallLoopsHicFile.java index 4cac389..f20e1af 100644 --- a/src/test/TestCallLoopsHicFile.java +++ b/src/test/TestCallLoopsHicFile.java @@ -74,12 +74,12 @@ public static void main(String[] args) throws IOException, InterruptedException File file = new File(output); if (file.exists()==false){file.mkdir();} - SIPIntra sip = new SIPIntra(output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,keepTif,false); + SIPIntra sip = new SIPIntra(output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false, keepTif,cpu ); sip.setIsGui(false); ProcessDumpData processDumpData = new ProcessDumpData(); - processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation,cpu); + processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation); - MultiResProcess multi = new MultiResProcess(sip, cpu, keepTif,fileChr); + MultiResProcess multi = new MultiResProcess(sip, fileChr); multi.run(); //String cooler = "/home/plop/anaconda3/bin/cooler"; //String cooltools = "/home/plop/anaconda3/bin/cooltools"; diff --git a/src/test/TestCallLoopsProcessedFile.java b/src/test/TestCallLoopsProcessedFile.java index 03a723d..0a8ae6e 100644 --- a/src/test/TestCallLoopsProcessedFile.java +++ b/src/test/TestCallLoopsProcessedFile.java @@ -38,9 +38,9 @@ public static void main(String[] args) throws IOException, InterruptedException //factor.add(5); //SIP_HiC_v1.3.6.jar hic SIP/Kc_allcombined.hic SIP/armsizes.txt SIP/Droso/ ../Tools/juicer_tools_1.13.02.jar String chrSizeFile = "/home/plop/Desktop/w_hg19.sizes"; - SIPIntra sip = new SIPIntra(input,output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01); + SIPIntra sip = new SIPIntra(input,output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, + thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false,true,2); sip.setIsGui(false); - sip.setIsDroso(false); sip.setIsProcessed(true); int cpu = 2; System.out.println("Processed Data\n"); @@ -56,7 +56,7 @@ public static void main(String[] args) throws IOException, InterruptedException + "threshold "+thresholdMax+"\n" + "isProcessed "+sip.isProcessed()+"\n"); System.out.println("ahhhhhhhhhhhhh\n"); - MultiResProcess multi = new MultiResProcess(sip, cpu, false,chrSizeFile); + MultiResProcess multi = new MultiResProcess(sip, chrSizeFile); multi.run(); //ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); //processDetectloops.go(sip, 2,false); diff --git a/src/test/TestCoolFormat.java b/src/test/TestCoolFormat.java index 0daf1a3..37edae0 100644 --- a/src/test/TestCoolFormat.java +++ b/src/test/TestCoolFormat.java @@ -42,18 +42,20 @@ public static void main(String[] args) throws IOException, InterruptedException boolean keepTif = false; int cpu = 1; - SIPIntra sip = new SIPIntra(input,output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03); + SIPIntra sip = new SIPIntra(input,output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, + diagSize, matrixSize, nbZero,factor,0.03,false,keepTif,cpu); + sip.setIsGui(false); sip.setIsCooler(true); sip.setIsProcessed(true); - sip.setIsDroso(false); - sip.setIsKeepTif(keepTif); + + //ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); // go(String coolTools, String cooler, SIPIntra sip, String coolFile, HashMap chrSize,int nbCPU) //processDumpData.go(cooltools, cooler, sip, input, chrsize,2); - MultiResProcess multi = new MultiResProcess(sip, cpu, keepTif,fileChr); + MultiResProcess multi = new MultiResProcess(sip,fileChr); multi.run(); System.out.println("end"); diff --git a/src/test/TestGui.java b/src/test/TestGui.java index e319a7f..653b288 100644 --- a/src/test/TestGui.java +++ b/src/test/TestGui.java @@ -38,7 +38,7 @@ public static void main(String[] args) throws IOException, InterruptedException{ double gauss = gui.getGaussian(); double max = gui.getMax(); double min = gui.getMin(); - double saturatedPixel = gui.getSaturatedPixell(); + double saturatedPixel = gui.getSaturatedPixel(); int thresholdMax = gui.getThresholdMaxima(); boolean isHic = gui.isHic(); boolean isProcessed = gui.isProcessed(); @@ -58,17 +58,18 @@ public static void main(String[] args) throws IOException, InterruptedException{ System.out.println("hic mode:\ninput: "+input+"\noutput: "+output+"\njuiceBox: "+juiceBoxTools+"\nnorm: "+ juiceBoXNormalisation+"\ngauss: "+gauss+"\n" + "min: "+min+"\nmax: "+max+"\nmatrix size: "+matrixSize+"\ndiag size: "+diagSize+"\nresolution: "+resolution+"\nsaturated pixel: "+saturatedPixel +"\nthreshold: "+thresholdMax+"\n number of zero:"+nbZero+"\n "); - sip = new SIPIntra(output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,gui.isProcessed(),false); + sip = new SIPIntra(output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false,true,2); sip.setIsGui(true); ProcessDumpData processDumpData = new ProcessDumpData(); - processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation,gui.getNbCpu()); + processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation); }else{ System.out.println("processed mode:\ninput: "+input+"\noutput: "+output+"\njuiceBox: "+juiceBoxTools+"\nnorm: "+ juiceBoXNormalisation+"\ngauss: "+gauss +"\nmin: "+min+"\nmax: "+max+"\nmatrix size: "+matrixSize+"\ndiag size: "+diagSize+"\nresolution: "+resolution+"\nsaturated pixel: "+saturatedPixel +"\nthreshold: "+thresholdMax+"\nisHic: "+isHic+"\nisProcessed: "+isProcessed+"\n number of zero:" +nbZero+"\n"); - sip = new SIPIntra(input,output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01); - sip.setIsDroso(false); + sip = new SIPIntra(input,output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, + diagSize, matrixSize, nbZero,factor,0.01,false, true ,2); + sip.setIsProcessed(gui.isProcessed()); sip.setIsGui(true); } diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 4abd1e5..d7955a4 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -26,7 +26,7 @@ public static void main(String[] args) throws IOException, InterruptedException boolean keepTif = true; int cpu = 2; - SIPInter sipInter = new SIPInter(input, output, fileChr, gauss, resolution, thresholdMax, matrixSize, nbZero,keepTif,0.025); + SIPInter sipInter = new SIPInter(input, output, fileChr, gauss, resolution, thresholdMax, matrixSize, nbZero,0.025,keepTif,cpu); //ProcessDumpData process = new ProcessDumpData(); //process.go(input,sipInter,chrsize,juicerTools,norm,2); diff --git a/src/utils/MultiResProcess.java b/src/utils/MultiResProcess.java index 5adf555..40d1e81 100644 --- a/src/utils/MultiResProcess.java +++ b/src/utils/MultiResProcess.java @@ -30,10 +30,7 @@ public class MultiResProcess { /** SIP object*/ private SIPIntra _sip; - /** number of cpu */ - private int _nbCpu; - /** boolean delImage*/ - private boolean _delImage; + /** path to chr size file*/ private String _chrFile; @@ -42,14 +39,10 @@ public class MultiResProcess { * Constructor * * @param sip SIPIntra - * @param cpu number of cpu - * @param delImage delete image boolean * @param chrSizeFile path of chrSize file */ - public MultiResProcess(SIPIntra sip, int cpu, boolean delImage, String chrSizeFile) { - this._nbCpu = cpu; + public MultiResProcess(SIPIntra sip, String chrSizeFile) { this._sip = sip; - this._delImage = delImage; this._chrFile = chrSizeFile; } @@ -86,35 +79,32 @@ public void run() throws InterruptedException, IOException{ File file = new File(resuFile); if(file.exists()) file.delete(); - SIPIntra sipTmp = new SIPIntra(); if(indexFact == 0) { ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); - processDetectloops.go(this._sip, this._nbCpu,this._delImage,resuFile,resName); + processDetectloops.go(this._sip, resuFile,resName); }else { - sipTmp.setInputDir(_sip.getOutputDir()); - sipTmp.setOutputDir(_sip.getOutputDir()); + + int matrixSizeTpm = (int)(this._sip.getMatrixSize()/listFactor.get(indexFact)); + double gaussTpm = this._sip.getGauss()/listFactor.get(indexFact); + SIPIntra sipTmp = new SIPIntra(_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, + _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), + _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getListFactor(), + _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); + if(this._sip.isProcessed()) { - sipTmp.setInputDir(_sip.getInputDir()); - sipTmp.setOutputDir(_sip.getOutputDir()); + sipTmp = new SIPIntra(_sip.getInputDir(),_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, + _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), + _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getListFactor(), + _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); } - sipTmp.setChrSizeHashMap(this._sip.getChrSizeHashMap()); sipTmp.setIsGui(_sip.isGui()); - sipTmp.setDiagonalSize(this._sip.getDiagonalSize()); - sipTmp.setGauss(this._sip.getGauss()/listFactor.get(indexFact)); - sipTmp.setMatrixSize((int)(this._sip.getMatrixSize()/listFactor.get(indexFact))); - sipTmp.setResolution(res); sipTmp.setStep(this._sip.getStep()/listFactor.get(indexFact)); - sipTmp.setMax(_sip.getMax()); - sipTmp.setMin(_sip.getMin()); - sipTmp.setSaturatedPixel(_sip.getSaturatedPixel()); - sipTmp.setThresholdMaxima(_sip.getThresholdMaxima()); - sipTmp.setNbZero(_sip.getNbZero()); sipTmp.setIsProcessed(_sip.isProcessed()); sipTmp.setFdr(_sip.getFdr()); - sipTmp.setIsDroso(_sip.isDroso()); sipTmp.setIsCooler(_sip.isCooler()); + ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); - processDetectloops.go(sipTmp, this._nbCpu,this._delImage,resuFile,resName); + processDetectloops.go(sipTmp,resuFile,resName); } } if(listOfFile.size() > 1) { From ec0f22d0e4b756b399aed296555ebae499cf27be Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Wed, 18 Nov 2020 21:01:08 -0500 Subject: [PATCH 16/27] Ended modifcation of ParameterCheck class Starting CLIHelper class --- src/cli/CLIHelper.java | 114 +++++++++++++++ src/cli/CLIOptionCool.java | 74 ++++++++++ src/cli/CLIOptionHiC.java | 64 ++++---- src/cli/CLIOptionMCool.java | 53 ------- src/cli/CLIOptionProcessed.java | 141 ++++++++++++++++++ src/cli/CLISipOption.java | 178 ----------------------- src/process/HiC.java | 39 ++--- src/process/ParametersCheck.java | 145 ++++++++++-------- src/sip/SIPIntra.java | 32 +++- src/sipMain/Hic_main.java | 17 +-- src/test/TestCallLoopsHicFile.java | 6 +- src/test/TestCallLoopsProcessedFile.java | 4 +- src/test/TestCoolFormat.java | 6 +- src/test/TestGui.java | 5 +- src/utils/MultiResProcess.java | 5 +- 15 files changed, 510 insertions(+), 373 deletions(-) create mode 100644 src/cli/CLIHelper.java create mode 100644 src/cli/CLIOptionCool.java delete mode 100644 src/cli/CLIOptionMCool.java create mode 100644 src/cli/CLIOptionProcessed.java delete mode 100644 src/cli/CLISipOption.java diff --git a/src/cli/CLIHelper.java b/src/cli/CLIHelper.java new file mode 100644 index 0000000..bef21f3 --- /dev/null +++ b/src/cli/CLIHelper.java @@ -0,0 +1,114 @@ +package cli; + +import org.apache.commons.cli.HelpFormatter; + +import java.io.PrintWriter; + +public class CLIHelper { + + /** */ + private static String _version ="1.6.1"; + + /** */ + private static String _hic ="java -jar SIPHiC"+ _version +".jar hic "; + /** */ + private static String _cool ="java -jar SIPHiC"+ _version +".jar cool "; + /** */ + private static String processed ="java -jar SIPHiC"+ _version +".jar processed "; + + /* Constructor*/ + + public CLIHelper(){ } + + + public static void main(String[] args) throws Exception{ + + CmdHelpCool(); + } + + + + /** + * Method get help for command line + * with example command line + */ + public static void CmdHelpHiC() { + String argument = "-i path/to/hicFile.hic -c path/to/chrSizeFile.txt -o path/to/output/folder -j path/to/juicerTool.jar -lt intra "; + String[] argv = argument.split(" "); + CLIOptionHiC command = new CLIOptionHiC (argv); + String usage = _cool+argument+" [options]"; + HelpFormatter formatter = new HelpFormatter(); + + System.out.println("\nHelp for "+_cool+"!!!!!!! \n"); + formatter.printHelp(200, usage, "SIP_HiC option hic : ", command.getOptions(),getAuthors()); + System.exit(1); + } + + + /** + * Method get help for command line + * with example command line + */ + public static void CmdHelpCool() { + String argument = "-i path/to/hicFile.hic -c path/to/chrSizeFile.txt -o path/to/output/folder -cooltools path/to/cooltools -cooler path/to/cooler -lt intra "; + String[] argv = argument.split(" "); + CLIOptionCool command = new CLIOptionCool (argv); + String usage = _hic+argument+" [options]"; + HelpFormatter formatter = new HelpFormatter(); + + System.out.println("\nHelp for "+_hic+"!!!!!!! \n"); + formatter.printHelp(200, usage, "SIP_HiC option hic : ", command.getOptions(),getAuthors()); + System.exit(1); + } + + + /** + * + * @return + */ + public static String getHelperInfos() { + return "More details :\n" + + "java -jar SIPHiC"+ _version +".jar hic --help \n" + + "or \n"+ + "java -jar SIPHiC-"+ _version +".jar cool -h or --help\n"+ + "or \n" + + "java -jar SIPHiC-"+ _version +".jar processed -h or --help \n" + + "\n\nCommand line g:\n" + + "\tjava -jar SIP_HiC.jar hic -i hicFile -c chrSizeFile -o Output -j juicerTool -tl inter [options]\n" + + "\tjava -jar SIP_HiC.jar cool -i mcoolFile -c chrSizeFile -o Output -cooltools cooltoolsPath -cooler coolerPath -tl inter [options]\n" + + "\tjava -jar SIP_HiC.jar processed [options]\n"; + + } + + /** + * + * @return + */ + public static String getAuthors() { + return "Authors:\n" + + "\nAxel Poulet\n" + + "Department of Molecular, Cellular and Developmental Biology Yale University \n" + + "\nM. Jordan Rowley\n" + + "Department of Genetics, Cell Biology and Anatomy, University of Nebraska Medical\n" + + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"; + } + + + + /** + * + * @return + */ + private String getCool() { + return "-i mcoolFile -c chrSizeFile -o Output -cooltools cooltoolsPath -cooler coolerPath -tl intra"; + } + + /** + * + * @return + */ + private String getPocessed() { + return "-i PathDirectoryWithProcessedData -c chrSizeFile --o Output -tl intra "; + } + +} diff --git a/src/cli/CLIOptionCool.java b/src/cli/CLIOptionCool.java new file mode 100644 index 0000000..e7c8a3e --- /dev/null +++ b/src/cli/CLIOptionCool.java @@ -0,0 +1,74 @@ +package cli; + +import org.apache.commons.cli.*; + +/** + * + */ +public class CLIOptionCool extends CLIOptionProcessed { + /** */ + private CommandLine _commandLine; + /** + * + * @param args + * @throws Exception + */ + public CLIOptionCool(String [] args){ + this._options.addOption(_inputFolder); + this._options.addOption(_outputFolder); + this._options.addOption(_chrSize); + this._options.addOption(_interOrIntra); + + /*optional parameters*/ + this._options.addOption(_resolution); + this._options.addOption(_deleteImage); + this._options.addOption(_fdr); + this._options.addOption(_nbZero); + this._options.addOption(_sizeImage); + this._options.addOption(_cpu); + this._options.addOption(_gaussianStrength); + this._options.addOption(_threshold); + this._options.addOption(_diagonal); + this._options.addOption(_factor); + this._options.addOption(_max); + this._options.addOption(_min); + this._options.addOption(_saturated); + this._options.addOption(_isDroso); + + this._options.addOption(Option.builder("cooltools").longOpt("cooltools").required() + .type(String.class).desc("Path to cooltools bin\n").numberOfArgs(1).build()); + + this._options.addOption(Option.builder("cooler").longOpt("cooler").required() + .type(String.class).desc("Path to cooler bin\n").numberOfArgs(1).build()); + + + try { + _commandLine = _parser.parse(this._options, args); + } + catch (ParseException exp){ + System.out.println(exp.getMessage()+"\n"); + System.out.println(CLIHelper.getHelperInfos()+"\n"+CLIHelper.getAuthors()); + System.exit(1); + } + + } + + + + /** + * + * @return + */ + public CommandLine getCommandLine() { + return _cmd; + } + + /** + * + * @return + */ + public Options getOptions() { + return _options; + } + +} diff --git a/src/cli/CLIOptionHiC.java b/src/cli/CLIOptionHiC.java index 20b05a7..20e26b9 100644 --- a/src/cli/CLIOptionHiC.java +++ b/src/cli/CLIOptionHiC.java @@ -2,39 +2,43 @@ import org.apache.commons.cli.*; -import java.io.File; - -public class CLIOptionHiC extends CLISipOption{ - - /** */ - private CommandLine _commandLine; - - public CLIOptionHiC(String [] args)throws Exception{ - super(args); - HelpFormatter formatter ; - CommandLineParser parser= new DefaultParser(); - CommandLine cmd = this._cmd; - +public class CLIOptionHiC extends CLIOptionProcessed { + + + + public CLIOptionHiC(String [] args){ + this._options.addOption(_inputFolder); + this._options.addOption(_outputFolder); + this._options.addOption(_chrSize); + this._options.addOption(_interOrIntra); + + /*optional parameters*/ + this._options.addOption(_resolution); + this._options.addOption(_deleteImage); + this._options.addOption(_fdr); + this._options.addOption(_nbZero); + this._options.addOption(_sizeImage); + this._options.addOption(_cpu); + this._options.addOption(_gaussianStrength); + this._options.addOption(_threshold); + this._options.addOption(_diagonal); + this._options.addOption(_factor); + this._options.addOption(_max); + this._options.addOption(_min); + this._options.addOption(_saturated); + this._options.addOption(_isDroso); this._options.addOption(Option.builder("j").longOpt("juicerTool").required() .type(String.class).desc("Path to juicerTool.jar\n").numberOfArgs(1).build()); this._options.addOption(Option.builder("n").longOpt("norm") - .type(String.class).desc(" (default KR)\n").numberOfArgs(1).build()); + .type(String.class).desc("\n (default KR)\n").numberOfArgs(1).build()); - - - String typeOfLoop = cmd.getOptionValue("tl"); - if(typeOfLoop.equals("inter")){ - this.addInterChange(); - }else{ - this.addIntraParam(); - } - try { - _commandLine = parser.parse(this._options, args); + try { + this._cmd = this._parser.parse(this._options, args,true); } catch (ParseException exp){ System.out.println(exp.getMessage()+"\n"); - System.out.println(getHelperInfos()); + // System.out.println(getHelperInfos()); System.exit(1); } @@ -46,6 +50,14 @@ public CLIOptionHiC(String [] args)throws Exception{ * @return */ public CommandLine getCommandLine() { - return _commandLine; + return _cmd; + } + + /** + * + * @return + */ + public Options getOptions() { + return _options; } } diff --git a/src/cli/CLIOptionMCool.java b/src/cli/CLIOptionMCool.java deleted file mode 100644 index 64f5ead..0000000 --- a/src/cli/CLIOptionMCool.java +++ /dev/null @@ -1,53 +0,0 @@ -package cli; - -import org.apache.commons.cli.*; - -/** - * - */ -public class CLIOptionMCool extends CLISipOption{ - /** */ - private CommandLine _commandLine; - /** - * - * @param args - * @throws Exception - */ - public CLIOptionMCool (String [] args)throws Exception{ - super(args); - HelpFormatter formatter ; - CommandLineParser parser= new DefaultParser(); - CommandLine cmd = this._cmd; - String typeOfLoop = cmd.getOptionValue("tl"); - this._options.addOption(Option.builder("cooltools").longOpt("cooltools").required() - .type(String.class).desc("Path to cooltools bin\n").numberOfArgs(1).build()); - - this._options.addOption(Option.builder("cooler").longOpt("cooler").required() - .type(String.class).desc("Path to cooler bin\n").numberOfArgs(1).build()); - - - if(typeOfLoop.equals("inter")){ - this.addInterChange(); - }else{ - this.addIntraParam(); - } - try { - _commandLine = parser.parse(this._options, args); - } - catch (ParseException exp){ - System.out.println(exp.getMessage()+"\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - } - - /** - * - * @return - */ - public CommandLine getCommandLine() { - return _commandLine; - } - -} diff --git a/src/cli/CLIOptionProcessed.java b/src/cli/CLIOptionProcessed.java new file mode 100644 index 0000000..886dafb --- /dev/null +++ b/src/cli/CLIOptionProcessed.java @@ -0,0 +1,141 @@ +package cli; +import org.apache.commons.cli.*; + +/** + * + */ +public class CLIOptionProcessed { + + /** */ + Options _options= new Options(); + /** */ + CommandLine _cmd; + /** */ + Option _inputFolder= Option.builder("i").longOpt("input").required() + .type(String.class).desc("Path to input .hic, .mcool or SIP folder containing processed data\n") + .numberOfArgs(1).build(); + /** */ + Option _outputFolder= Option.builder("o").longOpt("output").required() + .type(String.class).desc("Path to output folder for SIP's files \n") + .numberOfArgs(1).build(); + /** */ + Option _chrSize = Option.builder("c").longOpt("chrSize").required() + .type(String.class).desc("Path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1).\n") + .numberOfArgs(1).build(); + /** */ + Option _resolution = Option.builder("r").longOpt("resolution") + .type(Number.class).desc("Resolution in bp (default inter 5000 bp, intra 100 000 bp)\n") + .numberOfArgs(1).build(); + /** */ + Option _sizeImage = Option.builder("ms").longOpt("matrixSize") + .type(Number.class).desc("Matrix size to use for each chunk of the chromosome (default intra 2000 bins, inter 500)\n") + .numberOfArgs(1).build(); + /** */ + Option _cpu = Option.builder("cpu") + .type(Number.class).desc("Number of CPU used for SIP processing (default 1)\n") + .numberOfArgs(1).build(); + /** */ + Option _gaussianStrength = Option.builder("g").longOpt("gaussian") + .type(Number.class).desc("Gaussian filter: smoothing factor to reduce noise during primary loop detection (default intra 1.5, inter 1)\n") + .numberOfArgs(1).build(); + /** */ + Option _threshold = Option.builder("t").longOpt("threshold") + .type(Number.class).desc("Threshold for loops detection (default intra 2800, inter 0.01)\n") + .numberOfArgs(1).build(); + /** */ + Option _nbZero = Option.builder("nbZero") + .type(Number.class).desc("Number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected loop (default 6)\n") + .numberOfArgs(1).build(); + /** */ + Option _fdr = Option.builder("fdr") + .type(Number.class).desc("Empirical FDR value for filtering based on random sites (default intra value: 0.01, inter value: 0.025)\n") + .numberOfArgs(1).build(); + /** */ + Option _deleteImage = Option.builder("d").longOpt("delete") + .type(boolean.class).desc("Delete tif files used for loop detection (default true)\n") + .build(); + /** */ + Option _interOrIntra = Option.builder("lt").longOpt("loopsType").required() + .type(String.class).desc("value: inter or intra, call loops inter chromosomal or intra chromosomal interactions\n") + .build(); + /** */ + Option _isDroso = Option.builder("isDroso") + .type(boolean.class).desc("If true apply extra filter to help detect loops similar to those found in D. mel cells (Default: false, used only for intra chromosomal)\n") + .build(); + /** */ + Option _diagonal = Option.builder("d").longOpt("diagonal") + .type(Number.class).desc("diagonal size in bins, remove loops found at this size (eg: a size of 2 at 5000 bp resolution removes all loops\n" + + " detected at a distance inferior or equal to 10kb) (default: 6 bins, used only for intra chromosomal).\n") + .numberOfArgs(1).build(); + /** */ + Option _factor = Option.builder("f").longOpt("factor") + .type(Number.class).desc(" Multiple resolutions can be specified using (used only for intra chromosomal):\n" + + "\t\t-factor 1: run only for the input res (default)\n" + + "\t\t-factor 2: res and res*2\n" + + "\t\t-factor 3: res and res*5\n" + + "\t\t-factor 4: res, res*2 and res*5\n") + .numberOfArgs(1).build(); + + /** */ + Option _min = Option.builder("min").longOpt("minimum") + .type(Number.class).desc("Minimum filter strength (default 2, used only for intra chromosomal)\n") + .numberOfArgs(1).build(); + /** */ + Option _max = Option.builder("max").longOpt("maximum") + .type(Number.class).desc("Maximum filter strength (default 2, used only for intra chromosomal)\n") + .numberOfArgs(1).build(); + /** */ + Option _saturated = Option.builder("sat").longOpt("saturated") + .type(Number.class).desc("% of saturated pixel: enhances the contrast in the image (default 0.01, used only for intra chromosomal)\n") + .numberOfArgs(1).build(); + + /** + * Command line parser + */ + CommandLineParser _parser= new DefaultParser(); + + + public CLIOptionProcessed() { + + } + + /** + * + * @param args + * @throws Exception + */ + public CLIOptionProcessed(String[] args)throws Exception { + /*required parameters*/ + this._options.addOption(_inputFolder); + this._options.addOption(_outputFolder); + this._options.addOption(_chrSize); + this._options.addOption(_interOrIntra); + + /*optional parameters*/ + this._options.addOption(_resolution); + this._options.addOption(_deleteImage); + this._options.addOption(_fdr); + this._options.addOption(_nbZero); + this._options.addOption(_sizeImage); + this._options.addOption(_cpu); + this._options.addOption(_gaussianStrength); + this._options.addOption(_threshold); + this._options.addOption(_diagonal); + this._options.addOption(_factor); + this._options.addOption(_max); + this._options.addOption(_min); + this._options.addOption(_saturated); + this._options.addOption(_isDroso); + + try { + _cmd = _parser.parse(this._options, args); + } + catch (ParseException exp){ + System.out.println(exp.getMessage()+"\n"); + System.out.println(CLIHelper.getHelperInfos()+"\n"); + System.exit(1); + } + } + + +} diff --git a/src/cli/CLISipOption.java b/src/cli/CLISipOption.java deleted file mode 100644 index 4b07354..0000000 --- a/src/cli/CLISipOption.java +++ /dev/null @@ -1,178 +0,0 @@ -package cli; -import org.apache.commons.cli.*; - -/** - * - */ -public class CLISipOption { - - /** */ - Options _options= new Options(); - /** */ - CommandLine _cmd; - /** */ - private Option _inputFolder= Option.builder("i").longOpt("input").required() - .type(String.class).desc("Path to input .hic, .mcool or SIP folder containing processed data\n") - .numberOfArgs(1).build(); - /** */ - private Option _outputFolder= Option.builder("o").longOpt("output").required() - .type(String.class).desc("Path to output folder for SIP's files \n") - .numberOfArgs(1).build(); - /** */ - private Option _chrSize = Option.builder("c").longOpt("chrSize").required() - .type(String.class).desc("Path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1).\n") - .numberOfArgs(1).build(); - /** */ - private Option _resolution = Option.builder("r").longOpt("resolution") - .type(Number.class).desc("Resolution in bp (default 5000 bp)\n") - .numberOfArgs(1).build(); - /** */ - private Option _sizeImage = Option.builder("ms").longOpt("matrixSize") - .type(Number.class).desc("Matrix size to use for each chunk of the chromosome (default 2000 bins)\n") - .numberOfArgs(1).build(); - /** */ - private Option _cpu = Option.builder("cpu") - .type(Number.class).desc("Number of CPU used for SIP processing (default 1)\n") - .numberOfArgs(1).build(); - /** */ - private Option _gaussianStrength = Option.builder("g").longOpt("gaussian") - .type(Number.class).desc("Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1.5)\n") - .numberOfArgs(1).build(); - /** */ - private Option _threshold = Option.builder("t").longOpt("threshold") - .type(Number.class).desc("Threshold for loops detection (default 2800)\n") - .numberOfArgs(1).build(); - /** */ - private Option _nbZero = Option.builder("nbZero") - .type(Number.class).desc("Number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6)\n") - .numberOfArgs(1).build(); - /** */ - private Option _fdr = Option.builder("fdr") - .type(Number.class).desc("Empirical FDR value for filtering based on random sites (default 0.01)\n") - .numberOfArgs(1).build(); - /** */ - private Option _deleteImage = Option.builder("d").longOpt("delete") - .type(boolean.class).desc("Delete tif files used for loop detection (default true)\n") - .build(); - /** */ - private Option _interOrIntra = Option.builder("lt").longOpt("loopsType").required() - .type(String.class).desc("(inter or intra), call loops inter chromosomal or intra chromosomal loops\n") - .build(); - /** */ - private Option _isDroso = Option.builder("isDroso") - .type(boolean.class).desc("Default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n") - .build(); - /** */ - private Option _diagonal = Option.builder("d").longOpt("diagonal") - .type(Number.class).desc("diagonal size in bins, remove the maxima found at this size (eg: a size of 2 at 5000 bp resolution removes all maxima\n" + - " detected at a distance inferior or equal to 10kb) (default 6 bins).\n") - .numberOfArgs(1).build(); - /** */ - private Option _factor = Option.builder("f").longOpt("factor") - .type(Number.class).desc(" Multiple resolutions can be specified using:\n" + - "\t\t-factor 1: run only for the input res (default)\n" + - "\t\t-factor 2: res and res*2\n" + - "\t\t-factor 3: res and res*5\n" + - "\t\t-factor 4: res, res*2 and res*5\n") - .numberOfArgs(1).build(); - - /** */ - private Option _min = Option.builder("min").longOpt("minimum") - .type(Number.class).desc("Minimum filter strength (default 2)\n") - .numberOfArgs(1).build(); - /** */ - private Option _max = Option.builder("max").longOpt("maximum") - .type(Number.class).desc("Maximum filter strength (default 2)\n") - .numberOfArgs(1).build(); - /** */ - private Option _saturated = Option.builder("sat").longOpt("saturated") - .type(Number.class).desc("% of saturated pixel: enhances the contrast in the image (default 0.01)\n") - .numberOfArgs(1).build(); - - /** */ - private static String _Jversion ="1.6.1"; - /** - * - * @param args - * @throws Exception - */ - public CLISipOption(String[] args)throws Exception { - CommandLineParser parser= new DefaultParser(); - /*required parameters*/ - this._options.addOption(_inputFolder); - this._options.addOption(_outputFolder); - this._options.addOption(_chrSize); - this._options.addOption(_interOrIntra); - - /*optional parameters*/ - this._options.addOption(_resolution); - this._options.addOption(_deleteImage); - this._options.addOption(_fdr); - this._options.addOption(_nbZero); - this._options.addOption(_sizeImage); - this._options.addOption(_cpu); - this._options.addOption(_gaussianStrength); - this._options.addOption(_threshold); - - try { - _cmd = parser.parse(this._options, args); - } - catch (ParseException exp){ - System.out.println(exp.getMessage()+"\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - } - - - /** - * - * @return - */ - public static String getHelperInfos() { - return "More details :\n" + - "java -jar SIPHiC"+_Jversion+".jar hic --help \n" + - "or \n"+ - "java -jar SIPHiC-"+_Jversion+".jar cool -h or --help\n"+ - "or \n" + - "java -jar SIPHiC-"+_Jversion+".jar processed -h or --help \n" + - "\n\nCommand line eg:\n" + - "\tjava -jar SIP_HiC.jar hic -i hicFile -c chrSizeFile -o Output -j juicerTool -tl inter [options]\n" + - "\tjava -jar SIP_HiC.jar cool -i mcoolFile -c chrSizeFile -o Output -cooltools cooltoolsPath -cooler coolerPath -tl inter [options]\n" + - "\tjava -jar SIP_HiC.jar processed -i PathDirectoryWithProcessedData -c chrSizeFile -o Output -tl inter [options]\n" + - "\nAuthors:\n" + - "Axel Poulet\n" + - "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" + - "\tNew Haven, CT 06511, USA\n" + - "\nM. Jordan Rowley\n" + - "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" + - "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"; - } - - - - /** - * - */ - public void addInterChange(){ - this._gaussianStrength.setDescription("Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1)\n"); - this._fdr.setDescription("Empirical FDR value for filtering based on random sites (default 0.025)\n"); - this._resolution.setDescription("Resolution in bp (default 100000 bp)\n"); - this._sizeImage.setDescription("Matrix size to use for each chunk of the chromosome (default 500 bins)\n"); - this._threshold.setDescription("Threshold for loops detection (default 0.9)\n"); - } - - - /** - * - */ - public void addIntraParam(){ - this._options.addOption(_diagonal); - this._options.addOption(_factor); - this._options.addOption(_max); - this._options.addOption(_min); - this._options.addOption(_saturated); - this._options.addOption(_isDroso); - } - -} diff --git a/src/process/HiC.java b/src/process/HiC.java index 0c5fae9..534af93 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -44,8 +44,6 @@ public class HiC { /** */ private boolean _isGui; /** */ - private int _factorParam; - /** */ private GuiAnalysis _guiAnalysis; /** */ private String _juicerTool; @@ -75,7 +73,6 @@ public HiC(String args []) throws Exception { _delImages = true; _nbZero = 6; _cpu = 1; - _factorParam = 1; } /** @@ -92,7 +89,6 @@ public HiC(GuiAnalysis guiAnalysis ){ _delImages = true; _nbZero = 6; _cpu = 1; - _factorParam = 1; } /** * @@ -177,7 +173,7 @@ private String runIntra() throws IOException, InterruptedException { "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ "number of zero: "+this._nbZero+"\n"+ - "factor: "+ _factorParam +"\n"+ + "factor: "+ _sipIntra.getFactor() +"\n"+ "fdr: "+this._sipIntra.getFdr()+"\n"+ "delete images: "+_delImages+"\n"+ "cpu: "+ _cpu+"\n" + @@ -186,6 +182,7 @@ private String runIntra() throws IOException, InterruptedException { System.out.println("########### Starting dump Step inter chromosomal interactions"); _parameterCheck.optionalParametersValidity(_sipIntra); + _parameterCheck.speOption(_sipIntra); processDumpData.go(_input, _sipIntra, _juicerTool, _juicerNorm); System.out.println("########### End of the dump step\n"); @@ -209,6 +206,7 @@ private String runInter() throws IOException, InterruptedException { _sipIntra.setIsProcessed(false); _sipIntra.setIsCooler(false); + String allParam = "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ @@ -223,6 +221,8 @@ private String runInter() throws IOException, InterruptedException { "fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ "cpu "+ _cpu+"\n"; + _parameterCheck.optionalParametersValidity(_sipInter); + processDumpData.go(_input,_sipInter, _juicerTool, _juicerNorm); String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; @@ -249,8 +249,7 @@ private void setSipIntraCLI(){ int diagSize = 6; double saturatedPixel = 0.01; boolean isDroso = false; - ArrayList factor = new ArrayList(); - factor.add(1); + int factorParam = 1; if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); @@ -262,18 +261,13 @@ private void setSipIntraCLI(){ if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); - if (_cmd.hasOption("factor")) { - _factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); - if (_factorParam == 2) factor.add(2); - else if (_factorParam == 4) { - factor.add(2); - factor.add(5); - } else factor.add(5); - + if (_cmd.hasOption("factor")){ + factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); + _parameterCheck.checkFactor(factorParam); } - _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, - thresholdMax, diagSize, matrixSize, _nbZero, factor, fdr, isDroso,_delImages, _cpu); + _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, + thresholdMax, diagSize, matrixSize, _nbZero, factorParam, fdr, isDroso,_delImages, _cpu); } /** * @@ -281,19 +275,10 @@ else if (_factorParam == 4) { */ private void setSipIntraGUI(){ - ArrayList factor = new ArrayList(); - factor.add(1); - - if(this._guiAnalysis.getFactorChoice() == 2) factor.add(2); - else if(this._guiAnalysis.getFactorChoice() == 4){ - factor.add(2); - factor.add(5); - }else if(this._guiAnalysis.getFactorChoice() == 3) factor.add(5); - _sipIntra = new SIPIntra(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getMin(), _guiAnalysis.getMax(), _guiAnalysis.getResolution(), _guiAnalysis.getSaturatedPixel(), _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getDiagSize(), _guiAnalysis.getMatrixSize(), - _nbZero, factor, _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); + _nbZero, _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); } diff --git a/src/process/ParametersCheck.java b/src/process/ParametersCheck.java index fd03e74..d3c5ece 100644 --- a/src/process/ParametersCheck.java +++ b/src/process/ParametersCheck.java @@ -1,109 +1,106 @@ package process; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.HelpFormatter; -import sip.SIPInter; + import sip.SIPIntra; import sip.SIPObject; import java.io.File; -import static cli.CLISipOption.getHelperInfos; public class ParametersCheck { - private SIPIntra _sipIntra; - - private SIPIntra _sipInter; - - /** - * - * @param input - * @param output - * @param chrSizeFile - * @param interOrIntra - */ - public ParametersCheck(String input, String output, String chrSizeFile, String interOrIntra){ - File file = new File(input); - - if(!file.exists() && !input.startsWith("https")){ - System.out.println("-i "+input+" => this file doesn't existed !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - file = new File(output); - - if(!file.exists()){ - System.out.println("-i "+output+" => this file doesn't existed !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - file = new File(chrSizeFile); - if(!file.exists()){ - System.out.println("-i "+chrSizeFile+" => this file doesn't existed !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - - if(!interOrIntra.equals("inter") && !interOrIntra.equals("intra")){ - System.out.println("-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); - System.out.println(getHelperInfos()); - System.exit(1); - } - } /** * + * @param sip */ public void optionalParametersValidity(SIPObject sip){ if(sip.getResolution() <= 0 ){ System.out.println("-r "+sip.getResolution()+", resolution need to be a >= 0 !!! \n\n"); - System.out.println(getHelperInfos()); + //System.out.println(getHelperInfos()); System.exit(1); } if (sip.getNbZero() > 24|| sip.getNbZero() < 0) { System.out.println("\n-nbZero"+ sip.getNbZero() +" value invalid: choose an integer value between 0 and 24\n"); - //erreur mettre l'aide et stopper le prog. - System.exit(0); - } + //erreur mettre l'aide et stopper le prog. + System.exit(0); + } if(sip.getCpu() > Runtime.getRuntime().availableProcessors() || sip.getCpu() <= 0){ - System.out.println("\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); - System.exit(0); + System.out.println("\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + System.exit(0); } if(sip.getFdr() < 0 ){ System.out.println("-fdr "+sip.getFdr()+", fdr need to be a >= 0 !!! \n\n"); - System.out.println(getHelperInfos()); + //System.out.println(getHelperInfos()); System.exit(1); } if(sip.getMatrixSize() < 0 ){ System.out.println("-ms "+sip.getMatrixSize()+", matrix size need to be a > 0 !!! \n\n"); - System.out.println(getHelperInfos()); + //System.out.println(getHelperInfos()); System.exit(1); } if(sip.getGauss() < 0 ){ System.out.println("-g "+sip.getGauss()+", gaussian strength filter need to be a > 0 !!! \n\n"); - System.out.println(getHelperInfos()); + //System.out.println(getHelperInfos()); System.exit(1); } if(sip.getThresholdMaxima() < 0 ){ System.out.println("-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); - System.out.println(getHelperInfos()); + //System.out.println(getHelperInfos()); + System.exit(1); + } + } + + /** + * + * @param input + * @param output + * @param chrSizeFile + * @param interOrIntra + */ + public ParametersCheck(String input, String output, String chrSizeFile, String interOrIntra){ + File file = new File(input); + + if(!file.exists() && !input.startsWith("https")){ + System.out.println("-i "+input+" => this file doesn't existed !!! \n\n"); + //System.out.println(getHelperInfos()); + System.exit(1); + } + + file = new File(output); + + if(!file.exists()){ + System.out.println("-i "+output+" => this file doesn't existed !!! \n\n"); + //System.out.println(getHelperInfos()); + System.exit(1); + } + + file = new File(chrSizeFile); + if(!file.exists()){ + System.out.println("-i "+chrSizeFile+" => this file doesn't existed !!! \n\n"); + //System.out.println(getHelperInfos()); + System.exit(1); + } + + if(!interOrIntra.equals("inter") && !interOrIntra.equals("intra")){ + System.out.println("-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); + //System.out.println(getHelperInfos()); System.exit(1); } } /** * + * @param juicerTool + * @param juicerNorm */ public void testHiCOption(String juicerTool, String juicerNorm){ @@ -124,19 +121,53 @@ public void testHiCOption(String juicerTool, String juicerNorm){ /** * + * @param factor */ - public void speOption(SIPIntra sipIntra){ + public void checkFactor(int factor){ + if(factor < 1 || factor > 4 ){ + System.out.println("-f "+factor+", value for factor are 1, 2, 3 or 4 !!! \n\n"); + // System.out.println(getHelperInfos()); + System.exit(1); + } } /** * + * @param sipIntra */ - public void speOption(SIPInter sipInter){ + public void speOption(SIPIntra sipIntra){ + + if(sipIntra.getDiagonalSize() < 0 ){ + System.out.println("-d "+sipIntra.getDiagonalSize()+", diagonal size need to be a > 0 !!! \n\n"); + //System.out.println(getHelperInfos()); + System.exit(1); + } + + if(sipIntra.getMin() < 0 ){ + System.out.println("-min "+sipIntra.getMin()+", min strength filter need to be a > 0 !!! \n\n"); + //System.out.println(getHelperInfos()); + System.exit(1); + } + + if(sipIntra.getMax() < 0 ){ + System.out.println("-max "+sipIntra.getMax()+", max strength filter need to be a > 0 !!! \n\n"); + //System.out.println(getHelperInfos()); + System.exit(1); + } + + if(sipIntra.getSaturatedPixel() < 0 ){ + System.out.println("-sat "+sipIntra.getSaturatedPixel()+", max strength filter need to be a > 0 !!! \n\n"); + //System.out.println(getHelperInfos()); + System.exit(1); + } + } + + /** * */ diff --git a/src/sip/SIPIntra.java b/src/sip/SIPIntra.java index a7b130e..6740eb7 100644 --- a/src/sip/SIPIntra.java +++ b/src/sip/SIPIntra.java @@ -48,6 +48,7 @@ public class SIPIntra extends SIPObject { private double _medianAP = 0; /** median of loop regional AP score */ private double _medianAPReg = 0; + private int _factor = 0; /** @@ -69,13 +70,13 @@ public SIPIntra() { } * @param diagonalSize size of the diagonal, where the value will be not use * @param matrixSize size of the image * @param nbZero number of zero allowed around loops - * @param listFactor multi resolution calling loops used this list of factor + * @param factor multi resolution calling loops used this list of factor * @param fdr fdr value for final loops filtering * @param isDroso false if it isn't drosophila input */ public SIPIntra(String output, String chrFile, double gauss, double min, double max, int resolution, double saturatedPixel, double thresholdMax, - int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, + int diagonalSize, int matrixSize, int nbZero, int factor, double fdr, boolean isDroso, boolean delImage, int cpu) { super( output, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrFile, delImage, cpu); @@ -87,8 +88,14 @@ public SIPIntra(String output, String chrFile, double gauss, double min, this._saturatedPixel = saturatedPixel; this._diagonalSize = diagonalSize; this._step = matrixSize/2; - this._listFactor = listFactor; this._isDroso = isDroso; + this._factor = factor; + _listFactor.add(1); + if (_factor == 2) _listFactor.add(2); + else if (_factor == 4) { + _listFactor.add(2); + _listFactor.add(5); + } else if(_factor == 3) _listFactor.add(5); } /** @@ -106,12 +113,12 @@ public SIPIntra(String output, String chrFile, double gauss, double min, * @param diagonalSize size of the diagonal, where the value will be not use * @param matrixSize size of the image * @param nbZero number of zero allowed around loops - * @param listFactor multi resolution calling loops used this list of factor + * @param factor multi resolution calling loops used this list of factor * @param fdr fdr value for final loops filtering */ public SIPIntra(String input, String output, String chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, double thresholdMax, - int diagonalSize, int matrixSize, int nbZero, ArrayList listFactor, + int diagonalSize, int matrixSize, int nbZero, int factor, double fdr, boolean isDroso, boolean delImage, int cpu) { super( input, output, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, chrSize, delImage,cpu ); @@ -122,8 +129,15 @@ public SIPIntra(String input, String output, String chrSize, double gauss, doubl this._saturatedPixel = saturatedPixel; this._diagonalSize = diagonalSize; this._step = matrixSize/2; - this._listFactor = listFactor; this._isDroso = isDroso; + this._factor = factor; + _listFactor.add(1); + if (_factor == 2) _listFactor.add(2); + else if (_factor == 4) { + _listFactor.add(2); + _listFactor.add(5); + } else if(_factor == 3) _listFactor.add(5); + } @@ -349,7 +363,11 @@ private void median(HashMap data, double fdrCutoff){ */ public void setIsDroso(boolean droso){ this._isDroso = droso;} - + /** + * Getter of list of integer for multi resolution loop calling + * @return list of integer + */ + public int getFactor() {return this._factor;} diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index aa75716..2a6ff58 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -1,23 +1,15 @@ package sipMain; import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; -import javax.swing.JOptionPane; - -import cli.CLISipOption; +import cli.CLIHelper; import gui.GuiAnalysis; -import multiProcesing.ProcessCoolerDumpData; -import multiProcesing.ProcessDumpData; import process.HiC; import process.MCool; import process.Processed; -import utils.MultiResProcess; import sip.SIPIntra; /** @@ -104,6 +96,10 @@ public static void main(String[] args) throws Exception { if(args.length >= 1) { if (args[0].equals("hic")) { + if(args[1].equals("-h") || args[1].equals("--help")){ + + + } HiC hic = new HiC(args); hic.run(); @@ -113,7 +109,8 @@ public static void main(String[] args) throws Exception { MCool mCool = new MCool(args); }else { - System.out.println(CLISipOption.getHelperInfos()); + System.out.println(CLIHelper.getHelperInfos()+"\n"+CLIHelper.getAuthors()); + return; } } /*GUI */ diff --git a/src/test/TestCallLoopsHicFile.java b/src/test/TestCallLoopsHicFile.java index f20e1af..f7fc831 100644 --- a/src/test/TestCallLoopsHicFile.java +++ b/src/test/TestCallLoopsHicFile.java @@ -51,8 +51,8 @@ public static void main(String[] args) throws IOException, InterruptedException String juiceBoXNormalisation = "KR"; double saturatedPixel = 0.01; - ArrayList factor = new ArrayList(); - factor.add(1); + + int factor = 1; //factor.add(2); //factor.add(5); boolean keepTif = true; @@ -72,7 +72,7 @@ public static void main(String[] args) throws IOException, InterruptedException + "threshold "+thresholdMax+"\n"); File file = new File(output); - if (file.exists()==false){file.mkdir();} + if (!file.exists()){file.mkdir();} SIPIntra sip = new SIPIntra(output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false, keepTif,cpu ); sip.setIsGui(false); diff --git a/src/test/TestCallLoopsProcessedFile.java b/src/test/TestCallLoopsProcessedFile.java index 0a8ae6e..4ead35b 100644 --- a/src/test/TestCallLoopsProcessedFile.java +++ b/src/test/TestCallLoopsProcessedFile.java @@ -32,8 +32,8 @@ public static void main(String[] args) throws IOException, InterruptedException double max = 2;//1.5; double saturatedPixel = 0.01;//0.005; //boolean keepTif = false; - ArrayList factor = new ArrayList(); - factor.add(1); + + int factor = 1; //factor.add(2); //factor.add(5); //SIP_HiC_v1.3.6.jar hic SIP/Kc_allcombined.hic SIP/armsizes.txt SIP/Droso/ ../Tools/juicer_tools_1.13.02.jar diff --git a/src/test/TestCoolFormat.java b/src/test/TestCoolFormat.java index 37edae0..845f8d6 100644 --- a/src/test/TestCoolFormat.java +++ b/src/test/TestCoolFormat.java @@ -35,10 +35,8 @@ public static void main(String[] args) throws IOException, InterruptedException int nbZero = 6; int thresholdMax = 2800; double saturatedPixel = 0.01; - ArrayList factor = new ArrayList(); - factor.add(1); - factor.add(2); - factor.add(5); + int factor = 4; + boolean keepTif = false; int cpu = 1; diff --git a/src/test/TestGui.java b/src/test/TestGui.java index 653b288..5d28e84 100644 --- a/src/test/TestGui.java +++ b/src/test/TestGui.java @@ -48,9 +48,8 @@ public static void main(String[] args) throws IOException, InterruptedException{ else if (gui.isVC()) juiceBoXNormalisation = "VC"; else if (gui.isVC_SQRT()) juiceBoXNormalisation = "VC_SQRT"; int nbZero = gui.getNbZero(); - - ArrayList factor = new ArrayList(); - factor.add(1); + + int factor = 1; //factor.add(2); String chrSize = gui.getChrSizeFile(); diff --git a/src/utils/MultiResProcess.java b/src/utils/MultiResProcess.java index 40d1e81..8aa7b62 100644 --- a/src/utils/MultiResProcess.java +++ b/src/utils/MultiResProcess.java @@ -88,19 +88,18 @@ public void run() throws InterruptedException, IOException{ double gaussTpm = this._sip.getGauss()/listFactor.get(indexFact); SIPIntra sipTmp = new SIPIntra(_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), - _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getListFactor(), + _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getFactor(), _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); if(this._sip.isProcessed()) { sipTmp = new SIPIntra(_sip.getInputDir(),_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), - _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getListFactor(), + _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getFactor(), _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); } sipTmp.setIsGui(_sip.isGui()); sipTmp.setStep(this._sip.getStep()/listFactor.get(indexFact)); sipTmp.setIsProcessed(_sip.isProcessed()); - sipTmp.setFdr(_sip.getFdr()); sipTmp.setIsCooler(_sip.isCooler()); ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); From bab80402d638943c95a72faf1bb83743c4e69d97 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Thu, 19 Nov 2020 09:21:50 -0500 Subject: [PATCH 17/27] hic option helper/commandParser/run done --- src/cli/CLIHelper.java | 66 ++++++++++--- src/cli/CLIOptionCool.java | 5 +- src/cli/CLIOptionHiC.java | 5 +- src/cli/CLIOptionProcessed.java | 22 ++++- src/process/HiC.java | 2 +- src/process/ParametersCheck.java | 157 +++++++++++++++++++------------ src/sip/SIPObject.java | 44 +-------- src/sipMain/Hic_main.java | 82 ++-------------- src/utils/MultiResProcess.java | 6 +- 9 files changed, 186 insertions(+), 203 deletions(-) diff --git a/src/cli/CLIHelper.java b/src/cli/CLIHelper.java index bef21f3..b429faa 100644 --- a/src/cli/CLIHelper.java +++ b/src/cli/CLIHelper.java @@ -14,16 +14,16 @@ public class CLIHelper { /** */ private static String _cool ="java -jar SIPHiC"+ _version +".jar cool "; /** */ - private static String processed ="java -jar SIPHiC"+ _version +".jar processed "; + private static String _processed ="java -jar SIPHiC"+ _version +".jar processed "; /* Constructor*/ public CLIHelper(){ } - public static void main(String[] args) throws Exception{ + public static void main(String[] args){ - CmdHelpCool(); + CmdHelpProcessed(); } @@ -40,7 +40,7 @@ public static void CmdHelpHiC() { HelpFormatter formatter = new HelpFormatter(); System.out.println("\nHelp for "+_cool+"!!!!!!! \n"); - formatter.printHelp(200, usage, "SIP_HiC option hic : ", command.getOptions(),getAuthors()); + formatter.printHelp(200, usage, "SIP_HiC version"+_version+"option hic: ", command.getOptions(),getAuthors()); System.exit(1); } @@ -53,30 +53,72 @@ public static void CmdHelpCool() { String argument = "-i path/to/hicFile.hic -c path/to/chrSizeFile.txt -o path/to/output/folder -cooltools path/to/cooltools -cooler path/to/cooler -lt intra "; String[] argv = argument.split(" "); CLIOptionCool command = new CLIOptionCool (argv); - String usage = _hic+argument+" [options]"; + String usage = _cool+argument+" [options]"; HelpFormatter formatter = new HelpFormatter(); - System.out.println("\nHelp for "+_hic+"!!!!!!! \n"); - formatter.printHelp(200, usage, "SIP_HiC option hic : ", command.getOptions(),getAuthors()); + System.out.println("\nHelp for "+_cool+"!!!!!!! \n"); + formatter.printHelp(200, usage, "SIP_HiC version"+_version+"option cool: ", command.getOptions(),getAuthors()); System.exit(1); } + /** + * Method get help for command line + * with example command line + */ + public static void CmdHelpProcessed(){ + String argument = "-i SIP path/to/folder/SIPProcessedData -c path/to/chrSizeFile -o path/to/output/folder -lt intra "; + String[] argv = argument.split(" "); + CLIOptionProcessed command = new CLIOptionProcessed (argv); + String usage = _processed+argument+" [options]"; + HelpFormatter formatter = new HelpFormatter(); + + System.out.println("\nHelp for "+_processed+"!!!!!!! \n"); + formatter.printHelp(200, usage, "SIP_HiC option processed : ", command.getOptions(),getAuthors()); + System.exit(1); + } /** * * @return */ - public static String getHelperInfos() { - return "More details :\n" + + public static void getHelperInfos() { + System.out.println( "More details :\n" + "java -jar SIPHiC"+ _version +".jar hic --help \n" + "or \n"+ "java -jar SIPHiC-"+ _version +".jar cool -h or --help\n"+ "or \n" + "java -jar SIPHiC-"+ _version +".jar processed -h or --help \n" + "\n\nCommand line g:\n" + - "\tjava -jar SIP_HiC.jar hic -i hicFile -c chrSizeFile -o Output -j juicerTool -tl inter [options]\n" + - "\tjava -jar SIP_HiC.jar cool -i mcoolFile -c chrSizeFile -o Output -cooltools cooltoolsPath -cooler coolerPath -tl inter [options]\n" + - "\tjava -jar SIP_HiC.jar processed [options]\n"; + "\tjava -jar SIP_HiC.jar hic -i path/to/hicFile.hic -c path/to/chrSizeFile -o path/to/output/folder -j path/to/juicerTool.jar -lt intra [options]\n" + + "\tjava -jar SIP_HiC.jar cool -i path/to/hicFile.hic -c path/to/chrSizeFile -o path/to/output/folder -cooltools path/to/cooltools -cooler path/to/cooler -lt intra [options]\n" + + "\tjava -jar SIP_HiC.jar processed -i SIP path/to/folder/SIPProcessedData -c path/to/chrSizeFile -o path/to/output/folder -lt intra [options]\n"); + System.exit(1); + + } + + + /** + * + * @return + */ + public static void getHelperAllInfos() { + System.out.println( "More details :\n" + + "java -jar SIPHiC"+ _version +".jar hic --help \n" + + "or \n"+ + "java -jar SIPHiC-"+ _version +".jar cool -h or --help\n"+ + "or \n" + + "java -jar SIPHiC-"+ _version +".jar processed -h or --help \n" + + "\n\nCommand line g:\n" + + "\tjava -jar SIP_HiC.jar hic -i path/to/hicFile.hic -c path/to/chrSizeFile -o path/to/output/folder -j path/to/juicerTool.jar -lt intra [options]\n" + + "\tjava -jar SIP_HiC.jar cool -i path/to/hicFile.hic -c path/to/chrSizeFile -o path/to/output/folder -cooltools path/to/cooltools -cooler path/to/cooler -lt intra [options]\n" + + "\tjava -jar SIP_HiC.jar processed -i SIP path/to/folder/SIPProcessedData -c path/to/chrSizeFile -o path/to/output/folder -lt intra [options]\n" + + "\nAuthors:\n" + + "\nAxel Poulet\n" + + "Department of Molecular, Cellular and Developmental Biology Yale University \n" + + "\nM. Jordan Rowley\n" + + "Department of Genetics, Cell Biology and Anatomy, University of Nebraska Medical\n" + + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"); + System.exit(1); } diff --git a/src/cli/CLIOptionCool.java b/src/cli/CLIOptionCool.java index e7c8a3e..7e9b433 100644 --- a/src/cli/CLIOptionCool.java +++ b/src/cli/CLIOptionCool.java @@ -46,9 +46,8 @@ public CLIOptionCool(String [] args){ _commandLine = _parser.parse(this._options, args); } catch (ParseException exp){ - System.out.println(exp.getMessage()+"\n"); - System.out.println(CLIHelper.getHelperInfos()+"\n"+CLIHelper.getAuthors()); - System.exit(1); + System.out.println("\n"+exp.getMessage()+"\n"); + CLIHelper.CmdHelpCool(); } } diff --git a/src/cli/CLIOptionHiC.java b/src/cli/CLIOptionHiC.java index 20e26b9..c51fc79 100644 --- a/src/cli/CLIOptionHiC.java +++ b/src/cli/CLIOptionHiC.java @@ -37,9 +37,8 @@ public CLIOptionHiC(String [] args){ this._cmd = this._parser.parse(this._options, args,true); } catch (ParseException exp){ - System.out.println(exp.getMessage()+"\n"); - // System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("\n"+exp.getMessage()+"\n"); + CLIHelper.CmdHelpHiC(); } } diff --git a/src/cli/CLIOptionProcessed.java b/src/cli/CLIOptionProcessed.java index 886dafb..5b57dc5 100644 --- a/src/cli/CLIOptionProcessed.java +++ b/src/cli/CLIOptionProcessed.java @@ -104,7 +104,7 @@ public CLIOptionProcessed() { * @param args * @throws Exception */ - public CLIOptionProcessed(String[] args)throws Exception { + public CLIOptionProcessed(String[] args) { /*required parameters*/ this._options.addOption(_inputFolder); this._options.addOption(_outputFolder); @@ -131,11 +131,25 @@ public CLIOptionProcessed(String[] args)throws Exception { _cmd = _parser.parse(this._options, args); } catch (ParseException exp){ - System.out.println(exp.getMessage()+"\n"); - System.out.println(CLIHelper.getHelperInfos()+"\n"); - System.exit(1); + System.out.println("\n"+exp.getMessage()+"\n"); + CLIHelper.CmdHelpProcessed(); } } + /** + * + * @return + */ + public CommandLine getCommandLine() { + return _cmd; + } + + /** + * + * @return + */ + public Options getOptions() { + return _options; + } } diff --git a/src/process/HiC.java b/src/process/HiC.java index 534af93..bf1c783 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -61,7 +61,7 @@ public class HiC { * @param args * @throws Exception */ - public HiC(String args []) throws Exception { + public HiC(String args []){ _isGui = false; String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); CLIOptionHiC cli = new CLIOptionHiC(argsSubset); diff --git a/src/process/ParametersCheck.java b/src/process/ParametersCheck.java index d3c5ece..1fa5e4b 100644 --- a/src/process/ParametersCheck.java +++ b/src/process/ParametersCheck.java @@ -1,14 +1,16 @@ package process; +import cli.CLIHelper; import sip.SIPIntra; import sip.SIPObject; -import java.io.File; +import java.io.*; public class ParametersCheck { + String _logError; /** * @@ -17,45 +19,39 @@ public class ParametersCheck { public void optionalParametersValidity(SIPObject sip){ if(sip.getResolution() <= 0 ){ - System.out.println("-r "+sip.getResolution()+", resolution need to be a >= 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-r "+sip.getResolution()+", resolution need to be a >= 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } if (sip.getNbZero() > 24|| sip.getNbZero() < 0) { - System.out.println("\n-nbZero"+ sip.getNbZero() +" value invalid: choose an integer value between 0 and 24\n"); - //erreur mettre l'aide et stopper le prog. - System.exit(0); + System.out.println("Parameter value error !!!!\n-nbZero"+ sip.getNbZero() +" value invalid: choose an integer value between 0 and 24\n"); + CLIHelper.getHelperInfos(); } if(sip.getCpu() > Runtime.getRuntime().availableProcessors() || sip.getCpu() <= 0){ - System.out.println("\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); - System.exit(0); + System.out.println("Parameter value error !!!!\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + CLIHelper.getHelperInfos(); } if(sip.getFdr() < 0 ){ - System.out.println("-fdr "+sip.getFdr()+", fdr need to be a >= 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-fdr "+sip.getFdr()+", fdr need to be a >= 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } if(sip.getMatrixSize() < 0 ){ - System.out.println("-ms "+sip.getMatrixSize()+", matrix size need to be a > 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-ms "+sip.getMatrixSize()+", matrix size need to be a > 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } if(sip.getGauss() < 0 ){ - System.out.println("-g "+sip.getGauss()+", gaussian strength filter need to be a > 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-g "+sip.getGauss()+", gaussian strength filter need to be a > 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } if(sip.getThresholdMaxima() < 0 ){ - System.out.println("-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } } @@ -70,30 +66,26 @@ public ParametersCheck(String input, String output, String chrSizeFile, String i File file = new File(input); if(!file.exists() && !input.startsWith("https")){ - System.out.println("-i "+input+" => this file doesn't existed !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("File problem !!!!\n-i "+input+": this file doesn't existed !!! \n\n"); + CLIHelper.getHelperInfos(); } file = new File(output); if(!file.exists()){ - System.out.println("-i "+output+" => this file doesn't existed !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("File problem !!!!\n-o "+output+": this file doesn't existed !!! \n\n"); + CLIHelper.getHelperInfos(); } file = new File(chrSizeFile); if(!file.exists()){ - System.out.println("-i "+chrSizeFile+" => this file doesn't existed !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("File problem !!!!\n-c "+chrSizeFile+": this file doesn't existed !!! \n\n"); + CLIHelper.getHelperInfos(); } if(!interOrIntra.equals("inter") && !interOrIntra.equals("intra")){ - System.out.println("-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); + } } @@ -105,17 +97,15 @@ public ParametersCheck(String input, String output, String chrSizeFile, String i public void testHiCOption(String juicerTool, String juicerNorm){ if (!juicerNorm.equals("KR") && !juicerNorm.equals("NONE") && !juicerNorm.equals("VC") && !juicerNorm.equals("VC_SQRT")) { - System.out.println("-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); - //helper hic - System.exit(0); + System.out.println("Parameter value error !!!!\n-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); + CLIHelper.CmdHelpHiC(); } File file = new File(juicerTool); if(!file.exists()){ - System.out.println("-j "+juicerTool+" => this file doesn't existed !!! \n\n"); - //helper hic - System.exit(0); + System.out.println("File problem !!!!\n-j "+juicerTool+": this file doesn't existed !!! \n\n"); + CLIHelper.CmdHelpHiC(); } } @@ -126,9 +116,8 @@ public void testHiCOption(String juicerTool, String juicerNorm){ public void checkFactor(int factor){ if(factor < 1 || factor > 4 ){ - System.out.println("-f "+factor+", value for factor are 1, 2, 3 or 4 !!! \n\n"); - // System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-f "+factor+", value for factor are 1, 2, 3 or 4 !!! \n\n"); + CLIHelper.getHelperInfos(); } } @@ -139,40 +128,92 @@ public void checkFactor(int factor){ public void speOption(SIPIntra sipIntra){ if(sipIntra.getDiagonalSize() < 0 ){ - System.out.println("-d "+sipIntra.getDiagonalSize()+", diagonal size need to be a > 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-d "+sipIntra.getDiagonalSize()+", diagonal size need to be a > 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } if(sipIntra.getMin() < 0 ){ - System.out.println("-min "+sipIntra.getMin()+", min strength filter need to be a > 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-min "+sipIntra.getMin()+", min strength filter need to be a > 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } if(sipIntra.getMax() < 0 ){ - System.out.println("-max "+sipIntra.getMax()+", max strength filter need to be a > 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("\"Parameter value error !!!!\n-max "+sipIntra.getMax()+", max strength filter need to be a > 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } if(sipIntra.getSaturatedPixel() < 0 ){ - System.out.println("-sat "+sipIntra.getSaturatedPixel()+", max strength filter need to be a > 0 !!! \n\n"); - //System.out.println(getHelperInfos()); - System.exit(1); + System.out.println("Parameter value error !!!!\n-sat "+sipIntra.getSaturatedPixel()+", max strength filter need to be a > 0 !!! \n\n"); + CLIHelper.getHelperInfos(); } - - } - /** * + * @param pathTools + * @param first + * @param second + * @param third + * @return */ - public void testCoolOption() { + public boolean testTools(String pathTools, int first, int second, int third) { + Runtime runtime = Runtime.getRuntime(); + String cmd = pathTools+" --version"; + Process process; + try { + process = runtime.exec(cmd); + + new ReturnFlux(process.getInputStream()).start(); + new ReturnFlux(process.getErrorStream()).start(); + process.waitFor(); + + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + String [] tline = _logError.split(" "); + System.out.println(_logError); + _logError = ""; + if(tline.length > 0){ + tline = tline[tline.length-1].split("\\."); + tline[2] = tline[2].replace("\n", ""); + if(Integer.parseInt(tline[0]) >= first && Integer.parseInt(tline[1]) >= second) //&& Integer.parseInt(tline[2]) >= third) + return true; + else + return false; + }else + return false; + } + public class ReturnFlux extends Thread { + + /** Flux to redirect */ + private InputStream _flux; + + /** + * Constructor of ReturnFlux + * @param flux + * flux to redirect + */ + public ReturnFlux(InputStream flux){this._flux = flux; } + + /** + * + */ + public void run(){ + try { + InputStreamReader reader = new InputStreamReader(this._flux); + BufferedReader br = new BufferedReader(reader); + String line=null; + while ( (line = br.readLine()) != null) { + if(line.contains("WARN")== false) _logError = _logError+line+"\n"; + } + } + catch (IOException ioe){ + ioe.printStackTrace(); + } + } } } diff --git a/src/sip/SIPObject.java b/src/sip/SIPObject.java index a092e1c..2bf44ca 100644 --- a/src/sip/SIPObject.java +++ b/src/sip/SIPObject.java @@ -268,49 +268,7 @@ public SIPObject(){ public void setIsGui(boolean _isGui) { this._isGui = _isGui;} - public static void docError (){ - String doc = ("#SIP Version 1 run with java 8\n" - + "\nUsage:\n" - + "\thic [options]\n" - + "\tcool [options]\n" - + "\tprocessed [options]\n" - + "\nParameters:\n" - + "\t chrSizeFile: path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1)\n" - + "\t-res: resolution in bp (default 5000 bp)\n" - + "\t-mat: matrix size to use for each chunk of the chromosome (default 2000 bins)\n" - + "\t-d: diagonal size in bins, remove the maxima found at this size (eg: a size of 2 at 5000 bp resolution removes all maxima" - + " detected at a distance inferior or equal to 10kb) (default 6 bins).\n" - + "\t-g: Gaussian filter: smoothing factor to reduce noise during primary maxima detection (default 1.5)\n" - + "\t-cpu: Number of CPU used for SIP processing (default 1)\n" - + "\t-factor: Multiple resolutions can be specified using:\n" - + "\t\t-factor 1: run only for the input res (default)\n" - + "\t\t-factor 2: res and res*2\n" - + "\t\t-factor 3: res and res*5\n" - + "\t\t-factor 4: res, res*2 and res*5\n" - + "\t-max: Maximum filter: increases the region of high intensity (default 2)\n" - + "\t-min: Minimum filter: removes the isolated high value (default 2)\n" - + "\t-sat: % of saturated pixel: enhances the contrast in the image (default 0.01)\n" - + "\t-t Threshold for loops detection (default 2800)\n" - + "\t-nbZero: number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6)\n" - + "\t-norm: (default KR)\n" - + "\t-del: true or false, whether not to delete tif files used for loop detection (default true)\n" - + "\t-fdr: Empirical FDR value for filtering based on random sites (default 0.01)\n" - + "\t-isDroso: default false, if true apply extra filter to help detect loops similar to those found in D. mel cells\n" - + "\t-h, --help print help\n" - + "\nCommand line eg:\n" - + "\tjava -jar SIP_HiC.jar hic [options]\n" - + "\tjava -jar SIP_HiC.jar cool [options]\n" - + "\tjava -jar SIP_HiC.jar processed [options]\n" - + "\nAuthors:\n" - + "Axel Poulet\n" - + "\tDepartment of Molecular, Cellular and Developmental Biology Yale University 165 Prospect St\n" - + "\tNew Haven, CT 06511, USA\n" - + "M. Jordan Rowley\n" - + "\tDepartment of Genetics, Cell Biology and Anatomy, University of Nebraska Medical Center Omaha,NE 68198-5805\n" - + "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu"); - - System.out.println(doc); - } + /** * getter of chrSize hashMap diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 2a6ff58..da8f4ff 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -109,8 +109,7 @@ public static void main(String[] args) throws Exception { MCool mCool = new MCool(args); }else { - System.out.println(CLIHelper.getHelperInfos()+"\n"+CLIHelper.getAuthors()); - return; + CLIHelper.getHelperAllInfos(); } } /*GUI */ @@ -131,7 +130,7 @@ public static void main(String[] args) throws Exception { } }else { System.out.println("SIP closed: if you want the help: -h"); - return; + CLIHelper.getHelperAllInfos(); } } @@ -330,7 +329,7 @@ public static void main(String[] args) throws Exception { * @param index table index where start to read the arguments * @throws IOException if some parameters don't exist */ - private static void readOption(String args[], int index) throws IOException{ + /*private static void readOption(String args[], int index) throws IOException{ if(index < args.length){ for(int i = index; i < args.length;i+=2){ if(args[i].equals("-res")){ @@ -356,7 +355,7 @@ else if(a == 4){ catch(NumberFormatException e){ returnError("-cpu",args[i+1],"int");} if(_cpu > Runtime.getRuntime().availableProcessors() || _cpu <= 0){ System.out.println("the number of CPU "+ _cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); - SIPIntra.docError(); + //SIPIntra.docError(); System.exit(0); } }else if(args[i].equals("-nbZero")){ @@ -417,80 +416,11 @@ else if(args[i+1].equals("false") || args[i+1].equals("F") || args[i+1].equals(" } } } - } - - /** - * Return specifci error on function of thearugnent problems - * - * @param param String name of the arugment - * @param value String value of the argument - * @param type Strint type of the argument - */ - private static void returnError(String param, String value, String type){ - System.out.println(param+" has to be an integer "+value+" can't be convert in "+type+"\n"); - SIPIntra.docError(); - System.exit(0); - } - - - public static boolean testTools(String pathTools, int first, int second, int third) { - Runtime runtime = Runtime.getRuntime(); - String cmd = pathTools+" --version"; - Process process; - try { - process = runtime.exec(cmd); - - new ReturnFlux(process.getInputStream()).start(); - new ReturnFlux(process.getErrorStream()).start(); - process.waitFor(); - - } catch (IOException | InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - String [] tline = _logError.split(" "); - System.out.println(_logError); - _logError = ""; - if(tline.length > 0){ - tline = tline[tline.length-1].split("\\."); - tline[2] = tline[2].replace("\n", ""); - if(Integer.parseInt(tline[0]) >= first && Integer.parseInt(tline[1]) >= second) //&& Integer.parseInt(tline[2]) >= third) - return true; - else - return false; - }else - return false; - } + }*/ - public static class ReturnFlux extends Thread { - /** Flux to redirect */ - private InputStream _flux; + - /** - * Constructor of ReturnFlux - * @param flux - * flux to redirect - */ - public ReturnFlux(InputStream flux){this._flux = flux; } - - /** - * - */ - public void run(){ - try { - InputStreamReader reader = new InputStreamReader(this._flux); - BufferedReader br = new BufferedReader(reader); - String line=null; - while ( (line = br.readLine()) != null) { - if(line.contains("WARN")== false) _logError = _logError+line+"\n"; - } - } - catch (IOException ioe){ - ioe.printStackTrace(); - } - } - } } diff --git a/src/utils/MultiResProcess.java b/src/utils/MultiResProcess.java index 8aa7b62..bd32a9a 100644 --- a/src/utils/MultiResProcess.java +++ b/src/utils/MultiResProcess.java @@ -16,6 +16,7 @@ import javax.swing.JOptionPane; +import cli.CLIHelper; import multiProcesing.ProcessDetectLoops; import loops.Loop; import sip.SIPIntra; @@ -64,9 +65,8 @@ public void run() throws InterruptedException, IOException{ if(_sip.isGui()) { JOptionPane.showMessageDialog(null,"Resolution problem", "Enable to find all the directories needed for SIP (-factor option)", JOptionPane.ERROR_MESSAGE); } - System.out.println("!!!! It is missing one or several directories for factor paramter\n"); - SIPIntra.docError(); - System.exit(0); + System.out.println("!!!! It is missing one or several directories for factor parameter\n"); + CLIHelper.CmdHelpProcessed(); } } From 266b8728345d72c60ba0527a999abaf29bf9d793 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Thu, 19 Nov 2020 18:59:20 -0500 Subject: [PATCH 18/27] cool and processed options helper/commandParser/run done missing only inter chromosomal for cool option --- src/cli/CLIOptionCool.java | 4 +- src/process/Cool.java | 312 +++++++++++++++++++++++++++ src/process/HiC.java | 1 - src/process/MCool.java | 12 -- src/process/ParametersCheck.java | 40 +++- src/process/Processed.java | 273 +++++++++++++++++++++++- src/sipMain/Hic_main.java | 349 ++----------------------------- src/utils/MultiResProcess.java | 52 +++-- 8 files changed, 677 insertions(+), 366 deletions(-) create mode 100644 src/process/Cool.java delete mode 100644 src/process/MCool.java diff --git a/src/cli/CLIOptionCool.java b/src/cli/CLIOptionCool.java index 7e9b433..d27ea66 100644 --- a/src/cli/CLIOptionCool.java +++ b/src/cli/CLIOptionCool.java @@ -35,8 +35,8 @@ public CLIOptionCool(String [] args){ this._options.addOption(_saturated); this._options.addOption(_isDroso); - this._options.addOption(Option.builder("cooltools").longOpt("cooltools").required() - .type(String.class).desc("Path to cooltools bin\n").numberOfArgs(1).build()); + this._options.addOption(Option.builder("coolTool").longOpt("coolTool").required() + .type(String.class).desc("Path to coolTool bin\n").numberOfArgs(1).build()); this._options.addOption(Option.builder("cooler").longOpt("cooler").required() .type(String.class).desc("Path to cooler bin\n").numberOfArgs(1).build()); diff --git a/src/process/Cool.java b/src/process/Cool.java new file mode 100644 index 0000000..2ad6272 --- /dev/null +++ b/src/process/Cool.java @@ -0,0 +1,312 @@ +package process; + + +import cli.CLIOptionHiC; +import gui.GuiAnalysis; +import multiProcesing.ProcessCoolerDumpData; +import multiProcesing.ProcessDetectLoops; +import multiProcesing.ProcessDumpData; +import org.apache.commons.cli.CommandLine; +import sip.SIPInter; +import sip.SIPIntra; +import utils.MultiResProcess; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Arrays; + +/** + * + */ +public class Cool { + /** */ + private SIPIntra _sipIntra; + /** */ + private SIPInter _sipInter; + /** */ + private CommandLine _cmd; + + /** */ + private String _input; + /** */ + private String _output; + /** */ + private String _chrSizeFile; + + /** */ + private int _nbZero; + /** */ + private boolean _delImages; + /** */ + private int _cpu; + /** */ + private boolean _isGui; + /** */ + private GuiAnalysis _guiAnalysis; + /** */ + private String _coolTool; + /** */ + private String _interOrIntra; + /** */ + private ParametersCheck _parameterCheck; + /** */ + private String _cooler; + /** */ + String _log; + + /** + * + * @param args + * @throws Exception + */ + public Cool(String args []){ + _isGui = false; + String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); + CLIOptionHiC cli = new CLIOptionHiC(argsSubset); + _cmd = cli.getCommandLine(); + _input = _cmd.getOptionValue("input"); + _output = _cmd.getOptionValue("output"); + _log = _output+File.separator+"log.txt"; + _delImages = true; + _nbZero = 6; + _cpu = 1; + } + + /** + * + * @param guiAnalysis + */ + public Cool(GuiAnalysis guiAnalysis ){ + _isGui = true; + _guiAnalysis = guiAnalysis; + _input = this._guiAnalysis.getInput(); + _output = this._guiAnalysis.getOutputDir(); + _log = _output+File.separator+"log.txt"; + _delImages = true; + _nbZero = 6; + _cpu = 1; + } + /** + * + * Normalisation method to dump the the data with hic method (KR,NONE.VC,VC_SQRT) + * + * + * @throws IOException + * @throws InterruptedException + */ + public void run() throws IOException, InterruptedException { + + String allParam; + + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); + + if(_isGui) { + _cooler = this._guiAnalysis.getCooler(); + if(this._guiAnalysis.isInter()) _interOrIntra = "inter"; + else _interOrIntra = "intra"; + _chrSizeFile = this._guiAnalysis.getChrSizeFile(); + _coolTool = this._guiAnalysis.getCooltools(); + _nbZero = this._guiAnalysis.getNbZero(); + _delImages = this._guiAnalysis.isDeletTif(); + _cpu = this._guiAnalysis.getNbCpu(); + }else { + /* common required parameters*/ + + _cooler = _cmd.getOptionValue("cooler"); + _coolTool = _cmd.getOptionValue("coolTool"); + _interOrIntra = _cmd.getOptionValue("lt"); + _chrSizeFile = _cmd.getOptionValue("chrSize"); + /* common optional parameters */ + if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); + if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); + } + _parameterCheck = new ParametersCheck(_input, _output, _chrSizeFile, _interOrIntra); + _parameterCheck.testCoolOption(_coolTool, _cooler, _isGui); + + if(_interOrIntra.equals("intra")) + allParam = runIntra(); + else + allParam = runInter(); + + + writer.write(allParam); + + + } + + /** + * + * @return + * @throws IOException + * @throws InterruptedException + */ + private String runIntra() throws IOException, InterruptedException { + /* Param spe intra chromosomal loop*/ + if(_isGui) + this.setSipIntraGUI(); + else + this.setSipIntraCLI(); + + _sipIntra.setIsGui(_isGui); + _sipIntra.setIsProcessed(false); + _sipIntra.setIsCooler(false); + + ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); + String allParam = "SIPHiC hic: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "cooler: "+ _cooler +"\n"+ + "coolTool: "+ _coolTool +"\n" + + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipIntra.getGauss()+"\n"+ + "min: "+this._sipIntra.getMin()+"\n"+ + "max: "+this._sipIntra.getMax()+"\n"+ + "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ + "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ + "resolution: "+this._sipIntra.getResolution()+"\n"+ + "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ + "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ + "number of zero: "+this._nbZero+"\n"+ + "factor: "+ _sipIntra.getFactor() +"\n"+ + "fdr: "+this._sipIntra.getFdr()+"\n"+ + "delete images: "+_delImages+"\n"+ + "cpu: "+ _cpu+"\n" + + "isDroso: "+this._sipIntra.isDroso()+"\n"; + + System.out.println("########### Starting dump Step inter chromosomal interactions"); + + _parameterCheck.optionalParametersValidity(_sipIntra); + _parameterCheck.speOption(_sipIntra); + + processDumpData.go(_coolTool,_cooler, _sipIntra, _input); + System.out.println("########### End of the dump step\n"); + + System.out.println("########### Start loop detection\n"); + MultiResProcess multi = new MultiResProcess(_sipIntra, _chrSizeFile); + multi.run(); + System.out.println("###########End loop detection step\n"); + return allParam; + } + + + /** + * + * @throws IOException + */ + private String runInter() throws IOException, InterruptedException { + System.out.println("PAS finis de dev\n"); + //TODO inter chromosomal loop with cool option + /*ProcessDumpData processDumpData = new ProcessDumpData(); + + this.setSipInter(); + _sipInter.setIsGui(_isGui); + _sipIntra.setIsProcessed(false); + _sipIntra.setIsCooler(false); + + + String allParam = "SIPHiC hic: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "juiceBox: "+ _juicerTool +"\n"+ + "norm: "+ _juicerNorm +"\n" + + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipInter.getGauss()+"\n"+ + "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ + "resolution: "+this._sipInter.getResolution()+"\n"+ + "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ + "number of zero :"+_nbZero+"\n"+ + "fdr "+this._sipInter.getFdr()+"\n"+ + "delete images "+_delImages+"\n"+ + "cpu "+ _cpu+"\n"; + _parameterCheck.optionalParametersValidity(_sipInter); + + processDumpData.go(_input,_sipInter, _juicerTool, _juicerNorm); + + String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; + + ProcessDetectLoops detectLoops = new ProcessDetectLoops(); + detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); + */ + return "plopi"; + + } + + + /** + * + */ + private void setSipIntraCLI(){ + double min = 2.0; + double max = 2.0; + double gauss = 1.5; + int matrixSize = 2000; + double thresholdMax = 2800; + double fdr = 0.01; + int resolution = 5000; + int diagSize = 6; + double saturatedPixel = 0.01; + boolean isDroso = false; + int factorParam = 1; + + if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); + if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); + if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); + if (_cmd.hasOption("factor")){ + factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); + _parameterCheck.checkFactor(factorParam); + } + + _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, + thresholdMax, diagSize, matrixSize, _nbZero, factorParam, fdr, isDroso,_delImages, _cpu); + } + /** + * + * + */ + private void setSipIntraGUI(){ + + _sipIntra = new SIPIntra(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getMin(), + _guiAnalysis.getMax(), _guiAnalysis.getResolution(), _guiAnalysis.getSaturatedPixel(), + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getDiagSize(), _guiAnalysis.getMatrixSize(), + _nbZero, _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); + + + } + + /** + * + * + */ + private void setSipInter() throws IOException { + + if(_isGui){ + _sipInter = new SIPInter(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getMatrixSize(), _nbZero, _guiAnalysis.getFDR(), _delImages,_cpu); + + }else{ + double gauss = 1; + int matrixSize = 500; + double thresholdMax = 0.01; + double fdr = 0.025; + int resolution = 100000; + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + _sipInter = new SIPInter(_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, fdr, _delImages,_cpu); + } + + + } +} diff --git a/src/process/HiC.java b/src/process/HiC.java index bf1c783..1f2a407 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -14,7 +14,6 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; /** diff --git a/src/process/MCool.java b/src/process/MCool.java deleted file mode 100644 index e22b816..0000000 --- a/src/process/MCool.java +++ /dev/null @@ -1,12 +0,0 @@ -package process; - -public class MCool { - - private String [] _args; - - public MCool(String args []) { - _args = args; - } - - -} diff --git a/src/process/ParametersCheck.java b/src/process/ParametersCheck.java index 1fa5e4b..b7a9d58 100644 --- a/src/process/ParametersCheck.java +++ b/src/process/ParametersCheck.java @@ -5,6 +5,7 @@ import sip.SIPIntra; import sip.SIPObject; +import javax.swing.*; import java.io.*; @@ -89,6 +90,40 @@ public ParametersCheck(String input, String output, String chrSizeFile, String i } } + /** + * + * @param coolTool + * @param cooler + * @param isGui + */ + public void testCoolOption(String coolTool, String cooler,boolean isGui){ + + File f = new File(coolTool); + if(!f.exists()){ + System.out.println("File problem !!!!\n-coolTool "+coolTool+" doesn't existed or wrong path !!! \n\n"); + CLIHelper.CmdHelpCool(); + } + + f = new File(cooler); + if(!f.exists()){ + System.out.println("File problem !!!!\n-cooler "+cooler+" doesn't existed or wrong path !!! \n\n"); + CLIHelper.CmdHelpCool(); + } + + if(!testTools(coolTool, 0, 3, 0) || !testTools(cooler, 0, 8, 6)) { + System.out.println("Versioning problem !!!!\n"+coolTool + + " or" + cooler + " version is not the good one for SIP (it needs cooltool version >= 0.3.0 and " + + "cooler version >= 0.8.6) !!! \n\n"); + CLIHelper.CmdHelpCool(); + if (isGui) { + JOptionPane.showMessageDialog(null, "Error SIP program", coolTool + " or" + cooler + "version is not the good one" + + " for SIP (it needs cooltools version >= 0.3.0 and cooler version >= 0.8.6) !!!" + , JOptionPane.ERROR_MESSAGE); + } + } + + } + /** * * @param juicerTool @@ -186,6 +221,9 @@ public boolean testTools(String pathTools, int first, int second, int third) { return false; } + /** + * + */ public class ReturnFlux extends Thread { /** Flux to redirect */ @@ -207,7 +245,7 @@ public void run(){ BufferedReader br = new BufferedReader(reader); String line=null; while ( (line = br.readLine()) != null) { - if(line.contains("WARN")== false) _logError = _logError+line+"\n"; + if(!line.contains("WARN")) _logError = _logError+line+"\n"; } } catch (IOException ioe){ diff --git a/src/process/Processed.java b/src/process/Processed.java index a91b77c..dcf94f3 100644 --- a/src/process/Processed.java +++ b/src/process/Processed.java @@ -1,18 +1,287 @@ package process; + +import cli.CLIOptionProcessed; import gui.GuiAnalysis; +import multiProcesing.ProcessDetectLoops; +import multiProcesing.ProcessDumpData; +import org.apache.commons.cli.CommandLine; +import sip.SIPInter; +import sip.SIPIntra; +import utils.MultiResProcess; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Arrays; +/** + * + */ public class Processed { + /** */ + private SIPIntra _sipIntra; + /** */ + private SIPInter _sipInter; + /** */ + private CommandLine _cmd; + /** */ + private String _input; + /** */ + private String _output; + /** */ + private String _chrSizeFile; + /** */ + private int _nbZero; + /** */ + private boolean _delImages; + /** */ + private int _cpu; + /** */ + private boolean _isGui; + /** */ + private GuiAnalysis _guiAnalysis; + /** */ + private String _interOrIntra; + /** */ + private ParametersCheck _parameterCheck; + /** */ + String _log; + + /** + * + * @param args + * @throws Exception + */ + public Processed(String args []){ + _isGui = false; + String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); + CLIOptionProcessed cli = new CLIOptionProcessed(argsSubset); + _cmd = cli.getCommandLine(); + _input = _cmd.getOptionValue("input"); + _output = _cmd.getOptionValue("output"); + _log = _output+File.separator+"log.txt"; + _delImages = true; + _nbZero = 6; + _cpu = 1; + } + + /** + * + * @param guiAnalysis + */ + public Processed(GuiAnalysis guiAnalysis ){ + _isGui = true; + _guiAnalysis = guiAnalysis; + _input = this._guiAnalysis.getInput(); + _output = this._guiAnalysis.getOutputDir(); + _log = _output+File.separator+"log.txt"; + _delImages = true; + _nbZero = 6; + _cpu = 1; + } + /** + * + * Normalisation method to dump the the data with hic method (KR,NONE.VC,VC_SQRT) + * + * + * @throws IOException + * @throws InterruptedException + */ + public void run() throws IOException, InterruptedException { + + String allParam; + + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); + + if(_isGui) { + if(this._guiAnalysis.isInter()) _interOrIntra = "inter"; + else _interOrIntra = "intra"; + _chrSizeFile = this._guiAnalysis.getChrSizeFile(); + _nbZero = this._guiAnalysis.getNbZero(); + _delImages = this._guiAnalysis.isDeletTif(); + _cpu = this._guiAnalysis.getNbCpu(); + }else { + /* common required parameters*/ + _interOrIntra = _cmd.getOptionValue("lt"); + _chrSizeFile = _cmd.getOptionValue("chrSize"); + /* common optional parameters */ + if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); + if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); + } + _parameterCheck = new ParametersCheck(_input, _output, _chrSizeFile, _interOrIntra); + + if(_interOrIntra.equals("intra")) + allParam = runIntra(); + else + allParam = runInter(); - public Processed(String args[]){ + writer.write(allParam); } - public Processed(GuiAnalysis gui){ + /** + * + * @return + * @throws IOException + * @throws InterruptedException + */ + private String runIntra() throws IOException, InterruptedException { + /* Param spe intra chromosomal loop*/ + if(_isGui) + this.setSipIntraGUI(); + else + this.setSipIntraCLI(); + _sipIntra.setIsGui(_isGui); + _sipIntra.setIsProcessed(true); + _sipIntra.setIsCooler(false); + + String allParam = "SIPHiC processed: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipIntra.getGauss()+"\n"+ + "min: "+this._sipIntra.getMin()+"\n"+ + "max: "+this._sipIntra.getMax()+"\n"+ + "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ + "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ + "resolution: "+this._sipIntra.getResolution()+"\n"+ + "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ + "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ + "number of zero: "+this._nbZero+"\n"+ + "factor: "+ _sipIntra.getFactor() +"\n"+ + "fdr: "+this._sipIntra.getFdr()+"\n"+ + "delete images: "+_delImages+"\n"+ + "cpu: "+ _cpu+"\n" + + "isDroso: "+this._sipIntra.isDroso()+"\n"; + + System.out.println("########### Starting dump Step inter chromosomal interactions"); + + _parameterCheck.optionalParametersValidity(_sipIntra); + _parameterCheck.speOption(_sipIntra); + + System.out.println("########### Start loop detection\n"); + MultiResProcess multi = new MultiResProcess(_sipIntra, _chrSizeFile); + multi.run(); + System.out.println("###########End loop detection step\n"); + return allParam; } + + /** + * + * @throws IOException + */ + private String runInter() throws IOException, InterruptedException { + ProcessDumpData processDumpData = new ProcessDumpData(); + + this.setSipInter(); + _sipInter.setIsGui(_isGui); + _sipIntra.setIsProcessed(true); + _sipIntra.setIsCooler(false); + + + String allParam = "SIPHiC processed: \n" + + "input: "+_input+"\n" + + "output: "+_output+"\n"+ + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipInter.getGauss()+"\n"+ + "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ + "resolution: "+this._sipInter.getResolution()+"\n"+ + "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ + "number of zero :"+_nbZero+"\n"+ + "fdr "+this._sipInter.getFdr()+"\n"+ + "delete images "+_delImages+"\n"+ + "cpu "+ _cpu+"\n"; + _parameterCheck.optionalParametersValidity(_sipInter); + + String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; + + ProcessDetectLoops detectLoops = new ProcessDetectLoops(); + detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); + + return allParam; + + } + + + /** + * + */ + private void setSipIntraCLI(){ + double min = 2.0; + double max = 2.0; + double gauss = 1.5; + int matrixSize = 2000; + double thresholdMax = 2800; + double fdr = 0.01; + int resolution = 5000; + int diagSize = 6; + double saturatedPixel = 0.01; + boolean isDroso = false; + int factorParam = 1; + + if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); + if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); + if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); + if (_cmd.hasOption("factor")){ + factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); + _parameterCheck.checkFactor(factorParam); + } + + _sipIntra = new SIPIntra(_input,_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, + thresholdMax, diagSize, matrixSize, _nbZero, factorParam, fdr, isDroso,_delImages, _cpu); + } + /** + * + * + */ + private void setSipIntraGUI(){ + _sipIntra = new SIPIntra(_input, _output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getMin(), + _guiAnalysis.getMax(), _guiAnalysis.getResolution(), _guiAnalysis.getSaturatedPixel(), + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getDiagSize(), _guiAnalysis.getMatrixSize(), + _nbZero, _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); + + + } + + /** + * + * + */ + private void setSipInter() throws IOException { + + if(_isGui){ + _sipInter = new SIPInter(_input,_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getMatrixSize(), _nbZero, _guiAnalysis.getFDR(), _delImages,_cpu); + + }else{ + double gauss = 1; + int matrixSize = 500; + double thresholdMax = 0.01; + double fdr = 0.025; + int resolution = 100000; + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + _sipInter = new SIPInter(_input,_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, fdr, _delImages,_cpu); + } + + + } } diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index da8f4ff..1012aa1 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -1,16 +1,12 @@ package sipMain; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.util.ArrayList; import cli.CLIHelper; import gui.GuiAnalysis; import process.HiC; -import process.MCool; +import process.Cool; import process.Processed; -import sip.SIPIntra; /** * @@ -22,62 +18,6 @@ * */ public class Hic_main { - /** Path of input data directory if dumped or processed data else .hic for hic option*/ - private static String _input = ""; - /** Path of output if not existed it is created*/ - private static String _output = ""; - /** Path to the jucier_tools_box to dump the data not necessary for Processed and dumped method */ - private static String _juiceBoxTools = ""; - /** Path to the jucier_tools_box to dump the data not necessary for Processed and dumped method */ - private static String _cooler = ""; - /** Path to the jucier_tools_box to dump the data not necessary for Processed and dumped method */ - private static String _cooltools = ""; - /**Normalisation method to dump the the data with hic method (KR,NONE.VC,VC_SQRT)*/ - private static String _juiceBoXNormalisation = "KR"; - /**Size of the core for the gaussian blur filter allow to smooth the signal*/ - private static double _gauss = 1.5; - /**Size of the core for the Minimum filter*/ - private static double _min = 2.0; - /**Size of the core for the Maximum filter*/ - private static double _max = 2.0; - /**Matrix size: size in bins of the final image and defined the zone of interest in the hic map*/ - private static int _matrixSize = 2000; - /**Distance to the diagonal where the loops are ignored*/ - private static int _diagSize = 6; - /**Resolution of the matric in bases*/ - private static int _resolution = 5000; - /** % of saturated pixel in the image, allow the enhancement of the contrast in the image*/ - private static double _saturatedPixel = 0.01; - /** Threshold to accepet a maxima in the images as a loop*/ - private static int _thresholdMax = 2800; - /**number of pixel = 0 allowed around the loop*/ - private static int _nbZero = 6; - /** boolean if true run all the process (dump data + image +image processing*/ - private static boolean _isHic = true; - /** boolean if true run all the process (dump data + image +image processing*/ - private static boolean _isCool = false; - /** boolean if true run all the process (dump data + image +image processing*/ - private static boolean _isDroso = false; - /** factor(s) used to nalyse the matrix*/ - private static ArrayList _factor = new ArrayList(); - /** String factor option*/ - private static String _factOption = "1"; - /** if true run only image Processing step*/ - private static boolean _isProcessed = false; - /** hash map stocking in key the name of the chr and in value the size*/ -// private static HashMap _chrSize = new HashMap(); - /** path to the chromosome size file */ - private static String _chrSizeFile; - /**boolean is true supress all the image created*/ - private static boolean _delImages = true; - /** double FDR value for filtering */ - private static double _fdr = 0.01; - /** int number of cpu*/ - private static int _cpu = 1; - /**boolean is true supress all the image created*/ - private static boolean _gui = false; - private static String _logError = ""; - /** @@ -93,24 +33,31 @@ public class Hic_main { public static void main(String[] args) throws Exception { /*CLI */ - if(args.length >= 1) { if (args[0].equals("hic")) { - if(args[1].equals("-h") || args[1].equals("--help")){ + if(args[1].equals("-h") || args[1].equals("--help")) + CLIHelper.CmdHelpHiC(); - - } HiC hic = new HiC(args); hic.run(); }else if (args[0].equals("processed")) { + if(args[1].equals("-h") || args[1].equals("--help")) + CLIHelper.CmdHelpProcessed(); + Processed processed = new Processed(args); + processed.run(); + }else if (args[0].equals("cool")) { - MCool mCool = new MCool(args); + if(args[1].equals("-h") || args[1].equals("--help")) + CLIHelper.CmdHelpCool(); - }else { + Cool Cool = new Cool(args); + + + }else CLIHelper.getHelperAllInfos(); - } + } /*GUI */ else{ @@ -126,7 +73,8 @@ public static void main(String[] args) throws Exception { }else if(gui.isCool()){ }else if(gui.isProcessed()){ - + Processed processed = new Processed(gui); + processed.run(); } }else { System.out.println("SIP closed: if you want the help: -h"); @@ -134,101 +82,10 @@ public static void main(String[] args) throws Exception { } } -/* _input = args[1]; - _output = args[3]; - _chrSizeFile = args[2]; - if (args[0].equals("hic")){ - readOption(args,5); - _juiceBoxTools = args[4]; - }else if(args[0].equals("processed")){ - _isHic = false; - _isProcessed = true; - readOption(args,4); - }else if(args[0].equals("cool")){ - _isHic = false; - _isProcessed = false; - _isCool = true; - _cooler = args[5]; - _cooltools = args[4]; - readOption(args,6); - } - - }else{////////////////////////////////////////GUI parameter initialisation - GuiAnalysis gui = new GuiAnalysis(); - _gui =true; - while( gui.isShowing()){ - try {Thread.sleep(1);} - catch (InterruptedException e) {e.printStackTrace();} - } - if (gui.isStart()){ - _isCool = gui.isCool(); - _chrSizeFile = gui.getChrSizeFile(); - _output = gui.getOutputDir(); - _input = gui.getInput(); - _matrixSize = gui.getMatrixSize(); - _diagSize = gui.getDiagSize(); - _resolution = gui.getResolution(); - _delImages = gui.isDeletTif(); - _gauss = gui.getGaussian(); - _max = gui.getMax(); - _min = gui.getMin(); - _isDroso= gui.isDroso(); - _nbZero = gui.getNbZero(); - _saturatedPixel = gui.getSaturatedPixel(); - _thresholdMax = gui.getThresholdMaxima(); - _fdr = gui.getFDR(); - _cpu = gui.getNbCpu(); - if(gui.getFactorChoice() == 2){ - _factor.add(2); - }else if(gui.getFactorChoice() == 4){ - _factor.add(2); - _factor.add(5); - }else if(gui.getFactorChoice() == 3){ - _factor.add(5); - } - _isHic = gui.isHic(); - _isProcessed = gui.isProcessed(); - _juiceBoxTools = gui.getJuicerTool(); - _cooltools = gui.getCooltools(); - _cooler = gui.getCooler(); - - if(gui.isNONE()) _juiceBoXNormalisation = "NONE"; - else if (gui.isVC()) _juiceBoXNormalisation = "VC"; - else if (gui.isVC_SQRT()) _juiceBoXNormalisation = "VC_SQRT"; - }else { - System.out.println("SIP closed: if you want the help: -h"); - return; - } - } - File f = new File(_input); - - if(!f.exists() && !_input.startsWith("https")){ - System.out.println(_input+" doesn't existed !!! \n\n"); - SIPIntra.docError(); - return; - } - - f = new File(_chrSizeFile); - if(!f.exists()){ - System.out.println(_chrSizeFile+" doesn't existed !!! \n\n"); - SIPIntra.docError(); - return; - } - +/* SIPIntra sip; if(_isHic){ - f = new File(_juiceBoxTools); - if(!f.exists()){ - System.out.println(_juiceBoxTools+" doesn't existed !!! \n\n"); - SIPIntra.docError(); - return; - } - System.out.println("hic mode: \n"+ "input: "+_input+"\n"+ "output: "+_output+"\n"+ "juiceBox: "+_juiceBoxTools+"\n"+ "norm: "+ _juiceBoXNormalisation+"\n" - + "gauss: "+_gauss+"\n"+ "min: "+_min+"\n"+ "max: "+_max+"\n"+ "matrix size: "+_matrixSize+"\n"+ "diag size: "+_diagSize+"\n"+ "resolution: "+_resolution+"\n" - + "saturated pixel: "+_saturatedPixel+"\n"+ "threshold: "+_thresholdMax+"\n"+ "number of zero :"+_nbZero+"\n"+ "factor "+ _factOption+"\n"+ "fdr "+_fdr+"\n" - + "del "+_delImages+"\n"+ "cpu "+ _cpu+"\n-isDroso "+_isDroso+"\n"); - sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); sip.setIsGui(_gui); @@ -236,31 +93,6 @@ public static void main(String[] args) throws Exception { processDumpData.go(_input, sip, _juiceBoxTools, _juiceBoXNormalisation, _cpu); System.out.println("########### End of the dump Step"); }else if(_isCool){ - f = new File(_cooltools); - if(!f.exists()){ - System.out.println(_cooltools+" doesn't existed or wrong path !!! \n\n"); - SIPIntra.docError(); - return; - } - f = new File(_cooler); - if(!f.exists()){ - System.out.println(_cooler+" doesn't existed or wrong path !!! \n\n"); - SIPIntra.docError(); - return; - } - if(!testTools(_cooltools, 0, 3, 0) || !testTools(_cooler, 0, 8, 6)) { - System.out.println( _cooltools +" or" + _cooler+" is not the good version for SIP (it needs cooltools version >= 0.3.0 and cooler version >= 0.8.6) !!! \n\n"); - SIPIntra.docError(); - if(_gui){ - JOptionPane.showMessageDialog(null, "Error SIP program", _cooltools +" or" + _cooler+" is not the good version for SIP (it needs cooltools version >= 0.3.0 and cooler version >= 0.8.6) !!!" - , JOptionPane.ERROR_MESSAGE); - } - return; - } - System.out.println("cool mode: \n"+ "input: "+_input+"\n"+ "output: "+_output+"\n"+"cooltools: "+_cooltools+"\n"+ "cooler: "+_cooler+"\n"+ "norm: "+ _juiceBoXNormalisation+"\n" - + "gauss: "+_gauss+"\n"+ "min: "+_min+"\n"+ "max: "+_max+"\n"+ "matrix size: "+_matrixSize+"\n"+ "diag size: "+_diagSize+"\n"+ "resolution: "+_resolution+"\n" - + "saturated pixel: "+_saturatedPixel+"\n"+ "threshold: "+_thresholdMax+"\n"+ "number of zero :"+_nbZero+"\n"+ "factor "+ _factOption+"\n"+ "fdr "+_fdr+"\n" - + "del "+_delImages+"\n"+ "cpu "+ _cpu+"\n-isDroso "+_isDroso+"\n"); sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); sip.setIsCooler(_isCool); @@ -268,12 +100,7 @@ public static void main(String[] args) throws Exception { processDumpData.go(_cooltools, _cooler, sip, _input, _cpu); }else{ - System.out.println("processed mode:\n"+ "input: "+_input+"\n"+ "output: "+_output+"\n"+ "juiceBox: "+_juiceBoxTools+"\n" - + "norm: "+ _juiceBoXNormalisation+"\n"+ "gauss: "+_gauss+"\n"+ "min: "+_min+"\n"+ "max: "+_max+"\n"+ "matrix size: "+_matrixSize+"\n" - + "diag size: "+_diagSize+"\n"+ "resolution: "+_resolution+"\n"+ "saturated pixel: "+_saturatedPixel+"\n"+ "threshold: "+_thresholdMax+"\n" - + "isHic: "+_isHic+"\n" + "isProcessed: "+_isProcessed+"\n"+ "number of zero:"+_nbZero+"\n"+ "factor "+ _factOption+"\n"+ "fdr "+_fdr+ "\n" - + "del "+_delImages+"\n"+"cpu "+ _cpu+"\n-isDroso "+_isDroso+"\n"); - + sip = new SIPIntra(_input,_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero,_factor,_fdr); sip.setIsDroso(_isDroso); @@ -281,146 +108,12 @@ public static void main(String[] args) throws Exception { sip.setIsGui(_gui); } System.out.println("Start loop detction step"); - MultiResProcess multi = new MultiResProcess(sip, _cpu, _delImages,_chrSizeFile); multi.run(); System.out.println("###########End loop detction step"); - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_output+File.separator+"parameters.txt"))); - if(_isProcessed){ - writer.write("java -jar Sip_HiC.jar processed "+ _input+" "+ _chrSizeFile+" "+_output+" -g "+_gauss+" -mat "+_matrixSize+" -d "+_diagSize - +" -res "+_resolution+" -t "+_thresholdMax+" -min "+_min+" -max "+_max+" -sat "+_saturatedPixel+" -nbZero "+_nbZero - +" -factor "+ _factOption+" -fdr "+_fdr+" -del "+_delImages+" -cpu "+ _cpu+" -isDroso "+_isDroso+"\n"); - - }else if(_isCool){ - writer.write("java -jar SIP_HiC.jar hic "+_input+" "+_chrSizeFile+" "+_output+" "+_cooltools+" "+_cooler+ - " -g "+_gauss+" -min "+_min+" -max "+_max+" -mat "+_matrixSize+ - " -d "+_diagSize+" -res "+_resolution+" -sat "+_saturatedPixel+" -t "+_thresholdMax+" -nbZero "+_nbZero+ - " -factor "+ _factOption+" -fdr "+_fdr+" -del "+_delImages+" -cpu "+ _cpu+" -isDroso "+_isDroso+"\n"); - }else{ - writer.write("java -jar SIP_HiC.jar hic "+_input+" "+_chrSizeFile+" "+_output+" "+_juiceBoxTools+ - " -norm "+ _juiceBoXNormalisation+" -g "+_gauss+" -min "+_min+" -max "+_max+" -mat "+_matrixSize+ - " -d "+_diagSize+" -res "+_resolution+" -sat "+_saturatedPixel+" -t "+_thresholdMax+" -nbZero "+_nbZero+ - " -factor "+ _factOption+" -fdr "+_fdr+" -del "+_delImages+" -cpu "+ _cpu+" -isDroso "+_isDroso+"\n"); - } - writer.close(); - - if(_gui){ - JOptionPane.showMessageDialog(null,"Results available: "+_output , "End of SIP program", JOptionPane.INFORMATION_MESSAGE); - } - System.out.println("End of SIP loops are available in "+_output);*/ - } - /** - * -res: resolution in bases (default 5000 bases) - * -mat: matrix size in bins (default 2000 bins) - * -d: diagonal size in bins (default 2 bins) - * -g: Gaussian filter (default 1) - * -max: Maximum filter: increase the region of high intensity (default 1.5) - * -min: minimum filter: removed the isolated high value (default 1.5) - * -sat: % of staturated pixel: enhance the contrast in the image (default 0.05) - * -t Threshold for loops detection (default 3000) - * -norm: only for hic option (default KR) - * -nbZero: - * -cpu - * -del - * -fdr - * - * @param args table of String stocking the arguments for the program - * @param index table index where start to read the arguments - * @throws IOException if some parameters don't exist - */ - /*private static void readOption(String args[], int index) throws IOException{ - if(index < args.length){ - for(int i = index; i < args.length;i+=2){ - if(args[i].equals("-res")){ - try{_resolution =Integer.parseInt(args[i+1]);} - catch(NumberFormatException e){ returnError("-res",args[i+1],"int");} - }else if(args[i].equals("-mat")){ - try{_matrixSize =Integer.parseInt(args[i+1]);} - catch(NumberFormatException e){ returnError("-mat",args[i+1],"int");} - }else if(args[i].equals("-factor")){ - int a = Integer.parseInt(args[i+1]); - _factOption = args[i+1]; - if(a == 2){ _factor.add(2);} - else if(a == 4){ - _factor.add(2); - _factor.add(5); - }else if(a == 3){ _factor.add(5);} - else if(a != 1) returnError("-factor ",args[i+1]," int or not correct choice (1, 2, 3, 4)"); - }else if(args[i].equals("-d")){ - try{_diagSize =Integer.parseInt(args[i+1]);} - catch(NumberFormatException e){ returnError("-d",args[i+1],"int");} - }else if(args[i].equals("-cpu")){ - try{_cpu =Integer.parseInt(args[i+1]);} - catch(NumberFormatException e){ returnError("-cpu",args[i+1],"int");} - if(_cpu > Runtime.getRuntime().availableProcessors() || _cpu <= 0){ - System.out.println("the number of CPU "+ _cpu+" is superior of the server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); - //SIPIntra.docError(); - System.exit(0); - } - }else if(args[i].equals("-nbZero")){ - try{_nbZero =Integer.parseInt(args[i+1]);} - catch(NumberFormatException e){ returnError("-d",args[i+1],"int");} - }else if(args[i].equals("-g")){ - try{_gauss =Double.parseDouble(args[i+1]);} - catch(NumberFormatException e){ returnError("-g",args[i+1],"double");} - }else if(args[i].equals("-fdr")){ - try{_fdr =Double.parseDouble(args[i+1]);} - catch(NumberFormatException e){ returnError("-fdr",args[i+1],"double");} - }else if(args[i].equals("-max")){ - try{_max = Double.parseDouble(args[i+1]);} - catch(NumberFormatException e){ returnError("-max",args[i+1],"double");} - - }else if(args[i].equals("-min")){ - try{_min = Double.parseDouble(args[i+1]);} - catch(NumberFormatException e){ returnError("-min",args[i+1],"double");} - }else if(args[i].equals("-sat")){ - try{_saturatedPixel = Double.parseDouble(args[i+1]);} - catch(NumberFormatException e){ returnError("-sat",args[i+1],"double");} - }else if(args[i].equals("-t")){ - try{_thresholdMax =Integer.parseInt(args[i+1]);} - catch(NumberFormatException e){ returnError("-t",args[i+1],"int");} - }else if(args[i].equals("-norm")){ - if(args[i+1].equals("NONE") || args[i+1].equals("VC") - || args[i+1].equals("VC_SQRT") || args[i+1].equals("KR")){ - _juiceBoXNormalisation = args[i+1]; - }else{ - System.out.println("-norm = "+args[i+1]+", not defined\n"); - SIPIntra.docError(); - System.exit(0); - } - }else if(args[i].equals("-del")){ - if(args[i+1].equals("true") || args[i+1].equals("T") || args[i+1].equals("TRUE")) - _delImages = true; - else if(args[i+1].equals("false") || args[i+1].equals("F") || args[i+1].equals("False")) - _delImages = false; - else{ - System.out.println("-del = "+args[i+1]+", not defined\n"); - SIPIntra.docError(); - System.exit(0); - } - }else if(args[i].equals("-isDroso")){ - if(args[i+1].equals("true") || args[i+1].equals("T") || args[i+1].equals("TRUE")) - _isDroso = true; - else if(args[i+1].equals("false") || args[i+1].equals("F") || args[i+1].equals("False")) - _isDroso = false; - else{ - System.out.println("-_isDroso = "+args[i+1]+", not defined\n"); - SIPIntra.docError(); - System.exit(0); - } - }else{ - System.out.println(args[i]+" doesn't existed\n"); - SIPIntra.docError(); - System.exit(0); - } - } - } - }*/ - - - + */ + } - } diff --git a/src/utils/MultiResProcess.java b/src/utils/MultiResProcess.java index bd32a9a..5599259 100644 --- a/src/utils/MultiResProcess.java +++ b/src/utils/MultiResProcess.java @@ -83,25 +83,7 @@ public void run() throws InterruptedException, IOException{ ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); processDetectloops.go(this._sip, resuFile,resName); }else { - - int matrixSizeTpm = (int)(this._sip.getMatrixSize()/listFactor.get(indexFact)); - double gaussTpm = this._sip.getGauss()/listFactor.get(indexFact); - SIPIntra sipTmp = new SIPIntra(_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, - _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), - _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getFactor(), - _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); - - if(this._sip.isProcessed()) { - sipTmp = new SIPIntra(_sip.getInputDir(),_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, - _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), - _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getFactor(), - _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); - } - sipTmp.setIsGui(_sip.isGui()); - sipTmp.setStep(this._sip.getStep()/listFactor.get(indexFact)); - sipTmp.setIsProcessed(_sip.isProcessed()); - sipTmp.setIsCooler(_sip.isCooler()); - + SIPIntra sipTmp = setSIPIntraTmp(listFactor.get(indexFact)); ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); processDetectloops.go(sipTmp,resuFile,resName); } @@ -112,7 +94,37 @@ public void run() throws InterruptedException, IOException{ System.out.println("Merging File End !!!! "); } } - + + + /** + * + * @param factor + * @return + */ + private SIPIntra setSIPIntraTmp(int factor){ + int res = this._sip.getResolution()*factor; + int matrixSizeTpm = this._sip.getMatrixSize()/factor; + double gaussTpm = this._sip.getGauss()/factor; + SIPIntra sipTmp = new SIPIntra(_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, + _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), + _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getFactor(), + _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); + + if(this._sip.isProcessed()) { + sipTmp = new SIPIntra(_sip.getInputDir(),_sip.getOutputDir(), _sip.getChrSizeFile(), gaussTpm, + _sip.getMin(), _sip.getMax(), res, _sip.getSaturatedPixel(),_sip.getThresholdMaxima(), + _sip.getDiagonalSize(), matrixSizeTpm, _sip.getNbZero(), _sip.getFactor(), + _sip.getFdr(), _sip.isDroso(), _sip.isDelImage(), _sip.getCpu()); + } + sipTmp.setIsGui(_sip.isGui()); + sipTmp.setStep(this._sip.getStep()/factor); + sipTmp.setIsProcessed(_sip.isProcessed()); + sipTmp.setIsCooler(_sip.isCooler()); + return sipTmp; + + } + + /** * test the data organization * @return boolean if yes the dir of interest is existing From 91f05820f2fab9035f76293e4f07ad5aee97c6da Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Sun, 22 Nov 2020 20:31:03 -0500 Subject: [PATCH 19/27] First Beta version with inter chromosomal loop methods. --- src/cli/CLIHelper.java | 28 ++-- src/cli/CLIOptionCool.java | 8 +- src/cli/CLIOptionHiC.java | 10 +- src/cli/CLIOptionProcessed.java | 40 ++--- src/gui/GuiAnalysis.java | 1 + src/loops/CallLoops.java | 2 +- src/multiProcesing/ProcessDetectLoops.java | 6 +- src/process/Cool.java | 21 +-- src/process/HiC.java | 172 +++++++++------------ src/process/ParametersCheck.java | 166 ++++++++++++-------- src/process/Processed.java | 22 +-- src/sip/SIPInter.java | 4 +- src/sip/SIPIntra.java | 1 - src/sip/SIPObject.java | 2 +- src/sipMain/Hic_main.java | 24 ++- src/test/TestInter.java | 2 +- src/utils/FDR.java | 2 +- src/utils/FindMaxima.java | 2 +- src/utils/MultiResProcess.java | 7 +- 19 files changed, 271 insertions(+), 249 deletions(-) diff --git a/src/cli/CLIHelper.java b/src/cli/CLIHelper.java index b429faa..d240d91 100644 --- a/src/cli/CLIHelper.java +++ b/src/cli/CLIHelper.java @@ -2,8 +2,6 @@ import org.apache.commons.cli.HelpFormatter; -import java.io.PrintWriter; - public class CLIHelper { /** */ @@ -36,10 +34,10 @@ public static void CmdHelpHiC() { String argument = "-i path/to/hicFile.hic -c path/to/chrSizeFile.txt -o path/to/output/folder -j path/to/juicerTool.jar -lt intra "; String[] argv = argument.split(" "); CLIOptionHiC command = new CLIOptionHiC (argv); - String usage = _cool+argument+" [options]"; + String usage = _hic+argument+" [options]"; HelpFormatter formatter = new HelpFormatter(); - System.out.println("\nHelp for "+_cool+"!!!!!!! \n"); + System.out.println("\nHelp for "+_hic+"!!!!!!! \n"); formatter.printHelp(200, usage, "SIP_HiC version"+_version+"option hic: ", command.getOptions(),getAuthors()); System.exit(1); } @@ -83,10 +81,8 @@ public static void CmdHelpProcessed(){ */ public static void getHelperInfos() { System.out.println( "More details :\n" + - "java -jar SIPHiC"+ _version +".jar hic --help \n" + - "or \n"+ + "java -jar SIPHiC"+ _version +".jar hic -h or --help \n" + "java -jar SIPHiC-"+ _version +".jar cool -h or --help\n"+ - "or \n" + "java -jar SIPHiC-"+ _version +".jar processed -h or --help \n" + "\n\nCommand line g:\n" + "\tjava -jar SIP_HiC.jar hic -i path/to/hicFile.hic -c path/to/chrSizeFile -o path/to/output/folder -j path/to/juicerTool.jar -lt intra [options]\n" + @@ -102,22 +98,20 @@ public static void getHelperInfos() { * @return */ public static void getHelperAllInfos() { - System.out.println( "More details :\n" + - "java -jar SIPHiC"+ _version +".jar hic --help \n" + - "or \n"+ + System.out.println( "\nMore details :\n" + + "java -jar SIPHiC"+ _version +".jar hic -h or --help \n" + "java -jar SIPHiC-"+ _version +".jar cool -h or --help\n"+ - "or \n" + "java -jar SIPHiC-"+ _version +".jar processed -h or --help \n" + "\n\nCommand line g:\n" + "\tjava -jar SIP_HiC.jar hic -i path/to/hicFile.hic -c path/to/chrSizeFile -o path/to/output/folder -j path/to/juicerTool.jar -lt intra [options]\n" + "\tjava -jar SIP_HiC.jar cool -i path/to/hicFile.hic -c path/to/chrSizeFile -o path/to/output/folder -cooltools path/to/cooltools -cooler path/to/cooler -lt intra [options]\n" + "\tjava -jar SIP_HiC.jar processed -i SIP path/to/folder/SIPProcessedData -c path/to/chrSizeFile -o path/to/output/folder -lt intra [options]\n" + "\nAuthors:\n" + - "\nAxel Poulet\n" + + "Axel Poulet\n" + "Department of Molecular, Cellular and Developmental Biology Yale University \n" + - "\nM. Jordan Rowley\n" + + "M. Jordan Rowley\n" + "Department of Genetics, Cell Biology and Anatomy, University of Nebraska Medical\n" + - "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"); + "Contact: \npouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"); System.exit(1); } @@ -128,11 +122,11 @@ public static void getHelperAllInfos() { */ public static String getAuthors() { return "Authors:\n" + - "\nAxel Poulet\n" + + "Axel Poulet\n" + "Department of Molecular, Cellular and Developmental Biology Yale University \n" + - "\nM. Jordan Rowley\n" + + "M. Jordan Rowley\n" + "Department of Genetics, Cell Biology and Anatomy, University of Nebraska Medical\n" + - "\nContact: pouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"; + "Contact:\npouletaxel@gmail.com OR jordan.rowley@unmc.edu\n"; } diff --git a/src/cli/CLIOptionCool.java b/src/cli/CLIOptionCool.java index d27ea66..9be46b4 100644 --- a/src/cli/CLIOptionCool.java +++ b/src/cli/CLIOptionCool.java @@ -6,8 +6,7 @@ * */ public class CLIOptionCool extends CLIOptionProcessed { - /** */ - private CommandLine _commandLine; + /** * * @param args @@ -43,11 +42,14 @@ public CLIOptionCool(String [] args){ try { - _commandLine = _parser.parse(this._options, args); + _cmd = _parser.parse(this._options, args,false); } catch (ParseException exp){ System.out.println("\n"+exp.getMessage()+"\n"); CLIHelper.CmdHelpCool(); + }catch (IllegalArgumentException exp){ + System.out.println( exp.getMessage()); + CLIHelper.CmdHelpHiC(); } } diff --git a/src/cli/CLIOptionHiC.java b/src/cli/CLIOptionHiC.java index c51fc79..5efe3da 100644 --- a/src/cli/CLIOptionHiC.java +++ b/src/cli/CLIOptionHiC.java @@ -6,7 +6,7 @@ public class CLIOptionHiC extends CLIOptionProcessed { - public CLIOptionHiC(String [] args){ + public CLIOptionHiC(String [] args) { this._options.addOption(_inputFolder); this._options.addOption(_outputFolder); this._options.addOption(_chrSize); @@ -34,12 +34,16 @@ public CLIOptionHiC(String [] args){ .type(String.class).desc("\n (default KR)\n").numberOfArgs(1).build()); try { - this._cmd = this._parser.parse(this._options, args,true); + this._cmd = this._parser.parse(this._options, args, false); } catch (ParseException exp){ System.out.println("\n"+exp.getMessage()+"\n"); CLIHelper.CmdHelpHiC(); - } + }catch (IllegalArgumentException exp){ + System.out.println( exp.getMessage()); + CLIHelper.CmdHelpHiC(); + } + } diff --git a/src/cli/CLIOptionProcessed.java b/src/cli/CLIOptionProcessed.java index 5b57dc5..e5f83f8 100644 --- a/src/cli/CLIOptionProcessed.java +++ b/src/cli/CLIOptionProcessed.java @@ -15,6 +15,10 @@ public class CLIOptionProcessed { .type(String.class).desc("Path to input .hic, .mcool or SIP folder containing processed data\n") .numberOfArgs(1).build(); /** */ + Option _interOrIntra = Option.builder("lt").longOpt("loopsType").required() + .type(String.class).desc("value: inter or intra, call loops inter chromosomal or intra chromosomal interactions\n") + .numberOfArgs(1).build(); + /** */ Option _outputFolder= Option.builder("o").longOpt("output").required() .type(String.class).desc("Path to output folder for SIP's files \n") .numberOfArgs(1).build(); @@ -23,15 +27,14 @@ public class CLIOptionProcessed { .type(String.class).desc("Path to the chr size file, with the same name of the chr as in the hic file (i.e. chr1 does not match Chr1 or 1).\n") .numberOfArgs(1).build(); /** */ - Option _resolution = Option.builder("r").longOpt("resolution") - .type(Number.class).desc("Resolution in bp (default inter 5000 bp, intra 100 000 bp)\n") - .numberOfArgs(1).build(); + Option _resolution = Option.builder("r").longOpt("resolution").numberOfArgs(1) + .type(Number.class).desc("Resolution in bp (default inter 5000 bp, intra 100 000 bp)\n").build(); /** */ Option _sizeImage = Option.builder("ms").longOpt("matrixSize") .type(Number.class).desc("Matrix size to use for each chunk of the chromosome (default intra 2000 bins, inter 500)\n") .numberOfArgs(1).build(); /** */ - Option _cpu = Option.builder("cpu") + Option _cpu = Option.builder("cpu").longOpt("cpu") .type(Number.class).desc("Number of CPU used for SIP processing (default 1)\n") .numberOfArgs(1).build(); /** */ @@ -43,24 +46,21 @@ public class CLIOptionProcessed { .type(Number.class).desc("Threshold for loops detection (default intra 2800, inter 0.01)\n") .numberOfArgs(1).build(); /** */ - Option _nbZero = Option.builder("nbZero") + Option _nbZero = Option.builder("nb").longOpt("nbZero") .type(Number.class).desc("Number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected loop (default 6)\n") .numberOfArgs(1).build(); /** */ - Option _fdr = Option.builder("fdr") + Option _fdr = Option.builder("fdr").longOpt("fdr") .type(Number.class).desc("Empirical FDR value for filtering based on random sites (default intra value: 0.01, inter value: 0.025)\n") .numberOfArgs(1).build(); /** */ - Option _deleteImage = Option.builder("d").longOpt("delete") - .type(boolean.class).desc("Delete tif files used for loop detection (default true)\n") - .build(); - /** */ - Option _interOrIntra = Option.builder("lt").longOpt("loopsType").required() - .type(String.class).desc("value: inter or intra, call loops inter chromosomal or intra chromosomal interactions\n") - .build(); + Option _deleteImage = Option.builder("k").longOpt("keepImage").hasArg(false) + .type(boolean.class).desc("keep tif in output folder if used\n") + .numberOfArgs(0).build(); + /** */ - Option _isDroso = Option.builder("isDroso") - .type(boolean.class).desc("If true apply extra filter to help detect loops similar to those found in D. mel cells (Default: false, used only for intra chromosomal)\n") + final Option _isDroso = Option.builder("isDroso").longOpt("isDroso").hasArg(false) + .type(boolean.class).desc("If option use, apply extra filter to help detect loops similar to those found in D. mel cells (used only for intra chromosomal)\n") .build(); /** */ Option _diagonal = Option.builder("d").longOpt("diagonal") @@ -128,12 +128,16 @@ public CLIOptionProcessed(String[] args) { this._options.addOption(_isDroso); try { - _cmd = _parser.parse(this._options, args); + _cmd = _parser.parse(this._options, args,false); } - catch (ParseException exp){ + catch (ParseException exp ){ System.out.println("\n"+exp.getMessage()+"\n"); CLIHelper.CmdHelpProcessed(); - } + }catch (IllegalArgumentException exp){ + System.out.println( exp.getMessage()); + System.exit(1); + } + } /** diff --git a/src/gui/GuiAnalysis.java b/src/gui/GuiAnalysis.java index 1e8d22b..e559df4 100644 --- a/src/gui/GuiAnalysis.java +++ b/src/gui/GuiAnalysis.java @@ -149,6 +149,7 @@ public GuiAnalysis(){ this.setResizable(false); this.setLocationByPlatform(true); this.setBackground(Color.LIGHT_GRAY); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this._container = getContentPane(); diff --git a/src/loops/CallLoops.java b/src/loops/CallLoops.java index f4e48d7..c62af78 100644 --- a/src/loops/CallLoops.java +++ b/src/loops/CallLoops.java @@ -106,7 +106,7 @@ public HashMap detectLoops(File[] fileList, String chr,HashMap temp = findLoop.findloop(numImage, this._nbZero,imgRaw, this._backgroudValue); + HashMap temp = findLoop.findLoop(numImage, this._nbZero,imgRaw, this._backgroudValue); PeakAnalysisScore pas = new PeakAnalysisScore(imgNorm,temp); pas.computeScore(); diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index 7f7e447..f426b57 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -79,13 +79,11 @@ public void go(SIPIntra sip, String resuFile, String resName) throws Interrupte * multiprocessing for sip on inter-chromosomal interaction * for each couple of chromosome, RunnableDetectInterLoop is call. * @param sipInter SIPInter object - * @param nbCPU number of cpu - * @param delImage boolean if true del all the tif file * @param resuFile path to results file * @throws InterruptedException exception */ - public void go(SIPInter sipInter, int nbCPU, boolean delImage, String resuFile) throws InterruptedException { - ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nbCPU); + public void go(SIPInter sipInter, String resuFile) throws InterruptedException { + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); HashMap chrSize = sipInter.getChrSizeHashMap(); Object [] chrName = chrSize.keySet().toArray(); diff --git a/src/process/Cool.java b/src/process/Cool.java index 2ad6272..d4c9268 100644 --- a/src/process/Cool.java +++ b/src/process/Cool.java @@ -15,7 +15,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.Arrays; + /** * @@ -63,8 +63,7 @@ public class Cool { */ public Cool(String args []){ _isGui = false; - String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); - CLIOptionHiC cli = new CLIOptionHiC(argsSubset); + CLIOptionHiC cli = new CLIOptionHiC(args); _cmd = cli.getCommandLine(); _input = _cmd.getOptionValue("input"); _output = _cmd.getOptionValue("output"); @@ -100,8 +99,6 @@ public void run() throws IOException, InterruptedException { String allParam; - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); - if(_isGui) { _cooler = this._guiAnalysis.getCooler(); if(this._guiAnalysis.isInter()) _interOrIntra = "inter"; @@ -123,8 +120,13 @@ public void run() throws IOException, InterruptedException { if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } - _parameterCheck = new ParametersCheck(_input, _output, _chrSizeFile, _interOrIntra); - _parameterCheck.testCoolOption(_coolTool, _cooler, _isGui); + File file = new File(_output); + if(!file.exists()) file.mkdir(); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); + + _parameterCheck = new ParametersCheck(_input, _chrSizeFile, _interOrIntra, writer,false); + + _parameterCheck.testCoolOption(_coolTool, _cooler); if(_interOrIntra.equals("intra")) allParam = runIntra(); @@ -133,8 +135,7 @@ public void run() throws IOException, InterruptedException { writer.write(allParam); - - + writer.close(); } /** @@ -238,7 +239,7 @@ private String runInter() throws IOException, InterruptedException { /** * */ - private void setSipIntraCLI(){ + private void setSipIntraCLI() throws IOException { double min = 2.0; double max = 2.0; double gauss = 1.5; diff --git a/src/process/HiC.java b/src/process/HiC.java index 1f2a407..19b744a 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -1,6 +1,7 @@ package process; +import cli.CLIHelper; import cli.CLIOptionHiC; import gui.GuiAnalysis; import multiProcesing.ProcessDetectLoops; @@ -9,12 +10,12 @@ import sip.SIPInter; import sip.SIPIntra; import utils.MultiResProcess; - +import org.apache.commons.cli.ParseException; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.Arrays; + /** * @@ -26,20 +27,18 @@ public class HiC { private SIPInter _sipInter; /** */ private CommandLine _cmd; - /** */ private String _input; /** */ private String _output; /** */ private String _chrSizeFile; - /** */ - private int _nbZero; + private int _nbZero = 6; /** */ - private boolean _delImages; + private boolean _delImages = true; /** */ - private int _cpu; + private int _cpu =1; /** */ private boolean _isGui; /** */ @@ -51,9 +50,9 @@ public class HiC { /** */ private ParametersCheck _parameterCheck; /** */ - private String _juicerNorm; + private String _juicerNorm = "KR"; /** */ - String _log; + private String _log; /** * @@ -62,16 +61,12 @@ public class HiC { */ public HiC(String args []){ _isGui = false; - String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); - CLIOptionHiC cli = new CLIOptionHiC(argsSubset); - _cmd = cli.getCommandLine(); - _input = _cmd.getOptionValue("input"); - _output = _cmd.getOptionValue("output"); - _log = _output+File.separator+"log.txt"; - _juicerNorm = "KR"; - _delImages = true; - _nbZero = 6; - _cpu = 1; + CLIOptionHiC cli = new CLIOptionHiC(args); + _cmd = cli.getCommandLine(); + _input = _cmd.getOptionValue("input"); + _output = _cmd.getOptionValue("output"); + System.out.println(_input+"\n"+_output+"\n"+_cmd.getOptionValue("j")); + _log = _output+File.separator+"log.txt"; } /** @@ -84,10 +79,6 @@ public HiC(GuiAnalysis guiAnalysis ){ _input = this._guiAnalysis.getInput(); _output = this._guiAnalysis.getOutputDir(); _log = _output+File.separator+"log.txt"; - _juicerNorm = "KR"; - _delImages = true; - _nbZero = 6; - _cpu = 1; } /** * @@ -98,11 +89,7 @@ public HiC(GuiAnalysis guiAnalysis ){ * @throws InterruptedException */ public void run() throws IOException, InterruptedException { - String allParam; - - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); - if(_isGui) { _juicerTool = this._guiAnalysis.getJuicerTool(); if(this._guiAnalysis.isInter()) _interOrIntra = "inter"; @@ -116,16 +103,23 @@ public void run() throws IOException, InterruptedException { _cpu = this._guiAnalysis.getNbCpu(); }else { /* common required parameters*/ - _juicerTool = _cmd.getOptionValue("_juicerTool"); + _juicerTool = _cmd.getOptionValue("juicerTool"); _interOrIntra = _cmd.getOptionValue("lt"); + System.out.println(_interOrIntra); _chrSizeFile = _cmd.getOptionValue("chrSize"); /* common optional parameters */ if (_cmd.hasOption("norm")) _juicerNorm = _cmd.getOptionValue("norm"); if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); - if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + if (_cmd.hasOption("delete"))_delImages = false; if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } - _parameterCheck = new ParametersCheck(_input, _output, _chrSizeFile, _interOrIntra); + + File file = new File(_output); + if(!file.exists()) file.mkdir(); + + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); + + _parameterCheck = new ParametersCheck(_input, _chrSizeFile, _interOrIntra, writer,false); _parameterCheck.testHiCOption(_juicerTool, _juicerNorm); if(_interOrIntra.equals("intra")) @@ -133,10 +127,9 @@ public void run() throws IOException, InterruptedException { else allParam = runInter(); - + ; writer.write(allParam); - - + writer.close(); } /** @@ -147,41 +140,18 @@ public void run() throws IOException, InterruptedException { */ private String runIntra() throws IOException, InterruptedException { /* Param spe intra chromosomal loop*/ - if(_isGui) - this.setSipIntraGUI(); - else - this.setSipIntraCLI(); + if(_isGui) this.setSipIntraGUI(); + else this.setSipIntraCLI(); _sipIntra.setIsGui(_isGui); _sipIntra.setIsProcessed(false); _sipIntra.setIsCooler(false); - ProcessDumpData processDumpData = new ProcessDumpData(); - String allParam = "SIPHiC hic: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "juiceBox: "+ _juicerTool +"\n"+ - "norm: "+ _juicerNorm +"\n" + - "inter or intra chromosomal: "+ _interOrIntra +"\n" + - "gauss: "+this._sipIntra.getGauss()+"\n"+ - "min: "+this._sipIntra.getMin()+"\n"+ - "max: "+this._sipIntra.getMax()+"\n"+ - "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ - "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ - "resolution: "+this._sipIntra.getResolution()+"\n"+ - "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ - "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ - "number of zero: "+this._nbZero+"\n"+ - "factor: "+ _sipIntra.getFactor() +"\n"+ - "fdr: "+this._sipIntra.getFdr()+"\n"+ - "delete images: "+_delImages+"\n"+ - "cpu: "+ _cpu+"\n" + - "isDroso: "+this._sipIntra.isDroso()+"\n"; + _parameterCheck.optionalParametersValidity(_sipIntra); + _parameterCheck.speOption(_sipIntra); System.out.println("########### Starting dump Step inter chromosomal interactions"); - - _parameterCheck.optionalParametersValidity(_sipIntra); - _parameterCheck.speOption(_sipIntra); + ProcessDumpData processDumpData = new ProcessDumpData(); processDumpData.go(_input, _sipIntra, _juicerTool, _juicerNorm); System.out.println("########### End of the dump step\n"); @@ -189,7 +159,14 @@ private String runIntra() throws IOException, InterruptedException { MultiResProcess multi = new MultiResProcess(_sipIntra, _chrSizeFile); multi.run(); System.out.println("###########End loop detection step\n"); - return allParam; + + // System.out.println(allParam); + return "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ "juiceBox: "+ _juicerTool +"\n"+ + "norm: "+ _juicerNorm +"\n" + "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipIntra.getGauss()+"\n"+ + "min: "+this._sipIntra.getMin()+"\n"+ "max: "+this._sipIntra.getMax()+"\n"+ "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ + "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ "resolution: "+this._sipIntra.getResolution()+"\n"+ "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ + "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ "number of zero: "+this._nbZero+"\n"+ "factor: "+ _sipIntra.getFactor() +"\n"+ + "fdr: "+this._sipIntra.getFdr()+"\n"+ "delete images: "+_delImages+"\n"+ "cpu: "+ _cpu+"\n" + "isDroso: "+this._sipIntra.isDroso()+"\n"; } @@ -202,34 +179,26 @@ private String runInter() throws IOException, InterruptedException { this.setSipInter(); _sipInter.setIsGui(_isGui); - _sipIntra.setIsProcessed(false); - _sipIntra.setIsCooler(false); + _sipInter.setIsProcessed(false); + _sipInter.setIsCooler(false); - String allParam = "SIPHiC hic: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "juiceBox: "+ _juicerTool +"\n"+ - "norm: "+ _juicerNorm +"\n" + - "inter or intra chromosomal: "+ _interOrIntra +"\n" + - "gauss: "+this._sipInter.getGauss()+"\n"+ - "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ - "resolution: "+this._sipInter.getResolution()+"\n"+ - "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ - "number of zero :"+_nbZero+"\n"+ - "fdr "+this._sipInter.getFdr()+"\n"+ - "delete images "+_delImages+"\n"+ - "cpu "+ _cpu+"\n"; _parameterCheck.optionalParametersValidity(_sipInter); processDumpData.go(_input,_sipInter, _juicerTool, _juicerNorm); String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; - + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(loopFileRes))); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); - return allParam; + detectLoops.go(_sipInter, loopFileRes); + + return "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ "juiceBox: "+ _juicerTool +"\n"+ + "norm: "+ _juicerNorm +"\n" + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ + "resolution: "+this._sipInter.getResolution()+"\n"+ "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ + "number of zero :"+_nbZero+"\n"+ "fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ + "cpu "+ _cpu+"\n"; } @@ -249,24 +218,27 @@ private void setSipIntraCLI(){ double saturatedPixel = 0.01; boolean isDroso = false; int factorParam = 1; - - if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); - if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); - if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); - if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); - if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); - if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); - if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); - if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); - if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); - if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); - if (_cmd.hasOption("factor")){ - factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); - _parameterCheck.checkFactor(factorParam); - } - - _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, + try { + if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); + if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); + if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); + if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); + if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); + if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); + if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); + if (_cmd.hasOption("isDroso")){ isDroso = true; } + if (_cmd.hasOption("factor")){ + factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); + _parameterCheck.checkFactor(factorParam); + } + _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, _nbZero, factorParam, fdr, isDroso,_delImages, _cpu); + }catch (NumberFormatException ex) { + System.out.println("\n!!!!!! Error number is needed : \n"+ex.toString()+"\n"); + CLIHelper.getHelperAllInfos(); + } catch (IOException e) { e.printStackTrace(); } } /** * @@ -286,7 +258,7 @@ private void setSipIntraGUI(){ * * */ - private void setSipInter() throws IOException { + private void setSipInter(){ if(_isGui){ _sipInter = new SIPInter(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), @@ -295,7 +267,7 @@ private void setSipInter() throws IOException { }else{ double gauss = 1; int matrixSize = 500; - double thresholdMax = 0.01; + double thresholdMax = 0.9; double fdr = 0.025; int resolution = 100000; if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); diff --git a/src/process/ParametersCheck.java b/src/process/ParametersCheck.java index b7a9d58..8c8ff72 100644 --- a/src/process/ParametersCheck.java +++ b/src/process/ParametersCheck.java @@ -5,121 +5,149 @@ import sip.SIPIntra; import sip.SIPObject; -import javax.swing.*; import java.io.*; public class ParametersCheck { + /** + * + */ + BufferedWriter _logwWriter; + + /** + * + */ + String _logError; /** * - * @param sip + * @param input + * @param chrSizeFile + * @param interOrIntra */ - public void optionalParametersValidity(SIPObject sip){ + public ParametersCheck(String input, String chrSizeFile, String interOrIntra, BufferedWriter log, boolean processed) throws IOException { + _logwWriter = log; + File file = new File(input); - if(sip.getResolution() <= 0 ){ + if(processed && !file.isDirectory()){ + System.out.println("\nFDirectory problem !!!!\n-i "+input+": need to be a directory with processed daata from SIP !!! \n\n"); + _logwWriter.write("\nFDirectory problem !!!!\n-i "+input+": need to be a directory with processed daata from SIP !!! \n\n"); + _logwWriter.close(); + CLIHelper.getHelperInfos(); + } + if(!file.exists() && !input.startsWith("https")){ + System.out.println("\nFile problem !!!!\n-i "+input+": this file doesn't existed !!! \n\n"); + _logwWriter.write("\nFile problem !!!!\n-i "+input+": this file doesn't existed !!! \n\n"); + _logwWriter.close(); + CLIHelper.getHelperInfos(); + } + + file = new File(chrSizeFile); + if(!file.exists()){ + System.out.println("\nFile problem !!!!\n-c "+chrSizeFile+": this file doesn't existed !!! \n\n"); + _logwWriter.write("\nFile problem !!!!\n-c "+chrSizeFile+": this file doesn't existed !!! \n\n"); + _logwWriter.close(); + CLIHelper.getHelperInfos(); + } + + if(!interOrIntra.equals("inter") && !interOrIntra.equals("intra")){ + System.out.println("\nParameter value error !!!!\n-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); + _logwWriter.close(); + CLIHelper.getHelperInfos(); + } + } + + /** + * + * @param sip + */ + public void optionalParametersValidity(SIPObject sip) throws IOException { + if(sip.getResolution() <= 0 ){ + _logwWriter.write("Parameter value error !!!!\n-r "+sip.getResolution()+", resolution need to be a >= 0 !!! \n\n"); + _logwWriter.close(); System.out.println("Parameter value error !!!!\n-r "+sip.getResolution()+", resolution need to be a >= 0 !!! \n\n"); CLIHelper.getHelperInfos(); } if (sip.getNbZero() > 24|| sip.getNbZero() < 0) { - System.out.println("Parameter value error !!!!\n-nbZero"+ sip.getNbZero() +" value invalid: choose an integer value between 0 and 24\n"); + _logwWriter.write("\nParameter value error !!!!\n-nb "+ sip.getNbZero() +" value invalid: choose an integer value between 0 and 24\n"); + _logwWriter.close(); + System.out.println("\nParameter value error !!!!\n-nb "+ sip.getNbZero() +" value invalid: choose an integer value between 0 and 24\n"); CLIHelper.getHelperInfos(); } if(sip.getCpu() > Runtime.getRuntime().availableProcessors() || sip.getCpu() <= 0){ - System.out.println("Parameter value error !!!!\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + System.out.println("\nParameter value error !!!!\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + _logwWriter.write("\nParameter value error !!!!\n-cpu "+ sip.getCpu() +" is superior to server/computer' cpu "+Runtime.getRuntime().availableProcessors()+"\n"); + _logwWriter.close(); CLIHelper.getHelperInfos(); } if(sip.getFdr() < 0 ){ - System.out.println("Parameter value error !!!!\n-fdr "+sip.getFdr()+", fdr need to be a >= 0 !!! \n\n"); + System.out.println("\nParameter value error !!!!\n-fdr "+sip.getFdr()+", fdr need to be a >= 0 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-fdr "+sip.getFdr()+", fdr need to be a >= 0 !!! \n\n"); + _logwWriter.close(); CLIHelper.getHelperInfos(); } if(sip.getMatrixSize() < 0 ){ System.out.println("Parameter value error !!!!\n-ms "+sip.getMatrixSize()+", matrix size need to be a > 0 !!! \n\n"); + _logwWriter.write("Parameter value error !!!!\n-ms "+sip.getMatrixSize()+", matrix size need to be a > 0 !!! \n\n"); + _logwWriter.close(); CLIHelper.getHelperInfos(); } if(sip.getGauss() < 0 ){ - System.out.println("Parameter value error !!!!\n-g "+sip.getGauss()+", gaussian strength filter need to be a > 0 !!! \n\n"); + System.out.println("\nParameter value error !!!!\n-g "+sip.getGauss()+", gaussian strength filter need to be a > 0 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-g "+sip.getGauss()+", gaussian strength filter need to be a > 0 !!! \n\n"); + _logwWriter.close(); CLIHelper.getHelperInfos(); } if(sip.getThresholdMaxima() < 0 ){ - System.out.println("Parameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); + System.out.println("\nParameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); + _logwWriter.close(); CLIHelper.getHelperInfos(); } } - /** - * - * @param input - * @param output - * @param chrSizeFile - * @param interOrIntra - */ - public ParametersCheck(String input, String output, String chrSizeFile, String interOrIntra){ - File file = new File(input); - - if(!file.exists() && !input.startsWith("https")){ - System.out.println("File problem !!!!\n-i "+input+": this file doesn't existed !!! \n\n"); - CLIHelper.getHelperInfos(); - } - - file = new File(output); - - if(!file.exists()){ - System.out.println("File problem !!!!\n-o "+output+": this file doesn't existed !!! \n\n"); - CLIHelper.getHelperInfos(); - } - file = new File(chrSizeFile); - if(!file.exists()){ - System.out.println("File problem !!!!\n-c "+chrSizeFile+": this file doesn't existed !!! \n\n"); - CLIHelper.getHelperInfos(); - } - - if(!interOrIntra.equals("inter") && !interOrIntra.equals("intra")){ - System.out.println("Parameter value error !!!!\n-tl "+interOrIntra+", wrong value, choose inter or intra !!! \n\n"); - - } - } /** * * @param coolTool * @param cooler - * @param isGui */ - public void testCoolOption(String coolTool, String cooler,boolean isGui){ + public void testCoolOption(String coolTool, String cooler) throws IOException { File f = new File(coolTool); if(!f.exists()){ System.out.println("File problem !!!!\n-coolTool "+coolTool+" doesn't existed or wrong path !!! \n\n"); + _logwWriter.write("\nFile problem !!!!\n-coolTool "+coolTool+" doesn't existed or wrong path !!! \n\n"); + _logwWriter.close(); CLIHelper.CmdHelpCool(); } f = new File(cooler); if(!f.exists()){ - System.out.println("File problem !!!!\n-cooler "+cooler+" doesn't existed or wrong path !!! \n\n"); + _logwWriter.write("\nFile problem !!!!\n-cooler "+cooler+" doesn't existed or wrong path !!! \n\n"); + _logwWriter.close(); + System.out.println("\nFile problem !!!!\n-cooler "+cooler+" doesn't existed or wrong path !!! \n\n"); CLIHelper.CmdHelpCool(); } if(!testTools(coolTool, 0, 3, 0) || !testTools(cooler, 0, 8, 6)) { - System.out.println("Versioning problem !!!!\n"+coolTool + - " or" + cooler + " version is not the good one for SIP (it needs cooltool version >= 0.3.0 and " + - "cooler version >= 0.8.6) !!! \n\n"); + System.out.println("\nVersioning problem !!!!\n"+coolTool + " or" + cooler + + " version is not the good one for SIP (it needs cooltool version >= 0.3.0 and cooler version >= 0.8.6) !!! \n\n"); + _logwWriter.write("\nVersioning problem !!!!\n"+coolTool +" or" + cooler + + " version is not the good one for SIP (it needs cooltool version >= 0.3.0 and cooler version >= 0.8.6) !!! \n\n"); + _logwWriter.close(); CLIHelper.CmdHelpCool(); - if (isGui) { - JOptionPane.showMessageDialog(null, "Error SIP program", coolTool + " or" + cooler + "version is not the good one" + - " for SIP (it needs cooltools version >= 0.3.0 and cooler version >= 0.8.6) !!!" - , JOptionPane.ERROR_MESSAGE); - } } } @@ -129,17 +157,19 @@ public void testCoolOption(String coolTool, String cooler,boolean isGui){ * @param juicerTool * @param juicerNorm */ - public void testHiCOption(String juicerTool, String juicerNorm){ - + public void testHiCOption(String juicerTool, String juicerNorm) throws IOException { if (!juicerNorm.equals("KR") && !juicerNorm.equals("NONE") && !juicerNorm.equals("VC") && !juicerNorm.equals("VC_SQRT")) { - System.out.println("Parameter value error !!!!\n-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); + _logwWriter.write("\nParameter value error !!!!\n-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); + _logwWriter.close(); + System.out.println("\nParameter value error !!!!\n-norm = "+juicerNorm+", not defined for SIP, available norm: KR,NONE.VC,VC_SQRT\n Check the presence of this norm method in your hic file\n"); CLIHelper.CmdHelpHiC(); } - File file = new File(juicerTool); if(!file.exists()){ - System.out.println("File problem !!!!\n-j "+juicerTool+": this file doesn't existed !!! \n\n"); + _logwWriter.write("\nFile problem !!!!\n-j "+juicerTool+": this file doesn't existed !!! \n\n"); + _logwWriter.close(); + System.out.println("\nFile problem !!!!\n-j "+juicerTool+": this file doesn't existed !!! \n\n"); CLIHelper.CmdHelpHiC(); } } @@ -148,10 +178,12 @@ public void testHiCOption(String juicerTool, String juicerNorm){ * * @param factor */ - public void checkFactor(int factor){ + public void checkFactor(int factor) throws IOException { if(factor < 1 || factor > 4 ){ - System.out.println("Parameter value error !!!!\n-f "+factor+", value for factor are 1, 2, 3 or 4 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-f "+factor+", value for factor are 1, 2, 3 or 4 !!! \n\n"); + _logwWriter.close(); + System.out.println("\nParameter value error !!!!\n-f "+factor+", value for factor are 1, 2, 3 or 4 !!! \n\n"); CLIHelper.getHelperInfos(); } } @@ -160,25 +192,33 @@ public void checkFactor(int factor){ * * @param sipIntra */ - public void speOption(SIPIntra sipIntra){ + public void speOption(SIPIntra sipIntra) throws IOException { if(sipIntra.getDiagonalSize() < 0 ){ - System.out.println("Parameter value error !!!!\n-d "+sipIntra.getDiagonalSize()+", diagonal size need to be a > 0 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-d "+sipIntra.getDiagonalSize()+", diagonal size need to be a > 0 !!! \n\n"); + _logwWriter.close(); + System.out.println("\nParameter value error !!!!\n-d "+sipIntra.getDiagonalSize()+", diagonal size need to be a > 0 !!! \n\n"); CLIHelper.getHelperInfos(); } if(sipIntra.getMin() < 0 ){ - System.out.println("Parameter value error !!!!\n-min "+sipIntra.getMin()+", min strength filter need to be a > 0 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-min "+sipIntra.getMin()+", min strength filter need to be a > 0 !!! \n\n"); + _logwWriter.close(); + System.out.println("\nParameter value error !!!!\n-min "+sipIntra.getMin()+", min strength filter need to be a > 0 !!! \n\n"); CLIHelper.getHelperInfos(); } if(sipIntra.getMax() < 0 ){ + _logwWriter.write("\"Parameter value error !!!!\n-max "+sipIntra.getMax()+", max strength filter need to be a > 0 !!! \n\n"); + _logwWriter.close(); System.out.println("\"Parameter value error !!!!\n-max "+sipIntra.getMax()+", max strength filter need to be a > 0 !!! \n\n"); CLIHelper.getHelperInfos(); } if(sipIntra.getSaturatedPixel() < 0 ){ - System.out.println("Parameter value error !!!!\n-sat "+sipIntra.getSaturatedPixel()+", max strength filter need to be a > 0 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-sat "+sipIntra.getSaturatedPixel()+", max strength filter need to be a > 0 !!! \n\n"); + _logwWriter.close(); + System.out.println("\nParameter value error !!!!\n-sat "+sipIntra.getSaturatedPixel()+", max strength filter need to be a > 0 !!! \n\n"); CLIHelper.getHelperInfos(); } diff --git a/src/process/Processed.java b/src/process/Processed.java index dcf94f3..f76b70e 100644 --- a/src/process/Processed.java +++ b/src/process/Processed.java @@ -56,8 +56,7 @@ public class Processed { */ public Processed(String args []){ _isGui = false; - String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); - CLIOptionProcessed cli = new CLIOptionProcessed(argsSubset); + CLIOptionProcessed cli = new CLIOptionProcessed(args); _cmd = cli.getCommandLine(); _input = _cmd.getOptionValue("input"); _output = _cmd.getOptionValue("output"); @@ -93,8 +92,6 @@ public void run() throws IOException, InterruptedException { String allParam; - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); - if(_isGui) { if(this._guiAnalysis.isInter()) _interOrIntra = "inter"; else _interOrIntra = "intra"; @@ -111,7 +108,11 @@ public void run() throws IOException, InterruptedException { if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } - _parameterCheck = new ParametersCheck(_input, _output, _chrSizeFile, _interOrIntra); + File file = new File(_output); + if(!file.exists()) file.mkdir(); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_log))); + + _parameterCheck = new ParametersCheck(_input, _chrSizeFile, _interOrIntra, writer,true); if(_interOrIntra.equals("intra")) allParam = runIntra(); @@ -120,6 +121,7 @@ public void run() throws IOException, InterruptedException { writer.write(allParam); + writer.close(); } @@ -179,7 +181,7 @@ private String runIntra() throws IOException, InterruptedException { * @throws IOException */ private String runInter() throws IOException, InterruptedException { - ProcessDumpData processDumpData = new ProcessDumpData(); + this.setSipInter(); _sipInter.setIsGui(_isGui); @@ -204,7 +206,7 @@ private String runInter() throws IOException, InterruptedException { String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); + detectLoops.go(_sipInter, loopFileRes); return allParam; @@ -214,7 +216,7 @@ private String runInter() throws IOException, InterruptedException { /** * */ - private void setSipIntraCLI(){ + private void setSipIntraCLI() throws IOException { double min = 2.0; double max = 2.0; double gauss = 1.5; @@ -262,7 +264,7 @@ private void setSipIntraGUI(){ * * */ - private void setSipInter() throws IOException { + private void setSipInter() { if(_isGui){ _sipInter = new SIPInter(_input,_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), @@ -271,7 +273,7 @@ private void setSipInter() throws IOException { }else{ double gauss = 1; int matrixSize = 500; - double thresholdMax = 0.01; + double thresholdMax = 0.9; double fdr = 0.025; int resolution = 100000; if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); diff --git a/src/sip/SIPInter.java b/src/sip/SIPInter.java index deddfd6..0a8dc9d 100644 --- a/src/sip/SIPInter.java +++ b/src/sip/SIPInter.java @@ -28,10 +28,9 @@ public class SIPInter extends SIPObject { * @param matrixSize image size * @param nbZero nb of zero allowed around a loop * @param fdr fdr value for the final loops filter - * @throws IOException exception */ public SIPInter(String output,String chrSize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero,double fdr, - boolean delTif, int cpu) throws IOException { + boolean delTif, int cpu) { super(output, gauss, resolution, thresholdMax,matrixSize, nbZero, fdr,chrSize, delTif, cpu) ; } @@ -73,6 +72,7 @@ public void writeResu(String pathFile, HashMap hLoop, boolean firs double FDRcutoff = fdrDetection.getFDRCutoff(); System.out.println("Filtering value at "+fdr+" FDR is "+FDRcutoff+" APscore and "+RFDRcutoff+" RegionalAPscore\n"); BufferedWriter writer; + if(first) writer = new BufferedWriter(new FileWriter(new File(pathFile), true)); else{ writer = new BufferedWriter(new FileWriter(new File(pathFile))); diff --git a/src/sip/SIPIntra.java b/src/sip/SIPIntra.java index 6740eb7..8c43471 100644 --- a/src/sip/SIPIntra.java +++ b/src/sip/SIPIntra.java @@ -153,7 +153,6 @@ else if (_factor == 4) { public void saveFile(String pathFile, HashMap data, boolean first) throws IOException{ double fdr = this.getFdr(); FDR fdrDetection = new FDR (fdr, data); - fdrDetection.run(); double RFDRcutoff = fdrDetection.getRFDRCutoff(); double FDRcutoff = fdrDetection.getFDRCutoff(); diff --git a/src/sip/SIPObject.java b/src/sip/SIPObject.java index 2bf44ca..5ca0df6 100644 --- a/src/sip/SIPObject.java +++ b/src/sip/SIPObject.java @@ -89,7 +89,7 @@ public SIPObject (String input, String output, double gauss, int resolution, dou */ public SIPObject ( String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile, boolean delTif, int cpu){ - + if(!output.endsWith(File.separator)) output = output+File.separator; this._output = output; this._gauss = gauss; this._resolution = resolution; diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 1012aa1..caf15a9 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -1,6 +1,7 @@ package sipMain; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import cli.CLIHelper; import gui.GuiAnalysis; @@ -30,30 +31,35 @@ public class Hic_main { * @throws IOException exception * @throws InterruptedException exception */ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws IOException, InterruptedException { + + //command line test: + // hic -i /home/plop/Desktop/SIP/GSE104333_Rao-2017-treated_6hr_combined_30.hic -o /home/plop/Desktop/test -j /home/plop/Tools/juicer_tools_1.19.02.jar -c /home/plop/Desktop/SIP/testSize.tab -lt intra /*CLI */ - if(args.length >= 1) { + if(args.length == 1) { + CLIHelper.getHelperAllInfos(); + }else if(args.length > 1) { + String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); if (args[0].equals("hic")) { if(args[1].equals("-h") || args[1].equals("--help")) CLIHelper.CmdHelpHiC(); - - HiC hic = new HiC(args); + HiC hic = new HiC(argsSubset); hic.run(); }else if (args[0].equals("processed")) { if(args[1].equals("-h") || args[1].equals("--help")) CLIHelper.CmdHelpProcessed(); - Processed processed = new Processed(args); + Processed processed = new Processed(argsSubset); processed.run(); }else if (args[0].equals("cool")) { if(args[1].equals("-h") || args[1].equals("--help")) CLIHelper.CmdHelpCool(); - Cool Cool = new Cool(args); - + Cool cool = new Cool(argsSubset); + cool.run(); }else CLIHelper.getHelperAllInfos(); @@ -71,13 +77,15 @@ public static void main(String[] args) throws Exception { HiC hic = new HiC(gui); hic.run(); }else if(gui.isCool()){ + Cool cool = new Cool(args); + cool.run(); }else if(gui.isProcessed()){ Processed processed = new Processed(gui); processed.run(); } }else { - System.out.println("SIP closed: if you want the help: -h"); + System.out.println("\nSIP closed: "); CLIHelper.getHelperAllInfos(); } } diff --git a/src/test/TestInter.java b/src/test/TestInter.java index d7955a4..3bf6e80 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -31,7 +31,7 @@ public static void main(String[] args) throws IOException, InterruptedException //process.go(input,sipInter,chrsize,juicerTools,norm,2); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(sipInter, 1, false, "/home/plop/Desktop/testInter/loops.txt"); + detectLoops.go(sipInter, "/home/plop/Desktop/testInter/loops.txt"); System.out.println("end"); diff --git a/src/utils/FDR.java b/src/utils/FDR.java index 59251f8..3af2610 100644 --- a/src/utils/FDR.java +++ b/src/utils/FDR.java @@ -58,7 +58,7 @@ public void run(){ if(dubFDR2 > 0) myFDRValues.add(dubFDR2); if(dubFDR3 > 0) myFDRValues.add(dubFDR3); - + float dubRFDR = loop.getRegionalPaScoreAvgFDR(); float dubRFDR2 = loop.getRegionalPaScoreAvgFDR2(); float dubRFDR3 = loop.getRegionalPaScoreAvgFDR3(); diff --git a/src/utils/FindMaxima.java b/src/utils/FindMaxima.java index 7d60901..788eff4 100644 --- a/src/utils/FindMaxima.java +++ b/src/utils/FindMaxima.java @@ -93,7 +93,7 @@ public FindMaxima( ImagePlus imgDiff, String chr1,String chr2, double thresholdM * @return HashMap loop loop name => Loop object */ - public HashMap findloop(int index, int nbZero, ImagePlus raw, float val){ + public HashMap findLoop(int index, int nbZero, ImagePlus raw, float val){ run(nbZero, raw, val); ArrayList temp = this.getMaxima(); ImageProcessor ipN = this._imgNorm.getProcessor(); diff --git a/src/utils/MultiResProcess.java b/src/utils/MultiResProcess.java index 5599259..0119918 100644 --- a/src/utils/MultiResProcess.java +++ b/src/utils/MultiResProcess.java @@ -58,13 +58,10 @@ public MultiResProcess(SIPIntra sip, String chrSizeFile) { public void run() throws InterruptedException, IOException{ ArrayList listFactor = this._sip.getListFactor(); ArrayList listOfFile = new ArrayList(); - File outDir = new File(_sip.getOutputDir()); - if (!outDir.exists()) outDir.mkdir(); if (_sip.isProcessed()){ if(!this.testDir()){ - if(_sip.isGui()) { - JOptionPane.showMessageDialog(null,"Resolution problem", "Enable to find all the directories needed for SIP (-factor option)", JOptionPane.ERROR_MESSAGE); - } + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(_sip.getOutputDir()+"log.txt"), true)); + writer.write("!!!! It is missing one or several directories for factor parameter\nEnable to find all the directories needed for SIP (-factor option)\n\n"); System.out.println("!!!! It is missing one or several directories for factor parameter\n"); CLIHelper.CmdHelpProcessed(); } From e6ae24daf05fed99d0c93f45fc82ee654fb02fe9 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Wed, 25 Nov 2020 12:00:28 -0500 Subject: [PATCH 20/27] Beta version, Added test if chr file has only one chromosome. --- src/multiProcesing/ProcessDumpData.java | 15 +++++++++++---- src/process/HiC.java | 8 ++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/multiProcesing/ProcessDumpData.java b/src/multiProcesing/ProcessDumpData.java index 4fd769c..277d3a1 100644 --- a/src/multiProcesing/ProcessDumpData.java +++ b/src/multiProcesing/ProcessDumpData.java @@ -1,6 +1,9 @@ package multiProcesing; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.concurrent.Executors; @@ -77,14 +80,18 @@ public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJu * @param normJuiceBox String normalization method * @throws InterruptedException exception */ - public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String normJuiceBox) throws InterruptedException { + public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String normJuiceBox) throws InterruptedException, IOException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); HashMap chrSize = sipInter.getChrSizeHashMap(); Object [] chrName = chrSize.keySet().toArray(); - System.out.println(sipInter.getOutputDir()); - File outDir = new File(sipInter.getOutputDir()); - if (!outDir.exists()) outDir.mkdir(); + if (chrName.length < 2){ + System.out.println("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(sipInter.getOutputDir()+File.separator+"log.txt"))); + writer.write("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); + writer.close(); + System.exit(1); + } for(int i = 0; i < chrName.length;++i){ String chr1 = chrName[i].toString(); for(int j = i+1; j < chrName.length;++j){ diff --git a/src/process/HiC.java b/src/process/HiC.java index 19b744a..ce176c2 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -182,17 +182,17 @@ private String runInter() throws IOException, InterruptedException { _sipInter.setIsProcessed(false); _sipInter.setIsCooler(false); - _parameterCheck.optionalParametersValidity(_sipInter); - + System.out.println("########### Starting dump Step inter chromosomal interactions"); processDumpData.go(_input,_sipInter, _juicerTool, _juicerNorm); - + System.out.println("########### !!! End dump Step inter chromosomal interactions"); String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(loopFileRes))); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); + System.out.println("########### Starting loop detection"); detectLoops.go(_sipInter, loopFileRes); - + System.out.println("########### !!!!!!! end loops detection"); return "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ "juiceBox: "+ _juicerTool +"\n"+ "norm: "+ _juicerNorm +"\n" + "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ From 168e662063e1f4664bf081e5c91e5e8a02975864 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Wed, 25 Nov 2020 13:09:22 -0500 Subject: [PATCH 21/27] Beta version, corrected error in processed inter option --- src/process/Processed.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/process/Processed.java b/src/process/Processed.java index f76b70e..30149a8 100644 --- a/src/process/Processed.java +++ b/src/process/Processed.java @@ -185,8 +185,8 @@ private String runInter() throws IOException, InterruptedException { this.setSipInter(); _sipInter.setIsGui(_isGui); - _sipIntra.setIsProcessed(true); - _sipIntra.setIsCooler(false); + _sipInter.setIsProcessed(true); + _sipInter.setIsCooler(false); String allParam = "SIPHiC processed: \n" + From 39975741dfb91185428a4379682ce07b34a59150 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Thu, 26 Nov 2020 16:48:46 -0500 Subject: [PATCH 22/27] Beta version, corrected error in processed inter option --- src/cli/CLIOptionProcessed.java | 4 +- src/loops/CallLoopsInter.java | 4 +- src/process/HiC.java | 22 ++++----- src/process/Processed.java | 81 +++++++++++---------------------- src/sip/SIPInter.java | 2 +- src/test/TestInter.java | 2 + src/utils/FindMaxima.java | 17 ++++--- 7 files changed, 57 insertions(+), 75 deletions(-) diff --git a/src/cli/CLIOptionProcessed.java b/src/cli/CLIOptionProcessed.java index e5f83f8..8945603 100644 --- a/src/cli/CLIOptionProcessed.java +++ b/src/cli/CLIOptionProcessed.java @@ -43,11 +43,11 @@ public class CLIOptionProcessed { .numberOfArgs(1).build(); /** */ Option _threshold = Option.builder("t").longOpt("threshold") - .type(Number.class).desc("Threshold for loops detection (default intra 2800, inter 0.01)\n") + .type(Number.class).desc("Threshold for loops detection (default intra 2800, inter 0.9)\n") .numberOfArgs(1).build(); /** */ Option _nbZero = Option.builder("nb").longOpt("nbZero") - .type(Number.class).desc("Number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected loop (default 6)\n") + .type(Number.class).desc("Number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected loop (default intra 6; inter 3)\n") .numberOfArgs(1).build(); /** */ Option _fdr = Option.builder("fdr").longOpt("fdr") diff --git a/src/loops/CallLoopsInter.java b/src/loops/CallLoopsInter.java index 538b9ac..59b9559 100644 --- a/src/loops/CallLoopsInter.java +++ b/src/loops/CallLoopsInter.java @@ -23,6 +23,7 @@ public class CallLoopsInter { private int _resolution; private double _noiseTolerance; private double _gaussian; + private int _nbZero; /** * @@ -33,6 +34,7 @@ public CallLoopsInter(SIPInter sipInter){ _resolution = sipInter.getResolution(); _noiseTolerance= sipInter.getThresholdMaxima(); _gaussian = sipInter.getGauss(); + _nbZero = sipInter.getNbZero(); } /** @@ -59,7 +61,7 @@ public HashMap detectLoops(File[] fileList, String chrName1, Strin //System.out.println(imgPath); saveFile(img, imgPath); ImagePlus imageDiff = imgDiff(img,imgPath); - FindMaxima findMaxima = new FindMaxima( imageDiff, chrName1,chrName2, _noiseTolerance, _resolution,_gaussian); + FindMaxima findMaxima = new FindMaxima( imageDiff, chrName1,chrName2, _noiseTolerance, _resolution,_gaussian,_nbZero); HashMap temp = findMaxima.findLoopInter(imgPath); PeakAnalysisScore pas = new PeakAnalysisScore(img,temp); pas.computeScore(); diff --git a/src/process/HiC.java b/src/process/HiC.java index ce176c2..7096f2f 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -34,8 +34,6 @@ public class HiC { /** */ private String _chrSizeFile; /** */ - private int _nbZero = 6; - /** */ private boolean _delImages = true; /** */ private int _cpu =1; @@ -98,7 +96,6 @@ public void run() throws IOException, InterruptedException { if(this._guiAnalysis.isNONE()) _juicerNorm = "NONE"; else if (this._guiAnalysis.isVC()) _juicerNorm = "VC"; else if (this._guiAnalysis.isVC_SQRT()) _juicerNorm = "VC_SQRT"; - _nbZero = this._guiAnalysis.getNbZero(); _delImages = this._guiAnalysis.isDeletTif(); _cpu = this._guiAnalysis.getNbCpu(); }else { @@ -109,8 +106,7 @@ public void run() throws IOException, InterruptedException { _chrSizeFile = _cmd.getOptionValue("chrSize"); /* common optional parameters */ if (_cmd.hasOption("norm")) _juicerNorm = _cmd.getOptionValue("norm"); - if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); - if (_cmd.hasOption("delete"))_delImages = false; + if (_cmd.hasOption("keepImage"))_delImages = false; if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } @@ -165,7 +161,7 @@ private String runIntra() throws IOException, InterruptedException { "norm: "+ _juicerNorm +"\n" + "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipIntra.getGauss()+"\n"+ "min: "+this._sipIntra.getMin()+"\n"+ "max: "+this._sipIntra.getMax()+"\n"+ "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ "resolution: "+this._sipIntra.getResolution()+"\n"+ "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ - "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ "number of zero: "+this._nbZero+"\n"+ "factor: "+ _sipIntra.getFactor() +"\n"+ + "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ "number of zero: "+this._sipIntra.getNbZero()+"\n"+ "factor: "+ _sipIntra.getFactor() +"\n"+ "fdr: "+this._sipIntra.getFdr()+"\n"+ "delete images: "+_delImages+"\n"+ "cpu: "+ _cpu+"\n" + "isDroso: "+this._sipIntra.isDroso()+"\n"; } @@ -197,7 +193,7 @@ private String runInter() throws IOException, InterruptedException { "norm: "+ _juicerNorm +"\n" + "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ "resolution: "+this._sipInter.getResolution()+"\n"+ "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ - "number of zero :"+_nbZero+"\n"+ "fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ + "number of zero :"+_sipInter.getNbZero()+"\n"+ "fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ "cpu "+ _cpu+"\n"; } @@ -218,9 +214,11 @@ private void setSipIntraCLI(){ double saturatedPixel = 0.01; boolean isDroso = false; int factorParam = 1; + int nbZero = 6; try { if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if (_cmd.hasOption("nbZero")) nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); @@ -234,7 +232,7 @@ private void setSipIntraCLI(){ _parameterCheck.checkFactor(factorParam); } _sipIntra = new SIPIntra(_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, - thresholdMax, diagSize, matrixSize, _nbZero, factorParam, fdr, isDroso,_delImages, _cpu); + thresholdMax, diagSize, matrixSize, nbZero, factorParam, fdr, isDroso,_delImages, _cpu); }catch (NumberFormatException ex) { System.out.println("\n!!!!!! Error number is needed : \n"+ex.toString()+"\n"); CLIHelper.getHelperAllInfos(); @@ -249,7 +247,7 @@ private void setSipIntraGUI(){ _sipIntra = new SIPIntra(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getMin(), _guiAnalysis.getMax(), _guiAnalysis.getResolution(), _guiAnalysis.getSaturatedPixel(), _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getDiagSize(), _guiAnalysis.getMatrixSize(), - _nbZero, _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); + this._guiAnalysis.getNbZero(), _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); } @@ -262,7 +260,7 @@ private void setSipInter(){ if(_isGui){ _sipInter = new SIPInter(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), - _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getMatrixSize(), _nbZero, _guiAnalysis.getFDR(), _delImages,_cpu); + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getMatrixSize(), _guiAnalysis.getNbZero(), _guiAnalysis.getFDR(), _delImages,_cpu); }else{ double gauss = 1; @@ -270,12 +268,14 @@ private void setSipInter(){ double thresholdMax = 0.9; double fdr = 0.025; int resolution = 100000; + int nbZero = 3; if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); + if (_cmd.hasOption("nbZero")) nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); - _sipInter = new SIPInter(_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, fdr, _delImages,_cpu); + _sipInter = new SIPInter(_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, _delImages,_cpu); } diff --git a/src/process/Processed.java b/src/process/Processed.java index 30149a8..def9705 100644 --- a/src/process/Processed.java +++ b/src/process/Processed.java @@ -33,11 +33,9 @@ public class Processed { /** */ private String _chrSizeFile; /** */ - private int _nbZero; + private boolean _delImages = true; /** */ - private boolean _delImages; - /** */ - private int _cpu; + private int _cpu = 1; /** */ private boolean _isGui; /** */ @@ -61,9 +59,7 @@ public Processed(String args []){ _input = _cmd.getOptionValue("input"); _output = _cmd.getOptionValue("output"); _log = _output+File.separator+"log.txt"; - _delImages = true; - _nbZero = 6; - _cpu = 1; + } /** @@ -76,9 +72,6 @@ public Processed(GuiAnalysis guiAnalysis ){ _input = this._guiAnalysis.getInput(); _output = this._guiAnalysis.getOutputDir(); _log = _output+File.separator+"log.txt"; - _delImages = true; - _nbZero = 6; - _cpu = 1; } /** * @@ -96,7 +89,6 @@ public void run() throws IOException, InterruptedException { if(this._guiAnalysis.isInter()) _interOrIntra = "inter"; else _interOrIntra = "intra"; _chrSizeFile = this._guiAnalysis.getChrSizeFile(); - _nbZero = this._guiAnalysis.getNbZero(); _delImages = this._guiAnalysis.isDeletTif(); _cpu = this._guiAnalysis.getNbCpu(); }else { @@ -104,8 +96,7 @@ public void run() throws IOException, InterruptedException { _interOrIntra = _cmd.getOptionValue("lt"); _chrSizeFile = _cmd.getOptionValue("chrSize"); /* common optional parameters */ - if (_cmd.hasOption("nbZero")) _nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); - if (_cmd.hasOption("delete"))_delImages = Boolean.parseBoolean(_cmd.getOptionValue("delImages")); + if (_cmd.hasOption("keepImage"))_delImages = false; if (_cmd.hasOption("cpu")) _cpu = Integer.parseInt(_cmd.getOptionValue("cpu")); } File file = new File(_output); @@ -144,27 +135,6 @@ private String runIntra() throws IOException, InterruptedException { _sipIntra.setIsCooler(false); - String allParam = "SIPHiC processed: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "inter or intra chromosomal: "+ _interOrIntra +"\n" + - "gauss: "+this._sipIntra.getGauss()+"\n"+ - "min: "+this._sipIntra.getMin()+"\n"+ - "max: "+this._sipIntra.getMax()+"\n"+ - "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ - "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ - "resolution: "+this._sipIntra.getResolution()+"\n"+ - "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ - "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ - "number of zero: "+this._nbZero+"\n"+ - "factor: "+ _sipIntra.getFactor() +"\n"+ - "fdr: "+this._sipIntra.getFdr()+"\n"+ - "delete images: "+_delImages+"\n"+ - "cpu: "+ _cpu+"\n" + - "isDroso: "+this._sipIntra.isDroso()+"\n"; - - System.out.println("########### Starting dump Step inter chromosomal interactions"); - _parameterCheck.optionalParametersValidity(_sipIntra); _parameterCheck.speOption(_sipIntra); @@ -172,7 +142,13 @@ private String runIntra() throws IOException, InterruptedException { MultiResProcess multi = new MultiResProcess(_sipIntra, _chrSizeFile); multi.run(); System.out.println("###########End loop detection step\n"); - return allParam; + return "SIPHiC processed: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ + "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipIntra.getGauss()+"\n"+ + "min: "+this._sipIntra.getMin()+"\n"+ "max: "+this._sipIntra.getMax()+"\n"+ "matrix size: "+this._sipIntra.getMatrixSize()+"\n"+ + "diagonal size: "+this._sipIntra.getDiagonalSize()+"\n"+ "resolution: "+this._sipIntra.getResolution()+"\n"+ + "saturated pixel: "+this._sipIntra.getSaturatedPixel()+"\n"+ "threshold: "+this._sipIntra.getThresholdMaxima()+"\n"+ + "number of zero: "+this._sipIntra.getNbZero()+"\n"+ "factor: "+ _sipIntra.getFactor() +"\n"+ "fdr: "+this._sipIntra.getFdr()+"\n"+ "delete images: "+_delImages+"\n"+ + "cpu: "+ _cpu+"\n" + "isDroso: "+this._sipIntra.isDroso()+"\n"; } @@ -188,27 +164,20 @@ private String runInter() throws IOException, InterruptedException { _sipInter.setIsProcessed(true); _sipInter.setIsCooler(false); - - String allParam = "SIPHiC processed: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "inter or intra chromosomal: "+ _interOrIntra +"\n" + - "gauss: "+this._sipInter.getGauss()+"\n"+ - "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ - "resolution: "+this._sipInter.getResolution()+"\n"+ - "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ - "number of zero :"+_nbZero+"\n"+ - "fdr "+this._sipInter.getFdr()+"\n"+ - "delete images "+_delImages+"\n"+ - "cpu "+ _cpu+"\n"; _parameterCheck.optionalParametersValidity(_sipInter); String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(loopFileRes))); + System.out.println("########### Start loop detection\n"); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); detectLoops.go(_sipInter, loopFileRes); + System.out.println("###########End loop detection step\n"); - return allParam; + return "SIPHiC processed: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ "resolution: "+this._sipInter.getResolution()+"\n"+ + "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ "number of zero :"+_sipInter.getNbZero()+"\n"+"fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ + "cpu "+ _cpu+"\n"; } @@ -228,9 +197,11 @@ private void setSipIntraCLI() throws IOException { double saturatedPixel = 0.01; boolean isDroso = false; int factorParam = 1; + int nbZero = 6; if (_cmd.hasOption("min")) min = Double.parseDouble(_cmd.getOptionValue("min")); if (_cmd.hasOption("max")) max = Double.parseDouble(_cmd.getOptionValue("max")); + if (_cmd.hasOption("nbZero")) nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); @@ -238,14 +209,14 @@ private void setSipIntraCLI() throws IOException { if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); if (_cmd.hasOption("diagonal")) diagSize = Integer.parseInt(_cmd.getOptionValue("diagonal")); if (_cmd.hasOption("saturated")) saturatedPixel = Double.parseDouble(_cmd.getOptionValue("saturated")); - if (_cmd.hasOption("isDroso")) isDroso = Boolean.parseBoolean(_cmd.getOptionValue("isDroso")); + if (_cmd.hasOption("isDroso")) isDroso = true; if (_cmd.hasOption("factor")){ factorParam = Integer.parseInt(_cmd.getOptionValue("factor")); _parameterCheck.checkFactor(factorParam); } _sipIntra = new SIPIntra(_input,_output, _chrSizeFile, gauss, min, max, resolution, saturatedPixel, - thresholdMax, diagSize, matrixSize, _nbZero, factorParam, fdr, isDroso,_delImages, _cpu); + thresholdMax, diagSize, matrixSize, nbZero, factorParam, fdr, isDroso,_delImages, _cpu); } /** * @@ -255,7 +226,7 @@ private void setSipIntraGUI(){ _sipIntra = new SIPIntra(_input, _output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getMin(), _guiAnalysis.getMax(), _guiAnalysis.getResolution(), _guiAnalysis.getSaturatedPixel(), _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getDiagSize(), _guiAnalysis.getMatrixSize(), - _nbZero, _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); + this._guiAnalysis.getNbZero(), _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); } @@ -268,7 +239,7 @@ private void setSipInter() { if(_isGui){ _sipInter = new SIPInter(_input,_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), - _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getMatrixSize(), _nbZero, _guiAnalysis.getFDR(), _delImages,_cpu); + _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getMatrixSize(), this._guiAnalysis.getNbZero(), _guiAnalysis.getFDR(), _delImages,_cpu); }else{ double gauss = 1; @@ -276,12 +247,14 @@ private void setSipInter() { double thresholdMax = 0.9; double fdr = 0.025; int resolution = 100000; + int nbZero = 3; if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); if (_cmd.hasOption("threshold")) thresholdMax = Double.parseDouble(_cmd.getOptionValue("threshold")); if (_cmd.hasOption("fdr")) fdr = Double.parseDouble(_cmd.getOptionValue("fdr")); if (_cmd.hasOption("resolution")) resolution = Integer.parseInt(_cmd.getOptionValue("resolution")); - _sipInter = new SIPInter(_input,_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, _nbZero, fdr, _delImages,_cpu); + if (_cmd.hasOption("nbZero")) nbZero = Integer.parseInt(_cmd.getOptionValue("nbZero")); + _sipInter = new SIPInter(_input,_output, _chrSizeFile, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr, _delImages,_cpu); } diff --git a/src/sip/SIPInter.java b/src/sip/SIPInter.java index 0a8dc9d..27e96a2 100644 --- a/src/sip/SIPInter.java +++ b/src/sip/SIPInter.java @@ -85,7 +85,7 @@ public void writeResu(String pathFile, HashMap hLoop, boolean firs while (it.hasNext()) { Loop loop = hLoop.get(it.next()); ArrayList coord = loop.getCoordinates(); - if (loop.getPaScoreAvg() > FDRcutoff && loop.getRegionalPaScoreAvg() > RFDRcutoff && loop.getValueDiff() > 1.3 && loop.getValue() >= 8) { + if (loop.getPaScoreAvg() > FDRcutoff && loop.getRegionalPaScoreAvg() > RFDRcutoff ){//&& loop.getValue() >= 8 && loop.getValueDiff() > 1.3){//){//&& loop.getValueDiff() > 1.3 && loop.getValue() >= 8) { writer.write(loop.getChr() + "\t" + coord.get(0) + "\t" + coord.get(1) + "\t" + loop.getChr2() + "\t" + coord.get(2) + "\t" + coord.get(3) + "\t0,0,0" + "\t" + loop.getPaScoreAvg() + "\t" + loop.getRegionalPaScoreAvg() + "\t" + loop.getNeigbhoord1() + "\t" + loop.getNeigbhoord2() + "\t" + loop.getAvg() + "\t" + loop.getStd() + "\t" + loop.getValue() + "\t" +loop.getValueDiff() + "\t" + loop.getNbOfZero() +"\t"+loop.getPaScoreAvgdev()+"\n"); diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 3bf6e80..9214671 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -12,6 +12,8 @@ public class TestInter { public static void main(String[] args) throws IOException, InterruptedException { //String chr = "chr21"; + // hic -i SIP/GSE104333_Rao-2017-treated_6hr_combined_30.hic -c SIP/testSize.tab -o /home/plop/Desktop/interTreatedP -j /home/plop/Tools/juicer_tools_1.19.02.jar -lt inter -cpu 2 -r 50000 -ms 500 + //processed -i /home/plop/Desktop/interTreatedP/ -c /home/plop/Desktop/SIP/testSize.tab -o /home/plop/Desktop/re -lt inter -cpu 2 -r 50000 -ms 500 -t 0.001 --nbZero 6 -k -fdr 1 -g 1 String input = "/home/plop/Desktop/testInter/"; String output = "/home/plop/Desktop/testInter/"; String fileChr = "/home/plop/Desktop/SIP/testSize.tab"; diff --git a/src/utils/FindMaxima.java b/src/utils/FindMaxima.java index 788eff4..0096b0f 100644 --- a/src/utils/FindMaxima.java +++ b/src/utils/FindMaxima.java @@ -12,6 +12,8 @@ import ij.process.ImageProcessor; import loops.Loop; +import static java.lang.System.out; + /** * Detection of regional maxima in image. Return the HashMap, the loop can be corrected. * the class uses is the imageJ class to detect the maxima. @@ -38,6 +40,8 @@ public class FindMaxima{ private int _resolution; /** gaussian Filter strength*/ private double _gaussian; + /** gaussian Filter strength*/ + private int _nbZero; /** @@ -68,13 +72,14 @@ public FindMaxima(ImagePlus img, ImagePlus imgFilter, String chr, double thresho * @param resolution int size of the pixel in base * @param gaussian gaussian filter strength */ - public FindMaxima( ImagePlus imgDiff, String chr1,String chr2, double thresholdMaxima, int resolution, double gaussian){ + public FindMaxima( ImagePlus imgDiff, String chr1,String chr2, double thresholdMaxima, int resolution, double gaussian, int nbZero){ this._imgFilter = imgDiff; this._thresholdMaxima = thresholdMaxima; this._chr2 = chr2; this._chr = chr1; this._resolution = resolution; this._gaussian = gaussian; + this._nbZero = nbZero; } @@ -137,7 +142,6 @@ public HashMap findLoop(int index, int nbZero, ImagePlus raw, floa * @return HashMap loop loop name => Loop object */ public HashMap findLoopInter(String pathRaw){ - ImagePlus raw = IJ.openImage(pathRaw); ImageProcessor ipFilter = _imgFilter.getProcessor(); runInter(raw); @@ -152,12 +156,13 @@ public HashMap findLoopInter(String pathRaw){ String name= this._chr+"\t"+this._chr2+"\t"+temp.get(j); float avg = average(x,y); float std = standardDeviation(x,y,avg); - int nbOfZero = detectNbOfZero(x,y,ipRaw.getf(x, y)); - if(nbOfZero <= 3){ // filter on the loop value and region value + int nbOfZero = detectNbOfZero(x,y,1); + if(nbOfZero <= this._nbZero ){//&& nbOfZero > 0){ // filter on the loop value and region value + System.out.print("loop "+nbOfZero+" ref "+_nbZero+" "+ipFilter.getf(x,y)+"\n"); DecayAnalysis da = new DecayAnalysis(raw,x,y); float n1 =da.getNeighbourhood1(); float n2 =da.getNeighbourhood2(); - if(n2>n1 && n1 >= 0 && n2 >= 0){ // filter on the neighborood for hic datatset + if(n2>n1 && n1 > 0 && n2 > 0){ // filter on the neighborood for hic datatset Loop maxima = new Loop(temp.get(j),x,y,this._chr,this._chr2,avg,std,ipRaw.getf(x, y)); maxima.setValueDiff(ipFilter.getf(x,y)); maxima.setNeigbhoord1(n1); @@ -227,7 +232,7 @@ private int detectNbOfZero(int x, int y, float val){ nbZero = 0; for (int i = x - 2; i <= x + 2; ++i) { for (int j = y - 2; j <= y + 2; ++j) { - if (ip.getf(i, j) <= 1) { + if (ip.getf(i, j) <= val) { nbZero++; } else if (Double.isNaN(ip.getf(i, j))) { nbZero++; From ca79146218ffeaa092326ae5dc0af4c487a7f359 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Wed, 10 Feb 2021 09:53:42 -0500 Subject: [PATCH 23/27] Beta version, add cool opt for inter chromo Still need to test --- src/dumpProcessing/CoolerDumpInter.java | 113 +++++++++++++++++ ...olerDumpData.java => CoolerDumpIntra.java} | 8 +- ...nterChromosomal.java => HicDumpInter.java} | 8 +- .../{DumpData.java => HicDumpIntra.java} | 4 +- src/multiProcesing/ProcessDetectLoops.java | 4 +- ...erDumpData.java => ProcessDumpCooler.java} | 67 +++++++++- ...ocessDumpData.java => ProcessDumpHic.java} | 16 +-- ...ops.java => RunnableDetectIntraLoops.java} | 7 +- .../RunnableDumpCoolerInter.java | 114 ++++++++++++++++++ ...oler.java => RunnableDumpCoolerIntra.java} | 12 +- ...omoData.java => RunnableDumpHicInter.java} | 16 +-- ...DataHiC.java => RunnableDumpHicIntra.java} | 12 +- src/process/Cool.java | 50 +++----- src/process/HiC.java | 8 +- src/process/Processed.java | 2 - src/sipMain/Hic_main.java | 4 +- src/test/TestCallLoopsHicFile.java | 5 +- src/test/TestCallLoopsProcessedFile.java | 16 +-- src/test/TestCoolFormat.java | 54 +++++---- src/test/TestGui.java | 5 +- src/test/TestInter.java | 2 +- src/utils/MultiResProcess.java | 1 + src/utils/TupleFileToImage.java | 42 +++++++ 23 files changed, 445 insertions(+), 125 deletions(-) create mode 100644 src/dumpProcessing/CoolerDumpInter.java rename src/dumpProcessing/{CoolerDumpData.java => CoolerDumpIntra.java} (95%) rename src/dumpProcessing/{DumpInterChromosomal.java => HicDumpInter.java} (93%) rename src/dumpProcessing/{DumpData.java => HicDumpIntra.java} (98%) rename src/multiProcesing/{ProcessCoolerDumpData.java => ProcessDumpCooler.java} (54%) rename src/multiProcesing/{ProcessDumpData.java => ProcessDumpHic.java} (85%) rename src/multiProcesing/{RunnableDetectLoops.java => RunnableDetectIntraLoops.java} (91%) create mode 100644 src/multiProcesing/RunnableDumpCoolerInter.java rename src/multiProcesing/{RunnableDumpDataCooler.java => RunnableDumpCoolerIntra.java} (89%) rename src/multiProcesing/{RunnableDumpInterChromoData.java => RunnableDumpHicInter.java} (87%) rename src/multiProcesing/{RunnableDumpDataHiC.java => RunnableDumpHicIntra.java} (90%) diff --git a/src/dumpProcessing/CoolerDumpInter.java b/src/dumpProcessing/CoolerDumpInter.java new file mode 100644 index 0000000..0641f10 --- /dev/null +++ b/src/dumpProcessing/CoolerDumpInter.java @@ -0,0 +1,113 @@ +package dumpProcessing; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; + +/** + * dump data contained in mcool file via cooler tools + * + * https://github.com/open2c/cooler + * Abdennur, N., and Mirny, L. (2019). Cooler: scalable storage for Hi-C data and other genomically labeled arrays. Bioinformatics. doi: 10.1093/bioinformatics/btz540. + */ +public class CoolerDumpInter { + + + /** String to stock the error if need of juicerbox_tools*/ + private String _logError = ""; + /** String for the log*/ + private String _log = ""; + /** path to the hic file or url link*/ + private String _coolFile; + /** List of doucle to stock the expected vector*/ + private ArrayList _lExpected = new ArrayList(); + /** path to cooler tools*/ + private String _cooler ; + + + /** + * Constructor of this class to iniatilise the different variables + * + * @param cooler path to cooler bin + * @param coolFile path of mcool file + */ + public CoolerDumpInter(String cooler, String coolFile) { + this._coolFile = coolFile; + this._cooler = cooler; + } + /** + * Method to dump the oMe matrix + * + * @param chr: String for the name of teh chromosome + * @param output: String path of the output + * @return boolean + * @throws IOException exception + */ + public boolean dumpObserved(String chr, String chr2, String output, int resolution) throws IOException{ + int exitValue=1; + Runtime runtime = Runtime.getRuntime(); + String obs = output.replaceAll(".txt", "_obs.txt"); + try { + String cool = this._coolFile+"::/resolutions/"+resolution; + String line = this._cooler+" dump "+cool+" --balanced -r "+chr+" -r2 "+ chr2+" -o "+obs +" --join --na-rep NaN"; + System.out.println(line); + this._log = this._log+"\n"+obs+"\t"+line; + Process process = runtime.exec(line); + + new ReturnFlux(process.getInputStream()).start(); + new ReturnFlux(process.getErrorStream()).start(); + exitValue=process.waitFor(); + } + catch (IOException | InterruptedException e) { e.printStackTrace();} + if(_logError!=""){ + System.out.println(_logError); + System.exit(0); + } + return exitValue==0; + } + + + + /** + * Class to run command line in java + * @author axel poulet + * + */ + public class ReturnFlux extends Thread { + + /** Flux to redirect */ + private InputStream _flux; + + /** + * Constructor of ReturnFlux + * @param flux + * flux to redirect + */ + private ReturnFlux(InputStream flux){this._flux = flux; } + + /** + * + */ + public void run(){ + try { + InputStreamReader reader = new InputStreamReader(this._flux); + BufferedReader br = new BufferedReader(reader); + String line=null; + while ( (line = br.readLine()) != null) { + if(!line.contains("WARN")) _logError = _logError+line+"\n"; + } + } + catch (IOException ioe){ + ioe.printStackTrace(); + } + } + } +} diff --git a/src/dumpProcessing/CoolerDumpData.java b/src/dumpProcessing/CoolerDumpIntra.java similarity index 95% rename from src/dumpProcessing/CoolerDumpData.java rename to src/dumpProcessing/CoolerDumpIntra.java index b81b8f0..3a826c3 100644 --- a/src/dumpProcessing/CoolerDumpData.java +++ b/src/dumpProcessing/CoolerDumpIntra.java @@ -18,7 +18,7 @@ * https://github.com/open2c/cooler * Abdennur, N., and Mirny, L. (2019). Cooler: scalable storage for Hi-C data and other genomically labeled arrays. Bioinformatics. doi: 10.1093/bioinformatics/btz540. */ -public class CoolerDumpData { +public class CoolerDumpIntra { /** String to stock the error if need of juicerbox_tools*/ @@ -39,7 +39,7 @@ public class CoolerDumpData { * @param cooler path to cooler bin * @param coolFile path of mcool file */ - public CoolerDumpData(String cooler, String coolFile) { + public CoolerDumpIntra(String cooler, String coolFile) { this._coolFile = coolFile; this._cooler = cooler; } @@ -94,8 +94,8 @@ private void observedMExpected(String obs, String chr, int resolution) throws IO String [] tline = line.split("\t"); int dist = Math.abs((Integer.parseInt(tline[1])-Integer.parseInt(tline[4]))/resolution); if(!tline[7].equals("NaN")){ - double normalizedValue = ((Double.parseDouble(tline[7])*10000+1)/(this._lExpected.get(dist)*10000+1)); - double oMe = (Double.parseDouble(tline[7])*1000-this._lExpected.get(dist)*1000); + double normalizedValue = ((Double.parseDouble(tline[7])*1000000+1)/(this._lExpected.get(dist)*1000000+1)); + double oMe = (Double.parseDouble(tline[7])*1000000-this._lExpected.get(dist)*1000000); writer.write(tline[1]+"\t"+tline[4]+"\t"+oMe+"\t"+normalizedValue+"\n"); } } diff --git a/src/dumpProcessing/DumpInterChromosomal.java b/src/dumpProcessing/HicDumpInter.java similarity index 93% rename from src/dumpProcessing/DumpInterChromosomal.java rename to src/dumpProcessing/HicDumpInter.java index 636b00e..96ed752 100644 --- a/src/dumpProcessing/DumpInterChromosomal.java +++ b/src/dumpProcessing/HicDumpInter.java @@ -23,7 +23,7 @@ * @author axel poulet * */ -public class DumpInterChromosomal { +public class HicDumpInter { /** path of juiceBox */ private String _juiceBoxTools; @@ -43,7 +43,7 @@ public class DumpInterChromosomal { * @param hicFile path to the hic file * @param norm normalization methode used */ - public DumpInterChromosomal(String juiceboxTools,String hicFile, String norm) { + public HicDumpInter(String juiceboxTools, String hicFile, String norm) { this._juiceBoxTools = juiceboxTools; this._normalisation = norm; this._hicFile = hicFile; @@ -68,8 +68,8 @@ public boolean dumpObserved(String chr1, String chr2, String obs, int resolution this._log = this._log+"\n"+obs+"\t"+line; Process process = runtime.exec(line); - new DumpInterChromosomal.ReturnFlux(process.getInputStream()).start(); - new DumpInterChromosomal.ReturnFlux(process.getErrorStream()).start(); + new HicDumpInter.ReturnFlux(process.getInputStream()).start(); + new HicDumpInter.ReturnFlux(process.getErrorStream()).start(); exitValue=process.waitFor(); } catch (IOException | InterruptedException e) { e.printStackTrace();} diff --git a/src/dumpProcessing/DumpData.java b/src/dumpProcessing/HicDumpIntra.java similarity index 98% rename from src/dumpProcessing/DumpData.java rename to src/dumpProcessing/HicDumpIntra.java index a299e72..3f5531d 100644 --- a/src/dumpProcessing/DumpData.java +++ b/src/dumpProcessing/HicDumpIntra.java @@ -30,7 +30,7 @@ * @author axel poulet * */ -public class DumpData { +public class HicDumpIntra { /** String to stock the error if need of juicerbox_tools*/ private String _logError = ""; /** String for the log*/ @@ -53,7 +53,7 @@ public class DumpData { * @param hicFile: String: path to the HiC file * @param norm: String: type of normalisation */ - public DumpData(String juiceboxTools,String hicFile, String norm) { + public HicDumpIntra(String juiceboxTools, String hicFile, String norm) { this._juiceBoxTools = juiceboxTools; this._normalisation = norm; this._hicFile = hicFile; diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index f426b57..c6cb572 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -47,7 +47,7 @@ public void go(SIPIntra sip, String resuFile, String resName) throws Interrupte while(chrName.hasNext()){ String chr = chrName.next(); if(sip.isCooler()){ - RunnableDetectLoops task = new RunnableDetectLoops(chr, resuFile, sip); + RunnableDetectIntraLoops task = new RunnableDetectIntraLoops(chr, resuFile, sip); executor.execute(task); }else { @@ -55,7 +55,7 @@ public void go(SIPIntra sip, String resuFile, String resName) throws Interrupte if (sip.isProcessed()){ normFile = sip.getInputDir()+resName+File.separator+"normVector"+File.separator+chr+".norm"; } - RunnableDetectLoops task = new RunnableDetectLoops(chr, resuFile, sip,normFile); + RunnableDetectIntraLoops task = new RunnableDetectIntraLoops(chr, resuFile, sip,normFile); executor.execute(task); } } diff --git a/src/multiProcesing/ProcessCoolerDumpData.java b/src/multiProcesing/ProcessDumpCooler.java similarity index 54% rename from src/multiProcesing/ProcessCoolerDumpData.java rename to src/multiProcesing/ProcessDumpCooler.java index b3c4dac..8ea5e29 100644 --- a/src/multiProcesing/ProcessCoolerDumpData.java +++ b/src/multiProcesing/ProcessDumpCooler.java @@ -1,6 +1,9 @@ package multiProcesing; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -8,9 +11,11 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import dumpProcessing.CoolerDumpIntra; +import dumpProcessing.CoolerDumpInter; import gui.Progress; -import dumpProcessing.CoolerDumpData; import dumpProcessing.CoolerExpected; +import sip.SIPInter; import sip.SIPIntra; /** @@ -20,7 +25,7 @@ * * @author axel poulet */ -public class ProcessCoolerDumpData { +public class ProcessDumpCooler { /** progress bar if gui is true*/ private Progress _p; @@ -28,7 +33,7 @@ public class ProcessCoolerDumpData { /** * Constructor */ - public ProcessCoolerDumpData(){ } + public ProcessDumpCooler(){ } /** * run the processing on different cpu, if all cpu are running, take break else run a new one. @@ -68,8 +73,8 @@ public void go(String coolTools, String cooler, SIPIntra sip, String coolFile) t while(chrName.hasNext()){ String chr = chrName.next(); - CoolerDumpData dumpData = new CoolerDumpData( cooler, coolFile); - RunnableDumpDataCooler task = new RunnableDumpDataCooler(sip.getOutputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); + CoolerDumpIntra dumpData = new CoolerDumpIntra( cooler, coolFile); + RunnableDumpCoolerIntra task = new RunnableDumpCoolerIntra(sip.getOutputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); executor.execute(task); } executor.shutdown(); @@ -93,4 +98,56 @@ public void go(String coolTools, String cooler, SIPIntra sip, String coolFile) t } if(sip.isGui()) _p.dispose(); } + + + /** + * + * @param cooler + * @param sipInter + * @param coolFile + * @throws InterruptedException + * @throws IOException + */ + public void go(String cooler, SIPInter sipInter, String coolFile) throws InterruptedException, IOException { + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); + HashMap chrSize = sipInter.getChrSizeHashMap(); + Object [] chrName = chrSize.keySet().toArray(); + + if (chrName.length < 2){ + System.out.println("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(sipInter.getOutputDir()+File.separator+"log.txt"))); + writer.write("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); + writer.close(); + System.exit(1); + } + for(int i = 0; i < chrName.length;++i){ + String chr1 = chrName[i].toString(); + for(int j = i+1; j < chrName.length;++j){ + String chr2 = chrName[j].toString(); + int size1 = chrSize.get(chr1); + int size2 = chrSize.get(chr2); + System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); + CoolerDumpInter coolerDumpInter= new CoolerDumpInter(cooler, coolFile); + + RunnableDumpCoolerInter task = new RunnableDumpCoolerInter(sipInter.getOutputDir(), chr1, chrSize.get(chr1), + chr2, chrSize.get(chr2), coolerDumpInter, sipInter.getResolution(), sipInter.getMatrixSize()); + executor.execute(task); + } + } + + executor.shutdown(); + int nb = 0; + + if(sipInter.isGui()){ + _p = new Progress("Loop Detection step",sipInter.getChrSizeHashMap().size()+1); + _p._bar.setValue(nb); + } + while (!executor.awaitTermination(30, TimeUnit.SECONDS)) { + if (nb != executor.getCompletedTaskCount()) { + nb = (int) executor.getCompletedTaskCount(); + if(sipInter.isGui()) _p._bar.setValue(nb); + } + } + if(sipInter.isGui()) _p.dispose(); + } } diff --git a/src/multiProcesing/ProcessDumpData.java b/src/multiProcesing/ProcessDumpHic.java similarity index 85% rename from src/multiProcesing/ProcessDumpData.java rename to src/multiProcesing/ProcessDumpHic.java index 277d3a1..490e80b 100644 --- a/src/multiProcesing/ProcessDumpData.java +++ b/src/multiProcesing/ProcessDumpHic.java @@ -10,9 +10,9 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import dumpProcessing.HicDumpIntra; +import dumpProcessing.HicDumpInter; import gui.Progress; -import dumpProcessing.DumpData; -import dumpProcessing.DumpInterChromosomal; import sip.SIPInter; import sip.SIPIntra; @@ -25,14 +25,14 @@ * @author axel poulet * */ -public class ProcessDumpData { +public class ProcessDumpHic { /** progress bar if gui is true*/ private Progress _p; /** * */ - public ProcessDumpData(){ } + public ProcessDumpHic(){ } /** * run SiP for intra chr loops @@ -51,8 +51,8 @@ public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJu if (!outDir.exists()) outDir.mkdir(); while(chrName.hasNext()){ String chr = chrName.next(); - DumpData dumpData = new DumpData(juiceBoxTools, hicFile, normJuiceBox); - RunnableDumpDataHiC task = new RunnableDumpDataHiC(sip.getOutputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); + HicDumpIntra dumpData = new HicDumpIntra(juiceBoxTools, hicFile, normJuiceBox); + RunnableDumpHicIntra task = new RunnableDumpHicIntra(sip.getOutputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); executor.execute(task); } executor.shutdown(); @@ -99,8 +99,8 @@ public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String n int size1 = chrSize.get(chr1); int size2 = chrSize.get(chr2); System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); - DumpInterChromosomal DumpInterChromosomal = new DumpInterChromosomal(juiceBoxTools, hicFile, normJuiceBox); - RunnableDumpInterChromoData task = new RunnableDumpInterChromoData(sipInter.getOutputDir(), chr1, chrSize.get(chr1), + HicDumpInter DumpInterChromosomal = new HicDumpInter(juiceBoxTools, hicFile, normJuiceBox); + RunnableDumpHicInter task = new RunnableDumpHicInter(sipInter.getOutputDir(), chr1, chrSize.get(chr1), chr2, chrSize.get(chr2),DumpInterChromosomal, sipInter.getResolution(), sipInter.getMatrixSize()); executor.execute(task); } diff --git a/src/multiProcesing/RunnableDetectLoops.java b/src/multiProcesing/RunnableDetectIntraLoops.java similarity index 91% rename from src/multiProcesing/RunnableDetectLoops.java rename to src/multiProcesing/RunnableDetectIntraLoops.java index 55b6408..26d5420 100644 --- a/src/multiProcesing/RunnableDetectLoops.java +++ b/src/multiProcesing/RunnableDetectIntraLoops.java @@ -12,7 +12,7 @@ * @author axel poulet * */ -public class RunnableDetectLoops extends Thread implements Runnable{ +public class RunnableDetectIntraLoops extends Thread implements Runnable{ /** SIP object containing all the parameter for the loops detection*/ private SIPIntra _sip; /** CallLoops object */ @@ -38,7 +38,7 @@ public class RunnableDetectLoops extends Thread implements Runnable{ * @param normVectorFile path to normalized vector * */ - public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, String normVectorFile){ + public RunnableDetectIntraLoops(String chr, String resuFile, SIPIntra sip, String normVectorFile){ this._sip = sip; this._callLoops = new CallLoops(sip); this._chr= chr; @@ -55,7 +55,7 @@ public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip, String no * @param sip SIPIntra * */ - public RunnableDetectLoops (String chr, String resuFile, SIPIntra sip){ + public RunnableDetectIntraLoops(String chr, String resuFile, SIPIntra sip){ this._sip = sip; this._callLoops = new CallLoops(sip); this._chr= chr; @@ -84,6 +84,7 @@ public void run(){ if(!_sip.isCooler()) { System.out.println(_normVectorFile +"normVector end loading file: "+_chr+".norm "+resName); } + System.out.println(dir); data = this._callLoops.detectLoops(listOfFiles,this._chr,this._normVector); synchronized(this) { if (file.length() == 0) _sip.saveFile(this._resuFile,data,false); diff --git a/src/multiProcesing/RunnableDumpCoolerInter.java b/src/multiProcesing/RunnableDumpCoolerInter.java new file mode 100644 index 0000000..c8a774d --- /dev/null +++ b/src/multiProcesing/RunnableDumpCoolerInter.java @@ -0,0 +1,114 @@ +package multiProcesing; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +import dumpProcessing.CoolerDumpInter; +import dumpProcessing.CoolerExpected; + +/** + * + * @author axel poulet + * + */ +public class RunnableDumpCoolerInter extends Thread implements Runnable{ + /** path outdir */ + private String _outDir; + /** chr1 name */ + private String _chr1; + /** chr2 name*/ + private String _chr2; + /** size chr1*/ + private int _sizeChr1; + /** size chr2 */ + private int _sizeChr2; + /** Object HicDumpInter*/ + private CoolerDumpInter _dumpInter; + /** bin size*/ + private int _resolution; + /** image size*/ + private int _matrixSize; + + + /** + * Constructor, initialize the variables of interest + */ + public RunnableDumpCoolerInter(String outputDir, String chr1, int sizeChr1, String chr2, int sizeChr2, CoolerDumpInter dumpData, int res, int matrixSize){ + this._outDir = outputDir; + this._sizeChr1 = sizeChr1; + this._sizeChr2 = sizeChr2; + this._chr1 = chr1; + this._chr2 = chr2; + this._resolution = res; + this._matrixSize = matrixSize; + this._dumpInter = dumpData; + } + + /** + * Dump the data by chr for mcool data + * using cooler and cooltools + */ + public void run(){ + int step = _matrixSize; + String nameRes = String.valueOf(_resolution); + nameRes = nameRes.replace("000", ""); + nameRes = nameRes+"kb"; + String outdir = _outDir+nameRes+ File.separator+_chr1+"_"+_chr2+File.separator; + File file = new File(outdir); + if (!file.exists()) + file.mkdirs(); + step = step*_resolution; + System.out.println("start dump "+_chr1+" size "+_sizeChr1+" "+_chr2+" size "+_sizeChr2+" res "+ nameRes); + int endChr1 = _matrixSize*_resolution; + if(endChr1 > _sizeChr1) endChr1 = _sizeChr1; + try { + for(int startChr1 = 0 ; endChr1-1 <= _sizeChr1; startChr1+=step,endChr1+=step){ + int endChr2 = _matrixSize*_resolution; + if(endChr2 > _sizeChr2) endChr2 = _sizeChr2; + int end1 =endChr1-1; + + //hgdhdhgd + String dump1 = _chr1+":"+startChr1+"-"+end1; + for(int startChr2 = 0 ; endChr2-1 <= _sizeChr2; startChr2+=step,endChr2+=step) { + int end2 =endChr2-1; + // + String dump2 = _chr2+":"+startChr2+"-"+end2; + String name = outdir + _chr1 +"_" + startChr1 + "_" + end1 +"_" +_chr2 +"_" + startChr2 + "_" + end2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + if (endChr2 + step > _sizeChr2 && endChr2 < _sizeChr2) { + endChr2 = _sizeChr2-1; + startChr2 += step; + dump2 = _chr2+":"+startChr2+"-"+endChr2; + name = outdir + _chr1 +"_" + startChr1 + "_" + end1 +"_" +_chr2 +"_" + startChr2 + "_" + endChr2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + } + } + if (endChr1 + step > _sizeChr1 && endChr1 < _sizeChr1) { + endChr1 = _sizeChr1-1; + startChr1 += step; + dump1 = _chr1+":"+startChr1+"-"+endChr1; + endChr2 = _matrixSize*_resolution; + for(int startChr2 = 0 ; endChr2-1 <= _sizeChr2; startChr2+=step,endChr2+=step) { + int end2 =endChr2-1; + String dump2 = _chr2+":"+startChr2+"-"+end2; + String name = outdir + _chr1 +"_" + startChr1 + "_" + endChr1 +"_" +_chr2 +"_" + startChr2 + "_" + end2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + if (endChr2 + step > _sizeChr2 && endChr2 < _sizeChr2) { + endChr2 = _sizeChr2-1; + startChr2 += step; + dump2 = _chr2+":"+startChr2+"-"+endChr2; + name = outdir + _chr1 +"_" + startChr1 + "_" + endChr1 +"_" +_chr2 +"_" + startChr2 + "_" + endChr2 + ".txt"; + _dumpInter.dumpObserved(dump1, dump2, name, _resolution); + } + } + } + } + System.gc(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + +} diff --git a/src/multiProcesing/RunnableDumpDataCooler.java b/src/multiProcesing/RunnableDumpCoolerIntra.java similarity index 89% rename from src/multiProcesing/RunnableDumpDataCooler.java rename to src/multiProcesing/RunnableDumpCoolerIntra.java index 659620e..b0447d4 100644 --- a/src/multiProcesing/RunnableDumpDataCooler.java +++ b/src/multiProcesing/RunnableDumpCoolerIntra.java @@ -4,7 +4,7 @@ import java.io.IOException; import java.util.ArrayList; -import dumpProcessing.CoolerDumpData; +import dumpProcessing.CoolerDumpIntra; import dumpProcessing.CoolerExpected; /** @@ -12,15 +12,15 @@ * @author axel poulet * */ -public class RunnableDumpDataCooler extends Thread implements Runnable{ +public class RunnableDumpCoolerIntra extends Thread implements Runnable{ /**String: path where save the dump data */ private String _outdir ; /**String: name of the chr*/ private String _chrName; /**int: chr size */ private int _chrSize; - /** DumpData object run juicertoolbox.jar*/ - private CoolerDumpData _coolerDumpData; + /** HicDumpIntra object run juicertoolbox.jar*/ + private CoolerDumpIntra _coolerDumpData; /**int: bin resolution*/ private int _res; /**int: image Size */ @@ -37,13 +37,13 @@ public class RunnableDumpDataCooler extends Thread implements Runnable{ * @param outdir string path outdir * @param chrName string chr name * @param chrSize int chr size - * @param dumpData CoolerDumpData Object + * @param dumpData CoolerDumpIntra Object * @param res bin size * @param matrixSize image size * @param step step between each image * @param listFactor List of integer for multi-resolution loop calling */ - public RunnableDumpDataCooler (String outdir, String chrName, int chrSize, CoolerDumpData dumpData,int res, int matrixSize, int step, ArrayList listFactor){ + public RunnableDumpCoolerIntra(String outdir, String chrName, int chrSize, CoolerDumpIntra dumpData, int res, int matrixSize, int step, ArrayList listFactor){ this._outdir = outdir; this._chrName = chrName; this._chrSize = chrSize; diff --git a/src/multiProcesing/RunnableDumpInterChromoData.java b/src/multiProcesing/RunnableDumpHicInter.java similarity index 87% rename from src/multiProcesing/RunnableDumpInterChromoData.java rename to src/multiProcesing/RunnableDumpHicInter.java index 5f12686..f23d002 100644 --- a/src/multiProcesing/RunnableDumpInterChromoData.java +++ b/src/multiProcesing/RunnableDumpHicInter.java @@ -1,6 +1,6 @@ package multiProcesing; -import dumpProcessing.DumpInterChromosomal; +import dumpProcessing.HicDumpInter; import java.io.File; import java.io.IOException; @@ -9,7 +9,7 @@ /** * */ -public class RunnableDumpInterChromoData extends Thread implements Runnable{ +public class RunnableDumpHicInter extends Thread implements Runnable{ /** path outdir */ private String _outDir; /** chr1 name */ @@ -20,8 +20,8 @@ public class RunnableDumpInterChromoData extends Thread implements Runnable{ private int _sizeChr1; /** size chr2 */ private int _sizeChr2; - /** Object DumpInterChromosomal*/ - private DumpInterChromosomal _dumpInter; + /** Object HicDumpInter*/ + private HicDumpInter _dumpInter; /** bin size*/ private int _resolution; /** image size*/ @@ -34,12 +34,12 @@ public class RunnableDumpInterChromoData extends Thread implements Runnable{ * @param sizeChr1 int chr1 size * @param chr2 String chr2 name * @param sizeChr2 int chr2 size - * @param dumpInterChromosomal DumpInterChromosomal object dumping the data of interest + * @param dumpInterChromosomal HicDumpInter object dumping the data of interest * @param resolution int resolution == size of the bins to dump * @param matrixSize int size of the ImagePlus */ - public RunnableDumpInterChromoData(String outputDir, String chr1, int sizeChr1, String chr2, int sizeChr2, - DumpInterChromosomal dumpInterChromosomal, int resolution, int matrixSize) { + public RunnableDumpHicInter(String outputDir, String chr1, int sizeChr1, String chr2, int sizeChr2, + HicDumpInter dumpInterChromosomal, int resolution, int matrixSize) { _outDir = outputDir; _chr1 = chr1; @@ -76,7 +76,7 @@ public void run(){ String dump1 = _chr1+":"+startChr1+":"+end1; for(int startChr2 = 0 ; endChr2-1 <= _sizeChr2; startChr2+=step,endChr2+=step) { int end2 =endChr2-1; - String dump2 = _chr2+":"+startChr2+":"+end2; + String dump2 = _chr2+":"+startChr2+"-"+end2; String name = outdir + _chr1 +"_" + startChr1 + "_" + end1 +"_" +_chr2 +"_" + startChr2 + "_" + end2 + ".txt"; _dumpInter.dumpObserved(dump1, dump2, name, _resolution); if (endChr2 + step > _sizeChr2 && endChr2 < _sizeChr2) { diff --git a/src/multiProcesing/RunnableDumpDataHiC.java b/src/multiProcesing/RunnableDumpHicIntra.java similarity index 90% rename from src/multiProcesing/RunnableDumpDataHiC.java rename to src/multiProcesing/RunnableDumpHicIntra.java index 6d09c83..73e48ac 100644 --- a/src/multiProcesing/RunnableDumpDataHiC.java +++ b/src/multiProcesing/RunnableDumpHicIntra.java @@ -1,5 +1,5 @@ package multiProcesing; -import dumpProcessing.DumpData; +import dumpProcessing.HicDumpIntra; import java.io.File; import java.io.IOException; @@ -15,15 +15,15 @@ * @author axel poulet * */ -public class RunnableDumpDataHiC extends Thread implements Runnable{ +public class RunnableDumpHicIntra extends Thread implements Runnable{ /**String: path where save the dump data */ private String _outdir; /**String: name of the chr*/ private String _chrName; /**int: chr size */ private int _chrSize; - /** DumpData object run juicertoolbox.jar*/ - private DumpData _dumpData; + /** HicDumpIntra object run juicertoolbox.jar*/ + private HicDumpIntra _dumpData; /**int: bin resolution*/ private int _res; /**int: image Size */ @@ -40,13 +40,13 @@ public class RunnableDumpDataHiC extends Thread implements Runnable{ * @param outdir string path outdir * @param chrName string chr name * @param chrSize int chr size - * @param dumpData CoolerDumpData Object + * @param dumpData CoolerDumpIntra Object * @param res bin size * @param matrixSize image size * @param step step between each image * @param listFactor List of integer for multi-resolution loop calling */ - public RunnableDumpDataHiC (String outdir, String chrName, int chrSize, DumpData dumpData,int res, int matrixSize, int step, ArrayList listFactor){ + public RunnableDumpHicIntra(String outdir, String chrName, int chrSize, HicDumpIntra dumpData, int res, int matrixSize, int step, ArrayList listFactor){ this._outdir = outdir; this._chrName = chrName; this._chrSize = chrSize; diff --git a/src/process/Cool.java b/src/process/Cool.java index d4c9268..4262d21 100644 --- a/src/process/Cool.java +++ b/src/process/Cool.java @@ -3,9 +3,8 @@ import cli.CLIOptionHiC; import gui.GuiAnalysis; -import multiProcesing.ProcessCoolerDumpData; +import multiProcesing.ProcessDumpCooler; import multiProcesing.ProcessDetectLoops; -import multiProcesing.ProcessDumpData; import org.apache.commons.cli.CommandLine; import sip.SIPInter; import sip.SIPIntra; @@ -153,9 +152,9 @@ private String runIntra() throws IOException, InterruptedException { _sipIntra.setIsGui(_isGui); _sipIntra.setIsProcessed(false); - _sipIntra.setIsCooler(false); + _sipIntra.setIsCooler(true); - ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); + ProcessDumpCooler processDumpData = new ProcessDumpCooler(); String allParam = "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ @@ -198,41 +197,30 @@ private String runIntra() throws IOException, InterruptedException { * @throws IOException */ private String runInter() throws IOException, InterruptedException { - System.out.println("PAS finis de dev\n"); - //TODO inter chromosomal loop with cool option - /*ProcessDumpData processDumpData = new ProcessDumpData(); + ProcessDumpCooler processDumpData = new ProcessDumpCooler(); this.setSipInter(); _sipInter.setIsGui(_isGui); - _sipIntra.setIsProcessed(false); - _sipIntra.setIsCooler(false); - + _sipInter.setIsProcessed(false); + _sipInter.setIsCooler(true); - String allParam = "SIPHiC hic: \n" + - "input: "+_input+"\n" + - "output: "+_output+"\n"+ - "juiceBox: "+ _juicerTool +"\n"+ - "norm: "+ _juicerNorm +"\n" + - "inter or intra chromosomal: "+ _interOrIntra +"\n" + - "gauss: "+this._sipInter.getGauss()+"\n"+ - "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ - "resolution: "+this._sipInter.getResolution()+"\n"+ - "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ - "number of zero :"+_nbZero+"\n"+ - "fdr "+this._sipInter.getFdr()+"\n"+ - "delete images "+_delImages+"\n"+ - "cpu "+ _cpu+"\n"; _parameterCheck.optionalParametersValidity(_sipInter); - - processDumpData.go(_input,_sipInter, _juicerTool, _juicerNorm); - + System.out.println("########### Starting dump Step inter chromosomal interactions"); + processDumpData.go(_cooler, _sipInter, _input); + System.out.println("########### !!! End dump Step inter chromosomal interactions"); String loopFileRes = _sipInter.getOutputDir()+"finalLoops.txt"; - + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(loopFileRes))); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(_sipInter, _cpu, _delImages, loopFileRes); - */ - return "plopi"; + System.out.println("########### Starting loop detection"); + detectLoops.go(_sipInter, loopFileRes); + System.out.println("########### !!!!!!! end loops detection"); + return "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ "cooler: "+ _cooler +"\n"+ + "inter or intra chromosomal: "+ _interOrIntra +"\n" + + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ + "resolution: "+this._sipInter.getResolution()+"\n"+ "threshold: "+this._sipInter.getThresholdMaxima()+"\n"+ + "number of zero :"+_sipInter.getNbZero()+"\n"+ "fdr "+this._sipInter.getFdr()+"\n"+ "delete images "+_delImages+"\n"+ + "cpu "+ _cpu+"\n"; } diff --git a/src/process/HiC.java b/src/process/HiC.java index 7096f2f..45d84b4 100644 --- a/src/process/HiC.java +++ b/src/process/HiC.java @@ -5,12 +5,12 @@ import cli.CLIOptionHiC; import gui.GuiAnalysis; import multiProcesing.ProcessDetectLoops; -import multiProcesing.ProcessDumpData; +import multiProcesing.ProcessDumpHic; import org.apache.commons.cli.CommandLine; import sip.SIPInter; import sip.SIPIntra; import utils.MultiResProcess; -import org.apache.commons.cli.ParseException; + import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -147,7 +147,7 @@ private String runIntra() throws IOException, InterruptedException { _parameterCheck.optionalParametersValidity(_sipIntra); _parameterCheck.speOption(_sipIntra); System.out.println("########### Starting dump Step inter chromosomal interactions"); - ProcessDumpData processDumpData = new ProcessDumpData(); + ProcessDumpHic processDumpData = new ProcessDumpHic(); processDumpData.go(_input, _sipIntra, _juicerTool, _juicerNorm); System.out.println("########### End of the dump step\n"); @@ -171,7 +171,7 @@ private String runIntra() throws IOException, InterruptedException { * @throws IOException */ private String runInter() throws IOException, InterruptedException { - ProcessDumpData processDumpData = new ProcessDumpData(); + ProcessDumpHic processDumpData = new ProcessDumpHic(); this.setSipInter(); _sipInter.setIsGui(_isGui); diff --git a/src/process/Processed.java b/src/process/Processed.java index def9705..1618c24 100644 --- a/src/process/Processed.java +++ b/src/process/Processed.java @@ -4,7 +4,6 @@ import cli.CLIOptionProcessed; import gui.GuiAnalysis; import multiProcesing.ProcessDetectLoops; -import multiProcesing.ProcessDumpData; import org.apache.commons.cli.CommandLine; import sip.SIPInter; import sip.SIPIntra; @@ -14,7 +13,6 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.Arrays; /** * diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index caf15a9..1b6516e 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -97,14 +97,14 @@ public static void main(String[] args) throws IOException, InterruptedException sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); sip.setIsGui(_gui); - ProcessDumpData processDumpData = new ProcessDumpData(); + ProcessDumpHic processDumpData = new ProcessDumpHic(); processDumpData.go(_input, sip, _juiceBoxTools, _juiceBoXNormalisation, _cpu); System.out.println("########### End of the dump Step"); }else if(_isCool){ sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); sip.setIsCooler(_isCool); - ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); + ProcessDumpCooler processDumpData = new ProcessDumpCooler(); processDumpData.go(_cooltools, _cooler, sip, _input, _cpu); }else{ diff --git a/src/test/TestCallLoopsHicFile.java b/src/test/TestCallLoopsHicFile.java index f7fc831..9027158 100644 --- a/src/test/TestCallLoopsHicFile.java +++ b/src/test/TestCallLoopsHicFile.java @@ -4,9 +4,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.util.ArrayList; -import multiProcesing.ProcessDumpData; +import multiProcesing.ProcessDumpHic; import utils.MultiResProcess; import sip.SIPIntra; @@ -76,7 +75,7 @@ public static void main(String[] args) throws IOException, InterruptedException SIPIntra sip = new SIPIntra(output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false, keepTif,cpu ); sip.setIsGui(false); - ProcessDumpData processDumpData = new ProcessDumpData(); + ProcessDumpHic processDumpData = new ProcessDumpHic(); processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation); MultiResProcess multi = new MultiResProcess(sip, fileChr); diff --git a/src/test/TestCallLoopsProcessedFile.java b/src/test/TestCallLoopsProcessedFile.java index 4ead35b..7ad9cb9 100644 --- a/src/test/TestCallLoopsProcessedFile.java +++ b/src/test/TestCallLoopsProcessedFile.java @@ -20,14 +20,14 @@ public class TestCallLoopsProcessedFile { * @throws InterruptedException */ public static void main(String[] args) throws IOException, InterruptedException { - String input = "/home/plop/Desktop/GM12878TestBis"; - String output= "/home/plop/Desktop/testChr"; - int matrixSize = 2000; - int resolution = 5000; - int diagSize = 5; + String input = "/home/plop/Desktop/Cool"; + String output= "/home/plop/Desktop/Bis"; + int matrixSize = 500; + int resolution = 25000; + int diagSize = 2; double gauss = 1.5; int thresholdMax = 2800;// 2800;//1800 - int nbZero = 6;//6; + int nbZero = 8;//6; double min = 2;//1.5; double max = 2;//1.5; double saturatedPixel = 0.01;//0.005; @@ -37,9 +37,9 @@ public static void main(String[] args) throws IOException, InterruptedException //factor.add(2); //factor.add(5); //SIP_HiC_v1.3.6.jar hic SIP/Kc_allcombined.hic SIP/armsizes.txt SIP/Droso/ ../Tools/juicer_tools_1.13.02.jar - String chrSizeFile = "/home/plop/Desktop/w_hg19.sizes"; + String chrSizeFile = "/home/plop/Desktop/SIP/hg38_small.size"; SIPIntra sip = new SIPIntra(input,output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, - thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false,true,2); + thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false,false,2); sip.setIsGui(false); sip.setIsProcessed(true); int cpu = 2; diff --git a/src/test/TestCoolFormat.java b/src/test/TestCoolFormat.java index 845f8d6..02dd01b 100644 --- a/src/test/TestCoolFormat.java +++ b/src/test/TestCoolFormat.java @@ -1,8 +1,13 @@ package test; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.io.IOException; -import java.util.ArrayList; +import multiProcesing.ProcessDetectLoops; +import multiProcesing.ProcessDumpCooler; +import sip.SIPInter; import utils.MultiResProcess; import sip.SIPIntra; @SuppressWarnings("unused") @@ -11,50 +16,53 @@ public class TestCoolFormat { public static void main(String[] args) throws IOException, InterruptedException { String chr = "chr21"; //String input = "/home/plop/Desktop/SIP/testCooler/GM12878_4DNFIXP4QG5B.mcool"; - String input = "/home/plop/Desktop/CoolTest21"; - String output = "/home/plop/Desktop/CoolTest21Bis"; - String expectedFile = "/home/plop/Desktop/chr21Cooler/expected.txt"; - String fileChr = "/home/plop/Desktop/w_hg19.sizes"; + String input = "/home/plop/Desktop/SIP/hicData/4DNFIFLDVASC_untreated.mcool"; + String output = "/home/plop/Desktop/CoolTest"; + //String expectedFile = "/home/plop/Desktop/chr21Cooler/expected.txt"; + String chrSizeFile = "/home/plop/Desktop/SIP/hg38_small.size"; String cooler = "/home/plop/anaconda3/bin/cooler"; String cooltools = "/home/plop/anaconda3/bin/cooltools"; - int resolution = 5000; - int matrixSize = 2000; + int resolution = 100000; + int matrixSize = 500; //CoolerExpected expected = new CoolerExpected(input, resolution, matrixSize); //expected.dumpExpected(expectedFile); //CoolerExpected expected = new CoolerExpected(expectedFile, matrixSize); //expected.parseExpectedFile(); //ArrayList plop = expected.getExpected(chr); - //CoolerDumpData cooler = new CoolerDumpData(input, resolution, plop); + //CoolerDumpIntra cooler = new CoolerDumpIntra(input, resolution, plop); //run(resolution,matrixSize,matrixSize/2,chr,output, cooler, 46709983); - int diagSize = 5; + int diagSize = 3; double gauss = 1.5; double min = 2; double max = 2; - int nbZero = 6; + int nbZero = 8; int thresholdMax = 2800; double saturatedPixel = 0.01; - int factor = 4; - - boolean keepTif = false; + int factor = 1; + double fdr =0.025; + boolean keepTif = true; int cpu = 1; - SIPIntra sip = new SIPIntra(input,output, fileChr, gauss, min, max, resolution, saturatedPixel, thresholdMax, - diagSize, matrixSize, nbZero,factor,0.03,false,keepTif,cpu); - + //SIPIntra sip = new SIPIntra(output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03,false,keepTif,cpu); + SIPInter sip = new SIPInter(output, chrSizeFile, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr , true,2); sip.setIsGui(false); sip.setIsCooler(true); - sip.setIsProcessed(true); + sip.setIsProcessed(false); - + ProcessDumpCooler processDumpData = new ProcessDumpCooler(); + processDumpData.go(cooler, sip, input); + System.out.println("########### End of the dump step\n"); + System.out.println("########### Start loop detection\n"); + String loopFileRes = sip.getOutputDir()+"finalLoops.txt"; + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(loopFileRes))); + ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - //ProcessCoolerDumpData processDumpData = new ProcessCoolerDumpData(); - // go(String coolTools, String cooler, SIPIntra sip, String coolFile, HashMap chrSize,int nbCPU) - //processDumpData.go(cooltools, cooler, sip, input, chrsize,2); - MultiResProcess multi = new MultiResProcess(sip,fileChr); - multi.run(); + System.out.println("########### Starting loop detection"); + detectLoops.go(sip, loopFileRes); + System.out.println("########### !!!!!!! end loops detection"); System.out.println("end"); diff --git a/src/test/TestGui.java b/src/test/TestGui.java index 5d28e84..312d46e 100644 --- a/src/test/TestGui.java +++ b/src/test/TestGui.java @@ -1,10 +1,9 @@ package test; import java.io.IOException; -import java.util.ArrayList; import gui.GuiAnalysis; -import multiProcesing.ProcessDumpData; +import multiProcesing.ProcessDumpHic; import sip.SIPIntra; @@ -59,7 +58,7 @@ public static void main(String[] args) throws IOException, InterruptedException{ +"\nthreshold: "+thresholdMax+"\n number of zero:"+nbZero+"\n "); sip = new SIPIntra(output, chrSize, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.01,false,true,2); sip.setIsGui(true); - ProcessDumpData processDumpData = new ProcessDumpData(); + ProcessDumpHic processDumpData = new ProcessDumpHic(); processDumpData.go(input, sip, juiceBoxTools, juiceBoXNormalisation); }else{ System.out.println("processed mode:\ninput: "+input+"\noutput: "+output+"\njuiceBox: "+juiceBoxTools+"\nnorm: "+ juiceBoXNormalisation+"\ngauss: "+gauss diff --git a/src/test/TestInter.java b/src/test/TestInter.java index 9214671..2b8cbf4 100644 --- a/src/test/TestInter.java +++ b/src/test/TestInter.java @@ -29,7 +29,7 @@ public static void main(String[] args) throws IOException, InterruptedException boolean keepTif = true; int cpu = 2; SIPInter sipInter = new SIPInter(input, output, fileChr, gauss, resolution, thresholdMax, matrixSize, nbZero,0.025,keepTif,cpu); - //ProcessDumpData process = new ProcessDumpData(); + //ProcessDumpHic process = new ProcessDumpHic(); //process.go(input,sipInter,chrsize,juicerTools,norm,2); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); diff --git a/src/utils/MultiResProcess.java b/src/utils/MultiResProcess.java index 0119918..4fc81d2 100644 --- a/src/utils/MultiResProcess.java +++ b/src/utils/MultiResProcess.java @@ -77,6 +77,7 @@ public void run() throws InterruptedException, IOException{ if(file.exists()) file.delete(); if(indexFact == 0) { + //System.out.println("plopi"); ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); processDetectloops.go(this._sip, resuFile,resName); }else { diff --git a/src/utils/TupleFileToImage.java b/src/utils/TupleFileToImage.java index 73f88e8..cf97133 100644 --- a/src/utils/TupleFileToImage.java +++ b/src/utils/TupleFileToImage.java @@ -171,6 +171,48 @@ public ImagePlus readTupleFileInter(){ return img; } + /** + * Method to make the image with an input tuple file from inter chromosomal process + * @return ImagePlus + */ + public ImagePlus readTupleFileInterCool(){ + ImagePlus img = new ImagePlus(); + BufferedReader br; + FloatProcessor pRaw = new FloatProcessor(_size, _size); + String[] tfile = _file.split("_"); + //chr3 150000000 150100000 chr4 150000000 150100000 2 1.31032e-05 + int numImageX = Integer.parseInt(tfile[tfile.length-5])/(_size*_resolution); + int numImageY = Integer.parseInt(tfile[tfile.length-2])/(_size*_resolution); + try { + pRaw.abs(); + br = new BufferedReader(new FileReader(_file)); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null){ + sb.append(line); + String[] parts = line.split("\\t"); + float raw = 0; + + if(!(parts[2].equals("NAN"))){ + raw =Float.parseFloat(parts[7])*1000000; + if (raw < 0) raw = 0; + } + + int correctionX = numImageX*_size*_resolution; + int correctionY = numImageY*_size*_resolution; + int i = (Integer.parseInt(parts[1]) - correctionX)/_resolution; + int j = (Integer.parseInt(parts[4]) - correctionY)/_resolution; + if(i < _size && j< _size){ + pRaw.setf(i, j, raw); + } + sb.append(System.lineSeparator()); + line = br.readLine(); + } + br.close(); + } catch (IOException e) { e.printStackTrace();} + img.setProcessor(pRaw); + return img; + } /** * Compute the standard deviation of the pixel non zero values of m_img From 46347df7728932c7251aff1e285c7793582cbca2 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Mon, 15 Feb 2021 08:56:55 -0500 Subject: [PATCH 24/27] Beta version final mcool opt added for inter chrom --- src/cli/CLIOptionCool.java | 7 ++-- src/loops/CallLoopsInter.java | 8 ++++- src/multiProcesing/ProcessDetectLoops.java | 12 +++---- src/multiProcesing/ProcessDumpCooler.java | 12 +++---- src/multiProcesing/ProcessDumpHic.java | 14 ++++---- .../RunnableDetectInterLoops.java | 2 +- src/process/Cool.java | 14 ++++---- src/process/ParametersCheck.java | 4 +-- src/sip/SIPObject.java | 10 ++++++ src/sipMain/Hic_main.java | 35 +++++++++++-------- src/test/TestCoolFormat.java | 10 +++--- src/utils/FindMaxima.java | 4 +-- src/utils/TupleFileToImage.java | 8 +++-- 13 files changed, 82 insertions(+), 58 deletions(-) diff --git a/src/cli/CLIOptionCool.java b/src/cli/CLIOptionCool.java index 9be46b4..d3bfc20 100644 --- a/src/cli/CLIOptionCool.java +++ b/src/cli/CLIOptionCool.java @@ -34,9 +34,8 @@ public CLIOptionCool(String [] args){ this._options.addOption(_saturated); this._options.addOption(_isDroso); - this._options.addOption(Option.builder("coolTool").longOpt("coolTool").required() - .type(String.class).desc("Path to coolTool bin\n").numberOfArgs(1).build()); - + this._options.addOption(Option.builder("cooltools").longOpt("cooltools").required() + .type(String.class).desc("Path to cooltools bin\n").numberOfArgs(1).build()); this._options.addOption(Option.builder("cooler").longOpt("cooler").required() .type(String.class).desc("Path to cooler bin\n").numberOfArgs(1).build()); @@ -49,7 +48,7 @@ public CLIOptionCool(String [] args){ CLIHelper.CmdHelpCool(); }catch (IllegalArgumentException exp){ System.out.println( exp.getMessage()); - CLIHelper.CmdHelpHiC(); + CLIHelper.CmdHelpCool(); } } diff --git a/src/loops/CallLoopsInter.java b/src/loops/CallLoopsInter.java index 59b9559..ffeb5b4 100644 --- a/src/loops/CallLoopsInter.java +++ b/src/loops/CallLoopsInter.java @@ -24,6 +24,7 @@ public class CallLoopsInter { private double _noiseTolerance; private double _gaussian; private int _nbZero; + private boolean _cooler; /** * @@ -35,6 +36,7 @@ public CallLoopsInter(SIPInter sipInter){ _noiseTolerance= sipInter.getThresholdMaxima(); _gaussian = sipInter.getGauss(); _nbZero = sipInter.getNbZero(); + _cooler = sipInter.isCooler(); } /** @@ -54,7 +56,11 @@ public HashMap detectLoops(File[] fileList, String chrName1, Strin String fileName = fileList[i].toString(); if(fileName.contains("txt")) { TupleFileToImage tuple = new TupleFileToImage(fileName, _matrixSize, _resolution); - ImagePlus img = tuple.readTupleFileInter(); + ImagePlus img = new ImagePlus(); + if(_cooler){ + img = tuple.readTupleFileInterCool(); + }else + img = tuple.readTupleFileInter(); String imgPath = fileName; String [] name = fileName.split(File.separator); imgPath = imgPath.replace("txt", "tif"); diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/multiProcesing/ProcessDetectLoops.java index c6cb572..e2aedf6 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/multiProcesing/ProcessDetectLoops.java @@ -1,5 +1,6 @@ package multiProcesing; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -85,15 +86,14 @@ public void go(SIPIntra sip, String resuFile, String resName) throws Interrupte public void go(SIPInter sipInter, String resuFile) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); HashMap chrSize = sipInter.getChrSizeHashMap(); - Object [] chrName = chrSize.keySet().toArray(); - + ArrayList chrName = sipInter.getChrList(); System.out.println(sipInter.getOutputDir()); File outDir = new File(sipInter.getOutputDir()); if (!outDir.exists()) outDir.mkdir(); - for(int i = 0; i < chrName.length;++i){ - String chr1 = chrName[i].toString(); - for(int j = i+1; j < chrName.length;++j){ - String chr2 = chrName[j].toString(); + for(int i = 0; i < chrName.size();++i){ + String chr1 = chrName.get(i); + for(int j = i+1; j < chrName.size();++j){ + String chr2 = chrName.get(j); int size1 = chrSize.get(chr1); int size2 = chrSize.get(chr2); System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); diff --git a/src/multiProcesing/ProcessDumpCooler.java b/src/multiProcesing/ProcessDumpCooler.java index 8ea5e29..7486050 100644 --- a/src/multiProcesing/ProcessDumpCooler.java +++ b/src/multiProcesing/ProcessDumpCooler.java @@ -111,19 +111,19 @@ public void go(String coolTools, String cooler, SIPIntra sip, String coolFile) t public void go(String cooler, SIPInter sipInter, String coolFile) throws InterruptedException, IOException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); HashMap chrSize = sipInter.getChrSizeHashMap(); - Object [] chrName = chrSize.keySet().toArray(); + ArrayList chrName = sipInter.getChrList(); - if (chrName.length < 2){ + if (chrName.size() < 2){ System.out.println("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); BufferedWriter writer = new BufferedWriter(new FileWriter(new File(sipInter.getOutputDir()+File.separator+"log.txt"))); writer.write("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); writer.close(); System.exit(1); } - for(int i = 0; i < chrName.length;++i){ - String chr1 = chrName[i].toString(); - for(int j = i+1; j < chrName.length;++j){ - String chr2 = chrName[j].toString(); + for(int i = 0; i < chrName.size();++i){ + String chr1 = chrName.get(i); + for(int j = i+1; j < chrName.size();++j){ + String chr2 = chrName.get(j); int size1 = chrSize.get(chr1); int size2 = chrSize.get(chr2); System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); diff --git a/src/multiProcesing/ProcessDumpHic.java b/src/multiProcesing/ProcessDumpHic.java index 490e80b..16e4b95 100644 --- a/src/multiProcesing/ProcessDumpHic.java +++ b/src/multiProcesing/ProcessDumpHic.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.concurrent.Executors; @@ -83,19 +84,18 @@ public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJu public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String normJuiceBox) throws InterruptedException, IOException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); HashMap chrSize = sipInter.getChrSizeHashMap(); - Object [] chrName = chrSize.keySet().toArray(); - - if (chrName.length < 2){ + ArrayList chrName = sipInter.getChrList(); + if (chrName.size() < 2){ System.out.println("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); BufferedWriter writer = new BufferedWriter(new FileWriter(new File(sipInter.getOutputDir()+File.separator+"log.txt"))); writer.write("Error: !!! only one chromosome in"+ sipInter.getChrSizeFile() +", you need at least 2 chromosome in your file.\n"); writer.close(); System.exit(1); } - for(int i = 0; i < chrName.length;++i){ - String chr1 = chrName[i].toString(); - for(int j = i+1; j < chrName.length;++j){ - String chr2 = chrName[j].toString(); + for(int i = 0; i < chrName.size();++i){ + String chr1 = chrName.get(i); + for(int j = i+1; j < chrName.size();++j){ + String chr2 = chrName.get(j); int size1 = chrSize.get(chr1); int size2 = chrSize.get(chr2); System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/multiProcesing/RunnableDetectInterLoops.java index 93f5ffc..e5e18b9 100644 --- a/src/multiProcesing/RunnableDetectInterLoops.java +++ b/src/multiProcesing/RunnableDetectInterLoops.java @@ -59,7 +59,7 @@ public void run() { try { File folder = new File(dir); File[] listOfFiles = folder.listFiles(); - System.out.println(dir); + System.out.println(dir+" "+listOfFiles.length); if (listOfFiles.length == 0) System.out.println("!!!!!!!!!! dumped directory of chromosome"+this._chr1+"_"+_chr2+"empty"); else{ File file = new File(this._resuFile); diff --git a/src/process/Cool.java b/src/process/Cool.java index 4262d21..9b93e44 100644 --- a/src/process/Cool.java +++ b/src/process/Cool.java @@ -1,6 +1,7 @@ package process; +import cli.CLIOptionCool; import cli.CLIOptionHiC; import gui.GuiAnalysis; import multiProcesing.ProcessDumpCooler; @@ -62,7 +63,7 @@ public class Cool { */ public Cool(String args []){ _isGui = false; - CLIOptionHiC cli = new CLIOptionHiC(args); + CLIOptionCool cli = new CLIOptionCool(args); _cmd = cli.getCommandLine(); _input = _cmd.getOptionValue("input"); _output = _cmd.getOptionValue("output"); @@ -111,7 +112,7 @@ public void run() throws IOException, InterruptedException { /* common required parameters*/ _cooler = _cmd.getOptionValue("cooler"); - _coolTool = _cmd.getOptionValue("coolTool"); + _coolTool = _cmd.getOptionValue("cooltools"); _interOrIntra = _cmd.getOptionValue("lt"); _chrSizeFile = _cmd.getOptionValue("chrSize"); /* common optional parameters */ @@ -159,7 +160,7 @@ private String runIntra() throws IOException, InterruptedException { "input: "+_input+"\n" + "output: "+_output+"\n"+ "cooler: "+ _cooler +"\n"+ - "coolTool: "+ _coolTool +"\n" + + "cooltools: "+ _coolTool +"\n" + "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipIntra.getGauss()+"\n"+ "min: "+this._sipIntra.getMin()+"\n"+ @@ -263,20 +264,17 @@ private void setSipIntraCLI() throws IOException { * */ private void setSipIntraGUI(){ - _sipIntra = new SIPIntra(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getMin(), _guiAnalysis.getMax(), _guiAnalysis.getResolution(), _guiAnalysis.getSaturatedPixel(), _guiAnalysis.getThresholdMaxima(), _guiAnalysis.getDiagSize(), _guiAnalysis.getMatrixSize(), _nbZero, _guiAnalysis.getFactorChoice(), _guiAnalysis.getFDR(), _guiAnalysis.isDroso(),_delImages, _cpu); - - } /** * * */ - private void setSipInter() throws IOException { + private void setSipInter(){ if(_isGui){ _sipInter = new SIPInter(_output, _chrSizeFile, _guiAnalysis.getGaussian(), _guiAnalysis.getResolution(), @@ -285,7 +283,7 @@ private void setSipInter() throws IOException { }else{ double gauss = 1; int matrixSize = 500; - double thresholdMax = 0.01; + double thresholdMax = 10; double fdr = 0.025; int resolution = 100000; if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); diff --git a/src/process/ParametersCheck.java b/src/process/ParametersCheck.java index 8c8ff72..e4b331b 100644 --- a/src/process/ParametersCheck.java +++ b/src/process/ParametersCheck.java @@ -32,8 +32,8 @@ public ParametersCheck(String input, String chrSizeFile, String interOrIntra, Bu File file = new File(input); if(processed && !file.isDirectory()){ - System.out.println("\nFDirectory problem !!!!\n-i "+input+": need to be a directory with processed daata from SIP !!! \n\n"); - _logwWriter.write("\nFDirectory problem !!!!\n-i "+input+": need to be a directory with processed daata from SIP !!! \n\n"); + System.out.println("\nDirectory problem !!!!\n-i "+input+": need to be a directory with processed data from SIP !!! \n\n"); + _logwWriter.write("\nDirectory problem !!!!\n-i "+input+": need to be a directory with processed data from SIP !!! \n\n"); _logwWriter.close(); CLIHelper.getHelperInfos(); } diff --git a/src/sip/SIPObject.java b/src/sip/SIPObject.java index 5ca0df6..5dc7b5c 100644 --- a/src/sip/SIPObject.java +++ b/src/sip/SIPObject.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; /** @@ -46,6 +47,8 @@ public class SIPObject { private HashMap _chrSizeHashMap = new HashMap(); /** */ private String _chrSizeFile; + /** */ + private ArrayList _listChr = new ArrayList<>(); private int _cpu; /** @@ -276,6 +279,12 @@ public SIPObject(){ */ public HashMap getChrSizeHashMap(){return this._chrSizeHashMap;} + /** + * getter of chrSize hashMap + * @return hashMap chr name => chr size + */ + public ArrayList getChrList(){return this._listChr;} + /** * getter of chrSize hashMap @@ -299,6 +308,7 @@ public void setChrSize(String chrSizeFile) { String[] parts = line.split("\\t"); String chr = parts[0]; int size = Integer.parseInt(parts[1]); + _listChr.add(chr); _chrSizeHashMap.put(chr, size); sb.append(System.lineSeparator()); line = br.readLine(); diff --git a/src/sipMain/Hic_main.java b/src/sipMain/Hic_main.java index 1b6516e..91b46bc 100644 --- a/src/sipMain/Hic_main.java +++ b/src/sipMain/Hic_main.java @@ -42,28 +42,35 @@ public static void main(String[] args) throws IOException, InterruptedException }else if(args.length > 1) { String [] argsSubset = Arrays.copyOfRange(args, 1, args.length); if (args[0].equals("hic")) { - if(args[1].equals("-h") || args[1].equals("--help")) + if(args[1].equals("-h") || args[1].equals("--help")) { CLIHelper.CmdHelpHiC(); - HiC hic = new HiC(argsSubset); - hic.run(); + }else if(args.length > 2){ + HiC hic = new HiC(argsSubset); + hic.run(); + }else{ + CLIHelper.CmdHelpHiC(); + } }else if (args[0].equals("processed")) { - if(args[1].equals("-h") || args[1].equals("--help")) + if(args[1].equals("-h") || args[1].equals("--help")) { CLIHelper.CmdHelpProcessed(); - - Processed processed = new Processed(argsSubset); - processed.run(); - + }else if(args.length > 2){ + Processed processed = new Processed(argsSubset); + processed.run(); + }else{ + CLIHelper.CmdHelpProcessed(); + } }else if (args[0].equals("cool")) { - if(args[1].equals("-h") || args[1].equals("--help")) + if(args[1].equals("-h") || args[1].equals("--help")) { CLIHelper.CmdHelpCool(); - - Cool cool = new Cool(argsSubset); - cool.run(); - + }else if(args.length > 2){ + Cool cool = new Cool(argsSubset); + cool.run(); + }else{ + CLIHelper.CmdHelpCool(); + } }else CLIHelper.getHelperAllInfos(); - } /*GUI */ else{ diff --git a/src/test/TestCoolFormat.java b/src/test/TestCoolFormat.java index 02dd01b..c893d97 100644 --- a/src/test/TestCoolFormat.java +++ b/src/test/TestCoolFormat.java @@ -16,10 +16,10 @@ public class TestCoolFormat { public static void main(String[] args) throws IOException, InterruptedException { String chr = "chr21"; //String input = "/home/plop/Desktop/SIP/testCooler/GM12878_4DNFIXP4QG5B.mcool"; - String input = "/home/plop/Desktop/SIP/hicData/4DNFIFLDVASC_untreated.mcool"; + String input = "/home/plop/Desktop/SIP/hicData/4DNFIFLDVASC.mcool"; String output = "/home/plop/Desktop/CoolTest"; //String expectedFile = "/home/plop/Desktop/chr21Cooler/expected.txt"; - String chrSizeFile = "/home/plop/Desktop/SIP/hg38_small.size"; + String chrSizeFile = "/home/plop/Desktop/SIP/hg38.sizes"; String cooler = "/home/plop/anaconda3/bin/cooler"; String cooltools = "/home/plop/anaconda3/bin/cooltools"; @@ -34,11 +34,11 @@ public static void main(String[] args) throws IOException, InterruptedException //run(resolution,matrixSize,matrixSize/2,chr,output, cooler, 46709983); int diagSize = 3; - double gauss = 1.5; + double gauss = 1; double min = 2; double max = 2; - int nbZero = 8; - int thresholdMax = 2800; + int nbZero = 6; + double thresholdMax = 10; double saturatedPixel = 0.01; int factor = 1; double fdr =0.025; diff --git a/src/utils/FindMaxima.java b/src/utils/FindMaxima.java index 0096b0f..0894fee 100644 --- a/src/utils/FindMaxima.java +++ b/src/utils/FindMaxima.java @@ -158,11 +158,11 @@ public HashMap findLoopInter(String pathRaw){ float std = standardDeviation(x,y,avg); int nbOfZero = detectNbOfZero(x,y,1); if(nbOfZero <= this._nbZero ){//&& nbOfZero > 0){ // filter on the loop value and region value - System.out.print("loop "+nbOfZero+" ref "+_nbZero+" "+ipFilter.getf(x,y)+"\n"); + //System.out.print("loop "+nbOfZero+" ref "+_nbZero+" "+ipFilter.getf(x,y)+"\n"); DecayAnalysis da = new DecayAnalysis(raw,x,y); float n1 =da.getNeighbourhood1(); float n2 =da.getNeighbourhood2(); - if(n2>n1 && n1 > 0 && n2 > 0){ // filter on the neighborood for hic datatset + if(n2>n1 && n1 > 0 && n2 > 0){ // filter on the neighborood for hic datatset Loop maxima = new Loop(temp.get(j),x,y,this._chr,this._chr2,avg,std,ipRaw.getf(x, y)); maxima.setValueDiff(ipFilter.getf(x,y)); maxima.setNeigbhoord1(n1); diff --git a/src/utils/TupleFileToImage.java b/src/utils/TupleFileToImage.java index cf97133..eaebd38 100644 --- a/src/utils/TupleFileToImage.java +++ b/src/utils/TupleFileToImage.java @@ -166,8 +166,12 @@ public ImagePlus readTupleFileInter(){ line = br.readLine(); } br.close(); + img.setProcessor(pRaw); } catch (IOException e) { e.printStackTrace();} - img.setProcessor(pRaw); + catch(NumberFormatException ex){ + img = readTupleFileInterCool(); + } + return img; } @@ -209,8 +213,8 @@ public ImagePlus readTupleFileInterCool(){ line = br.readLine(); } br.close(); + img.setProcessor(pRaw); } catch (IOException e) { e.printStackTrace();} - img.setProcessor(pRaw); return img; } From 86e833bde412f33ac0f0f716c5aa21f330aaf1fe Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Thu, 8 Apr 2021 10:41:11 -0400 Subject: [PATCH 25/27] change of the project structure, chane in the pom.xml --- .classpath | 23 -- .gitignore | 4 +- .idea/compiler.xml | 2 +- .../Maven__sc_fiji_Auto_Threshold_1_17_2.xml | 13 - .project | 23 -- README.md | 12 +- SIP.iml | 72 +++++- bin/gui/GuiAnalysis$FileListener.class | Bin 1517 -> 0 bytes bin/gui/GuiAnalysis$QuitListener.class | Bin 783 -> 0 bytes bin/gui/GuiAnalysis$RBHicListener.class | Bin 2274 -> 0 bytes ...GuiAnalysis$RawDataDirectoryListener.class | Bin 1786 -> 0 bytes bin/gui/GuiAnalysis$StartListener.class | Bin 2414 -> 0 bytes .../GuiAnalysis$WorkDirectoryListener.class | Bin 1521 -> 0 bytes bin/gui/GuiAnalysis.class | Bin 16121 -> 0 bytes bin/gui/Progress.class | Bin 1390 -> 0 bytes bin/test/TestCallLoopsHicFile.class | Bin 4299 -> 0 bytes bin/test/TestCallLoopsProcessedFile.class | Bin 3811 -> 0 bytes bin/test/TestGui.class | Bin 5405 -> 0 bytes bin/utils/ChangeImageRes.class | Bin 1816 -> 0 bytes bin/utils/CoordinatesCorrection.class | Bin 3136 -> 0 bytes bin/utils/DecayAnalysis.class | Bin 1358 -> 0 bytes bin/utils/FindMaxima.class | Bin 9566 -> 0 bytes bin/utils/Loop.class | Bin 7193 -> 0 bytes bin/utils/PeakAnalysisScore.class | Bin 4052 -> 0 bytes bin/utils/Strip.class | Bin 2599 -> 0 bytes pom.xml | 234 +++++++++++++++-- src/loops/CallLoopsInter.java | 135 ---------- src/main/java/META-INF/MANIFEST.MF | 3 + src/{ => main/java/plop}/cli/CLIHelper.java | 2 +- .../java/plop}/cli/CLIOptionCool.java | 2 +- .../java/plop}/cli/CLIOptionHiC.java | 2 +- .../java/plop}/cli/CLIOptionProcessed.java | 10 +- .../plop}/dumpProcessing/CoolerDumpInter.java | 8 +- .../plop}/dumpProcessing/CoolerDumpIntra.java | 2 +- .../plop}/dumpProcessing/CoolerExpected.java | 2 +- .../plop}/dumpProcessing/HicDumpInter.java | 2 +- .../plop}/dumpProcessing/HicDumpIntra.java | 2 +- src/{ => main/java/plop}/gui/GuiAnalysis.java | 18 +- src/{ => main/java/plop}/gui/Progress.java | 4 +- src/{ => main/java/plop}/loops/CallLoops.java | 18 +- src/main/java/plop/loops/CallLoopsInter.java | 241 ++++++++++++++++++ .../java/plop}/loops/FilterLoops.java | 24 +- src/{ => main/java/plop}/loops/Loop.java | 20 +- .../multiProcessing}/ProcessDetectLoops.java | 31 ++- .../multiProcessing}/ProcessDumpCooler.java | 20 +- .../plop/multiProcessing}/ProcessDumpHic.java | 24 +- .../RunnableDetectInterLoops.java | 22 +- .../RunnableDetectIntraLoops.java | 15 +- .../RunnableDumpCoolerInter.java | 6 +- .../RunnableDumpCoolerIntra.java | 6 +- .../RunnableDumpHicInter.java | 9 +- .../RunnableDumpHicIntra.java | 4 +- src/{ => main/java/plop}/process/Cool.java | 19 +- src/{ => main/java/plop}/process/HiC.java | 20 +- .../java/plop}/process/ParametersCheck.java | 12 +- .../java/plop}/process/Processed.java | 18 +- src/{ => main/java/plop}/sip/SIPInter.java | 16 +- src/{ => main/java/plop}/sip/SIPIntra.java | 26 +- src/{ => main/java/plop}/sip/SIPObject.java | 11 +- .../java/plop}/sipMain/Hic_main.java | 45 ++-- .../java/plop}/test/TestCallLoopsHicFile.java | 12 +- .../test/TestCallLoopsProcessedFile.java | 14 +- .../java/plop}/test/TestCoolFormat.java | 15 +- src/{ => main/java/plop}/test/TestGui.java | 14 +- src/{ => main/java/plop}/test/TestInter.java | 30 ++- .../java/plop}/test/TestMergeLoops.java | 4 +- .../plop}/utils/CoordinatesCorrection.java | 14 +- .../java/plop}/utils/DecayAnalysis.java | 2 +- src/{ => main/java/plop}/utils/FDR.java | 8 +- .../java/plop}/utils/FindMaxima.java | 26 +- .../plop}/utils/ImageProcessingMethod.java | 4 +- .../java/plop}/utils/MultiResProcess.java | 24 +- .../java/plop}/utils/PeakAnalysisScore.java | 14 +- .../java/plop}/utils/TupleFileToImage.java | 26 +- src/main/resources/META-INF/MANIFEST.MF | 3 - 75 files changed, 849 insertions(+), 543 deletions(-) delete mode 100644 .classpath delete mode 100644 .idea/libraries/Maven__sc_fiji_Auto_Threshold_1_17_2.xml delete mode 100644 .project delete mode 100644 bin/gui/GuiAnalysis$FileListener.class delete mode 100644 bin/gui/GuiAnalysis$QuitListener.class delete mode 100644 bin/gui/GuiAnalysis$RBHicListener.class delete mode 100644 bin/gui/GuiAnalysis$RawDataDirectoryListener.class delete mode 100644 bin/gui/GuiAnalysis$StartListener.class delete mode 100644 bin/gui/GuiAnalysis$WorkDirectoryListener.class delete mode 100644 bin/gui/GuiAnalysis.class delete mode 100644 bin/gui/Progress.class delete mode 100644 bin/test/TestCallLoopsHicFile.class delete mode 100644 bin/test/TestCallLoopsProcessedFile.class delete mode 100644 bin/test/TestGui.class delete mode 100644 bin/utils/ChangeImageRes.class delete mode 100644 bin/utils/CoordinatesCorrection.class delete mode 100644 bin/utils/DecayAnalysis.class delete mode 100644 bin/utils/FindMaxima.class delete mode 100644 bin/utils/Loop.class delete mode 100644 bin/utils/PeakAnalysisScore.class delete mode 100644 bin/utils/Strip.class delete mode 100644 src/loops/CallLoopsInter.java create mode 100644 src/main/java/META-INF/MANIFEST.MF rename src/{ => main/java/plop}/cli/CLIHelper.java (99%) rename src/{ => main/java/plop}/cli/CLIOptionCool.java (99%) rename src/{ => main/java/plop}/cli/CLIOptionHiC.java (99%) rename src/{ => main/java/plop}/cli/CLIOptionProcessed.java (93%) rename src/{ => main/java/plop}/dumpProcessing/CoolerDumpInter.java (94%) rename src/{ => main/java/plop}/dumpProcessing/CoolerDumpIntra.java (99%) rename src/{ => main/java/plop}/dumpProcessing/CoolerExpected.java (99%) rename src/{ => main/java/plop}/dumpProcessing/HicDumpInter.java (99%) rename src/{ => main/java/plop}/dumpProcessing/HicDumpIntra.java (99%) rename src/{ => main/java/plop}/gui/GuiAnalysis.java (98%) rename src/{ => main/java/plop}/gui/Progress.java (90%) rename src/{ => main/java/plop}/loops/CallLoops.java (91%) create mode 100644 src/main/java/plop/loops/CallLoopsInter.java rename src/{ => main/java/plop}/loops/FilterLoops.java (91%) rename src/{ => main/java/plop}/loops/Loop.java (95%) rename src/{multiProcesing => main/java/plop/multiProcessing}/ProcessDetectLoops.java (80%) rename src/{multiProcesing => main/java/plop/multiProcessing}/ProcessDumpCooler.java (92%) rename src/{multiProcesing => main/java/plop/multiProcessing}/ProcessDumpHic.java (88%) rename src/{multiProcesing => main/java/plop/multiProcessing}/RunnableDetectInterLoops.java (80%) rename src/{multiProcesing => main/java/plop/multiProcessing}/RunnableDetectIntraLoops.java (89%) rename src/{multiProcesing => main/java/plop/multiProcessing}/RunnableDumpCoolerInter.java (97%) rename src/{multiProcesing => main/java/plop/multiProcessing}/RunnableDumpCoolerIntra.java (97%) rename src/{multiProcesing => main/java/plop/multiProcessing}/RunnableDumpHicInter.java (94%) rename src/{multiProcesing => main/java/plop/multiProcessing}/RunnableDumpHicIntra.java (98%) rename src/{ => main/java/plop}/process/Cool.java (96%) rename src/{ => main/java/plop}/process/HiC.java (96%) rename src/{ => main/java/plop}/process/ParametersCheck.java (97%) rename src/{ => main/java/plop}/process/Processed.java (96%) rename src/{ => main/java/plop}/sip/SIPInter.java (89%) rename src/{ => main/java/plop}/sip/SIPIntra.java (94%) rename src/{ => main/java/plop}/sip/SIPObject.java (96%) rename src/{ => main/java/plop}/sipMain/Hic_main.java (67%) rename src/{ => main/java/plop}/test/TestCallLoopsHicFile.java (96%) rename src/{ => main/java/plop}/test/TestCallLoopsProcessedFile.java (87%) rename src/{ => main/java/plop}/test/TestCoolFormat.java (84%) rename src/{ => main/java/plop}/test/TestGui.java (90%) rename src/{ => main/java/plop}/test/TestInter.java (56%) rename src/{ => main/java/plop}/test/TestMergeLoops.java (99%) rename src/{ => main/java/plop}/utils/CoordinatesCorrection.java (89%) rename src/{ => main/java/plop}/utils/DecayAnalysis.java (99%) rename src/{ => main/java/plop}/utils/FDR.java (93%) rename src/{ => main/java/plop}/utils/FindMaxima.java (93%) rename src/{ => main/java/plop}/utils/ImageProcessingMethod.java (97%) rename src/{ => main/java/plop}/utils/MultiResProcess.java (92%) rename src/{ => main/java/plop}/utils/PeakAnalysisScore.java (91%) rename src/{ => main/java/plop}/utils/TupleFileToImage.java (90%) delete mode 100644 src/main/resources/META-INF/MANIFEST.MF diff --git a/.classpath b/.classpath deleted file mode 100644 index 5d379b9..0000000 --- a/.classpath +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.gitignore b/.gitignore index f080823..2d7a953 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /bin/ -/test/ -/utils/ +/java.plop.test/ +/java.plop.utils/ .idea .project .directory diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 32c94bd..3cbc689 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -10,7 +10,7 @@ - + \ No newline at end of file diff --git a/.idea/libraries/Maven__sc_fiji_Auto_Threshold_1_17_2.xml b/.idea/libraries/Maven__sc_fiji_Auto_Threshold_1_17_2.xml deleted file mode 100644 index abc07ab..0000000 --- a/.idea/libraries/Maven__sc_fiji_Auto_Threshold_1_17_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.project b/.project deleted file mode 100644 index fd2402b..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - SIP - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - diff --git a/README.md b/README.md index 4ae64f5..9803c3a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ +WARNING: We just noticed that the newest version of Juicer Tools (v1.22) interacts with SIPMeta in weird ways. Please use Juicer Tools v1.13 instead. + # SIP # What is SIP? -SIP (Significant Interaction Peak caller) is a tool to identify and analyze loops that appear as high intensity +SIP (Significant Interaction Peak caller) is a tool to identify and analyze java.plop.loops that appear as high intensity signal in Hi-C maps. This program is written in java and can be run on Linux, Windows, or MAC systems and includes either command line options or a graphical user interface. @@ -16,13 +18,13 @@ Follow the links below to get started: * [View the Paper](https://genome.cshlp.org/content/early/2020/03/03/gr.257832.119.long) -Rowley MJ, Poulet A, Nichols MH, Bixler BJ, Sanborn AL, Brouhard EA, Hermetz K, Linsenbaum H, Csankovszki G, Lieberman Aiden E, Corces G. Analysis of Hi-C data using SIP effectively identifies loops in organisms from C. elegans to mammals. Genome Research 2020. +Rowley MJ, Poulet A, Nichols MH, Bixler BJ, Sanborn AL, Brouhard EA, Hermetz K, Linsenbaum H, Csankovszki G, Lieberman Aiden E, Corces G. Analysis of Hi-C data using SIP effectively identifies java.plop.loops in organisms from C. elegans to mammals. Genome Research 2020. ## SIP help menu: SIP_HiC run with java 8. -SIP is implemented in java and includes achoice between command line options or a graphical user interface (gui) allowing for more general use. This method is intended as an alternative loop caller especially for difficult to identify loops and works in conjunction with juicebox .hic files. +SIP is implemented in java and includes achoice between command line options or a graphical user interface (java.plop.gui) allowing for more general use. This method is intended as an alternative loop caller especially for difficult to identify java.plop.loops and works in conjunction with juicebox .hic files. #### Usage @@ -49,12 +51,12 @@ SIP is implemented in java and includes achoice between command line options or * **-max**: Maximum filter: increases the region of high intensity (default 2) * **-min**: Minimum filter: removes the isolated high value (default 2) * **-sat**: % of staturated pixel: enhances the contrast in the image (default 0.01) - * **-t**: Threshold for loops detection (default 2800 for hic) + * **-t**: Threshold for java.plop.loops detection (default 2800 for hic) * **-nbZero**: number of zeros: number of pixels equal to zero that are allowed in the 24 pixels surrounding the detected maxima (default 6) * **-norm**: (default KR) * **-del**: true or false, whether not to delete tif files used for loop detection (default true) * **-fdr**: Empirical FDR value for filtering based on random sites (default 0.01) - * **-isDroso**: default false, if true apply extra filter to help detect loops similar to those found in D. mel cells + * **-isDroso**: default false, if true apply extra filter to help detect java.plop.loops similar to those found in D. mel cells * -h or --help print help #### Command line eg: diff --git a/SIP.iml b/SIP.iml index 08d1edd..61d8733 100644 --- a/SIP.iml +++ b/SIP.iml @@ -13,14 +13,82 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bin/gui/GuiAnalysis$FileListener.class b/bin/gui/GuiAnalysis$FileListener.class deleted file mode 100644 index e9272c667b08133449857c4ad2aa489037d5a53d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1517 zcmZ`(+j84f6kR9Bv52ka<~B`BlL8GOJEm%&+?)~!YEx32IN)I5iBas6L_v`?BS)JXqG*m$lbkXK(%R@3-FrxQR~;3<+G>Nj>{+ z>MaMZ|3&P@b1R;&>Rz0vKt%>}0^@t`eb@HgV8?E3?WuNRATKbJS>40LR`*qq*vsw2 z3xlIXf!t?%$+p0BUB^AJ<3o@6_cqmoWW`f{XHg)Z?6TYqfrkT(vU3_F1X!XxSFatpa9n)xazX z9ZTw@Q5;4lp24#Mr5%-QM5?2<$+y#Uu?uUpd;;9FE*5YN&l{K{))`4nynq)4Mq-tm zAUu&@ZW$=^(oWr(9tdYQ3}Y1)U|~W(swQ5-b+RCy_BWN!!QcR_QGVV6$+59(xM5-e zFSD-h!Hw9lz?3yeJPZ<-eMRJM;iidK@tVMByc-@i4pea4bNz5f;NpOYPPl&%2AO!P zI_V7)Z=$AKR!NVC>S#`!+@nffXln~=+`^K9w*<^g>%QH@+jvL7Ai%o2&&2abiP_XQ zlZeBcCBJLJ(V@E5@>U%BX`(jVWVe7jxNBgA-JR0zc-~FChgFuKUfL#bq2JM91wFvU z-T-CO!R{}@8l(AdaHWgqzJvAYBUIL^vWxkuc64EP@ygQ7mzb?~ z@p>1FwOsFIxi-vz(xu@pZtF+Bi%X7V;v3RFJKZI_y9T7sMd#k8%C2g`7Qeg YjsZ(Be3OPDe1sPN3j`8ezK?Wyz+=spGV|8(Xlp985aC&W!DmoHi5R1o*D+jh`=z0TyS^-E=C!+-)P%Ew*(vvG1NjG zs~35{qtZ9B6Dfvzm~>^-mZ`S!d9rM|FiZ`$yCMT|=EXEMSxos#rSFoouX+sAe)vxz zHmoRXjkb#kOgWe&LIXkwOk3VgPiG&JOu2Z7IR~>>^xod5J@f_Uu|UJCPuh_2x2zP^ z-&Be|w8j6iU~spSJngDy+UnqKUTk~Sl4lTGF>SjQ$t+W(hPeC&Fhi4#wdV2(ZZ^M>vvPv^=c4d7ofRqsKfoRG#|pR_*}D|cCEO!O z3wR&n=YY@2+NPrU1@*6Zz`tYW0&T=Lvks5*lcdbtyxl HVHx-Z9ki|x diff --git a/bin/gui/GuiAnalysis$RBHicListener.class b/bin/gui/GuiAnalysis$RBHicListener.class deleted file mode 100644 index c21b327e3d56a3585b1f689e83691340f1ca3639..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2274 zcmah}O;B4^6#i~5kPt3~#ui(pLMgOKfc)`KX!!{QXhVyDw8hr;k-WmAA*sm=KmJu~ zYu%{hlJ2!LuGF!}=-8#sxRbqm_b!>~cAg?sUz{omT{`urX9cw1j#&vplb+W|aB3%HW73qe^^MNojJO zGnPm#40U_M73YCObK^QyigC?JHFYPMT2^Cp(iu506C*M!LD#GuwRppdQ>185CIsqG z&tTKiV_Il&eA2kXob+!HIDP-j>I2HSwZpn20Uh6IK&Qb-f= zw;r0NDJ7;QhcddJOa$#1#kdt?3@3`xV)7BVh)WC=l#gjOPR%cCUgDg~7Is45vaDgb zQNv+HS8SjA zR%|4u=`uSq>_-CkWoj$5^kgb2pOs9S6AGEKkJ@;#47D$N&kU8*x)QxRq1?+25c_m8 zlZvWgO^%rA(ZVG4NP!GuJVApr6jvx94VucL`HFf_i_otW78=SlxPaoy?@v4*uqfBCc;l~ zJIf#0!0bW%SMp~AjyLnT%Y=I!(|LQpI*&bs`M3Z4(572r?-UM;{l z!Ce&u_p9io&>tTxNcIGW?1}H-CRhhMuSX3(jRxKT4?lxm-iR=7!W2J?oBSM>xDzYf zg$LY?FL^Vb@D_Z_Tk#|J;5Y8aA3T6<-iE(;f*^cpYPmt4bvuhC`#gGjg>2wM_QgXIYgU|5_!A ze2*!;iE#^W9Y)n)V`BnW1d>izgJD=_BiuFsCT+ZpcL>0cr~*-{=5=r|_rfsQJHS5$6=8Hza;DX4g64r3}Baj=7;803kSNR>XFS3C9bOs@Eqprq^U z&K^8_7mW|%ne$l6ysN@cbBz0sdkitir$O>-<_hyxaD{m(fUYj{s_@iAy^RxGJ9xUo zbAtcg%BVWhz!SaT z3}ZCKy8%WuSkB^HJ=Q3+GcUQnFf8QnyXkgma^v50GBYpN0}<*k7$=a5%kaK zmrrqC{(_AB6=U)@jLYAVmw%uj|HMuC7w*ZwfrJn)F%bw$0)YULga84Iy|bO&3A@wFOmA+8 ziWj`T`2^*gWm)B$rNopE{s15RF+N#ZWqEpLw{|z7v}$)|&e!Lh?sLv}PXG4LFTVol z!4F(uC>KtvZ|xt_dIDx{@9Dbjh#kQ`Hv$WIC1HF6nj zG-qLGTf1F-9_Y|K45vkeVUA0GR`~^)AKv_EIEXHC;0D8mqFxGfJZ<7RY@xgE=*J9t#6oW! zdOQw_>C!D#vNLYR_LR1roKk_bg{?}uSki?1L@4Dib=f*6ZC@@NhGE}VegY@)dJO#xJL|%~S~NTy7oM~*fI(tlkW&knDZ?Tw&$%M6 zvJ8VYMN6qdQF*3VQ6X!HUW=5|H5yg)l!enKHyhmGg6o**hb)|}i@rCGa}0-{8~w$S z>qvhltrlmrQu*NUobc_U&^hC2#KL)8s3FD)hQ9wL#t89IXe~3f47q3+a*0SQMvESa`b@>@{H8f>USTZ&0fAY^`da0dp4IS}>&OJq!6- z``(^7JcctwG9qQZm=kHKU5BVAeCl-R+Zm~epfY2-9{se;5=Pvd%`2g)V!kMlR$w+P zTDT9NvOxWIC7mjk!hRV|Kw~}zlD33%B23@4lBeAQoqGX`3<RX%8U->2XQ=PNKH};dEv;j)vTQwzi#@C+RY8@pj4E;ODESV?6j(y zL;NpM5C;NdVIq0Y!uxnsC1CH7u=;Dp*T8ht3Ljed$PD0E#tn+J8$(kxB*O{Fu=~H} zBSSM?IL^JxqF5fti3wHm9XUeXP9y1j^=6_TnHLP!s7Du5DldY-u+o@U?&sAse$kWn&@eflp>kayQTBsGc)KdqtRkFJAXp+DqdQ_D=Rqg6ni82P(|KKa&i?tk^BTL zEO|6}jIZLvckE@ewt_dFpe@omQ=^qCYvIpmZFmKv$*~n&d5Ui%M#x)LI&2_xIhngaFl0ooTt&xXEDWdxW!%E;aSY^dw9(A z_?{Q=JNNJhS8NBr&vtR2?dC<+#x)z{^XxQVU}t%W4f7>-fiJUh{(#-!535yYH!D@A quaEJVs{IL_!9u*JY5(8&v1wP+W~%$Agf-wZd`|BK=@9Sn1@JGH-*3XlX zx$>j(Tr+Y5eY5eWhl&dBgSHXjWjj@ZN5*A&{vAE!78s4;0z>O6TG6Vdo)B^?-7>_h#l6I- zbtZ>1IA`N5bM4d2!FgN|=nGY}m*KtmV#7vWV8j46JO|7}LF!16?t;lG@aQ)K3 z9KIq~*=(vX%uiht7(bvr6V-RsT~#lrpz>PGKaT|)x2VuN`tN!;xQ#o6NzIK-;8;hM zZj`3E`_m>&I!xg7-Z6JiTH1d`iLL_{IQ1^Pu07K3*D8v&-;iERl|+@(q+{RAP9kSF z4&vNSZv+luJ(A65i*l!#`)Qr9IiY0?l<)n`XkJQ;?H(|7E^s|Dvc-WH!; zh`~WK<-DDG`1B!1YkzWA^(2;DY5Wg3rPnz8TjFzs?<{>_eT}1BJ7&$OAq?}&f;isE z@Gs-Dv^^;O4k!BtC)ybO3uBL8qkskKVjPX84K1gxNrTM zpq)(-bGFFgbhda2>RWJRGM&duyY-57%bsBoG Oiii9f=>(g(0lWnPcz%8W diff --git a/bin/gui/GuiAnalysis.class b/bin/gui/GuiAnalysis.class deleted file mode 100644 index f77e333ebc3cbcedc093797cd45919506afb18a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16121 zcmb7L349aP)<0*mHkqbLi)7^?1#T!x#ym_|8vhh_uO;O zoQ%8veB^N=8Z3DnBr)aGHiia_Zw!r&1j38rp}2#rOu2Ic^8*V9#217jwF4%Oiv{X~ zOx}1f77Bzbg0Xlg8acb9n29GcWfw&w@kAh!s0f4`gEoj3|1pzmR&_Lz2!tZR7*mHy zLgawJg2VufSGgm^m^oGFL}PP{Ll|?6GA1?cn8rjR8c7Z+3oIxOBmyd;s4g}wbRkr7 z&zh5%o$7VY#FqybCdP$=;Tnig2Bs!bdMSxc=rAo2h$WaDAkS(Hf%49(8Xt=`Hk3pf z8WZJ<8ZcRx4DqUV${5H8Fjh4oRL#^iW7Nd5Kusu`S_vjDsw#;W$D;8lQ>VRFiR+XW2#|IkY@lXIyVKU4SN>PD@OnHJgHc}UeR0oBd!~$_>11Cw$ zo>DbE7=zJrl}2xSCG873V zMlo6P`&5VrXUOz78V#S02NRQ`)d69VvS1kPd?=2+&sQa@2co_K+Y(7AvU4Wk#7t?d zuL{P>165(HE>{Q$R|IhS&`&b0fmki}I?qHyXn{k`|sfXo^_oRIDbcb*4SCu->y|k}2Cs)1axoP?udQ;xEDJX@v?V!}G?mpIgdH%F#p#5`f_fOa0uX?D?Eb)u+D z9jTLp<}r2Fj@6!NCt(jPSgDH|Xo{F&zD%8|i-X|J$7G<|j<=I8#91tf`;{o*q6I4M z?=p3zW1X~^DXXFFaIS&N~Yt575;&v zH?c8P9gO*vh#*E?Ba@%91+`M99@NQ6*TXDRrcN0vc>k2Cr;vOjlXPa8;M^qB34*g0 zoQfjBxml(Y1?N^Al!_w%w6n^}1^afHdWrRJU^+fyy~Y^fpnt)?#31!RsZQ>q^>ml; zue){rHMMFEJP>C>OmmM+CsA)f-78bRN^Oy;k4oJqQ-Mm|FH>KYdO)UrD)pdDC#zJm zO#M~rA(;lK)FUztq(MURqcRmzZznwt`^8dmte{Zr(N3Y^lOiM-Bf@l5#iwODMeN`+ zneZV(^m8%|7SH|z1E>+lp9sxX+&?a!zaY~PI#y6G$~06c@iLqQM`so`+Ajjit1|5o zN6?9YQXWc#mGJYrOmEPe*bp$)AZyDnDN!TPTQa>(??4wkLsSl3s0I^jKGYQg_sR60 zc&?35V-}SnM9oHY&!PkLfrH-1U7&238mGe1m`oqiM~J4AO2$tppEbU0bS0Lgjb#{v zIK%X@Ob6)`9Cpktxta@{94YP|cV??WDk>Xk)@fU(pEr84s@&|EY zSaiWT!BA~o0!LUnuUI_$MW$crkos&w`dNv1_Pb1f2wZkGF1Y$g5-Oe?mYD=fPCg0M zB1fJx(9_~&Gq`->CghVs*pMpPpqa_~Uy zju(gOgAtJ~yLbQ>iWu@H?o%Et^AH}2g9Bt~EI2zDiv?@c1FTI9QfS5Y!*KXVhmjT} z8skC;bePVA#Xq@DMh?Gm>ydE77>e2==kVvpu`al9%pU;} z_XpyBtVYRM#B;GEBr4rX>Tv}9$@>`MGYuj_Ut2;eVma&t9C8@Tp#E6d4ER!c9TcsL zhHLzYs{Z=G!ccv{UjvI)i%r7lS;BC`#1aEI5tGG$#`?6dY8a`|$q0iv$dxmn)gqYo z@<(U;Dc;)P%H%d_{SBO;VE7PhNxGsz+Q-~ z8p{udqYEGbHb~S3{e^@5@y3`Eu$4s%xxxdY&}OKUkrDMQne7k7{WaoEMr3*6(A;3M zCvL3zKm&#&uzJ!n6_uV19@26iBxp+P=5(oc6re67m zOxD0q&*jB3|D7*E>WlL~S}}2(JgBUR2EqBbUIt{2Py+3xm`$%&^1V?_huh@2crh;# z`dtnOH|i(UDdCG9ybNBX7dQ?cmX@=WmkT*p!NZMmlwj2siYBJAVMSNudHH(L$+ud( zPwUmanvnyJ#-*4LU5q$TJ3d?R6HH~GcJ0(HQU1CQf#X=q>QFqm3Vx--e)o$4kKI( zYT9&T>TMWq>IZ;X5JnJI4db=jEYzDLa&pX4qnV|^fI89+LV`R`V`Z}$wYz}v*~(jS zdPznLWbB7PAoPka4qAxa6;kp$*fG9O*r{}9PfTkegI8>7eC0& z4sJq}RBn3BNSRysA(3YV8^VF=;OH>6ZCLVrYKEz9nECpxxxSNcE1Eg-swxAFW%U4jlxx%q%SDEdnq=;Xc(v1#n13_4t_Rc zjm6PMxUkI6GxB}6GPTM&!tBLJ1tGMp#NkwErGlZ%B}x%q@REg*X`x!w>Tn@|H4ceM zG*+Z!V&cksMdnv|4-6ZMw`C-Xp3|`m>~;0r$$^Gs0l_C`(bZAh;I&<7&>THY`35~T zVL)&ZS;v;7Y1GP`Qo&PlceOYtoL?28yo#b81@D1YYMsU%il@q3B9(dtTNH|`FSRg+ zLaMbbo1k$E0-G$GVQtDQlv1-12Ew(bU{JmiZ>6~WLUB>kvWMd01y|{dVwW>eEedKU z4rCf^41uaUr=o`O^%cjXO~RlwS(qkINt1)qS|Sg31Sv@up4RDI7oK3&!BF9HJsXh{UAMNv3_vMTNtSsS6z)rLEh;fei#m+bq6(w5sKF>LDlkfm`is({`l7U` zy(ldzFG`CNiqfK7qO>TBC@qR2Xa`dkol3)Cxzo^_2)jvWJ*~u*Ei`;mUv8#R+m-QS z1YfasBkVgLt6M-t;B{0HR7_*hb7B|9(Rj#Xyqle_%I*9j3WqMD+~W#bXhK0Nl~m@Q z*+P?>s8sEgDV=h)Q=xRuMQ1v6IKPQzq{&%nGN6vGRz?TaPOZ`jp)(iI`X-8iY^cnQ zwNRpo8qrx$nY*ZkE^4BS)hCxIPcGFCTcUQZP@XJ9C#lAAkWl<;WsVi-B|5kg?s=eo}%ClWs*zSVdmzwF70-tn}Pr9d>UMmo8 zQebJOy#>~0dbi*K+TTq7EhuQFPn+nAR{9FN@y(>Zjz=Ap7Ef8F6@NDT**nm;Wli)w z9=IwkUf0D)U&jdgT`OG_$W?9v{=poy0gi>so2CS}Y!qH`mh2-JprfVrk*-;-4PP zd?H3g@ONo5=O@WVm26CkwRzo&*uG+v3GWN=F;+K?w}ZEXejYIr5{x5j^dlRs&D;;8 zSG4kgO7BANF)ci(nNLwUVzH;%ye>tn)4&sQF;XwL(5S(3AYI$JI$!rwHUfewYwl!r^$6`@-~%RWwHsYO?c}} zc(UGp?$KU?{+u@_fjr)-q*YbFbMqWFo3f^j5>c%`SZsu{Y z;zq@aBa;Vzyvj+gS&eTKgxjcm!bg0P&s25YY|s@PQ(eI~ z==!r>SIz!R{%aj=ntQ_QGOD;KkEg0CZZfC{j;V^^L&Xfqj=#|GENCb;!gzk+Fg`k@ z--V}A)2f%>wB#;=Z?McBANSMapFIK|d;|U)Jzitka*bt80#U~L^No&wu3}H^MF&oX zJ=+dB_RuW)-t}O;#!7 zUxsLn8(wfUI-1-K+w-_eRdKsPMQ}`21Yf73k8ai5Q=?h^N`h~q z-J{l!WuIr{ej;MxgGUy17sgB?qbbQ-)WE~qcI<^z2aordL*u^?M+AbXM^?I;u z^p#ync-z!%aPSTAg1@+LVn?wI?q^&^YaS<5Q@0vSEzS_QCi>8dj5CCBK?SY7xC9zp z1A45_hz^;e!8M|FOK9c!l?4SYyl@JpYdpD`FG9N{*)B`Amx{KP7gu87Wy7r)QQ8GB z5LdMFQh*<%87+L}a2tqoyVx}B<$`Sodqo$!!oC`#(G9flis23r#2U0#1_qyW)rM~zeX(&EG8jTN* zCgB64N_<*08|ABc;9i0P)<0-Ct)WqL7d{hwfX2{cC`j!>De4WHfDddY($_%!PE$CG zO1UGI@d;GU1F3>fr*nBCitp#p`CLOYc^+NBmrxa7j&I+tquG2LK6l$fbNCT_;`SU} z#xK$m-bSMiT@HUB~XkUG)|sgSOb&ZKLlT3RVZ=>};5-6$=m z)zV73Nm@f|r1i8`dH{42-6HLzTcsE1cIg1Em%gVB(qX#8g73O4U1@{mIJ(Qyhwiov zqK%ef(BqL}Po;lb0`!cfk)E|&M$cKUqUSBQfWDnxuslG!Ezi=6mOb>6tOK5HetXRV?A)`fJyx`N)fuBQ*I z57LL$o%E6QdHSz)ALs*g(E2%jV*Q>zwK?dZ%|)NvI?@-m?)0Ut5cClG#x|P1wUy9! zwi%!=pdV~?^s}vjez7f}Uv10jknMW<&9;_)w`~EvjSkzM#P4`-Fxx(0$@UprY=1DL zj%&B)vBTb*o%T~W%RYi#_EON(INKg%k9`s6*q5@`ehvHV8$jR59qcW9jQs`fXy417 z><75B{RhxLb2s~8KF(q1?v74;yu;6aM?Uv(j0AlKpWqnJCpxBbFGmHRW zJKqJppC>v$=R@U2mLDpBGzvW=ouRI&S4%fPTT<7Y_Ay-eH z;~D~b7}vWda>O;0qpmsJ;EM4)*HX~SIpMmQ8(rIYzN?iNxSr;PuDzh&;fq`!^2M&t z`0uVme2Lq_i`{O%)ZHC)55C;php%uC;-&6kyv$v~SGvo1xqCWa<&J=!$1B_y@ip#i z_*(Y{Ug_S-*SVYcdiQ@o@8%oauk(%WeZ1QJ5#Qwgf!DbI;I*=i*U4RZjeH#6D);8w zdq3~W{tony{9^WDe#ztGmp#4s70)1k z)pHu}@k{}I7Qf-C(qzwKGV?|5zky^i1W+{ybTIi5eu>COMk83B3}f0;9Zzsi};U*|;lo16>z+ngo* zUCvFQ*YS@zckoX+oA~FPNBEbVr}@{M7x+-l0ni`vpE*DAVXq{S*CnyHJLn#g)jLG8 zc}GijZ;9ma&IBEhT;7o6_BKee_cAHld$r{8u99-RcZ1#}<$8BWdERHF4&GO#W4v!m z9lc+H{#NSZvq)WiInuGdPEt2tKhOiD<9(wgzi+bC!*{mS(-#6AmU{W-qlSEm)Z4dA z%J*F>_3^Ei3ViFOzP?RTKVOSW>V(20uU$|KauXT3$yiEy%f>Z{}M_^3A7>_`vv9viR21-}yGa zovgkVMEUi+fo#5)@X6gBpzOYbbSnRg?<9xs5S_qx@!jOi^-vCP$(CP@AZHrZSr$zD3T;y6LT|ynD#ne-}l=@4TDYMI}+~kRR z4dZQO>F9RDOUNg)hN;=M>SY_YJ7b!2fEB z|I`$Z-yjY6!$!Q<$)EB6k_V%g=3s2qMFpx*z(^DT`P>w;Lk~G$1Np)fvP};;R|EOd z6tZ0pQSWC}v9C-aO?t>o%`9J=LR$2Y3p9{#_*)Z;t2MAO4AUDOd*@} zkTMN~O(Cs%NR0*}NtWckoP^f~csJP#j>We-sS=s;ts7C524gk#m`43HL)#!EN#g%4 smn6I7KwC(5UW#`mC*GV^qRm1(A1yxH;;Yf(V>(`iRz|xREk17hKSBMNO8@`> diff --git a/bin/gui/Progress.class b/bin/gui/Progress.class deleted file mode 100644 index e3276f86d0173e0968e0f262f597633878cc37e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1390 zcmZ`(e^VP(6g{s5l7>e~(-J6!8q~JQVw)C0Z9{)Z5Czkc7McpE_yUh~nawV<`_gv& z6n+(F>@p)WegOaS6FHuj1f>J+AG`0~ci%ndo_pW^`S+2{FldH4 zijqhOWcSr;^|lnfas6g#WhqoGEs%+H=qj(S!^jQ%7t4zRVntx668Mo(zNss(t^1kR zK0+X|-B6*xc=f$x$2bcrEDH?GyS{543gil%u#%^UxMo5EmzRrmW~l_bI*mSLBqS~h z^c9NrGz2b5T*in%GSX(v{h0*&3(Gu`#Hhfi#XOm8q3wFRI!xgTQ#y{5Pa}t`HsyrC z$Qj@kB!_DfA0SVj>fk{8y8^e)3Oz-=hgMGEL&D{WXOn#_aUC}VQYPqDC~&z@JaxEi zt1CzpEwvP@TX&5|2?VAkKEW-4F*+CZo@#rh;sudjJtYzn~&l)%Q8B<|oYYh!FR z*y(IP*B-yG^?E>sdWEPrrc?=92Z67BQ?~MbN`U`sSsF9QoM-yaB+?kP<`)w8EU7es zo~XBOtKG8hvc&wqZZ^5+ekkz>k2}L;x+2t+>l;mJ6NSw#^#zFvI9(T-+HklGiPe

XP;ikLr*rFR?=vhUqYkZ?KZYa&Lx9??p;{iz+8b?GmndrT{0pvD(X2oF&sz4xXqB6jYG`7!<_RQ<|bl%Zohpo?%Qu7 z#seqDmv)`~D#q6iJx_k^;Me$`AqQZD=s9v3#SM&M8do^@<0#`Qr)Yv5pTruj;U`{X zjXa+5M83-w&$(ltJ*?veYq6_3Ub61<_zoMr>gE`2_Xdw3vYVOQA-?~Qf)xh@wrOQI O3_oISO5yi*GIADm8TIZMxGOa(!K8he+Xjl}zkD++1_ z)-N27XDrPy@;OUO7Wep2C$KFtkxgrnTq>K3?9UsTnvV>``*UheGa@k~Yi8xp(9C>4 zclgjC(Dte)j_3zQ3@x`~XWN9H@L`QW>#LqojkKws*UUC++VVr-H36){dODUWB@av( z16-5=64=tTf?J%ayrriiM^tm7N6mHm&?vB@MDSoXn=&Jlc|D;SBbFSr?P%N8)-f`f z$S2jd?d(sghIh~Zh!p;L_u3!8hs^?Iw;l8DdEorZhaa!KTfx?X*KLXW3`0HFt(#Q5 z8RdSoBBG#8pn9?Y$2B8>?bsopoK;hKt#3>QIo@1ijtmpGb;^rw3=pq36LD%XDG(~P z+CgP!^KdzCL5G4}i!eKI&a||208tQ3u56z04LLH1k$%F+BA7Ha-KpSKf%*j{9gOYI z>#3w>_^^kt*E6}i)#yhT_DQ7gU!q76m2yWcfP*;1LuxLkWvFv&sm_J1CDtyI$9NqP z5Plzy(m~W(3ihE}pxh4G{_He|y#k(0)=0D4Pf6oy-ZX9Xj!EGI#7$GI)S*j7+#%_u zXL$UCO*DDukU$`#C~ z%E*|il{Zu}uQ8`jYbnmsH-2k^8z-`4xgi9`BvJ~d3iw+b z(E!piL`qHuIh9e6rD=uiAlc(b2K!_~B$|+UO`9fenUa{-hULQ90A4Q_Jn5;VZYVfM z3QCZhG7mVo^J5x!OElagaCC(bI}u*Q#aJvBkHz^{vQ}hGXKZ+QxcRue_KgADi~HyX zQ?ugc;k?cuHE~VB{Y+=+e9F@Mjch_QnF|SJ*)wDLbS|b^svj35`7YqW0N#v;NZE0k ze`X~Gml)JpqE#V#I8$~FZ~`*FsdOeT6?==ohU+M%S*#s)b@Ah()a@ePE_Hi{zevNIzw z>99biS~4-ti3Kb(CKBk*n#blH_r$0z=_FfqnrdZ6hc!cju88g)IUkxAbh4M!RZ}_{ zL3#*O6sgfKnZXOj)P$8aiV4dG(E?Ct(v+s<26bjmF-#wg*%hI}v5s7j7?(-U)N@R~ z%Unz>=N5xTpt1Wp(VK@AuL~9q*#S+-=Yqhd>z!MOI*-;Zeg&M%6!Pc9nW^zMhvvyHMem zPx)E$e;vSYq(Q4wG-g1fbd{`;rv5H~-^=%?Cy~mU4A?5B0LfYDIwv7G3@#fb$r_y7 z>9fUNC&J21R<3Y~^u?8r)RUqqhqCSRK{=c>?bP8P$mWg2yv*=Q&ul)l&Z^kJcb?0B zWVzVmJDRP+afDyNuV?Ele3#fMgP*Nj25PX1ZNS;U?`n?9QGrVCs0E zgaL6e80rqz_XNY2v9>q(+Nir)d7<4?U30PB>uXnPv7y6Pi%lJV*#xS*?G@Gj|F%~K zZ-`daVoOK$9GZt_(Gsl**SIfZ+YEM|aJSb!f%Z9c4Fz}4VlU?o1P{w5&Zea}x{bZC zyEyET!>Z!2kG%%p3~qOh4$7gwI6N+gf#UEahat}lhMmoK%Arymj>w_6I8^1?>f+gi zT&*mu&On=iK8MUu%PexyP&hP$*FA!A`OTl0!}L%~YlE-B-w+6S8>&NCS56s~rr{5ZF2sec5+?;tET@`#M zWy)B(?N~mFCid4d{OcLljf~?BjNWF1umx+lwvG?rjo8Xj3%2p!cCzhew4sCG*o_@H zjGee0H)4=%(6NhemJSxyDBh1we1^P#61U^NRcNKK9BG z5cg2(2WUx^n8pV==SE1F_z*r!NUsqYJi?wA>%-VFfUnV(x}xrvsJnC96TIz7uC+j1qkDo1 zzOLXY`~NIkAp`*+1iLN;&HQG#*)M;nN%Prv(>2xj276_AT2fFPq7!@^r{^$BRLphH z;mXh)t`3pg-=4*HdL)Nt@x5MB=-H_IF?10}gzJg0JNSbcJRkLhJ+7TmZ`kABc^N-# zS6af}kYcm&=OzhZl%1we?j)wp z5H%x2$Xz%Bl~@|(O2Tf(q0yIPHU^G42H+2jfc!P6;g5_r(}5J( zGm-gM8v`Ab@i(Hz!}~Yk@0{~e${PH`#(>mN<}l~BOYBL%hf#Ko$2~em%bI#fO z?6dd&zP-Jw%p2;M0xx77O<)#eVHc}_ejG@3Uu;rqD zNsngqY&v>&@}e>22n3IrS<~qe@U^s#3i$hSDMN)1l^OyF3T#fAS!1v;J84)W`eeos z2q$w>dS+C&OgUd(^gGk0EwDTJ8g9gR#H?;+1-7=_pImik*s;uPIwoCEPs~jjdB@CU zZ3SV0T35@=MH6RB5(RYvyH>X+vW{U{g}h^=N;)BI71$n~&dnOpd?uHV#tnPM;lE7M zaAGKghK=RNO*`28FXorO;N9*Y2ffafzxO{=_ke=t6~79OnTg(GS^DLqX*(*KP^n@M z_A0ntpk}RyX~WX65Bmj_OM0eYoV_5^kZ3K-gA9afF=?n(!vVAr89kK}sBbA#^U#a6 zPK3}duxFhh8DLbmW^MC|VIOkl=$SxN!yPzGOf5rC^-WvD6iRLg>@PRIf`xaU8{jG3 zo*vNiF$H&WyIiuPJi&7#*n9m6`Fm1D2kw%*IVx~|9gAfFET6H?5%G9D5l`?}CM)GP z7N3}yXdRUYb!&*>m_W!joP^z9Fv+YI$|})=yA|}VVf*l9+c9P}+=JuHXRbiv*L(KK zt07X)p+kl~8w(-M085qA9M>IPRdEuh6!foPzIKm>1Wpsuyfl*`v)3TClFU&BNr7#v zgzyB%3uY!|SRo9u6wPeD;54f^gCUv4({gl9!!SlD)bn{GOCGeZlh|?wt+C5^SW!X^ z;SKbVamxcjn4rD1Ua)QVu=DbWHwrYi#Q&F}H_OsBv)rz`MLfsRlz=v?vv%j2CDUAU zhBQZJH?C#&&3;X@(o?3M_BMuaQJ~5)>|BQI%E?nQM9|iqf~B*noAc(Jk>M)yt2)zE zoX%xZoagC*x!UUJK?hi6HVAQ5nZRvu6EdThq{3Ap!U6R+_D~cAa)95O6sooAS-fVy6vyfHPwrMzY??h6EQ@GtKxU44y3DvVuBs zrnQvj0ez0fvXc{rMUQJmUh5+8DG#xU|DCgB&7WEb=)Cufz4&Fv+t#Z2|7 zX-g7^;gyy9O1I%Dwn>0%Zb=aX&X*@RBkwyl!sKhBz_e^#dx2ffuUujW%6uq!d8{n6 zE8V$=R=UfSmmMxw^%xV|U~}cLna)aXGxEWW3);=s|7l#oS5_{b^6e_Fp;E!u7{1FC z_ORoH3l|K_NS)(tU|0&i&aAG;`BiMsbzm@!PDTaEz5=6p2u?< zZn!nWZkm!$hY-F)rl05iQ^cZzg|%(jz4bMG56_dzc0OaWYS+Ds)*-*VX1}lD2Y7)L z&g+(K5S|UXZ$gIuBMm>sPe>{@L4l*?Xl)7SP-wgq`K z&*9k)sqdp@E_%hZY1q-HW_V#Qzs}U*T)~=J_MvIxN8%v~KX&t};B%imK92Yb<|*)h6K9pE#%5}5akVN?gIZ~*VgU`P2gE?QJ{jIN zP@}xkQ&am$r$5vgs6(VHSfl>4GqfexSy_i2U8?+Ob=cWe?d#mKgr@NY?C!3K)c6;1 zTM;c|;e(4f)E!!$ePyJk4oCbx-vTKp)+AhM-M2MQPjp#N~-Ynm!xSbEoy~K4NFU|dYPPO0! z4kC$mSU7|^N*>~i@e??VFH_?N?qmTS!7F$j{)SHc19#!yeCt)AOKeBCh~f^>ftZlb zvN(D~61^@do+j`F8}G%#(noO`@53V`N>KFUQI1F>(TB(II6dAhdhmXZ{CxSx@Bxkj z*d{vhL41g@G>XIcFxNt87VY>5N0rzsTJTXyRU8m|@G*`wM8z(AoTF-Vh#mC*lcZow zgz+hSn!Y53z!P|q`LOU;d!@CEv~l|Fg;Uo7cAMGaNHpXsF}w4V{w z;7c4;Fgv8RI7weaoX;-d8bSJMatZU}OSnGHdillzo*s}~TfnylNv>zR{qs219wCDF zjz#?8Zx`|1?m#5q>*x+f0{)IgEOjbvkzl>zviyf*?Th%S)b;j8{4c%wB8NY3d)9SD z)?p7p22Rn11ncWGAwEN3lW4^N-5x|2&JvIzYMjFepFrpNouoXCQOsb>h3cFa0DehW zz_EdsnJ6|Y+=pM`*9^6p)_#NEG70<8kKa+xPs^<&#lsB0m$dpl*MdA{JN`g`6gQ!= mFL>6T;^>dG9YMvb+!jz!RB%nfyn-_v14pUwCn{9n&;JFD#@I^$ diff --git a/bin/test/TestGui.class b/bin/test/TestGui.class deleted file mode 100644 index fc1b689e7008e18adf8787efc6c0de8be553fd5c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5405 zcmbtY3wRt=75?vJH?x^e(`J)RvQSD&p-q~mDTRi1(+6#~kF;r8l91B0v`jXWWXfhY z?#@D66cJIY0*Vi`Rm2Ba6-A0QsYX!|tfJyuQ9;EQqNs>ZM2Y{I-6Wed^~2A8?cFo? zoO|zi{O8FYi6L^PIXw_aa$qSl8jmLPAlcecW%<> z_B&~X;+Fg~8@bZz0X z)4+weNXN1~_v8thxERZMsHbe4&JI;i=W9{$5)&)1lE~<@-R&87Fyls@ltNi`&FL#d zzR|=gk)KKVHtX7`>xL26iC9(56>CH||W_Fv{ zBQrCc^o~?AW~bA3kIe5iu}_>LrftbMF?)UTKmeA4wzW<8F%vzquFy%hZg1TXKrh26 zlrZ~EIKuQf>CUDAuI8%FCSec}31JXdolX1NFKg=vfSA;CA0m=6kro4r#DMNDJC)Rt z8N&qq7_VQKN?8Y696^jL$UlHXIu6q0$;s1abF1s{a&CW(70=k)sbP6_b3OoZQg$4&+CMjF}g#Ht2Zz9NQ`AhaV@1`gvE zsbkB9dXtGa<2J^{8XU9}w50CLM|&l5(h*F@x6<_n6V}^1fVUF@#{L`tB2@vrgZ?xU z$<%;+98m}ueS+hx9`BOV->opGI-2k2sb{=LK^XzOmp~kF60*_zsj)F&9T561I+wJh zTUDCw&2Ifc+4`7lJt>4!xBf8m-soX2=9UI<5A)YZjc1{p@G;hRBW<~vl*RH|HRv3$ z<1+toS?scEru&oe9+^2#j~i79?`Eh<_EsGt9wPyKf`~Re&wtXykia3}CbO#OI7tLZ zRMYkC%{#K#DO`Kgp(i)pTXvlw{4*v#D@hQLBy8$$-eF)EpOXlFUSZ2L;hF|0(P*?e z+RQ(Byz#tfjCOT(Ns%AMgC@R+hj>=ncAL|@HRJ*yPsf*d+YDslu9HoBmUz}>uK+|d z1A|fo4LmIA6~b3cJR&I>@KUmAFe99=nfN*$r62l|3VWy1dWsJk^Hd$fdv+=hhdH7A zndX|#0KUnz7#yollkp$Gw>|J=f%ILfX?WEw3!Co?YH2So{GnhjuLR2CVfmD>CBs&rPJB>Qo^L;Ckpe<5DMF6|I(674)U6RA{&h-P5fNoLv^Ee+;%&hUg7;x z;_)jfaV=9F-^_qB?pCUg%}ePtJqoK{+F>0oIc+I9Y&V26rR!kVqj(cm(S%$vAxx%6(ta%6ewS9d5yUnkpx}i-$z76?2np9&*i#cy{9cp>cXF zdj-(1)4-dBAP3s9oDz?nA=J67d7F7nvyP{9HFI)r=rzW=nnhT7i156c zJBPQA*UYds6JD*;Bwj9!^B28T>pLzSv9D}rK|U7AyjJ7gu;=gak5BtqwyYOZ%DNFN|Ci-4+Pq1@vd%2el> zYQAFn`qP7PhrpkPV)5o6-# z9)n9Hj+h6^^1TR-T#Z7GI=|}qtN80*G>pJ;5*iGS!UpfW863^50Douls|dxIMXA}I zl!g+%p}3L%Y*g~`1?}z;gmw+1V%ssyGESoM7y_+zLzugG2=k7PKFgmAj%YXDkLuu( zAuQ!*Lo0_!#K&=UgP-HNhC+_f2A$)kl>v@hR~j5!SDG9zTUpGpqhU73oed=%yBdNV zuZ)xiuZonB>OKM^Xh+J9VGh6g zlzG)j+!U!G(RCD0Q_&F|-W7bqFm4X}hHz`}EgWdjt--f(2$u?VyHI69y^}*_U!U;NV z1jD=P!WET)O0&`k>6OKy*`dOaKNJd=m*G>QJpYXp4C8^8TB`kp5j;#&Pem%jm0@3P zxFTE{7GHgN2wy#h$H%Pv#{X*Nw?tj@|26PCVqnP-z88Esu z+`}DCU?mp3p18dbLc9t>Hy;!Gi!+Lc)n$(?$s^i$8PGF;Y2Ai~MY}U4- zS-S!owcXgF9mZDe7PM-&W4m@2+Pq|aj%mmw#INxbz@6sfH+UL~vU9Q&0@@w;Eq=!o z7Tce}?^zL+X({{xeazEQ@gBsZlilYe}!@ z<#h~mlj&FFM1fH%F>xM!!xu5VD@D^s?3E~?G*u#{ld<>Hk3eEX74I5W!IlwKx@$y* zb}brK6~n4>n^d4-bv6s7niKII!|FP(6zvTAO4YeTYF@-2_7^OR6o&o2Whd1I4SH?3 zFr-UGQ#Cv5PAVx^tZcG4>^n935Xq&r_j$UAf7UP)fG+B=o9Nj?^j}G&?I7tJuVQL5(mB2cWWQXPj$ OgGr^-Y96ksHU9w?cXRsy diff --git a/bin/utils/ChangeImageRes.class b/bin/utils/ChangeImageRes.class deleted file mode 100644 index a628fef1fa4ce93cfcbbf293cd8ec6656de41a00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1816 zcmcgsTW=dh7(L@%?>g@0(xh%EPC`m=z9e-^i%CgwlR9-VbwWf?P$W>Nc!M2L^69s6r*L&x#Q5Va4J_VK&I)(> zkmPuXt2OS+xWQZpMlOGs#@JmP{v}8l;W!MHO} zuwG-M80}-s3)+b92|_l%e-G)k+^-ni$2h0M&Oy6_6SZ)CdQmCu;VY%6?%}gTGx71F zwugL5E$Vw18I4b+w3NP&-1R~IQgrOH~Ls~bQ5^~bIzQd&?uSU=2%eZmlDG`^2> z-SDCs7!r!iyb~ss7RK51(KDk7~*)EES%vR$zU2;TtE&* z-u}y&LYbar&L-DipnzTO-(lQOyx<*1{?6~2WbspSN>;ioPT~h#!n@=wgYPiQN-@^_ z7VnWe1?O-ZC0Z)GEa3{~$mu1_V4gmWtK&qK;D@Ngf0-Ty3#@$tiKp^Grgh}SW5mT1 zBw{o)G582WejA( diff --git a/bin/utils/CoordinatesCorrection.class b/bin/utils/CoordinatesCorrection.class deleted file mode 100644 index 430aa11b2755abc127934354a3f8acfd48fc8dfa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3136 zcma)8=~EMD82`Nx*bp}1&`?pSS49p1&!~hVf<>qt)+mCt)rG9dYRJYM2=>13yY}Ei zJ8hkDI@9U2oi=KncKX>5{n&q?GyTv%z?pui_V?~?NGR!0X4rl9x!&jfJy&ks`SE7} zyD+byL|{!OZNyR?eWsZV8*weIr~1rfQlCm2W?X?wp!%FPqjkizc%)-=@*D*MWv9bh zS`%0?WXYt5jsYzd9o7;-fr^k3p`%Pv7udN}qswMl4nygr5sw6i>==ejGZE~jhw?5X zZlt>fN}HO;1YCV)Sofe5UKJJaD5w&sS#q)mK6oo2P^+R0$BPGz_1W^<{>?9PV0Fsf##;AmkbUz7hwt* zMRb=1q?oT|jU*gvRIEh<@jS23g>)varl~M2vVxUZhYbqW3wZO0QlMfZHVL?mw4T(` zW>TPTk?o+vr-RMdqM(uJ<{jjuDw@#D1jhAQp1v~Yp`e(8GR{^NThYdJM`VzV4n~Dq zPS}Mk1swvOeC2r1j_oRTU?&fxqj9Tz1|@s9ia?G%AsKsB?2`;H^^WQ(Ge$RNTuOo} zx}>C%l7og82^p7IdhO^|u|H=qtg&oor9{C2R)%%&f_m=F7_qRPlxBS@4&ni3fbROD zL~$_&PW^ju2!jd+7B!nKQ}G}U3n(*METfN}T^^kUmpvGk?J^?ZF9g()H;=h-L_kz{ z(1W8YLO8}KwM0UXhXvY-SuE*W=blVq55}a669Q|Sa@D#N5KD1F#Yu^XJ8jybcyJ1j zDtJV|mj{v%M^&80875JiWP7^km$~#|QpFS)V&#+>Pisazby%PK*A?wC6>L5!GjLW# z1W`IqF$4J_M@X9n`PV!qmCmU+FOgEHG@?y2<33EQh{NRhi42Q!Zy_Si0R@2Mj$F!; z?k}iFf|roxc0>zJnMwV?OvI|se%U`66*IWVVW;Lf#;t)TtDKgp zv`$OGnO~-zwn{`ylAg3_C9YqTu*nIV&!JOkoE(eC?pz`_dN&os$?%KJG`S5NO9wwGusu}#n!6w=Vp)PCcmt97vmT4UWl0tN>+;Pxvnt2oMXAR0!0MN zdbakRy9hQ-qTLEqVHH-Ar`k5~qmEx3cjT8iC)7*7rCmI= zhN6qDS*-3Xt1r8Odj&enuZoG*`tlpNPaunyU(nvE)GJwR>z2=50hfI33Ap8})9;Q3 zDkOD(z~lFn#R8QLYyFkcGm@|RRloa8!0UG{uzY@>WL4cn&xEwE$g|Fjbf5jF2)Zn^;>wXuX-}zlUGyFNeY_Q*-wS147`sysS zc{J85H1qPnsx0(+MY0WBE>Dh~xQb*>U0#xR^1HA6AG4sePb{`gT>b=`mOD{`$~K?B z^My42hG~%r1D?ftJ~y)j8kxQ=sO9?Ih-N-p(1BJi!L1zCZQM5P7$#>N+c;ylbN21v zfZB<9{wn+$yK#$}zhMu4$6ox&O?exg_zOYdMVDBO`^5%yi#F^R1LzUQxdKn2S46Qz zBr#x>%vW|fI3>fvz^ql4lA6OMmQR!D!DFOKxy1M3aZ)b+WV?VT@Fa_=ir${W)3n(r z`tc0!r63@7;5q8Kd1e!yCslz%jN}DU9t?{$c#%{k#zi$=BE{_?D)2HXFYos^ULob< zEpOvhQdPX`uXqiwqZ)4zv-Ps@tvKB*aXXSX7b1C!k-SZ<5L|Z&s-i$B@UfK?tW$_L z?&1&BI9x%QSx*#M7(KVTmZ2z+tyFAq1*f}MTE$^TP+VA&HprN9!kfYBqG$?xOD{%Z<_#w? zj+uG#g&2G=8e?KY5J`OS2l$hWQO~UcGbT0jP<78e_ghY#`=vg7e)k^0SxgvE1Ueh_ zpis+9`JTIax#SjBYeCI`D$us#-f=Spx0KKPnp^R`x`4V66!QYDv%yLxTXggO^+KaI zE}$&j6%bhoRt5C)K`E$DuypGCz-%@>&mxoMMc+gMtrkq|6G)`e^Gy(Fw_xB0i8?Jb zMaZ_GK^NFJ8Mu~WHOW7PW$TjNz|DwROx8EhACV#M-s3mWx<@}n z#@5#1*!nv9hh!mH<1Ge;Y|YlWEheVsbWnRQD*Yivo8JX}T*S8yMb_zP3`oBR`=zd{z9xEk8? zTR2Qx->!WNr^#@P8F2<9Tur>>zwRgYYr%7j@>GS5$M~5@wxK9Mf?s hIt=3ri|Pi1Pz($T&d4X2qJ3yU`N&FwdgZ8G_zG$Q?$`hT diff --git a/bin/utils/FindMaxima.class b/bin/utils/FindMaxima.class deleted file mode 100644 index 57ec29b2f46bd75f09aa11d6ae94a0690e3eff49..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9566 zcmcIqd3@C6nSY)+e!n?>IY{zj7y|-w%}B1Yb&#1f_jC1XW6<=bgu)HgPkZh)LCqQQ`d>{Mh>KABARlF|)2`IwCC8+m9v z6}gG&9D_WhY2Ww_6owz^I@cgC8Pb|!P!8ov>pX++!YBV`eTrH)!(>m z(djry-KGi0*Dk5`Kta_8EuOumwAQR`x{ z!1ktaJb_)u(=vnVXgTbO`DM?w>h~c6&Otvc%9%`aX4O&MnOwM>; zPZ;~mDmh($rB|HZ=b_7JqfWrJCA&JcF_H*%g<=L>POacuUmz9_p--eceTP!q>wp~QwC8Iq?qraO%xECwV&ne4K50T zb#&sRSl+DSL)bUl;*tS~g_Mmfp>EOly2|MZaj?9=HBK%V6a>O&oY?RAkr&-QpY z?xCA#K-7DSkY_BH#o5XDtp?pjw?jf~*&GUYb+x-QkYzFg!AE0<_?tL)$=tNc*Nx3<$Ny0>GCY%)^8R40HxM z65`GriBK;Vnbxt&XJuTH3KMvY}Bge$f(@yb)Sxoe%u&QZUdn> z(QV1-212Yuag^LETMk%sCmq2rwi#>}Um>~ADskV)7Iw1JV2yRlgRKp33&A(2nAGTD zH+yyV;OtSa3rE&%u)#UP(RK+h@Q`qKJ2}tbd>$vHmE1)`z)~r)Tg=vH<@pTn!|;%< za9?0NC%q1?6Ll`mlvDVA}$}QJ#*aW8Kmj=qGvLc(#dK1T~r%3H8-HRa81A zk4l*h(|DS}(|LwmB?w0|M)hg83)O4kKC8s=^dK!vOKy+%qja%FkdA0^c=x``#m=~N z$_vObeYGC0;7Xn603V}DZ0Lyw5+dCBk}5Q0=OJoHt(s@>dIyFnFbmNT5_BEs3CP*J$v?5)F0fSFy?&7Y$*L zF$$9z{k?La(6GOEo!}Jr6xGYEL%kiSH?rJuCQxM~!cwF7V9PeG+R|TrSAJe~G4fkm z>t>PZa)Vn%)^U(Yog+z&5*q6g-6(bdRvBzQwX#Ho;b}qg(~Nxd@Qc!)O{!^c*{?sRGKYZq3hkP1`-v#*g7Iu@>%gctSu{wKD;ijiJq(;7t+}|F+<7^6%*8GUtk~0r6GT5%a#PzMQ4gC$+)*~k@9;T? z=)$rj)z;``&(pLdEv<1Krxm#TMKx}Fm1mIW`E}Eiq=uKMsh~MYYiqoIuYKMyt*Y13NaFTjza?4D^%o(D->O9r*TbkNrzMe`Z}DXFZAb~uKO^q=9#ZsBlHdJt5pw)CYHPZ{UhQ32<=}o$nen?l*@8QrU zp|qP$ZCp+PUVut%F?Dbw%CZ(X+cpX-_`GGAHw_=|pl9hhfe%{G0~UY}TF1}=e9%e) zGJp?SLo^IBN$c+wkn(svq&N;BP2fxDALvCuZYnRQuhTbhlj*#OUcx*NRdX?&pqBxx zIxe7Zq7QX8yXjkK<={^5(m!HlE^hV)eH&-w;eOwue?luCH@uDhnf?Vtd=u5pE9fi0 zZFiu5mCNB<8MKm20a z_uwJ^6aW9Lta$c}A^KpH?=v9^Q3AjFaj~s1`E^u+>(8a_VBiiMzLS>G^~y-=ti#hr z0szDy!tpx#FvamY`Y$NKj{T}(1~F1T_WBjf;Kbe~^xyPr^p>FgKlB?Y#7)1Y|4m(Q z1J;Rm$UjaWwL;q8uby3=q(5vNl~$RbZo#TuFvzV+swvhQ`V{-hPd@z#aw4O_?ti8c zD9|Perges`26E(J)`!rNxQ?dsB-3L2;w9+ui#8pOD(4`*;H=UH>8RgfI!!Ifj)SzX zTs1-Mg}Ujia+_L}$8uAV9;7~v>hIKdBDq9zHu?E#HVZIUy1 zXymd1C!5ZR4m9iKHiC}#M0@ruLf-}L+zlPv1JK?J-+muReLqn6CHUP3XbJ6sC*BLH zKL{#6gcqKDK*4@I8yo-?9;V&sdkAAk=n#nc7-;o42yj2WjeUMhUq-@yR9R(*iX$JU zu;QYhfMhSi208Q|7Xmdloc;qYLdy;rUSkuZ4my`!=JDur(sY!tLR1YB-N`=erbDjV zcmn#|kZyqeXvyPIE1!dw7w=T{ptR6fsI`tfBe<9bYJpEeuAKntr{v@`<1*cB2l-^o z#S3hokaq;3OV3`1LG*hdGwK)%M=a6`b6);yIJ(avIJzkdM={gs3|8rb)MjdExCZGG zjOwOKp==Qhu0Kj1Q!`zU(42BLKs(Ync;F!AkHTP(a;&9-i2)azE^G7CNQ< zu!Ro+#SNqQ=s5#E*1=^FJq>(313Ntn3q1$hAc%nHv*2>)!`UtZyDx&Py%g-;3^yBx zi~T%Ma0mMLVEi%6eG+Si;WSUcT}p0nrKPD17GB6;;aCO>PiL?&n8Cun3>I!rVPPSK zm9+&6>y@=#%G#A=oWuL@8F1#ZIMI8+N&xXM$vQ>~$H>g6SL}*_xD!%i!cKx=GA30CH>AYnUZ; zI+vWn8=;fp62er9PV=Ep7c_|{%oH`w!y1WFUET(Jl>^EXKU?E0hJ%E{8sMG;{PRtO zD)`>VXr`$hq^YK!`sy?FgH$lX55H$3bnR$w7;vz{^F;B9-%-jdmgevb)3Gb^6ppg| zo29s)LYSYygZv!6;C+PO4HZDUx zq|$i%`Je}qeSV6Yz10qHwbNUz*{k$4+FWT3x{Hz9()WB0KU_aD(;a>{bSjN@X|<_V zdo}W7HNhEFQ!rJN7UrO-t7dz()2CUJ+A@=*m71iQ?bTZLQCRF4-N%ud;uz5FewW%x zjSll{0eGqlJC5y8%Tiqfo)PT%*vLE|9Nw;oh@?I>Z?(rRF?F`jgZ$Pjc|2Dnd9KgV zdFuBq?bRL?Fa0jbUq@c|d3F!;f_thxKBxhVyaJyZK3jy3gH0?{Tha^?RY+ zS)xWq5Wk_tAzsv6;R7<4R`?M2@!OH){o#a&&qkP>3t`J^rY;+Q^ zgR?;b;zjC_i{!%xBu!!bJ%epvjGcPeLHDwgo@b4QfQnbxMeic({59r$%w8J7Gm4If z6c6X()mn-i0G67U#RW@*><)*uDnkwwWyOa_T71Y1Kn|e! z|AQn>pChunh+7`qPx(I3-THEXS}nR<2D+q6;4Hep4}&OU=z^sdV^m|~-$)vSAsZm* z1khYu2Jn>wcC!JN3P5cRNK;9Td_F~ZF5S=bXb&F0j-rHofiIv}G5!u;NI&9gdY>19 zKsEGRt_6t}@gzKXmGNSpk0-9xyp-E`8SmgazL}TvouJcw_(uQ_@{kmjxoX>Q4o<~bE1Jg9k|w@5?3%aEpxR-8r} z?2#c&9ciCMnxis!cGAo~i3Hgue@wKZ4ol$kfQ!2jaFEHQgNzQdN=mv(!nAvkR+=sp zkP@bAOxHoWz;vg+mYeQ_G}GtYjh6|R=?0;8mv&{huj#m_+KFI2;AYdULido$P*vzY z3_NSf={uFf9u4B^0SeOD@jjrTme1qM0Ei7VnK#m6zMQVY^IRLgUxWUwd==fuS1Ti0 zN#?G!5m6wfJRe$?=fho*lp64ScDh-qUmoE;uMDQ4oV-q%NkVkU z9>y#$59F|!gJI-I@1vIV974^YHkLABkn*f@(XB2M5Lr62zuVJofW>rkC-gF3fUAMd~) zp10BG_J%Y7g!5%|AKritvqkKg5kbX-%k$Go0k$Go0p&owZoncs| zx(=l9UsI{B6Pef(D%I5xm>*3UbvjOyfaSsoH>Hfa2oF)4(C5K})fxo@FLJ|1Rbd#k z89qqr$s853s-?o1MQ$;^dZ>|wG1|U~F`i%;&5B0^NcvO#lD@ diff --git a/bin/utils/Loop.class b/bin/utils/Loop.class deleted file mode 100644 index 9eee1f36b3341e57a08695f5aac877b18df7b45b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7193 zcmd5FzEcC`6c}tk52l)Ijw!p z%=|O=-udn~ckW!h^Y2&R0I&&v4x-9IXgr@98Efy!WU@g794r`)pNY4R#M8<4!zYIm zgLwym*x>1$gGD{1rT%;_l}>gzsEMWHqX`F9u?YuGR1GE_G{ka=vCIffXVU6xG*0=6 z{?zT1td9+);z>QOiB0TF4=F2?(g$N>6wDrVFt11BQX6HtkGFEnfg4LFQpuC2Gnw4b zdhXe+Hps^N2Q#@u=b5B~`M$5A#2MdmZ-RUI^*1Q#Tq1eBR+n}EgxCwj;>v6&mQBQO z9f*&N(}@6q(pGWf?!A5Grewk`AmJCcYV>WTXZ!*i=Lm47c4sP`%I|j2(ma>_Xmsve z%K*W3Wrh+VRHNC&8nig5Zf+TQ78r|%ODCgNA>(s7sm?o z457xJR622JeDq`@cO-stgy*@aCo>oy8Hndn>f4(Py z>LQ3*`aw~0#Mp?c>Dye?DMa%~U7zpr&ZAh_H`jZM*I8+vap8(4B}*&39F*MaU3DdQ zyNh{Bu7Prec@5*3TE5doNG;cK*}G-L#@k)X3Au=B(66rDd=3uzlfZm#RW=c57HS&G zQboP!>-^G4di)tiA^5b51z5-oMQf6GNY8@iGBL$>jpQhb70e0zM_eo_Q)Zl%<5bC} z3@0ai0Qsf3_EM2JyrAq`a+x|Fzev!_d_-EdBElhWQEQfrNuDFQd-ZX9_H_26l`fT9 zQ|Wjp{TsV^ynp(4AzGnb1`_N2!0 zyhru@sU-Ip&++=T*`;>+A~>4PCz6R=$L@|Go^x=SyhY_kLwFX=A-sT>f_Txv!qRi) zDZ99U@6si?bcatl2s1%g_E3gib}@rlb-RWbab+n-zl$9$$LYifoe_sAqb-$VqNCyR z+%lOhd^*-(I@H>f1Y4P2k3+OLu*_w$SLv;3aPMhoeQ zN3%vki*x3bDt9T9W1--2r|p>Qw9`-$P*zO|TJ=frE7YGE&kZKJQ|hIvSI^K|7213> z8J;ZVmZM6&=p0q4)Gj@9x%5n_((|>Eo|#&DW@71ipQYz*mYxYvdge0eSsF;s!a#bK z1=6!9ke(%h^ehOZXE`7}ivj6b3P{gFKzfz|(z6JVo+W_vEC8hE^DjLgfA*W`;Tn99 z?S}v-B7OqrA{X)D$fC#$+9HeA&Y)e|_0n#XcC)lwrQI%VhqSw--6L(Mv|ZBflXkzf zQE3lK+Z$<}#o@?`S@cI%&f5)FVm!4f8QsE>iiLBCb2T8mo%DF?lehq;{>QvUmekB(Po$}K27@IIPqCN; zjuZ3y!QqYM@FsG2GdVm#4rBNvZoz|OMR9q6_k%nXxtuC;IaTCxit?JvDUVB~kzhQk zbC|*@t}6c5AnEaYiu~4bZTkO#-(8U<1nMv6>N7nzBQJ4K#SnsbG42out`_hhIOe|#sT4yj)B1vDXyG1*!C5jHzdJZ^H z&Pzfn1Cf2+0CArcL=FRUKrAo24;sYz3Lw;tSDueqK@6H89x2O|J=ab^MVnWZ&^XyZB^c7D!*-2zQ?NEX)3>KRle7%+-@qrXI1_L zGmrMUbg5UfBrv)Ai)hci)SqIGQQX~!`z_o(U}l!TT0uO>XTb!)%<_N<;%^l|oM*A6 zKs;mx@vsTv?^Y0x+Ce;Qg80WJKulYYW2<=_|FnX5%zhkOO%VU80OE1)I6h+qvEBgT zR9QiM)~dYGRIauvf6nf~dcy;!u7U@j_dIyQZfB!ur@n%nFL-voh%b4uwT>^6dh%-d z7T>%t+fi&bQ8ZORQSjy~c+x{LK@_SG3P<>CWg{zQ@Kj{w49-TH zSQTM1ei-Rzp;hZXI zzkzRZ?OR-}!nf5=0zA%{1ZBDz7ogE(PI+pVn@d{CWpB7ZDp=Vy@$iZvY5ZrEt z;1=JZ)f5lyb^D=hFOe%Xg0s^Ht8nD11p0v&I&WA(beJHnwSsul4x+;Zai9W-A9^5u zWG&g+jGX4^-#TW=_Ld#QE)&F&3LsQ1sgC2vRwnkDOdPi|@e`|Z)KrdHm49kg?lqN% ztja&LyT8wLf4GACZ+q_l+-@go+R0R~^9#?;J9az0rk#8RJHPbo{K`s7mr2T`m6Ug_ z%KJ^_JFUvUwkjVqmG8AG|Hkfqm+Aif72N-==l<{PcJ`ZgD*Xody=Uh=yPboko#_gA O{@~g9BNJE^{`4Q&6`VK# diff --git a/bin/utils/PeakAnalysisScore.class b/bin/utils/PeakAnalysisScore.class deleted file mode 100644 index b5a6fec3655cfa9322a7d4139a4301f3c051e168..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4052 zcmai0TU1on8UFTRW)94p8DZcsqG${e3*!X?%{U4g5kyEvgJMvrQ4TYQVYtkYnE}Nl zji%J3O^n7Sy_nWkYo%!$qg{$kvTDW|`P;pEJWn)WCxC z-}Zn1|GoeA)d#l#d=uAHC<1}8Y+^W5*J&C<%}HZ;B9q8;MN?^0g+rit&=@!BhK*#r z?y0^(Gny4p4<|Pp0uMs_T13N$Q~XtGI`t*&f3k&HJ+Y}X>G)M(=tYH%G+j9QkLO3S0^RMgC5avs=7 zDlNsD63Ik%i@?g7`5rDb+F08y(E7DvU+bGx<7i36Og9SP*Wg8|KtWAyw+dZAo0}&$ z%HS`8z+w$fxKu0=C|Qs%H!5tYWg1iz%0mxnSb>MBEpBEz^Wh3CtEqiJHl(3PG z;=bLk;VE?5YWg{UH60zbZElu)kA^PED9a5=!?uZru4l)LwAnl!m(BFFhHh!8kPhri z#IggDxL?BoNh~6<-Au#>vQpQ#G#r$=igUH3hL%)1X{M#ehcp~UFH4nSQyNy8$)`s( zZMEG}pie_o3g{HrW5yFH?wDCY*H-7P@xNZ*xZm-oF}-mAaD}Qc`#EJmWEQTr!{4kY31aYuzK6Sq)>7x%i%5<%EuCI4Xro z=BX#MUaB~z;W^2zxStA3>IDtozNd}`spGhY6A#qUAba^c8Yb~wZr%YSv&(8*Zk8UV zgEJ(jdbY{CI6eYOLU#5Xa=!P;D~Q^2Kbzm&u4T!Fxo5dv=5Ad9ag=`@{G%xs?*-PK zNSj2=BqxpzWUR(&u~4h{D!Z;PIX1#h>Nlbs)r7(7d7`PYWR_&^AF5!L#UKYGJ2E;W z?l{Wq(vu16Q)FAPVEnCt%WPc{Am^@BlD#s`y87;`Q-18tsDn>*OeMe zN6of`EL!=3O}tK45f4+afERiJ6nUW#Qsk9EYLNxIiF5xGc97g)G?@C@+b@Z>A+!eMBtim^l(Hd&#tFWM2daEEvSev0puLV}4l>h0ab3LUi7+OCa zsGP={$m;j8USQ{xvUAP*2nl?Ird^V^b{bng!nRG03db~BLr(c=54k*HmE0=bsk^4} zWVkRWp_|wpF4CRF+66_`UGf9nX-BxXSc_d0pX)9g-Djbn>IRYh$+nTSO}3CTnhGmt#i!@x#~7w5PV&rnH4Z>WR@ z`SI%|^9}m%Hdqm}Wn&@9s?tkzzcg4Hl#n!7Mgw_F8W<;Dmg7o%f(C1PLplxeQ?Bdt z4VK?+uqI~9#zK-+rR#dRG#CgDcKA9}va4&^!Rz@_*?@Y!C>pSXuan&f;RRA&=9xFJ5pSar=h1`<*o@2A zg5TkBT;mJkI+}5l>;D6^;2+qIfAcZ$U+}?-c2R^UL@}Ne0Yt=Oy!@N6OSE9O=)@k; zgDx?Mz2X?U#R=>auVBBpj056b^oZ*?DE^FR#K$-!KE+}2FBsxK=o9}#R0$xaEQhI7 zBd*kAKxslkiC|DUh_#A|5jme?38Uh4<>s?cIfRppgWFx%hga}DPGhCA72n6Joa0)h z0k7c{Gqhe=gV%AIduIc+pCRPJCZ&qepXE;2q3HMlp+f9dJb05(5zdQSc#Du57sQA7 zAt4Vgi)s9bXEnToecVT?oaMXxV|sUyP#NpOYh+mN# zV3t;}YG<+7+DzrlfSr}8nXLSpw0GDYZ^H8>{3;$*vEdHA_NfpyrlLv3HX#)GBUoVf zZ4?Uk7jUh*jSg`KqbR+fFb~NSQYP>~nY>&G1v7H=N|8@Mdwa5*9M+B=^0XC%97~}#8Jh)I{wU6sz>OLzV< z=@hzisRVzoJI=xBxl*k=PA0F=1^araw=SP?I&_4Ma+JlLU~!LeP@ZG+KaY0eU8Env zahBl(OuS@W8SS>qGgrot)oM%$UxTvM6#gdgTb8JRdiyzErx~Ujd#x67a#WkG7IIld zDue4Qc$w1MP({7+1y}`n74mIsCka=n#X;@u!KK`mmHgwFZM4V>@;$52SN{)^--7=D diff --git a/bin/utils/Strip.class b/bin/utils/Strip.class deleted file mode 100644 index 207261140a4f65d714ec5015b141e61b6828c770..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2599 zcmai!VRKVO6o%hTZxY+wLJI^eC6rRB=`9jb1ci!XZL~JFLNJsMP9_c4^fDpUmul;eAL(>C31Cdte_XZN0S_StvO-hco5`yT+eu$@LiA=8bcW~We& z+tCkccnVX`YcFesX06pIZ0$S`>#;(z+N!+>70#57-bq5MaZkak)_2v%}hCF%BgBI{65|cqlU&&I9+W=jorbS z)JoKf;`<8A`I9gwXV&>!st|H@?^!s3F`S3ALwo=pzH@h!(!uI3ZPE*UXSFbfIwRR-q{-hW0MjeI8(tysQ zno)F2Yo{okXH-)Z%`=*%8)3Yubw8J1I=MB4bmt%->kvb>onnbqIh_$13W&gyvXi*j| z`Z$HtltmUD=m;-g6z=3p(;%6Hbhd}2m3&M|TIL{4x6KrzN`s9fq2KtJme47N9($=U z&G<*h`brWW`#2*B(@Z%2R$-#N*KOCsVkE~rp@DD6RlqzG$9S7ENJ#h4OGrOy%O28} z9i%P$M_YD}wp3kP3ZX4`rY*6xB@OKbu5cFT_{?(ji>?nW27lpvaJ`3_V7Z6cAlE}K z$a+1@1=(Z|^FcP%!@?iB&NV)-vZH|+c(}+_XDR+AR?TtdGUoWdhAUWP#FwOJb-ax{ zt$0h^jnZB~FQL6<){tE<;yOJ~d+*RoYVQU;$tmF7K6QasY9xa{G5b561Q*0%VOiKW z0sVy)ZsNUu@?A#DvMIgOqb(V%WsQB_L>ywL`q&EZJ0WIlh?}~M4ROm2F=IpA9s%(I zZud7csKlLLEhSc*5Fg?02_+7y==OCGy{MLgZ|Sq7!1p4Uw}UHby{v?1Y%J zAs#v*?z -4.0.0 - SIP - SIP - 1.3.6-SNAPSHOT - - + 4.0.0 + SIP + SIP + 0-SNAPSHOT + SIP_HiC + + - sc.fiji - Auto_Threshold - 1.17.2 + sc.fiji + imagescience + 2.4.1 net.imagej - ij - 1.51n + ij + 1.51n + fr.inra.ijpb MorphoLibJ_ 1.4.0 + + ome + bioformats_package + 6.6.0 + + + + + commons-cli + commons-cli + 1.4 + + + gov.nist.math + jama + 1.0.3 + + + commons-io + commons-io + 2.6 + commons-cli commons-cli 1.4 - - - - - - src - - - maven-compiler-plugin - 3.8.0 - - 1.8 - 1.8 - - - - + + + + + ${basedir}/src/main/resources + + + ${project.build.sourceDirectory} + + + + + ${basedir}/src/test/resources + + + ${project.build.testSourceDirectory} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.0.0 + + + + plop.sipMain.Hic_main + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + plop.sipMain.Hic_main + + . + + + + + + + *:* + + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 7 + 7 + + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + + + + DesTristus + Tristan Dubos + tristan.duos33@gmail.com + iGReD + + architect + developer + + +1 + + + + + + imagej.public + http://maven.imagej.net/content/groups/public + + + gred-releases + https://artifacts.igred.fr/releases + + + gitlab-maven + https://gitlab.com/api/v4/projects/19044962/packages/maven + + + + + + + 7 + 7 + + \ No newline at end of file diff --git a/src/loops/CallLoopsInter.java b/src/loops/CallLoopsInter.java deleted file mode 100644 index ffeb5b4..0000000 --- a/src/loops/CallLoopsInter.java +++ /dev/null @@ -1,135 +0,0 @@ -package loops; - -import ij.ImagePlus; -import ij.io.FileSaver; -import ij.plugin.filter.GaussianBlur; -import ij.process.FloatProcessor; -import ij.process.ImageProcessor; -import sip.SIPInter; -import utils.CoordinatesCorrection; -import utils.FindMaxima; -import utils.PeakAnalysisScore; -import utils.TupleFileToImage; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; - - - -public class CallLoopsInter { - - private int _matrixSize; - private int _resolution; - private double _noiseTolerance; - private double _gaussian; - private int _nbZero; - private boolean _cooler; - - /** - * - * @param sipInter - */ - public CallLoopsInter(SIPInter sipInter){ - _matrixSize = sipInter.getMatrixSize(); - _resolution = sipInter.getResolution(); - _noiseTolerance= sipInter.getThresholdMaxima(); - _gaussian = sipInter.getGauss(); - _nbZero = sipInter.getNbZero(); - _cooler = sipInter.isCooler(); - } - - /** - * Detect loops methods - * - * @param fileList list with tuple file - * @param chrName1 name of chr 1 - * @param chrName2 name of chr 2 - * @return HashMap name loop => Loop Object - * @throws IOException exception - */ - public HashMap detectLoops(File[] fileList, String chrName1, String chrName2){ - CoordinatesCorrection coord = new CoordinatesCorrection(); - //System.out.println(outdir+" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + listOfFiles.length); - HashMap hLoop = new HashMap<> (); - for (int i = 0; i temp = findMaxima.findLoopInter(imgPath); - PeakAnalysisScore pas = new PeakAnalysisScore(img,temp); - pas.computeScore(); - coord.setData(hLoop); - coord.imageToGenomeCoordinate(temp,name[name.length-1]); - hLoop = coord.getData(); - //System.out.println(hLoop.size()+" temp "+ temp.size()); - } - } - return hLoop; - } - - /** - * Create and save the diff image. - * for each pixel compute the new value computing the average subtraction between the pixel of interest and all - * pixel inside the neighbor 3 - * - * @param imagePlusInput imagePlus raw - * @param pathFile path to the imagePlus raw - * @return the diff ImagePlus - */ - private ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ - GaussianBlur gb = new GaussianBlur(); - ImageProcessor ip = imagePlusInput.getProcessor(); - gb.blurGaussian(ip, _gaussian); - FloatProcessor pRaw = new FloatProcessor(ip.getWidth(), ip.getHeight()); - for(int i = 3; i < ip.getWidth()-3; ++i){ - for(int j = 3; j < ip.getWidth()-3; ++j){ - float sum = 0; - for(int ii = i-3; ii < i+3; ++ii) { - for (int jj = j-3; jj < j+3; ++jj){ - if(i!=ii || j!= jj) { - float valueA = ip.getf(i, j); - float valueB = ip.getf(ii, jj); - if (Double.isNaN(ip.getf(i, j))) valueA = 0; - if (Double.isNaN(ip.getf(ii, jj))) valueB = 0; - sum = sum + (valueA - valueB); - } - } - } - pRaw.setf(i,j,sum/48); - } - } - ImagePlus img = new ImagePlus(); - img.setProcessor(pRaw); - - pathFile = pathFile.replace(".tif","_diff.tif"); - saveFile(img, pathFile); - return img; - - } - - /** - * Save the image file - * - * @param imagePlusInput image to save - * @param pathFile path to save the image - */ - private void saveFile ( ImagePlus imagePlusInput, String pathFile){ - FileSaver fileSaver = new FileSaver(imagePlusInput); - fileSaver.saveAsTiff(pathFile); - } - - -} diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 0000000..ec8969f --- /dev/null +++ b/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: plop.sipMain.Hic_main + diff --git a/src/cli/CLIHelper.java b/src/main/java/plop/cli/CLIHelper.java similarity index 99% rename from src/cli/CLIHelper.java rename to src/main/java/plop/cli/CLIHelper.java index d240d91..9920fb3 100644 --- a/src/cli/CLIHelper.java +++ b/src/main/java/plop/cli/CLIHelper.java @@ -1,4 +1,4 @@ -package cli; +package plop.cli; import org.apache.commons.cli.HelpFormatter; diff --git a/src/cli/CLIOptionCool.java b/src/main/java/plop/cli/CLIOptionCool.java similarity index 99% rename from src/cli/CLIOptionCool.java rename to src/main/java/plop/cli/CLIOptionCool.java index d3bfc20..e585ddd 100644 --- a/src/cli/CLIOptionCool.java +++ b/src/main/java/plop/cli/CLIOptionCool.java @@ -1,4 +1,4 @@ -package cli; +package plop.cli; import org.apache.commons.cli.*; diff --git a/src/cli/CLIOptionHiC.java b/src/main/java/plop/cli/CLIOptionHiC.java similarity index 99% rename from src/cli/CLIOptionHiC.java rename to src/main/java/plop/cli/CLIOptionHiC.java index 5efe3da..21104e1 100644 --- a/src/cli/CLIOptionHiC.java +++ b/src/main/java/plop/cli/CLIOptionHiC.java @@ -1,4 +1,4 @@ -package cli; +package plop.cli; import org.apache.commons.cli.*; diff --git a/src/cli/CLIOptionProcessed.java b/src/main/java/plop/cli/CLIOptionProcessed.java similarity index 93% rename from src/cli/CLIOptionProcessed.java rename to src/main/java/plop/cli/CLIOptionProcessed.java index 8945603..d4f5d69 100644 --- a/src/cli/CLIOptionProcessed.java +++ b/src/main/java/plop/cli/CLIOptionProcessed.java @@ -1,4 +1,4 @@ -package cli; +package plop.cli; import org.apache.commons.cli.*; /** @@ -16,7 +16,7 @@ public class CLIOptionProcessed { .numberOfArgs(1).build(); /** */ Option _interOrIntra = Option.builder("lt").longOpt("loopsType").required() - .type(String.class).desc("value: inter or intra, call loops inter chromosomal or intra chromosomal interactions\n") + .type(String.class).desc("value: inter or intra, call java.plop.loops inter chromosomal or intra chromosomal interactions\n") .numberOfArgs(1).build(); /** */ Option _outputFolder= Option.builder("o").longOpt("output").required() @@ -43,7 +43,7 @@ public class CLIOptionProcessed { .numberOfArgs(1).build(); /** */ Option _threshold = Option.builder("t").longOpt("threshold") - .type(Number.class).desc("Threshold for loops detection (default intra 2800, inter 0.9)\n") + .type(Number.class).desc("Threshold for java.plop.loops detection (default intra 2800, inter 0.9)\n") .numberOfArgs(1).build(); /** */ Option _nbZero = Option.builder("nb").longOpt("nbZero") @@ -60,11 +60,11 @@ public class CLIOptionProcessed { /** */ final Option _isDroso = Option.builder("isDroso").longOpt("isDroso").hasArg(false) - .type(boolean.class).desc("If option use, apply extra filter to help detect loops similar to those found in D. mel cells (used only for intra chromosomal)\n") + .type(boolean.class).desc("If option use, apply extra filter to help detect java.plop.loops similar to those found in D. mel cells (used only for intra chromosomal)\n") .build(); /** */ Option _diagonal = Option.builder("d").longOpt("diagonal") - .type(Number.class).desc("diagonal size in bins, remove loops found at this size (eg: a size of 2 at 5000 bp resolution removes all loops\n" + + .type(Number.class).desc("diagonal size in bins, remove java.plop.loops found at this size (eg: a size of 2 at 5000 bp resolution removes all java.plop.loops\n" + " detected at a distance inferior or equal to 10kb) (default: 6 bins, used only for intra chromosomal).\n") .numberOfArgs(1).build(); /** */ diff --git a/src/dumpProcessing/CoolerDumpInter.java b/src/main/java/plop/dumpProcessing/CoolerDumpInter.java similarity index 94% rename from src/dumpProcessing/CoolerDumpInter.java rename to src/main/java/plop/dumpProcessing/CoolerDumpInter.java index 0641f10..2de77c5 100644 --- a/src/dumpProcessing/CoolerDumpInter.java +++ b/src/main/java/plop/dumpProcessing/CoolerDumpInter.java @@ -1,15 +1,9 @@ -package dumpProcessing; +package plop.dumpProcessing; import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.ArrayList; /** diff --git a/src/dumpProcessing/CoolerDumpIntra.java b/src/main/java/plop/dumpProcessing/CoolerDumpIntra.java similarity index 99% rename from src/dumpProcessing/CoolerDumpIntra.java rename to src/main/java/plop/dumpProcessing/CoolerDumpIntra.java index 3a826c3..e4c3396 100644 --- a/src/dumpProcessing/CoolerDumpIntra.java +++ b/src/main/java/plop/dumpProcessing/CoolerDumpIntra.java @@ -1,4 +1,4 @@ -package dumpProcessing; +package plop.dumpProcessing; import java.io.BufferedReader; import java.io.BufferedWriter; diff --git a/src/dumpProcessing/CoolerExpected.java b/src/main/java/plop/dumpProcessing/CoolerExpected.java similarity index 99% rename from src/dumpProcessing/CoolerExpected.java rename to src/main/java/plop/dumpProcessing/CoolerExpected.java index 229ad60..20ae4e0 100644 --- a/src/dumpProcessing/CoolerExpected.java +++ b/src/main/java/plop/dumpProcessing/CoolerExpected.java @@ -1,4 +1,4 @@ -package dumpProcessing; +package plop.dumpProcessing; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/dumpProcessing/HicDumpInter.java b/src/main/java/plop/dumpProcessing/HicDumpInter.java similarity index 99% rename from src/dumpProcessing/HicDumpInter.java rename to src/main/java/plop/dumpProcessing/HicDumpInter.java index 96ed752..2aab81a 100644 --- a/src/dumpProcessing/HicDumpInter.java +++ b/src/main/java/plop/dumpProcessing/HicDumpInter.java @@ -1,4 +1,4 @@ -package dumpProcessing; +package plop.dumpProcessing; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/dumpProcessing/HicDumpIntra.java b/src/main/java/plop/dumpProcessing/HicDumpIntra.java similarity index 99% rename from src/dumpProcessing/HicDumpIntra.java rename to src/main/java/plop/dumpProcessing/HicDumpIntra.java index 3f5531d..2986956 100644 --- a/src/dumpProcessing/HicDumpIntra.java +++ b/src/main/java/plop/dumpProcessing/HicDumpIntra.java @@ -1,4 +1,4 @@ -package dumpProcessing; +package plop.dumpProcessing; import java.io.BufferedReader; import java.io.BufferedWriter; diff --git a/src/gui/GuiAnalysis.java b/src/main/java/plop/gui/GuiAnalysis.java similarity index 98% rename from src/gui/GuiAnalysis.java rename to src/main/java/plop/gui/GuiAnalysis.java index e559df4..dfee24b 100644 --- a/src/gui/GuiAnalysis.java +++ b/src/main/java/plop/gui/GuiAnalysis.java @@ -1,4 +1,4 @@ -package gui; +package plop.gui; import java.awt.Color; import java.awt.Container; import java.awt.Cursor; @@ -126,7 +126,7 @@ public class GuiAnalysis extends JFrame{ /** - * gui main + * java.plop.gui main * * @param args */ @@ -548,7 +548,7 @@ GridBagConstraints.NONE,new Insets(242, 230, 0, 0), 0, 0 label = new JLabel(); - label.setText("Type of loops (inter or intra chromosomal):"); + label.setText("Type of java.plop.loops (inter or intra chromosomal):"); label.setFont(new java.awt.Font("arial",1,12)); this._container.add(label, new GridBagConstraints( 0, 2, 0, 0, 0.0, 0.0, GridBagConstraints.NORTHWEST, @@ -656,7 +656,7 @@ public double getMax(){ } /** - * getter of the nb of zero allow around a detected loops + * getter of the nb of zero allow around a detected java.plop.loops * @return int nb of zero */ public int getNbZero(){ @@ -721,7 +721,7 @@ public double getGaussian(){ } /** - * size of the diag, all the loops detected inside this size will be removed + * size of the diag, all the java.plop.loops detected inside this size will be removed * @return int diag size */ public int getDiagSize(){ @@ -767,7 +767,7 @@ public int getDiagSize(){ public String getCooler(){ return this._jtfCooler.getText();} /** - * boolean if true start was pushed else keep the gui active + * boolean if true start was pushed else keep the java.plop.gui active * @return */ public boolean isStart(){ return this._start;} @@ -966,7 +966,7 @@ private void changeCool(){ } /** - * manage the access of the different gui element on function of the paramter choose + * manage the access of the different java.plop.gui element on function of the paramter choose */ public void actionPerformed(ActionEvent actionEvent){ if (_gui.isHic()) { @@ -995,7 +995,7 @@ class StartListener implements ActionListener { */ public StartListener (GuiAnalysis gui){ _gui = gui; } /** - * Test all the box, condition etc before to allow the program to run and dispose the gui + * Test all the box, condition etc before to allow the program to run and dispose the java.plop.gui */ public void actionPerformed(ActionEvent actionEvent){ if (_jtfWorkDir.getText().isEmpty() || _jtfRawData.getText().isEmpty() || _gui._jtfChrSize.getText().isEmpty()){ @@ -1044,7 +1044,7 @@ class QuitListener implements ActionListener { */ public QuitListener (GuiAnalysis gui){ _gui = gui; } /** - * dipose the gui and quit the program + * dipose the java.plop.gui and quit the program */ public void actionPerformed(ActionEvent actionEvent){ _gui.dispose(); diff --git a/src/gui/Progress.java b/src/main/java/plop/gui/Progress.java similarity index 90% rename from src/gui/Progress.java rename to src/main/java/plop/gui/Progress.java index 9ee3db4..4ca67d5 100644 --- a/src/gui/Progress.java +++ b/src/main/java/plop/gui/Progress.java @@ -1,4 +1,4 @@ -package gui; +package plop.gui; import java.awt.BorderLayout; import javax.swing.JFrame; @@ -37,5 +37,5 @@ public Progress(String title, int nbChromo){ * * @param args */ - public static void main(String[] args){ new Progress("test", 22);} + public static void main(String[] args){ new Progress("java/plop/test", 22);} } \ No newline at end of file diff --git a/src/loops/CallLoops.java b/src/main/java/plop/loops/CallLoops.java similarity index 91% rename from src/loops/CallLoops.java rename to src/main/java/plop/loops/CallLoops.java index c62af78..a391489 100644 --- a/src/loops/CallLoops.java +++ b/src/main/java/plop/loops/CallLoops.java @@ -1,4 +1,4 @@ -package loops; +package plop.loops; import java.io.File; import java.io.IOException; @@ -9,11 +9,11 @@ import ij.io.FileSaver; import inra.ijpb.morphology.Morphology; import inra.ijpb.morphology.Strel; -import sip.SIPIntra; -import utils.*; +import plop.sip.SIPIntra; +import plop.utils.*; /** - * Class with all the methods to call the reginal maxima in the images and filter and write the output loops file list + * Class with all the methods to call the reginal maxima in the images and filter and write the output java.plop.loops file list * * @author axel poulet * @@ -36,7 +36,7 @@ public class CallLoops { private double _thresholdMaxima; /** Diage size to removed maxima close to diagonal*/ private int _diagSize; - /** Size of the step to process each chr (step = matrixSize/2)*/ + /** Size of the step to java.plop.process each chr (step = matrixSize/2)*/ private int _step; /** Number of pixel = 0 allowed around the loop*/ private int _nbZero = -1; @@ -71,9 +71,9 @@ public CallLoops(SIPIntra sip){ } /** - * Detect loops methods - * detect the loops at two different resolution, initial resolution + 2 fold bigger - * call the loops first in the smaller resolution + * Detect java.plop.loops methods + * detect the java.plop.loops at two different resolution, initial resolution + 2 fold bigger + * call the java.plop.loops first in the smaller resolution * then making image with bigger resolution and fill no Zero list * faire un gros for deguelasse por passer les faceteur de grossissement seulement si listDefacteur > 1. * make and save image at two differents resolution (m_resolution and m_resolution*2) @@ -120,7 +120,7 @@ public HashMap detectLoops(File[] fileList, String chr,HashMap Loop Object + * @throws IOException exception + */ + public HashMap detectLoops(File[] fileList, String chrName1, String chrName2){ + CoordinatesCorrection coord = new CoordinatesCorrection(); + //System.out.println(outdir+" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + listOfFiles.length); + HashMap hLoop = new HashMap<> (); + for (int i = 0; i col = computeSumCol(img); + ArrayList row = computeSumRow(img); + + ImagePlus imageDiff = imgDiff(img,imgPath); + FindMaxima findMaxima = new FindMaxima( imageDiff, chrName1,chrName2, _noiseTolerance, _resolution,_gaussian,_nbZero); + HashMap temp = findMaxima.findLoopInter(imgPath); + filterLoop(col,row,temp); + PeakAnalysisScore pas = new PeakAnalysisScore(img,temp); + pas.computeScore(); + coord.setData(hLoop); + coord.imageToGenomeCoordinate(temp,name[name.length-1]); + hLoop = coord.getData(); + //System.out.println(hLoop.size()+" temp "+ temp.size()); + } + } + return hLoop; + } + + /** + * Create and save the diff image. + * for each pixel compute the new value computing the average subtraction between the pixel of interest and all + * pixel inside the neighbor 3 + * + * @param imagePlusInput imagePlus raw + * @param pathFile path to the imagePlus raw + * @return the diff ImagePlus + */ + private ImagePlus imgDiff(ImagePlus imagePlusInput, String pathFile){ + + ImageProcessor ip = imagePlusInput.getProcessor(); + + + + FloatProcessor ipDiff = new FloatProcessor(ip.getWidth(), ip.getHeight()); + + int nbPixel = 48; + int x = 3; + + for(int i = 0; i < ip.getWidth(); ++i){ + for(int j = 0; j < ip.getHeight(); ++j){ + float sum = 0; + float valueA = ip.getf(i, j); + if (Double.isNaN(ip.getf(i, j))) valueA = 0; + for (int ii = i - x; ii < i + x; ++ii) { + for (int jj = j - x; jj < j + x; ++jj) { + if ((i != ii || j != jj) && ii >= 0 && jj >= 0 && ii < ip.getWidth() && jj < ip.getHeight()) { + float valueB = ip.getf(ii, jj); + if (Double.isNaN(ip.getf(ii, jj))) valueB = 0; + sum = sum + (valueA - valueB); + } + } + }ipDiff.setf(i,j,sum/nbPixel); + } + } + + ImagePlus img = new ImagePlus(); + img.setProcessor(ipDiff); + + pathFile = pathFile.replace(".tif","_diff.tif"); + saveFile(img, pathFile); + return img; + + } + + private void filterLoop(ArrayList col , ArrayList row, HashMap temp) { + + double threshLowCol = this.computeAvg(col) - this.computeStdDev(col, this.computeAvg(col)) * 1.5; + double threshHighCol = this.computeAvg(col) + this.computeStdDev(col, this.computeAvg(col)); + double threshLowRow = this.computeAvg(row) - this.computeStdDev(row, this.computeAvg(row)) * 1.5; + double threshHighRow = this.computeAvg(row) + this.computeStdDev(row, this.computeAvg(row)); + System.out.println( threshLowCol + "\t" + threshHighCol + "\t" + threshLowRow + "\t" + threshHighRow); + Set arrayKey = temp.keySet(); + Iterator it = arrayKey .iterator(); + + while (it.hasNext()) { + String key = it.next(); + Loop loop = temp.get(key); + int i = loop.getX(); + int j = loop.getY(); + if (col.get(i) > threshLowCol && col.get(i) < threshHighCol && row.get(j) > threshLowRow && row.get(j) < threshHighRow) { + } + } + } + + /** + * + * @param plop + * @return + */ + private double computeAvg(ArrayList plop){ + double sum = 0; + for(int i = 0; i < plop.size(); ++i){ + sum = sum + plop.get(i); + } + return sum/plop.size(); + } + + + /** + * + * @param plop + * @param avg + * @return + */ + private double computeStdDev(ArrayList plop, double avg){ + double sum = 0; + for(int i = 0; i < plop.size(); ++i){ + sum = sum + (plop.get(i)-avg)*(plop.get(i)-avg); + } + return Math.sqrt(sum/plop.size()); + } + + + /** + * + * @param + * @return + */ + ArrayList computeSumRow(ImagePlus img){ + ImageProcessor ip = img.getProcessor(); + ArrayList plop = new ArrayList<>(); + for(int i = 0; i < ip.getHeight(); ++i) { + double sum = 0; + for (int j = 0; j < ip.getWidth(); ++j) { + double valueA = ip.getf(j, i); + if (Double.isNaN(ip.getf(j, i))) valueA = 0; + sum = sum + valueA ; + } + plop.add(sum); + } + return plop; + } + + /** + * + * @param + * @return + */ + ArrayList computeSumCol(ImagePlus img){ + ImageProcessor ip = img.getProcessor(); + ArrayList plop = new ArrayList<>(); + for(int i = 0; i < ip.getWidth(); ++i) { + double sum = 0; + for (int j = 0; j < ip.getHeight(); ++j) { + double valueA = ip.getf(i, j); + if (Double.isNaN(ip.getf(i, j))) valueA = 0; + sum = sum + valueA ; + } + plop.add(sum); + } + return plop; + } + + /** + * Save the image file + * + * @param imagePlusInput image to save + * @param pathFile path to save the image + */ + private void saveFile ( ImagePlus imagePlusInput, String pathFile){ + FileSaver fileSaver = new FileSaver(imagePlusInput); + fileSaver.saveAsTiff(pathFile); + } + + +} diff --git a/src/loops/FilterLoops.java b/src/main/java/plop/loops/FilterLoops.java similarity index 91% rename from src/loops/FilterLoops.java rename to src/main/java/plop/loops/FilterLoops.java index 9d639d7..f83f9d6 100644 --- a/src/loops/FilterLoops.java +++ b/src/main/java/plop/loops/FilterLoops.java @@ -1,4 +1,4 @@ -package loops; +package plop.loops; import java.util.ArrayList; import java.util.HashMap; @@ -6,12 +6,12 @@ import java.util.Set; /** - * Method to filter the loops close to white strip or loops which don't reach the different threshold filter + * Method to filter the java.plop.loops close to white strip or java.plop.loops which don't reach the different threshold filter * @author axel poulet * */ public class FilterLoops { - /** loops resoluiton*/ + /** java.plop.loops resoluiton*/ private int _resolution; @@ -25,7 +25,7 @@ public FilterLoops(int resolution){ /** - * Remove loops which doesn't respect the rule + * Remove java.plop.loops which doesn't respect the rule * * @param input loop collection before correction * @return loop collection after correction @@ -53,8 +53,8 @@ public HashMap removedBadLoops(HashMap input){ /** * Removed loop close to white strip * - * @param hLoop loop collection before correction of the loops - * @return loop collection sfter correction of the loops + * @param hLoop loop collection before correction of the java.plop.loops + * @return loop collection sfter correction of the java.plop.loops */ public HashMap removedLoopCloseToWhiteStrip(HashMap hLoop, HashMap normVector){ //System.out.println("plop "+hLoop.size()+" debut Filter"); @@ -119,8 +119,8 @@ public HashMap removedLoopCloseToWhiteStrip(HashMap hL /** * Removed loop close to white strip * - * @param hLoop loop collection before correction of the loops - * @return loop collection sfter correction of the loops + * @param hLoop loop collection before correction of the java.plop.loops + * @return loop collection sfter correction of the java.plop.loops */ public HashMap removedLoopCloseToWhiteStrip(HashMap hLoop){ //System.out.println("plop "+hLoop.size()+" debut Filter"); @@ -176,8 +176,8 @@ public HashMap removedLoopCloseToWhiteStrip(HashMap hL return hLoop; } /** - * Removed loops close to biased HiC signal - * @param loop Loop to test + * Removed java.plop.loops close to biased HiC signal + * @param loop Loop to java.plop.test * @return boolean true if loop have to be removed else false */ private boolean removedVectoNorm(Loop loop, HashMap normVector){ @@ -212,8 +212,8 @@ else if(loop.getResolution() == this._resolution*5){ /** - * Remove overlapping loops - * @param loop loop to test + * Remove overlapping java.plop.loops + * @param loop loop to java.plop.test * @param input loop collection * @param removed arrayList of loop * @return removed arrayList of loop diff --git a/src/loops/Loop.java b/src/main/java/plop/loops/Loop.java similarity index 95% rename from src/loops/Loop.java rename to src/main/java/plop/loops/Loop.java index a274fe9..7592cba 100644 --- a/src/loops/Loop.java +++ b/src/main/java/plop/loops/Loop.java @@ -1,9 +1,9 @@ -package loops; +package plop.loops; import java.util.ArrayList; /** - * Class making loops object with its coordinate, value, and parameters + * Class making java.plop.loops object with its coordinate, value, and parameters * * @author axel poulet * @@ -13,7 +13,7 @@ public class Loop { private String _chr =""; /** chromosome name.*/ private String _chr2 =""; - /** loops name: chr start end value.*/ + /** java.plop.loops name: chr start end value.*/ private String _name; /** x coordinate.*/ private int _x; @@ -31,18 +31,18 @@ public class Loop { private int _xEnd; /** y coordinate+resolution.*/ private int _yEnd; - /** value of the avg of the diff between loops value and the neighbourhood 8.*/ + /** value of the avg of the diff between java.plop.loops value and the neighbourhood 8.*/ private float _neigbhoord1 = -1; - /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of loops.*/ + /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of java.plop.loops.*/ private float _paScoreAvg = -1; private float _paScoreAvgdev = -1; - /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of loops.*/ + /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of java.plop.loops.*/ private float _paScoreMed = -1; - /** value of the avg of the differential between loops value and the neighbourhood 24.*/ + /** value of the avg of the differential between java.plop.loops value and the neighbourhood 24.*/ private float _neigbhoord2 = -1; - /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of loops.*/ + /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of java.plop.loops.*/ private float _regPaScoreMed = -1; - /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of loops.*/ + /** value of the peak analysis value inspirate from Rao&Huntley et al., 2014, but the score is compute foreach loop and not for a set of java.plop.loops.*/ private float _regPaScoreAvg = -1; /** Average value of the neighbourhood 9.*/ private float _avg = -1; @@ -218,7 +218,7 @@ public Loop(String name, int x, int y, String chr, String chr2, float avg, float public int getY(){ return this._y; } /** - * Setter of the y loops coordinate's + * Setter of the y java.plop.loops coordinate's * @param y int loop coordinate's */ public void setY(int y){ this._y = y; } diff --git a/src/multiProcesing/ProcessDetectLoops.java b/src/main/java/plop/multiProcessing/ProcessDetectLoops.java similarity index 80% rename from src/multiProcesing/ProcessDetectLoops.java rename to src/main/java/plop/multiProcessing/ProcessDetectLoops.java index e2aedf6..f5e8ac9 100644 --- a/src/multiProcesing/ProcessDetectLoops.java +++ b/src/main/java/plop/multiProcessing/ProcessDetectLoops.java @@ -1,12 +1,12 @@ -package multiProcesing; +package plop.multiProcessing; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import gui.Progress; -import sip.SIPInter; -import sip.SIPIntra; +import plop.gui.Progress; +import plop.sip.SIPInter; +import plop.sip.SIPIntra; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; @@ -22,7 +22,7 @@ */ public class ProcessDetectLoops{ - /** progress bar if gui is true*/ + /** progress bar if java.plop.gui is true*/ private Progress _p; /** */ @@ -41,7 +41,7 @@ public void go(SIPIntra sip, String resuFile, String resName) throws Interrupte ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sip.getCpu()); Iterator chrName = sip.getChrSizeHashMap().keySet().iterator(); if(sip.isProcessed()) { - boolean isCool = isProcessedMcool(sip.getOutputDir()+resName+File.separator+"normVector"); + boolean isCool = isProcessedMcool(sip.getInputDir()+resName+File.separator+"normVector"); //System.out.println(isCool); sip.setIsCooler(isCool); } @@ -52,10 +52,10 @@ public void go(SIPIntra sip, String resuFile, String resName) throws Interrupte executor.execute(task); }else { - String normFile = sip.getOutputDir()+resName+File.separator+"normVector"+File.separator+chr+".norm"; - if (sip.isProcessed()){ - normFile = sip.getInputDir()+resName+File.separator+"normVector"+File.separator+chr+".norm"; - } + String normFile = sip.getInputDir()+resName+File.separator+"normVector"+File.separator+chr+".norm"; + /*if (java.plop.sip.isProcessed()){ + normFile = java.plop.sip.getInputDir()+resName+File.separator+"normVector"+File.separator+chr+".norm"; + }*/ RunnableDetectIntraLoops task = new RunnableDetectIntraLoops(chr, resuFile, sip,normFile); executor.execute(task); } @@ -77,7 +77,7 @@ public void go(SIPIntra sip, String resuFile, String resName) throws Interrupte } /** - * multiprocessing for sip on inter-chromosomal interaction + * multiprocessing for java.plop.sip on inter-chromosomal interaction * for each couple of chromosome, RunnableDetectInterLoop is call. * @param sipInter SIPInter object * @param resuFile path to results file @@ -87,8 +87,11 @@ public void go(SIPInter sipInter, String resuFile) throws InterruptedException { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sipInter.getCpu()); HashMap chrSize = sipInter.getChrSizeHashMap(); ArrayList chrName = sipInter.getChrList(); - System.out.println(sipInter.getOutputDir()); - File outDir = new File(sipInter.getOutputDir()); + + File outDir = new File(sipInter.getInputDir()); + System.out.println("dans pdl.go out "+sipInter.getOutputDir()); + System.out.println("dans pdl.go in "+sipInter.getInputDir()); + if (!outDir.exists()) outDir.mkdir(); for(int i = 0; i < chrName.size();++i){ String chr1 = chrName.get(i); @@ -120,7 +123,7 @@ public void go(SIPInter sipInter, String resuFile) throws InterruptedException { } /** * - * @param dirToTest path to test if it is existing + * @param dirToTest path to java.plop.test if it is existing * @return boolean */ private boolean isProcessedMcool(String dirToTest) { diff --git a/src/multiProcesing/ProcessDumpCooler.java b/src/main/java/plop/multiProcessing/ProcessDumpCooler.java similarity index 92% rename from src/multiProcesing/ProcessDumpCooler.java rename to src/main/java/plop/multiProcessing/ProcessDumpCooler.java index 7486050..599f75c 100644 --- a/src/multiProcesing/ProcessDumpCooler.java +++ b/src/main/java/plop/multiProcessing/ProcessDumpCooler.java @@ -1,4 +1,4 @@ -package multiProcesing; +package plop.multiProcessing; import java.io.BufferedWriter; import java.io.File; @@ -11,12 +11,12 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import dumpProcessing.CoolerDumpIntra; -import dumpProcessing.CoolerDumpInter; -import gui.Progress; -import dumpProcessing.CoolerExpected; -import sip.SIPInter; -import sip.SIPIntra; +import plop.dumpProcessing.CoolerDumpIntra; +import plop.dumpProcessing.CoolerDumpInter; +import plop.gui.Progress; +import plop.dumpProcessing.CoolerExpected; +import plop.sip.SIPInter; +import plop.sip.SIPIntra; /** * multi thread class dumping the data via juicertoolsbox.jar @@ -27,7 +27,7 @@ */ public class ProcessDumpCooler { - /** progress bar if gui is true*/ + /** progress bar if java.plop.gui is true*/ private Progress _p; /** @@ -38,9 +38,9 @@ public ProcessDumpCooler(){ } /** * run the processing on different cpu, if all cpu are running, take break else run a new one. *for each chromosome the normalized data and expected data will be dump via cooler and cooltool. - * the SIP are produce in this step allowing later, the creation of the images and the loops calling step. + * the SIP are produce in this step allowing later, the creation of the images and the java.plop.loops calling step. * - * if gui is true a progress bar will pop up. + * if java.plop.gui is true a progress bar will pop up. * * * @param coolTools String coolTools path diff --git a/src/multiProcesing/ProcessDumpHic.java b/src/main/java/plop/multiProcessing/ProcessDumpHic.java similarity index 88% rename from src/multiProcesing/ProcessDumpHic.java rename to src/main/java/plop/multiProcessing/ProcessDumpHic.java index 16e4b95..1b8479b 100644 --- a/src/multiProcesing/ProcessDumpHic.java +++ b/src/main/java/plop/multiProcessing/ProcessDumpHic.java @@ -1,4 +1,4 @@ -package multiProcesing; +package plop.multiProcessing; import java.io.BufferedWriter; import java.io.File; @@ -11,11 +11,11 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import dumpProcessing.HicDumpIntra; -import dumpProcessing.HicDumpInter; -import gui.Progress; -import sip.SIPInter; -import sip.SIPIntra; +import plop.dumpProcessing.HicDumpIntra; +import plop.dumpProcessing.HicDumpInter; +import plop.gui.Progress; +import plop.sip.SIPInter; +import plop.sip.SIPIntra; /** @@ -27,7 +27,7 @@ * */ public class ProcessDumpHic { - /** progress bar if gui is true*/ + /** progress bar if java.plop.gui is true*/ private Progress _p; /** @@ -36,7 +36,7 @@ public class ProcessDumpHic { public ProcessDumpHic(){ } /** - * run SiP for intra chr loops + * run SiP for intra chr java.plop.loops * * @param hicFile Sting input file path * @param sip SIPIntra with all the paramters needed @@ -48,12 +48,12 @@ public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJu HashMap chrSize = sip.getChrSizeHashMap(); ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(sip.getCpu()); Iterator chrName = chrSize.keySet().iterator(); - File outDir = new File(sip.getOutputDir()); + File outDir = new File(sip.getInputDir()); if (!outDir.exists()) outDir.mkdir(); while(chrName.hasNext()){ String chr = chrName.next(); HicDumpIntra dumpData = new HicDumpIntra(juiceBoxTools, hicFile, normJuiceBox); - RunnableDumpHicIntra task = new RunnableDumpHicIntra(sip.getOutputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); + RunnableDumpHicIntra task = new RunnableDumpHicIntra(sip.getInputDir(), chr, chrSize.get(chr), dumpData, sip.getResolution(), sip.getMatrixSize(), sip.getStep(), sip.getListFactor()); executor.execute(task); } executor.shutdown(); @@ -73,7 +73,7 @@ public void go(String hicFile, SIPIntra sip, String juiceBoxTools, String normJu } /** - * run SiP for inter chr loops + * run SiP for inter chr java.plop.loops * * @param hicFile Sting input file path * @param sipInter SIPInter object with all the parameters needed @@ -100,7 +100,7 @@ public void go(String hicFile, SIPInter sipInter, String juiceBoxTools, String n int size2 = chrSize.get(chr2); System.out.println(chr1+"\t"+size1+"\t"+chr2+"\t"+size2); HicDumpInter DumpInterChromosomal = new HicDumpInter(juiceBoxTools, hicFile, normJuiceBox); - RunnableDumpHicInter task = new RunnableDumpHicInter(sipInter.getOutputDir(), chr1, chrSize.get(chr1), + RunnableDumpHicInter task = new RunnableDumpHicInter(sipInter.getInputDir(), chr1, chrSize.get(chr1), chr2, chrSize.get(chr2),DumpInterChromosomal, sipInter.getResolution(), sipInter.getMatrixSize()); executor.execute(task); } diff --git a/src/multiProcesing/RunnableDetectInterLoops.java b/src/main/java/plop/multiProcessing/RunnableDetectInterLoops.java similarity index 80% rename from src/multiProcesing/RunnableDetectInterLoops.java rename to src/main/java/plop/multiProcessing/RunnableDetectInterLoops.java index e5e18b9..89a1e12 100644 --- a/src/multiProcesing/RunnableDetectInterLoops.java +++ b/src/main/java/plop/multiProcessing/RunnableDetectInterLoops.java @@ -1,8 +1,8 @@ -package multiProcesing; +package plop.multiProcessing; -import loops.CallLoopsInter; -import loops.Loop; -import sip.SIPInter; +import plop.loops.CallLoopsInter; +import plop.loops.Loop; +import plop.sip.SIPInter; import java.io.File; @@ -10,12 +10,12 @@ import java.util.HashMap; /** - * runnable class for inter loops detection + * runnable class for inter java.plop.loops detection * */ public class RunnableDetectInterLoops extends Thread implements Runnable { - /*** SIP object containing all the parameter for the loops detection */ + /*** SIP object containing all the parameter for the java.plop.loops detection */ private SIPInter _sipInter; /** CallLoops object */ private CallLoopsInter _callLoopsInter; @@ -47,18 +47,24 @@ public RunnableDetectInterLoops(String chr1, String chr2, String resuFile, SIPIn /** - * Run all the process for loops detection by chr using the objet CallLoops and then save loops in + * Run all the java.plop.process for java.plop.loops detection by chr using the objet CallLoops and then save java.plop.loops in * txt file with SIPIntra via he method saveFile */ public void run() { String resName = String.valueOf(this._sipInter.getResolution()); resName = resName.replace("000", "")+"kb"; - String dir = this._sipInter.getOutputDir()+resName+File.separator+_chr1+"_"+_chr2+File.separator; + String dir = this._sipInter.getInputDir()+resName+File.separator+_chr1+"_"+_chr2+File.separator; HashMap data; if (this._sipInter.isProcessed()) dir = this._sipInter.getInputDir()+resName+File.separator+_chr1+"_"+_chr2+File.separator; try { File folder = new File(dir); + File[] listOfFiles = folder.listFiles(); + if(folder.exists()){ + System.out.println("yupyup !!!"+dir); + }else{ + System.out.println("yupyup !!!"+folder.toString()); + } System.out.println(dir+" "+listOfFiles.length); if (listOfFiles.length == 0) System.out.println("!!!!!!!!!! dumped directory of chromosome"+this._chr1+"_"+_chr2+"empty"); else{ diff --git a/src/multiProcesing/RunnableDetectIntraLoops.java b/src/main/java/plop/multiProcessing/RunnableDetectIntraLoops.java similarity index 89% rename from src/multiProcesing/RunnableDetectIntraLoops.java rename to src/main/java/plop/multiProcessing/RunnableDetectIntraLoops.java index 26d5420..4fbbec6 100644 --- a/src/multiProcesing/RunnableDetectIntraLoops.java +++ b/src/main/java/plop/multiProcessing/RunnableDetectIntraLoops.java @@ -1,19 +1,20 @@ -package multiProcesing; -import loops.CallLoops; -import sip.SIPIntra; -import loops.Loop; +package plop.multiProcessing; + +import plop.loops.CallLoops; +import plop.sip.SIPIntra; +import plop.loops.Loop; import java.io.File; import java.io.IOException; import java.util.HashMap; /** - * Runnable class for loops detection + * Runnable class for java.plop.loops detection * * @author axel poulet * */ public class RunnableDetectIntraLoops extends Thread implements Runnable{ - /** SIP object containing all the parameter for the loops detection*/ + /** SIP object containing all the parameter for the java.plop.loops detection*/ private SIPIntra _sip; /** CallLoops object */ private CallLoops _callLoops; @@ -63,7 +64,7 @@ public RunnableDetectIntraLoops(String chr, String resuFile, SIPIntra sip){ } /** - * Run all the process for loops detection by chr using the objet CallLoops and then save loops in + * Run all the java.plop.process for java.plop.loops detection by chr using the objet CallLoops and then save java.plop.loops in * txt file with SIPIntra via he method saveFile * */ diff --git a/src/multiProcesing/RunnableDumpCoolerInter.java b/src/main/java/plop/multiProcessing/RunnableDumpCoolerInter.java similarity index 97% rename from src/multiProcesing/RunnableDumpCoolerInter.java rename to src/main/java/plop/multiProcessing/RunnableDumpCoolerInter.java index c8a774d..e44a00b 100644 --- a/src/multiProcesing/RunnableDumpCoolerInter.java +++ b/src/main/java/plop/multiProcessing/RunnableDumpCoolerInter.java @@ -1,11 +1,9 @@ -package multiProcesing; +package plop.multiProcessing; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import dumpProcessing.CoolerDumpInter; -import dumpProcessing.CoolerExpected; +import plop.dumpProcessing.CoolerDumpInter; /** * diff --git a/src/multiProcesing/RunnableDumpCoolerIntra.java b/src/main/java/plop/multiProcessing/RunnableDumpCoolerIntra.java similarity index 97% rename from src/multiProcesing/RunnableDumpCoolerIntra.java rename to src/main/java/plop/multiProcessing/RunnableDumpCoolerIntra.java index b0447d4..b957291 100644 --- a/src/multiProcesing/RunnableDumpCoolerIntra.java +++ b/src/main/java/plop/multiProcessing/RunnableDumpCoolerIntra.java @@ -1,11 +1,11 @@ -package multiProcesing; +package plop.multiProcessing; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import dumpProcessing.CoolerDumpIntra; -import dumpProcessing.CoolerExpected; +import plop.dumpProcessing.CoolerDumpIntra; +import plop.dumpProcessing.CoolerExpected; /** * diff --git a/src/multiProcesing/RunnableDumpHicInter.java b/src/main/java/plop/multiProcessing/RunnableDumpHicInter.java similarity index 94% rename from src/multiProcesing/RunnableDumpHicInter.java rename to src/main/java/plop/multiProcessing/RunnableDumpHicInter.java index f23d002..b3528c3 100644 --- a/src/multiProcesing/RunnableDumpHicInter.java +++ b/src/main/java/plop/multiProcessing/RunnableDumpHicInter.java @@ -1,6 +1,6 @@ -package multiProcesing; +package plop.multiProcessing; -import dumpProcessing.HicDumpInter; +import plop.dumpProcessing.HicDumpInter; import java.io.File; import java.io.IOException; @@ -65,7 +65,8 @@ public void run(){ if (!file.exists()) file.mkdirs(); step = step*_resolution; - System.out.println("start dump "+_chr1+" size "+_sizeChr1+" "+_chr2+" size "+_sizeChr2+" res "+ nameRes); + + System.out.println(file.toString()+" "+file.exists()+" start dump "+_chr1+" size "+_sizeChr1+" "+_chr2+" size "+_sizeChr2+" res "+ nameRes); int endChr1 = _matrixSize*_resolution; if(endChr1 > _sizeChr1) endChr1 = _sizeChr1; try { @@ -76,7 +77,7 @@ public void run(){ String dump1 = _chr1+":"+startChr1+":"+end1; for(int startChr2 = 0 ; endChr2-1 <= _sizeChr2; startChr2+=step,endChr2+=step) { int end2 =endChr2-1; - String dump2 = _chr2+":"+startChr2+"-"+end2; + String dump2 = _chr2+":"+startChr2+":"+end2; String name = outdir + _chr1 +"_" + startChr1 + "_" + end1 +"_" +_chr2 +"_" + startChr2 + "_" + end2 + ".txt"; _dumpInter.dumpObserved(dump1, dump2, name, _resolution); if (endChr2 + step > _sizeChr2 && endChr2 < _sizeChr2) { diff --git a/src/multiProcesing/RunnableDumpHicIntra.java b/src/main/java/plop/multiProcessing/RunnableDumpHicIntra.java similarity index 98% rename from src/multiProcesing/RunnableDumpHicIntra.java rename to src/main/java/plop/multiProcessing/RunnableDumpHicIntra.java index 73e48ac..ce72986 100644 --- a/src/multiProcesing/RunnableDumpHicIntra.java +++ b/src/main/java/plop/multiProcessing/RunnableDumpHicIntra.java @@ -1,5 +1,5 @@ -package multiProcesing; -import dumpProcessing.HicDumpIntra; +package plop.multiProcessing; +import plop.dumpProcessing.HicDumpIntra; import java.io.File; import java.io.IOException; diff --git a/src/process/Cool.java b/src/main/java/plop/process/Cool.java similarity index 96% rename from src/process/Cool.java rename to src/main/java/plop/process/Cool.java index 9b93e44..b752637 100644 --- a/src/process/Cool.java +++ b/src/main/java/plop/process/Cool.java @@ -1,15 +1,14 @@ -package process; +package plop.process; -import cli.CLIOptionCool; -import cli.CLIOptionHiC; -import gui.GuiAnalysis; -import multiProcesing.ProcessDumpCooler; -import multiProcesing.ProcessDetectLoops; +import plop.cli.CLIOptionCool; +import plop.gui.GuiAnalysis; +import plop.multiProcessing.ProcessDumpCooler; +import plop.multiProcessing.ProcessDetectLoops; import org.apache.commons.cli.CommandLine; -import sip.SIPInter; -import sip.SIPIntra; -import utils.MultiResProcess; +import plop.sip.SIPInter; +import plop.sip.SIPIntra; +import plop.utils.MultiResProcess; import java.io.BufferedWriter; import java.io.File; @@ -215,7 +214,7 @@ private String runInter() throws IOException, InterruptedException { System.out.println("########### Starting loop detection"); detectLoops.go(_sipInter, loopFileRes); - System.out.println("########### !!!!!!! end loops detection"); + System.out.println("########### !!!!!!! end java.plop.loops detection"); return "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ "cooler: "+ _cooler +"\n"+ "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ diff --git a/src/process/HiC.java b/src/main/java/plop/process/HiC.java similarity index 96% rename from src/process/HiC.java rename to src/main/java/plop/process/HiC.java index 45d84b4..ec4cbd3 100644 --- a/src/process/HiC.java +++ b/src/main/java/plop/process/HiC.java @@ -1,15 +1,15 @@ -package process; +package plop.process; -import cli.CLIHelper; -import cli.CLIOptionHiC; -import gui.GuiAnalysis; -import multiProcesing.ProcessDetectLoops; -import multiProcesing.ProcessDumpHic; +import plop.cli.CLIHelper; +import plop.cli.CLIOptionHiC; +import plop.gui.GuiAnalysis; +import plop.multiProcessing.ProcessDetectLoops; +import plop.multiProcessing.ProcessDumpHic; import org.apache.commons.cli.CommandLine; -import sip.SIPInter; -import sip.SIPIntra; -import utils.MultiResProcess; +import plop.sip.SIPInter; +import plop.sip.SIPIntra; +import plop.utils.MultiResProcess; import java.io.BufferedWriter; import java.io.File; @@ -188,7 +188,7 @@ private String runInter() throws IOException, InterruptedException { System.out.println("########### Starting loop detection"); detectLoops.go(_sipInter, loopFileRes); - System.out.println("########### !!!!!!! end loops detection"); + System.out.println("########### !!!!!!! end java.plop.loops detection"); return "SIPHiC hic: \n" + "input: "+_input+"\n" + "output: "+_output+"\n"+ "juiceBox: "+ _juicerTool +"\n"+ "norm: "+ _juicerNorm +"\n" + "inter or intra chromosomal: "+ _interOrIntra +"\n" + "gauss: "+this._sipInter.getGauss()+"\n"+ "matrix size: "+this._sipInter.getMatrixSize()+"\n"+ diff --git a/src/process/ParametersCheck.java b/src/main/java/plop/process/ParametersCheck.java similarity index 97% rename from src/process/ParametersCheck.java rename to src/main/java/plop/process/ParametersCheck.java index e4b331b..9c82d9e 100644 --- a/src/process/ParametersCheck.java +++ b/src/main/java/plop/process/ParametersCheck.java @@ -1,9 +1,9 @@ -package process; +package plop.process; -import cli.CLIHelper; -import sip.SIPIntra; -import sip.SIPObject; +import plop.cli.CLIHelper; +import plop.sip.SIPIntra; +import plop.sip.SIPObject; import java.io.*; @@ -109,8 +109,8 @@ public void optionalParametersValidity(SIPObject sip) throws IOException { } if(sip.getThresholdMaxima() < 0 ){ - System.out.println("\nParameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); - _logwWriter.write("\nParameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for loops detection need to be a > 0 !!! \n\n"); + System.out.println("\nParameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for java.plop.loops detection need to be a > 0 !!! \n\n"); + _logwWriter.write("\nParameter value error !!!!\n-t "+sip.getThresholdMaxima()+", threshold for java.plop.loops detection need to be a > 0 !!! \n\n"); _logwWriter.close(); CLIHelper.getHelperInfos(); } diff --git a/src/process/Processed.java b/src/main/java/plop/process/Processed.java similarity index 96% rename from src/process/Processed.java rename to src/main/java/plop/process/Processed.java index 1618c24..37336fc 100644 --- a/src/process/Processed.java +++ b/src/main/java/plop/process/Processed.java @@ -1,13 +1,13 @@ -package process; +package plop.process; -import cli.CLIOptionProcessed; -import gui.GuiAnalysis; -import multiProcesing.ProcessDetectLoops; +import plop.cli.CLIOptionProcessed; +import plop.gui.GuiAnalysis; +import plop.multiProcessing.ProcessDetectLoops; import org.apache.commons.cli.CommandLine; -import sip.SIPInter; -import sip.SIPIntra; -import utils.MultiResProcess; +import plop.sip.SIPInter; +import plop.sip.SIPIntra; +import plop.utils.MultiResProcess; import java.io.BufferedWriter; import java.io.File; @@ -242,9 +242,9 @@ private void setSipInter() { }else{ double gauss = 1; int matrixSize = 500; - double thresholdMax = 0.9; + double thresholdMax = 0.01; double fdr = 0.025; - int resolution = 100000; + int resolution = 1000000; int nbZero = 3; if (_cmd.hasOption("gaussian")) gauss = Double.parseDouble(_cmd.getOptionValue("gaussian")); if (_cmd.hasOption("matrixSize")) matrixSize = Integer.parseInt(_cmd.getOptionValue("matrixSize")); diff --git a/src/sip/SIPInter.java b/src/main/java/plop/sip/SIPInter.java similarity index 89% rename from src/sip/SIPInter.java rename to src/main/java/plop/sip/SIPInter.java index 27e96a2..9242d89 100644 --- a/src/sip/SIPInter.java +++ b/src/main/java/plop/sip/SIPInter.java @@ -1,7 +1,7 @@ -package sip; +package plop.sip; -import utils.FDR; -import loops.Loop; +import plop.utils.FDR; +import plop.loops.Loop; import java.io.*; import java.util.*; @@ -24,10 +24,10 @@ public class SIPInter extends SIPObject { * @param chrSize chr size path * @param gauss gaussian filter strength * @param resolution bins size - * @param thresholdMax threshold value for loops detection + * @param thresholdMax threshold value for java.plop.loops detection * @param matrixSize image size * @param nbZero nb of zero allowed around a loop - * @param fdr fdr value for the final loops filter + * @param fdr fdr value for the final java.plop.loops filter */ public SIPInter(String output,String chrSize, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero,double fdr, boolean delTif, int cpu) { @@ -43,10 +43,10 @@ public SIPInter(String output,String chrSize, double gauss, int resolution, dou * @param chrSize chr size path * @param gauss gaussian filter strength * @param resolution bins size - * @param thresholdMax threshold value for loops detection + * @param thresholdMax threshold value for java.plop.loops detection * @param matrixSize image size * @param nbZero nb of zero allowed around a loop - * @param fdr fdr value for the final loops filter + * @param fdr fdr value for the final java.plop.loops filter * @throws IOException exception */ public SIPInter(String input,String output,String chrSize, double gauss, int resolution, @@ -58,7 +58,7 @@ public SIPInter(String input,String output,String chrSize, double gauss, int res } /** - * Write detected loops after filtering via the fdr value + * Write detected java.plop.loops after filtering via the fdr value * @param pathFile path for the output file * @param hLoop hashmap loopsName => Loop object * @param first boolean if true it is the first results so need to write the header diff --git a/src/sip/SIPIntra.java b/src/main/java/plop/sip/SIPIntra.java similarity index 94% rename from src/sip/SIPIntra.java rename to src/main/java/plop/sip/SIPIntra.java index 8c43471..4f25e1c 100644 --- a/src/sip/SIPIntra.java +++ b/src/main/java/plop/sip/SIPIntra.java @@ -1,7 +1,7 @@ -package sip; +package plop.sip; -import utils.FDR; -import loops.Loop; +import plop.utils.FDR; +import plop.loops.Loop; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -38,7 +38,7 @@ public class SIPIntra extends SIPObject { private double _saturatedPixel; /** Diage size to removed maxima close to diagonal*/ private int _diagonalSize; - /** Size of the step to process each chr (step = matrixSize/2)*/ + /** Size of the step to java.plop.process each chr (step = matrixSize/2)*/ private int _step; /** list of the image resolution to find loop*/ private ArrayList _listFactor = new ArrayList(); @@ -69,9 +69,9 @@ public SIPIntra() { } * @param thresholdMax threshold for loop detection with findMaxima * @param diagonalSize size of the diagonal, where the value will be not use * @param matrixSize size of the image - * @param nbZero number of zero allowed around loops - * @param factor multi resolution calling loops used this list of factor - * @param fdr fdr value for final loops filtering + * @param nbZero number of zero allowed around java.plop.loops + * @param factor multi resolution calling java.plop.loops used this list of factor + * @param fdr fdr value for final java.plop.loops filtering * @param isDroso false if it isn't drosophila input */ public SIPIntra(String output, String chrFile, double gauss, double min, @@ -112,9 +112,9 @@ else if (_factor == 4) { * @param thresholdMax threshold for loop detection with findMaxima * @param diagonalSize size of the diagonal, where the value will be not use * @param matrixSize size of the image - * @param nbZero number of zero allowed around loops - * @param factor multi resolution calling loops used this list of factor - * @param fdr fdr value for final loops filtering + * @param nbZero number of zero allowed around java.plop.loops + * @param factor multi resolution calling java.plop.loops used this list of factor + * @param fdr fdr value for final java.plop.loops filtering */ public SIPIntra(String input, String output, String chrSize, double gauss, double min, double max, int resolution, double saturatedPixel, double thresholdMax, @@ -216,7 +216,7 @@ public void saveFile(String pathFile, HashMap data, boolean first) /** * Test the normalized vector by chromosome and return a hashMap with biased coordinate. - * if loops is detected around this region in theis hashMap the loop will be deleted + * if java.plop.loops is detected around this region in theis hashMap the loop will be deleted * * @param normFile normalized file */ @@ -244,9 +244,9 @@ public HashMap getNormValueFilter(String normFile){ /** - * compute median of pa score and regional pa score for a set of loops + * compute median of pa score and regional pa score for a set of java.plop.loops * - * @param data hashMap loops name=> Loop object + * @param data hashMap java.plop.loops name=> Loop object * @param fdrCutoff fdr cutoff */ private void median(HashMap data, double fdrCutoff){ diff --git a/src/sip/SIPObject.java b/src/main/java/plop/sip/SIPObject.java similarity index 96% rename from src/sip/SIPObject.java rename to src/main/java/plop/sip/SIPObject.java index 5dc7b5c..c3ecc21 100644 --- a/src/sip/SIPObject.java +++ b/src/main/java/plop/sip/SIPObject.java @@ -1,4 +1,4 @@ -package sip; +package plop.sip; import java.io.BufferedReader; @@ -37,7 +37,7 @@ public class SIPObject { private int _nbZero; /** is processed booelan*/ private boolean _isProcessed; - /** if is gui analysis*/ + /** if is java.plop.gui analysis*/ private boolean _isGui; /** if data set is mcool format*/ private boolean _isCooler; @@ -68,6 +68,7 @@ public SIPObject (String input, String output, double gauss, int resolution, dou if(!input.endsWith(File.separator)) input = input+File.separator; this._input = input; this._output = output; + System.out.println("dans SIPObject: "+output); this._gauss = gauss; this._resolution = resolution; this._thresholdMaxima = thresholdMax; @@ -93,7 +94,7 @@ public SIPObject (String input, String output, double gauss, int resolution, dou public SIPObject ( String output, double gauss, int resolution, double thresholdMax, int matrixSize, int nbZero, double fdr, String chrSizeFile, boolean delTif, int cpu){ if(!output.endsWith(File.separator)) output = output+File.separator; - this._output = output; + this._input = output; this._gauss = gauss; this._resolution = resolution; this._thresholdMaxima = thresholdMax; @@ -220,13 +221,13 @@ public SIPObject(){ /** * Getter of getNbZero - * @return int nb of zero allowed around the loops + * @return int nb of zero allowed around the java.plop.loops */ public int getNbZero(){ return this._nbZero;} /** * setter of nb of zero - * @param nbZero int nb of zero allowed around the loops + * @param nbZero int nb of zero allowed around the java.plop.loops */ public void setNbZero(int nbZero){ this._nbZero = nbZero;} diff --git a/src/sipMain/Hic_main.java b/src/main/java/plop/sipMain/Hic_main.java similarity index 67% rename from src/sipMain/Hic_main.java rename to src/main/java/plop/sipMain/Hic_main.java index 91b46bc..8723fc6 100644 --- a/src/sipMain/Hic_main.java +++ b/src/main/java/plop/sipMain/Hic_main.java @@ -1,13 +1,12 @@ -package sipMain; +package plop.sipMain; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; -import cli.CLIHelper; -import gui.GuiAnalysis; -import process.HiC; -import process.Cool; -import process.Processed; +import plop.cli.CLIHelper; +import plop.gui.GuiAnalysis; +import plop.process.HiC; +import plop.process.Cool; +import plop.process.Processed; /** * @@ -22,9 +21,9 @@ public class Hic_main { /** - * Main function to run all the process, can be run with gui or in command line. + * Main function to run all the java.plop.process, can be run with java.plop.gui or in command line. * With command line with 1 or less than 5 parameter => run only the help - * With zero parameter only java -jar SIP.jar => gui + * With zero parameter only java -jar SIP.jar => java.plop.gui * With more than 5 paramter => command line mode * * @param args table with parameters for command line @@ -34,8 +33,8 @@ public class Hic_main { public static void main(String[] args) throws IOException, InterruptedException { - //command line test: - // hic -i /home/plop/Desktop/SIP/GSE104333_Rao-2017-treated_6hr_combined_30.hic -o /home/plop/Desktop/test -j /home/plop/Tools/juicer_tools_1.19.02.jar -c /home/plop/Desktop/SIP/testSize.tab -lt intra + //command line java.plop.test: + // hic -i /home/plop/Desktop/SIP/GSE104333_Rao-2017-treated_6hr_combined_30.hic -o /home/plop/Desktop/java.plop.test -j /home/plop/Tools/juicer_tools_1.19.02.jar -c /home/plop/Desktop/SIP/testSize.tab -lt intra /*CLI */ if(args.length == 1) { CLIHelper.getHelperAllInfos(); @@ -99,31 +98,31 @@ public static void main(String[] args) throws IOException, InterruptedException /* - SIPIntra sip; + SIPIntra java.plop.sip; if(_isHic){ - sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, + java.plop.sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); - sip.setIsGui(_gui); + java.plop.sip.setIsGui(_gui); ProcessDumpHic processDumpData = new ProcessDumpHic(); - processDumpData.go(_input, sip, _juiceBoxTools, _juiceBoXNormalisation, _cpu); + processDumpData.go(_input, java.plop.sip, _juiceBoxTools, _juiceBoXNormalisation, _cpu); System.out.println("########### End of the dump Step"); }else if(_isCool){ - sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); - sip.setIsCooler(_isCool); + java.plop.sip = new SIPIntra(_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero, _factor,_fdr, _isProcessed,_isDroso); + java.plop.sip.setIsCooler(_isCool); ProcessDumpCooler processDumpData = new ProcessDumpCooler(); - processDumpData.go(_cooltools, _cooler, sip, _input, _cpu); + processDumpData.go(_cooltools, _cooler, java.plop.sip, _input, _cpu); }else{ - sip = new SIPIntra(_input,_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, + java.plop.sip = new SIPIntra(_input,_output, _chrSizeFile, _gauss, _min, _max, _resolution, _saturatedPixel, _thresholdMax, _diagSize, _matrixSize, _nbZero,_factor,_fdr); - sip.setIsDroso(_isDroso); - sip.setIsProcessed(_isProcessed); - sip.setIsGui(_gui); + java.plop.sip.setIsDroso(_isDroso); + java.plop.sip.setIsProcessed(_isProcessed); + java.plop.sip.setIsGui(_gui); } System.out.println("Start loop detction step"); - MultiResProcess multi = new MultiResProcess(sip, _cpu, _delImages,_chrSizeFile); + MultiResProcess multi = new MultiResProcess(java.plop.sip, _cpu, _delImages,_chrSizeFile); multi.run(); System.out.println("###########End loop detction step"); diff --git a/src/test/TestCallLoopsHicFile.java b/src/main/java/plop/test/TestCallLoopsHicFile.java similarity index 96% rename from src/test/TestCallLoopsHicFile.java rename to src/main/java/plop/test/TestCallLoopsHicFile.java index 9027158..e906fa2 100644 --- a/src/test/TestCallLoopsHicFile.java +++ b/src/main/java/plop/test/TestCallLoopsHicFile.java @@ -1,17 +1,19 @@ -package test; +package plop.test; + + import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import multiProcesing.ProcessDumpHic; -import utils.MultiResProcess; -import sip.SIPIntra; +import plop.multiProcessing.ProcessDumpHic; +import plop.utils.MultiResProcess; +import plop.sip.SIPIntra; /** - * Test loops calling on Hic file + * Test java.plop.loops calling on Hic file * * @author Axel Poulet * diff --git a/src/test/TestCallLoopsProcessedFile.java b/src/main/java/plop/test/TestCallLoopsProcessedFile.java similarity index 87% rename from src/test/TestCallLoopsProcessedFile.java rename to src/main/java/plop/test/TestCallLoopsProcessedFile.java index 7ad9cb9..421065e 100644 --- a/src/test/TestCallLoopsProcessedFile.java +++ b/src/main/java/plop/test/TestCallLoopsProcessedFile.java @@ -1,12 +1,12 @@ -package test; +package main.java.plop.test; + import java.io.IOException; -import java.util.ArrayList; -import utils.MultiResProcess; -import sip.SIPIntra; +import plop.utils.MultiResProcess; +import plop.sip.SIPIntra; /** - * Test of calling loops on processed files + * Test of calling java.plop.loops on processed files * * @author Axel Poulet * @@ -59,8 +59,8 @@ public static void main(String[] args) throws IOException, InterruptedException MultiResProcess multi = new MultiResProcess(sip, chrSizeFile); multi.run(); //ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); - //processDetectloops.go(sip, 2,false); - //Testpb plop = new Testpb(sip, true); + //processDetectloops.go(java.plop.sip, 2,false); + //Testpb plop = new Testpb(java.plop.sip, true); //plop.run(2); System.out.println("End"); } diff --git a/src/test/TestCoolFormat.java b/src/main/java/plop/test/TestCoolFormat.java similarity index 84% rename from src/test/TestCoolFormat.java rename to src/main/java/plop/test/TestCoolFormat.java index c893d97..dede103 100644 --- a/src/test/TestCoolFormat.java +++ b/src/main/java/plop/test/TestCoolFormat.java @@ -1,15 +1,14 @@ -package test; +package plop.test; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; -import multiProcesing.ProcessDetectLoops; -import multiProcesing.ProcessDumpCooler; -import sip.SIPInter; -import utils.MultiResProcess; -import sip.SIPIntra; +import plop.multiProcessing.ProcessDetectLoops; +import plop.multiProcessing.ProcessDumpCooler; +import plop.sip.SIPInter; + @SuppressWarnings("unused") public class TestCoolFormat { @@ -45,7 +44,7 @@ public static void main(String[] args) throws IOException, InterruptedException boolean keepTif = true; int cpu = 1; - //SIPIntra sip = new SIPIntra(output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03,false,keepTif,cpu); + //SIPIntra java.plop.sip = new SIPIntra(output, chrSizeFile, gauss, min, max, resolution, saturatedPixel, thresholdMax, diagSize, matrixSize, nbZero,factor,0.03,false,keepTif,cpu); SIPInter sip = new SIPInter(output, chrSizeFile, gauss, resolution, thresholdMax, matrixSize, nbZero, fdr , true,2); sip.setIsGui(false); sip.setIsCooler(true); @@ -62,7 +61,7 @@ public static void main(String[] args) throws IOException, InterruptedException System.out.println("########### Starting loop detection"); detectLoops.go(sip, loopFileRes); - System.out.println("########### !!!!!!! end loops detection"); + System.out.println("########### !!!!!!! end java.plop.loops detection"); System.out.println("end"); diff --git a/src/test/TestGui.java b/src/main/java/plop/test/TestGui.java similarity index 90% rename from src/test/TestGui.java rename to src/main/java/plop/test/TestGui.java index 312d46e..7ccd0ee 100644 --- a/src/test/TestGui.java +++ b/src/main/java/plop/test/TestGui.java @@ -1,14 +1,14 @@ -package test; +package plop.test; import java.io.IOException; -import gui.GuiAnalysis; -import multiProcesing.ProcessDumpHic; -import sip.SIPIntra; +import plop.gui.GuiAnalysis; +import plop.multiProcessing.ProcessDumpHic; +import plop.sip.SIPIntra; /** - * test of the GUI + * java.plop.test of the GUI * * @author Axel Poulet * @@ -28,7 +28,7 @@ public static void main(String[] args) throws IOException, InterruptedException{ catch (InterruptedException e) {e.printStackTrace();} } if (gui.isStart()){ - System.out.println("test"); + System.out.println("java/plop/test"); String output = gui.getOutputDir(); String input = gui.getInput(); int matrixSize = gui.getMatrixSize(); @@ -73,7 +73,7 @@ public static void main(String[] args) throws IOException, InterruptedException{ } //ProcessDetectLoops processDetectloops = new ProcessDetectLoops(); - //processDetectloops.go(sip, gui.getNbCpu(),gui.isDeletTif()); + //processDetectloops.go(java.plop.sip, java.plop.gui.getNbCpu(),java.plop.gui.isDeletTif()); } } diff --git a/src/test/TestInter.java b/src/main/java/plop/test/TestInter.java similarity index 56% rename from src/test/TestInter.java rename to src/main/java/plop/test/TestInter.java index 2b8cbf4..fed1329 100644 --- a/src/test/TestInter.java +++ b/src/main/java/plop/test/TestInter.java @@ -1,7 +1,8 @@ -package test; +package plop.test; -import multiProcesing.ProcessDetectLoops; -import sip.SIPInter; + +import plop.multiProcessing.ProcessDetectLoops; +import plop.sip.SIPInter; import java.io.IOException; import java.util.ArrayList; @@ -14,26 +15,29 @@ public static void main(String[] args) throws IOException, InterruptedException //String chr = "chr21"; // hic -i SIP/GSE104333_Rao-2017-treated_6hr_combined_30.hic -c SIP/testSize.tab -o /home/plop/Desktop/interTreatedP -j /home/plop/Tools/juicer_tools_1.19.02.jar -lt inter -cpu 2 -r 50000 -ms 500 //processed -i /home/plop/Desktop/interTreatedP/ -c /home/plop/Desktop/SIP/testSize.tab -o /home/plop/Desktop/re -lt inter -cpu 2 -r 50000 -ms 500 -t 0.001 --nbZero 6 -k -fdr 1 -g 1 - String input = "/home/plop/Desktop/testInter/"; + //String input = "/home/plop/Desktop/testInter/"; + String input = "/home/plop/Desktop/SIP/hicData/4DNFILIM6FDL.hic"; String output = "/home/plop/Desktop/testInter/"; - String fileChr = "/home/plop/Desktop/SIP/testSize.tab"; + String fileChr = "/home/plop/Desktop/SIP/hg38_small.size"; String juicerTools = "/home/plop/Tools/juicer_tools_1.19.02.jar"; int resolution = 100000; int matrixSize = 500; double gauss = 1; - int nbZero = 6; - double thresholdMax = 0.9; - + int nbZero = 3; + double thresholdMax = 0.6; + double fdr =0.025; - boolean keepTif = true; + boolean delTif = false; int cpu = 2; - SIPInter sipInter = new SIPInter(input, output, fileChr, gauss, resolution, thresholdMax, matrixSize, nbZero,0.025,keepTif,cpu); - //ProcessDumpHic process = new ProcessDumpHic(); - //process.go(input,sipInter,chrsize,juicerTools,norm,2); + SIPInter sipInter = new SIPInter(output, fileChr, gauss, resolution, thresholdMax, matrixSize, nbZero,fdr,delTif,cpu); + //ProcessDumpHic java.plop.process = new ProcessDumpHic(); + //java.plop.process.go(input,sipInter,juicerTools,"KR"); + System.out.println("dans Test out : "+sipInter.getOutputDir()); + System.out.println("dans Test in : "+sipInter.getInputDir()); ProcessDetectLoops detectLoops = new ProcessDetectLoops(); - detectLoops.go(sipInter, "/home/plop/Desktop/testInter/loops.txt"); + detectLoops.go(sipInter, "/home/plop/Desktop/testInter/loopsBis.txt"); System.out.println("end"); diff --git a/src/test/TestMergeLoops.java b/src/main/java/plop/test/TestMergeLoops.java similarity index 99% rename from src/test/TestMergeLoops.java rename to src/main/java/plop/test/TestMergeLoops.java index eb4408e..a40709d 100644 --- a/src/test/TestMergeLoops.java +++ b/src/main/java/plop/test/TestMergeLoops.java @@ -1,4 +1,4 @@ -package test; +package plop.test; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -13,7 +13,7 @@ import java.util.Set; import java.util.stream.Collectors; -import loops.Loop; +import plop.loops.Loop; public class TestMergeLoops { diff --git a/src/utils/CoordinatesCorrection.java b/src/main/java/plop/utils/CoordinatesCorrection.java similarity index 89% rename from src/utils/CoordinatesCorrection.java rename to src/main/java/plop/utils/CoordinatesCorrection.java index eb5630b..29b583a 100644 --- a/src/utils/CoordinatesCorrection.java +++ b/src/main/java/plop/utils/CoordinatesCorrection.java @@ -1,6 +1,6 @@ -package utils; +package plop.utils; -import loops.Loop; +import plop.loops.Loop; import java.util.HashMap; import java.util.Iterator; @@ -10,14 +10,14 @@ * Class to change the image coordinate in genome coordinate, with the name of the image, the resolution, the size of the image, * the step and the size of the diagonal. * - * Loops detected with white strips are removed. Furthermore the corner of the images are not take account. We test also the proximal loops to avoid overlaping loops. + * Loops detected with white strips are removed. Furthermore the corner of the images are not take account. We java.plop.test also the proximal java.plop.loops to avoid overlaping java.plop.loops. * * @author axel poulet * */ public class CoordinatesCorrection { - /** HashMap of the loops with new coordinates*/ + /** HashMap of the java.plop.loops with new coordinates*/ private HashMap _data = new HashMap(); /** @@ -28,7 +28,7 @@ public CoordinatesCorrection(){ } /** * change loop image coordinates in loop genomes coordinates, * - * @param temp: HashMap of loops with the image coordinates + * @param temp: HashMap of java.plop.loops with the image coordinates * @param index: index of the image * @return HashMap: key is a string with the name of the chr start end. And value is Loop class, to stock * the loop characteristics. @@ -106,13 +106,13 @@ public HashMap imageToGenomeCoordinate(HashMap temp, S } /** * getter of m_data - * @return HashMap of loops + * @return HashMap of java.plop.loops */ public HashMap getData(){ return this._data;} /** * setter of m_data - * @param data setter loops hashMAp + * @param data setter java.plop.loops hashMAp */ public void setData(HashMap data){ this._data = data;} } \ No newline at end of file diff --git a/src/utils/DecayAnalysis.java b/src/main/java/plop/utils/DecayAnalysis.java similarity index 99% rename from src/utils/DecayAnalysis.java rename to src/main/java/plop/utils/DecayAnalysis.java index c933891..3300580 100644 --- a/src/utils/DecayAnalysis.java +++ b/src/main/java/plop/utils/DecayAnalysis.java @@ -1,4 +1,4 @@ -package utils; +package plop.utils; import ij.ImagePlus; import ij.process.ImageProcessor; diff --git a/src/utils/FDR.java b/src/main/java/plop/utils/FDR.java similarity index 93% rename from src/utils/FDR.java rename to src/main/java/plop/utils/FDR.java index 3af2610..58c8cf7 100644 --- a/src/utils/FDR.java +++ b/src/main/java/plop/utils/FDR.java @@ -1,6 +1,6 @@ -package utils; +package plop.utils; -import loops.Loop; +import plop.loops.Loop; import java.util.ArrayList; import java.util.Collections; @@ -11,7 +11,7 @@ /** * - * Compute the cut off for AP and Regional AP score for loops gave in input + * Compute the cut off for AP and Regional AP score for java.plop.loops gave in input * * @author axel poulet and m. jordan rowley * @@ -29,7 +29,7 @@ public class FDR { /** * Constructor * @param fdr fdr value use to compute the two cutoff - * @param data loops data + * @param data java.plop.loops data */ public FDR(double fdr,HashMap data){ this._fdr = fdr; diff --git a/src/utils/FindMaxima.java b/src/main/java/plop/utils/FindMaxima.java similarity index 93% rename from src/utils/FindMaxima.java rename to src/main/java/plop/utils/FindMaxima.java index 0894fee..a10f868 100644 --- a/src/utils/FindMaxima.java +++ b/src/main/java/plop/utils/FindMaxima.java @@ -1,4 +1,4 @@ -package utils; +package plop.utils; import java.util.ArrayList; import java.util.HashMap; @@ -10,9 +10,7 @@ import ij.plugin.filter.MaximumFinder; import ij.process.ByteProcessor; import ij.process.ImageProcessor; -import loops.Loop; - -import static java.lang.System.out; +import plop.loops.Loop; /** * Detection of regional maxima in image. Return the HashMap, the loop can be corrected. @@ -86,9 +84,9 @@ public FindMaxima( ImagePlus imgDiff, String chr1,String chr2, double thresholdM /** * findLoop for intra chromosomal interaction * call ImageJ findMaxima method - * filter loops with low value in oMe image and normalize image - * if the loops didn't possess a decay => suppress - * Loop correction: => avoid overlapping loops, correct also the coordinate if higher value pixel is in the loops + * filter java.plop.loops with low value in oMe image and normalize image + * if the java.plop.loops didn't possess a decay => suppress + * Loop correction: => avoid overlapping java.plop.loops, correct also the coordinate if higher value pixel is in the java.plop.loops * neighbor * * @param index image index @@ -134,9 +132,9 @@ public HashMap findLoop(int index, int nbZero, ImagePlus raw, floa /** * findLoop for inter chromosomal interaction * call ImageJ findMaxima method - * filter loops with more than the nb of zero allowed in its neighbor - * if the loops didn't possess a decay => suppress - * Loop correction: correct also the coordinate if higher value pixel is in the loops + * filter java.plop.loops with more than the nb of zero allowed in its neighbor + * if the java.plop.loops didn't possess a decay => suppress + * Loop correction: correct also the coordinate if higher value pixel is in the java.plop.loops * neighbor * @param pathRaw path to the raw image * @return HashMap loop loop name => Loop object @@ -181,7 +179,7 @@ public HashMap findLoopInter(String pathRaw){ /** * Detect maxima with the oMe or observed methods, call the different methods * to detect the maxima and correct them. - * @param nbZero nb zero allowed around the loops + * @param nbZero nb zero allowed around the java.plop.loops * @param rawImage ImagePlus raw image * @param backgroundValue background value of the image */ @@ -410,10 +408,10 @@ private float standardDeviation(int x, int y, double avg){ /** * Removed maxima surrounded by several pixel with the 0 value. * The method search the pixel with value 0 in the 24 neighbourhood around the initial maxima. - * for the oMe method if the loops is suurounded by more than 6 0 the loops will be removed. For observed the thsreshold is smaller, 3. - * ig the loops is closed too the diagonal the test is less stringent 7 for oMe methods and 4 for observed method. + * for the oMe method if the java.plop.loops is suurounded by more than 6 0 the java.plop.loops will be removed. For observed the thsreshold is smaller, 3. + * ig the java.plop.loops is closed too the diagonal the java.plop.test is less stringent 7 for oMe methods and 4 for observed method. * - * @param nbZero nb zero allowed around the loops + * @param nbZero nb zero allowed around the java.plop.loops * @param rawImage ImagePlus raw image * @param val background value of the image */ diff --git a/src/utils/ImageProcessingMethod.java b/src/main/java/plop/utils/ImageProcessingMethod.java similarity index 97% rename from src/utils/ImageProcessingMethod.java rename to src/main/java/plop/utils/ImageProcessingMethod.java index bd1ee88..9d2953a 100644 --- a/src/utils/ImageProcessingMethod.java +++ b/src/main/java/plop/utils/ImageProcessingMethod.java @@ -1,4 +1,4 @@ -package utils; +package plop.utils; import ij.ImagePlus; import ij.plugin.ContrastEnhancer; @@ -7,7 +7,7 @@ import ij.process.ImageProcessor; /** - * Method of image pre-processing before call maxima, to enhance the loops and reduce the noise + * Method of image pre-processing before call maxima, to enhance the java.plop.loops and reduce the noise * This class is using the ImageJ methode for the different filters (min, max, gaussian). * * @author axel poulet diff --git a/src/utils/MultiResProcess.java b/src/main/java/plop/utils/MultiResProcess.java similarity index 92% rename from src/utils/MultiResProcess.java rename to src/main/java/plop/utils/MultiResProcess.java index 4fc81d2..e1514e1 100644 --- a/src/utils/MultiResProcess.java +++ b/src/main/java/plop/utils/MultiResProcess.java @@ -1,4 +1,4 @@ -package utils; +package plop.utils; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -13,13 +13,11 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.swing.JOptionPane; - -import cli.CLIHelper; -import multiProcesing.ProcessDetectLoops; -import loops.Loop; -import sip.SIPIntra; +import plop.cli.CLIHelper; +import plop.multiProcessing.ProcessDetectLoops; +import plop.loops.Loop; +import plop.sip.SIPIntra; /** * Class allowing the multi resolution loop calling @@ -49,7 +47,7 @@ public MultiResProcess(SIPIntra sip, String chrSizeFile) { /** * - * for each resolution used run the same process to otain the loop at the resolution of interest + * for each resolution used run the same java.plop.process to otain the loop at the resolution of interest * at each resolution the input parameters will be adapted to the resolution used * @throws InterruptedException exception * @throws IOException exception @@ -124,7 +122,7 @@ private SIPIntra setSIPIntraTmp(int factor){ /** - * test the data organization + * java.plop.test the data organization * @return boolean if yes the dir of interest is existing */ private boolean testDir(){ @@ -143,8 +141,8 @@ private boolean testDir(){ } /** - * merge loops from different resolution - * test if loops are present at different resolution if yes keep this one at smaller resolution + * merge java.plop.loops from different resolution + * java.plop.test if java.plop.loops are present at different resolution if yes keep this one at smaller resolution * * @param listOfFile list of of llops file * @throws IOException exception @@ -214,10 +212,10 @@ private void mergedFile(ArrayList listOfFile) throws IOException{ /** - * test if the loop is existing at other resolution, if yes keep it if it is the smaller reolution + * java.plop.test if the loop is existing at other resolution, if yes keep it if it is the smaller reolution * * @param loopHashMap hashmap loop name => Loop object - * @param loopOfInterest Loop to test + * @param loopOfInterest Loop to java.plop.test * @return boolean true or false */ private boolean compareLoop(HashMap loopHashMap, Loop loopOfInterest) { diff --git a/src/utils/PeakAnalysisScore.java b/src/main/java/plop/utils/PeakAnalysisScore.java similarity index 91% rename from src/utils/PeakAnalysisScore.java rename to src/main/java/plop/utils/PeakAnalysisScore.java index c95c6b4..093b797 100644 --- a/src/utils/PeakAnalysisScore.java +++ b/src/main/java/plop/utils/PeakAnalysisScore.java @@ -1,4 +1,4 @@ -package utils; +package plop.utils; import java.util.HashMap; import java.lang.Math; @@ -6,7 +6,7 @@ import java.util.Set; import ij.ImagePlus; import ij.process.ImageProcessor; -import loops.Loop; +import plop.loops.Loop; /** * Peak analysis score. @@ -17,7 +17,7 @@ public class PeakAnalysisScore { /** Raw image of the matrix*/ private ImagePlus _imgRaw = new ImagePlus(); - /** HashMap of object loops*/ + /** HashMap of object java.plop.loops*/ private HashMap _data = new HashMap(); /** ImageProcessor of the raw ImagePlus*/ private ImageProcessor _ipRaw; @@ -25,7 +25,7 @@ public class PeakAnalysisScore { /** * Constructor of PeakAnalysisScore * @param imgRaw ImagePlus raw image - * @param data HashMap of loops + * @param data HashMap of java.plop.loops */ public PeakAnalysisScore(ImagePlus imgRaw, HashMap data){ this._imgRaw = imgRaw; @@ -35,8 +35,8 @@ public PeakAnalysisScore(ImagePlus imgRaw, HashMap data){ /** - * Method to compute the score of each loop. on a 11*11 square, the average of the corner (3*3) are computed. then the ration between the loops value and this avg is computed. - * For the regional value, the avg of the n_8 value of the loops are done, then a ratio is computed with the avg value of the corner, + * Method to compute the score of each loop. on a 11*11 square, the average of the corner (3*3) are computed. then the ration between the java.plop.loops value and this avg is computed. + * For the regional value, the avg of the n_8 value of the java.plop.loops are done, then a ratio is computed with the avg value of the corner, * This method is used for the observed and oMe method. * */ @@ -125,7 +125,7 @@ private float process3By3SquareAvg(int x, int y){ int nb = 0; for(int i = x-1; i <= x+1; ++i){ for(int j = y-1; j <= y+1; ++j){ - if(i < this._ipRaw.getWidth() && i>0 && j < this._ipRaw.getWidth() && j > 0){ + if(i < this._ipRaw.getWidth() && i>0 && j < this._ipRaw.getHeight() && j > 0){ if( Double.isNaN(this._ipRaw.getf(i, j))){ sum += 0; }else{ diff --git a/src/utils/TupleFileToImage.java b/src/main/java/plop/utils/TupleFileToImage.java similarity index 90% rename from src/utils/TupleFileToImage.java rename to src/main/java/plop/utils/TupleFileToImage.java index eaebd38..c2bfe1b 100644 --- a/src/utils/TupleFileToImage.java +++ b/src/main/java/plop/utils/TupleFileToImage.java @@ -1,4 +1,4 @@ -package utils; +package plop.utils; import java.io.BufferedReader; import java.io.FileReader; @@ -28,7 +28,7 @@ public class TupleFileToImage { private int _size; /** Resolution of the image in base*/ private int _resolution; - /** Step to process the whole chromosme*/ + /** Step to java.plop.process the whole chromosme*/ private int _step ; /** number of pixe == 0 */ private int _noZeroPixel = 0; @@ -49,7 +49,7 @@ public TupleFileToImage(String fileMatrix, int size, int resolution){ /** - * Method to make the image with an input tuple file from intra chromosomal process + * Method to make the image with an input tuple file from intra chromosomal java.plop.process * */ public void readTupleFile(){ @@ -129,17 +129,25 @@ public void correctImage(ImagePlus img){ } /** - * Method to make the image with an input tuple file from inter chromosomal process + * Method to make the image with an input tuple file from inter chromosomal java.plop.process * @return ImagePlus */ public ImagePlus readTupleFileInter(){ ImagePlus img = new ImagePlus(); BufferedReader br; - FloatProcessor pRaw = new FloatProcessor(_size, _size); + String[] tfile = _file.split("_"); + //0 1 2 3 4 5 //4_0_191154275_6_0_171115066 - int numImageX = Integer.parseInt(tfile[tfile.length-5])/(_size*_resolution); - int numImageY = Integer.parseInt(tfile[tfile.length-2])/(_size*_resolution); + int size = tfile.length; + + int numImageX = Integer.parseInt(tfile[size-5])/(_size*_resolution); + int numImageY = Integer.parseInt(tfile[size-2])/(_size*_resolution); + int x = (((Integer.parseInt(tfile[size-4])-Integer.parseInt(tfile[size-5])))/_resolution)+1; + tfile[size-1] = tfile[size-1].replace(".txt",""); + int y = (((Integer.parseInt(tfile[size-1])-Integer.parseInt(tfile[size-2])))/_resolution)+1; + System.out.println(_file+" "+x+" "+y); + FloatProcessor pRaw = new FloatProcessor(x, y); try { pRaw.abs(); br = new BufferedReader(new FileReader(_file)); @@ -159,7 +167,7 @@ public ImagePlus readTupleFileInter(){ int correctionY = numImageY*_size*_resolution; int i = (Integer.parseInt(parts[0]) - correctionX)/_resolution; int j = (Integer.parseInt(parts[1]) - correctionY)/_resolution; - if(i < _size && j< _size){ + if(i < x && j< y){ pRaw.setf(i, j, raw); } sb.append(System.lineSeparator()); @@ -176,7 +184,7 @@ public ImagePlus readTupleFileInter(){ } /** - * Method to make the image with an input tuple file from inter chromosomal process + * Method to make the image with an input tuple file from inter chromosomal java.plop.process * @return ImagePlus */ public ImagePlus readTupleFileInterCool(){ diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 075ae79..0000000 --- a/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: sipMain.Hic_main - From d574ab4c39fbaeb97d8fe656526190e6ce24aa58 Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Thu, 8 Apr 2021 10:56:27 -0400 Subject: [PATCH 26/27] chage pom.xml --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4fcf80b..731b3f9 100644 --- a/pom.xml +++ b/pom.xml @@ -190,10 +190,10 @@ - DesTristus - Tristan Dubos - tristan.duos33@gmail.com - iGReD + axpoulet + Axel Poulet + pouletaxel@gmail.comm + plop architect developer From e404fd3fe9606f6bdeff87978a6e084b1dabe73c Mon Sep 17 00:00:00 2001 From: PouletAxel Date: Fri, 9 Apr 2021 11:06:39 -0400 Subject: [PATCH 27/27] correct CLI helper --- src/main/java/plop/cli/CLIHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/plop/cli/CLIHelper.java b/src/main/java/plop/cli/CLIHelper.java index 9920fb3..425a15c 100644 --- a/src/main/java/plop/cli/CLIHelper.java +++ b/src/main/java/plop/cli/CLIHelper.java @@ -31,10 +31,10 @@ public static void main(String[] args){ * with example command line */ public static void CmdHelpHiC() { - String argument = "-i path/to/hicFile.hic -c path/to/chrSizeFile.txt -o path/to/output/folder -j path/to/juicerTool.jar -lt intra "; + String argument = "-i path/to/file.hic -c path/to/chrSizeFile.txt -o path/to/output/folder -j path/to/juicerTool.jar -lt intra "; String[] argv = argument.split(" "); CLIOptionHiC command = new CLIOptionHiC (argv); - String usage = _hic+argument+" [options]"; + String usage = _hic + argument + " [options]"; HelpFormatter formatter = new HelpFormatter(); System.out.println("\nHelp for "+_hic+"!!!!!!! \n"); @@ -48,7 +48,7 @@ public static void CmdHelpHiC() { * with example command line */ public static void CmdHelpCool() { - String argument = "-i path/to/hicFile.hic -c path/to/chrSizeFile.txt -o path/to/output/folder -cooltools path/to/cooltools -cooler path/to/cooler -lt intra "; + String argument = "-i path/to/file.mcool -c path/to/chrSizeFile.txt -o path/to/output/folder -cooltools path/to/cooltools -cooler path/to/cooler -lt intra "; String[] argv = argument.split(" "); CLIOptionCool command = new CLIOptionCool (argv); String usage = _cool+argument+" [options]"; @@ -64,7 +64,7 @@ public static void CmdHelpCool() { * with example command line */ public static void CmdHelpProcessed(){ - String argument = "-i SIP path/to/folder/SIPProcessedData -c path/to/chrSizeFile -o path/to/output/folder -lt intra "; + String argument = "-i path/to/folder/toSIP/ProcessedData -c path/to/chrSizeFile -o path/to/output/folder -lt intra "; String[] argv = argument.split(" "); CLIOptionProcessed command = new CLIOptionProcessed (argv); String usage = _processed+argument+" [options]";