Skip to content

Commit

Permalink
Merge pull request #12 from aidenlab/moshe_version
Browse files Browse the repository at this point in the history
latest SCALE version
  • Loading branch information
sa501428 authored Oct 10, 2022
2 parents 93df763 + e899693 commit 50e8191
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 143 deletions.
2 changes: 1 addition & 1 deletion src/hic/HiCGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @since 11/25/14
*/
public class HiCGlobals {
public static final String versionNum = "3.27.00";
public static final String versionNum = "3.30.00";
public static final int writingVersion = 9;
public static final int bufferSize = 2097152;
public static int MAX_PEARSON_ZOOM = 50000;
Expand Down
5 changes: 2 additions & 3 deletions src/hic/tools/utils/bigarray/BigContactArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import hic.HiCGlobals;
import hic.tools.utils.largelists.BigDoublesArray;
import hic.tools.utils.largelists.BigFloatsArray;
import hic.tools.utils.largelists.BigShortsArray;
import hic.tools.utils.largelists.BigIntsArray;
import hic.tools.utils.original.ExpectedValueCalculation;
import javastraw.reader.datastructures.ListOfFloatArrays;
import javastraw.reader.datastructures.ListOfIntArrays;
Expand Down Expand Up @@ -112,11 +112,10 @@ public BigFloatsArray parSparseMultiplyAcrossLists(BigFloatsArray vector, long v

@Override
public void clearIntraAndShiftInter() {
return;
}

@Override
public BigFloatsArray parSparseMultiplyAcrossLists(BigShortsArray vector, long vectorLength) {
public BigFloatsArray parSparseMultiplyAcrossLists(BigIntsArray vector, long vectorLength) {
final BigDoublesArray totalSumVector = new BigDoublesArray(vectorLength);

AtomicInteger index = new AtomicInteger(0);
Expand Down
4 changes: 2 additions & 2 deletions src/hic/tools/utils/bigarray/BigContactList.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package hic.tools.utils.bigarray;

import hic.tools.utils.largelists.BigFloatsArray;
import hic.tools.utils.largelists.BigShortsArray;
import hic.tools.utils.largelists.BigIntsArray;
import hic.tools.utils.original.ExpectedValueCalculation;
import javastraw.reader.datastructures.ListOfFloatArrays;
import javastraw.reader.datastructures.ListOfIntArrays;
Expand All @@ -45,7 +45,7 @@ public interface BigContactList {

ListOfIntArrays getNumNonZeroInRows();

BigFloatsArray parSparseMultiplyAcrossLists(BigShortsArray one, long matrixSize);
BigFloatsArray parSparseMultiplyAcrossLists(BigIntsArray one, long matrixSize);

BigFloatsArray parSparseMultiplyAcrossLists(BigFloatsArray one, long matrixSize);

Expand Down
4 changes: 2 additions & 2 deletions src/hic/tools/utils/bigarray/LocallySavedContacts.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import hic.HiCGlobals;
import hic.tools.utils.largelists.BigDoublesArray;
import hic.tools.utils.largelists.BigFloatsArray;
import hic.tools.utils.largelists.BigShortsArray;
import hic.tools.utils.largelists.BigIntsArray;
import hic.tools.utils.localtemps.BinRecordsReader;
import hic.tools.utils.localtemps.BinRecordsWriter;
import hic.tools.utils.original.ExpectedValueCalculation;
Expand Down Expand Up @@ -145,7 +145,7 @@ public BigFloatsArray parSparseMultiplyAcrossLists(BigFloatsArray vector, long v
}

@Override
public BigFloatsArray parSparseMultiplyAcrossLists(BigShortsArray vector, long vectorLength) {
public BigFloatsArray parSparseMultiplyAcrossLists(BigIntsArray vector, long vectorLength) {
final BigDoublesArray totalSumVector = new BigDoublesArray(vectorLength);

AtomicInteger index = new AtomicInteger(0);
Expand Down
4 changes: 2 additions & 2 deletions src/hic/tools/utils/bigarray/SparseMatrixTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import hic.tools.utils.largelists.BigDoublesArray;
import hic.tools.utils.largelists.BigFloatsArray;
import hic.tools.utils.largelists.BigShortsArray;
import hic.tools.utils.largelists.BigIntsArray;
import hic.tools.utils.original.ExpectedValueCalculation;
import javastraw.reader.datastructures.ListOfFloatArrays;

Expand All @@ -41,7 +41,7 @@ public static void matrixVectorMult(BigFloatsArray vector,
sumVector.addTo(y, counts * vector.get(x));
}

public static void matrixVectorMult(BigShortsArray vector,
public static void matrixVectorMult(BigIntsArray vector,
BigDoublesArray sumVector, int x, int y, float c) {
double counts = c;
if (x == y) {
Expand Down
34 changes: 17 additions & 17 deletions src/hic/tools/utils/largelists/BigDoublesArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class BigDoublesArray {

final long DEFAULT_LENGTH = BigShortsArray.DEFAULT_LENGTH;
final long DEFAULT_LENGTH = BigIntsArray.DEFAULT_LENGTH;
final long overallLength;
final List<double[]> internalList = new ArrayList<>();

Expand Down Expand Up @@ -137,7 +137,7 @@ private int getNumThreads() {
return Math.min(HiCGlobals.normThreads, internalList.size());
}

public static double parCalculateError(BigDoublesArray col, BigDoublesArray scale, BigShortsArray target, BigShortsArray bad) {
public static double parCalculateError(BigDoublesArray col, BigDoublesArray scale, BigIntsArray target, BigIntsArray bad) {
AtomicDouble atomicDouble = new AtomicDouble(0);
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(col.getNumThreads(), () -> {
Expand All @@ -146,8 +146,8 @@ public static double parCalculateError(BigDoublesArray col, BigDoublesArray scal
while (i < col.internalList.size()) {
double[] colA = col.internalList.get(i);
double[] scaleA = scale.internalList.get(i);
short[] targetA = target.internalList.get(i);
short[] badA = bad.internalList.get(i);
int[] targetA = target.internalList.get(i);
int[] badA = bad.internalList.get(i);

for (int z = 0; z < colA.length; z++) {
if (badA[z] == 1) continue;
Expand All @@ -168,13 +168,13 @@ public static double parCalculateError(BigDoublesArray col, BigDoublesArray scal
}

public static double calculateError90(BigDoublesArray col, BigDoublesArray scale,
BigShortsArray target, BigShortsArray bad) {
BigIntsArray target, BigIntsArray bad) {
DescriptiveStatistics stats = new DescriptiveStatistics();
for (int i = 0; i < col.internalList.size(); i++) {
double[] colA = col.internalList.get(i);
double[] scaleA = scale.internalList.get(i);
short[] targetA = target.internalList.get(i);
short[] badA = bad.internalList.get(i);
int[] targetA = target.internalList.get(i);
int[] badA = bad.internalList.get(i);

for (int z = 0; z < colA.length; z++) {
if (badA[z] == 1) continue;
Expand All @@ -186,7 +186,7 @@ public static double calculateError90(BigDoublesArray col, BigDoublesArray scale
}

public static double parCalculateConvergenceError(BigDoublesArray calculatedVectorB, BigDoublesArray current,
BigShortsArray bad) {
BigIntsArray bad) {
AtomicDouble atomicDouble = new AtomicDouble(0);
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(current.getNumThreads(), () -> {
Expand All @@ -196,7 +196,7 @@ public static double parCalculateConvergenceError(BigDoublesArray calculatedVect

double[] calcA = calculatedVectorB.internalList.get(i);
double[] currA = current.internalList.get(i);
short[] badA = bad.internalList.get(i);
int[] badA = bad.internalList.get(i);

for (int z = 0; z < calcA.length; z++) {
if (badA[z] == 1) continue;
Expand Down Expand Up @@ -224,8 +224,8 @@ public BigDoublesArray deepClone() {
return clone;
}

public BigShortsArray deepCovertedClone() {
BigShortsArray clone = new BigShortsArray(overallLength);
public BigIntsArray deepCovertedClone() {
BigIntsArray clone = new BigIntsArray(overallLength);
for (long p = 0; p < overallLength; p++) {
clone.set(p, (short) get(p));
}
Expand Down Expand Up @@ -261,13 +261,13 @@ public void parSetTo(BigDoublesArray srcArrays) {
});
}

public void parMultiplyByOneMinus(BigShortsArray array) {
public void parMultiplyByOneMinus(BigIntsArray array) {
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(getNumThreads(), () -> {
int i = index.getAndIncrement();
while (i < internalList.size()) {
double[] orig = internalList.get(i);
short[] arr = array.internalList.get(i);
int[] arr = array.internalList.get(i);
for (int p = 0; p < orig.length; p++) {
orig[p] *= (1 - arr[p]);
}
Expand All @@ -291,13 +291,13 @@ public void parMultiplyBy(BigDoublesArray dv) {
});
}

public void parSetToDivision(BigShortsArray num, BigDoublesArray denom) {
public void parSetToDivision(BigIntsArray num, BigDoublesArray denom) {
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(getNumThreads(), () -> {
int i = index.getAndIncrement();
while (i < internalList.size()) {
double[] orig = internalList.get(i);
short[] num1 = num.internalList.get(i);
int[] num1 = num.internalList.get(i);
double[] denom1 = denom.internalList.get(i);
for (int p = 0; p < orig.length; p++) {
orig[p] = num1[p] / denom1[p];
Expand All @@ -307,13 +307,13 @@ public void parSetToDivision(BigShortsArray num, BigDoublesArray denom) {
});
}

public void parScaleByRatio(BigShortsArray num, BigDoublesArray denom) {
public void parScaleByRatio(BigIntsArray num, BigDoublesArray denom) {
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(getNumThreads(), () -> {
int i = index.getAndIncrement();
while (i < internalList.size()) {
double[] orig = internalList.get(i);
short[] num1 = num.internalList.get(i);
int[] num1 = num.internalList.get(i);
double[] denom1 = denom.internalList.get(i);
for (int p = 0; p < orig.length; p++) {
orig[p] *= (num1[p] / denom1[p]);
Expand Down
30 changes: 15 additions & 15 deletions src/hic/tools/utils/largelists/BigFloatsArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class BigFloatsArray {

final long DEFAULT_LENGTH = BigShortsArray.DEFAULT_LENGTH;
final long DEFAULT_LENGTH = BigIntsArray.DEFAULT_LENGTH;
final long overallLength;
final List<float[]> internalList = new ArrayList<>();

Expand Down Expand Up @@ -128,7 +128,7 @@ public ListOfFloatArrays convertToRegular() {
return clone;
}

public static double parCalculateError(BigFloatsArray col, BigFloatsArray scale, BigShortsArray target, BigShortsArray bad) {
public static double parCalculateError(BigFloatsArray col, BigFloatsArray scale, BigIntsArray target, BigIntsArray bad) {
AtomicDouble atomicDouble = new AtomicDouble(0);
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(col.getNumThreads(), () -> {
Expand All @@ -137,8 +137,8 @@ public static double parCalculateError(BigFloatsArray col, BigFloatsArray scale,
while (i < col.internalList.size()) {
float[] colA = col.internalList.get(i);
float[] scaleA = scale.internalList.get(i);
short[] targetA = target.internalList.get(i);
short[] badA = bad.internalList.get(i);
int[] targetA = target.internalList.get(i);
int[] badA = bad.internalList.get(i);

for (int z = 0; z < colA.length; z++) {
if (badA[z] == 1) continue;
Expand All @@ -159,13 +159,13 @@ public static double parCalculateError(BigFloatsArray col, BigFloatsArray scale,
}

public static double calculateError90(BigFloatsArray col, BigFloatsArray scale,
BigShortsArray target, BigShortsArray bad) {
BigIntsArray target, BigIntsArray bad) {
DescriptiveStatistics stats = new DescriptiveStatistics();
for (int i = 0; i < col.internalList.size(); i++) {
float[] colA = col.internalList.get(i);
float[] scaleA = scale.internalList.get(i);
short[] targetA = target.internalList.get(i);
short[] badA = bad.internalList.get(i);
int[] targetA = target.internalList.get(i);
int[] badA = bad.internalList.get(i);

for (int z = 0; z < colA.length; z++) {
if (badA[z] == 1) continue;
Expand All @@ -178,7 +178,7 @@ public static double calculateError90(BigFloatsArray col, BigFloatsArray scale,


public static double parCalculateConvergenceError(BigFloatsArray calculatedVectorB, BigFloatsArray current,
BigShortsArray bad) {
BigIntsArray bad) {
AtomicDouble atomicDouble = new AtomicDouble(0);
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(current.getNumThreads(), () -> {
Expand All @@ -188,7 +188,7 @@ public static double parCalculateConvergenceError(BigFloatsArray calculatedVecto

float[] calcA = calculatedVectorB.internalList.get(i);
float[] currA = current.internalList.get(i);
short[] badA = bad.internalList.get(i);
int[] badA = bad.internalList.get(i);

for (int z = 0; z < calcA.length; z++) {
if (badA[z] == 1) continue;
Expand Down Expand Up @@ -238,13 +238,13 @@ public void parSetTo(BigFloatsArray srcArrays) {
});
}

public void parMultiplyByOneMinus(BigShortsArray array) {
public void parMultiplyByOneMinus(BigIntsArray array) {
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(getNumThreads(), () -> {
int i = index.getAndIncrement();
while (i < internalList.size()) {
float[] orig = internalList.get(i);
short[] arr = array.internalList.get(i);
int[] arr = array.internalList.get(i);
for (int p = 0; p < orig.length; p++) {
orig[p] *= (1 - arr[p]);
}
Expand All @@ -268,13 +268,13 @@ public void parMultiplyBy(BigFloatsArray dv) {
});
}

public void parSetToDivision(BigShortsArray num, BigFloatsArray denom) {
public void parSetToDivision(BigIntsArray num, BigFloatsArray denom) {
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(getNumThreads(), () -> {
int i = index.getAndIncrement();
while (i < internalList.size()) {
float[] orig = internalList.get(i);
short[] num1 = num.internalList.get(i);
int[] num1 = num.internalList.get(i);
float[] denom1 = denom.internalList.get(i);
for (int p = 0; p < orig.length; p++) {
orig[p] = num1[p] / denom1[p];
Expand All @@ -288,13 +288,13 @@ private int getNumThreads() {
return Math.min(HiCGlobals.normThreads, internalList.size());
}

public void parScaleByRatio(BigShortsArray num, BigFloatsArray denom) {
public void parScaleByRatio(BigIntsArray num, BigFloatsArray denom) {
AtomicInteger index = new AtomicInteger();
ParallelizationTools.launchParallelizedCode(getNumThreads(), () -> {
int i = index.getAndIncrement();
while (i < internalList.size()) {
float[] orig = internalList.get(i);
short[] num1 = num.internalList.get(i);
int[] num1 = num.internalList.get(i);
float[] denom1 = denom.internalList.get(i);
for (int p = 0; p < orig.length; p++) {
orig[p] *= (num1[p] / denom1[p]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@
/**
* can't use <T> because we need to instantiate the array, otherwise that would have been nice
*/
public class BigShortsArray {
public class BigIntsArray {

public static final int DEFAULT_LENGTH = 10000;
final long overallLength;
final List<short[]> internalList = new ArrayList<>();
final List<int[]> internalList = new ArrayList<>();

public BigShortsArray(long length) {
public BigIntsArray(long length) {
this.overallLength = length;
long tempLength = length;
while (tempLength > 0) {
if (tempLength < DEFAULT_LENGTH) {
internalList.add(new short[(int) tempLength]);
internalList.add(new int[(int) tempLength]);
break;
} else {
internalList.add(new short[DEFAULT_LENGTH]);
internalList.add(new int[DEFAULT_LENGTH]);
tempLength -= DEFAULT_LENGTH;
}
}
}

public BigShortsArray(long totSize, short defaultValue) {
public BigIntsArray(long totSize, short defaultValue) {
this(totSize);
for (short[] array : internalList) {
for (int[] array : internalList) {
Arrays.fill(array, defaultValue);
}
}
Expand Down Expand Up @@ -95,15 +95,15 @@ public BigFloatsArray deepConvertedClone() {
BigFloatsArray clone = new BigFloatsArray(overallLength);
for (int k = 0; k < internalList.size(); k++) {
float[] dest = clone.internalList.get(k);
short[] src = internalList.get(k);
int[] src = internalList.get(k);
for (int q = 0; q < dest.length; q++) {
dest[q] = src[q];
}
}
return clone;
}

public List<short[]> getValues() {
public List<int[]> getValues() {
return internalList;
}

Expand All @@ -112,7 +112,7 @@ public void parSetTo(BigFloatsArray srcArrays) {
ParallelizationTools.launchParallelizedCode(getNumThreads(), () -> {
int i = index.getAndIncrement();
while (i < internalList.size()) {
short[] dest = internalList.get(i);
int[] dest = internalList.get(i);
float[] src = srcArrays.internalList.get(i);
for (int z = 0; z < dest.length; z++) {
dest[z] = (short) src[z];
Expand All @@ -122,6 +122,14 @@ public void parSetTo(BigFloatsArray srcArrays) {
});
}

public BigIntsArray deepClone() {
BigIntsArray clone = new BigIntsArray(overallLength);
for (int k = 0; k < internalList.size(); k++) {
System.arraycopy(internalList.get(k), 0, clone.internalList.get(k), 0, internalList.get(k).length);
}
return clone;
}

private int getNumThreads() {
return Math.min(HiCGlobals.normThreads, internalList.size());
}
Expand Down
Loading

0 comments on commit 50e8191

Please sign in to comment.