Command line arguments working, need better documentation and error handling
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
TODO: Implement exponential distribution using inversion method - DONE
|
||||
TODO: Implement discrete frequency distributions using Vose's Alias Method
|
||||
*/
|
||||
|
||||
@@ -12,13 +13,15 @@ public class Plate {
|
||||
private double error;
|
||||
private Integer[] concentrations;
|
||||
private double stdDev;
|
||||
private double lambda;
|
||||
boolean exponential = false;
|
||||
|
||||
|
||||
public Plate (int size, double error, Integer[] concentrations, double stdDev) {
|
||||
public Plate (int size, double error, Integer[] concentrations) {
|
||||
this.size = size;
|
||||
this.error = error;
|
||||
this.concentrations = concentrations;
|
||||
this.stdDev = stdDev;
|
||||
//this.stdDev = stdDev;
|
||||
wells = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -28,7 +31,47 @@ public class Plate {
|
||||
this.size = wells.size();
|
||||
}
|
||||
|
||||
public void fillWells(String sourceFileName, List<Integer[]> cells) {
|
||||
public void fillWellsExponential(String sourceFileName, List<Integer[]> cells, double lambda){
|
||||
this.lambda = lambda;
|
||||
exponential = true;
|
||||
sourceFile = sourceFileName;
|
||||
int numSections = concentrations.length;
|
||||
int section = 0;
|
||||
double m;
|
||||
int n;
|
||||
int test=0;
|
||||
while (section < numSections){
|
||||
for (int i = 0; i < (size / numSections); i++) {
|
||||
List<Integer[]> well = new ArrayList<>();
|
||||
for (int j = 0; j < concentrations[section]; j++) {
|
||||
do {
|
||||
m = (Math.log10((1 - rand.nextDouble()))/(-lambda)) * Math.sqrt(cells.size());
|
||||
} while (m >= cells.size() || m < 0);
|
||||
n = (int) Math.floor(m);
|
||||
//n = Equations.getRandomNumber(0, cells.size());
|
||||
// was testing generating the cell sample file with exponential dist, then sampling flat here
|
||||
//that would be more realistic
|
||||
//But would mess up my
|
||||
if(n > test){
|
||||
test = n;
|
||||
}
|
||||
Integer[] cellToAdd = cells.get(n).clone();
|
||||
for(int k = 0; k < cellToAdd.length; k++){
|
||||
if(Math.abs(rand.nextDouble()) < error){//error applied to each peptide
|
||||
cellToAdd[k] = -1;
|
||||
}
|
||||
}
|
||||
well.add(cellToAdd);
|
||||
}
|
||||
wells.add(well);
|
||||
}
|
||||
section++;
|
||||
}
|
||||
System.out.println("Highest index: " +test);
|
||||
}
|
||||
|
||||
public void fillWells(String sourceFileName, List<Integer[]> cells, double stdDev) {
|
||||
this.stdDev = stdDev;
|
||||
sourceFile = sourceFileName;
|
||||
int numSections = concentrations.length;
|
||||
int section = 0;
|
||||
@@ -68,6 +111,10 @@ public class Plate {
|
||||
return stdDev;
|
||||
}
|
||||
|
||||
public boolean isExponential(){return exponential;}
|
||||
|
||||
public double getLambda(){return lambda;}
|
||||
|
||||
public double getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user