Refactor sequences to be strings instead of integers, to make simulating read errors easier
This commit is contained in:
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
public class CellFileReader {
|
||||
|
||||
private String filename;
|
||||
private List<Integer[]> distinctCells = new ArrayList<>();
|
||||
private List<String[]> distinctCells = new ArrayList<>();
|
||||
private Integer cdr1Freq;
|
||||
|
||||
public CellFileReader(String filename) {
|
||||
@@ -32,11 +32,11 @@ public class CellFileReader {
|
||||
CSVParser parser = new CSVParser(reader, cellFileFormat);
|
||||
){
|
||||
for(CSVRecord record: parser.getRecords()) {
|
||||
Integer[] cell = new Integer[4];
|
||||
cell[0] = Integer.valueOf(record.get("Alpha CDR3"));
|
||||
cell[1] = Integer.valueOf(record.get("Beta CDR3"));
|
||||
cell[2] = Integer.valueOf(record.get("Alpha CDR1"));
|
||||
cell[3] = Integer.valueOf(record.get("Beta CDR1"));
|
||||
String[] cell = new String[4];
|
||||
cell[0] = record.get("Alpha CDR3");
|
||||
cell[1] = record.get("Beta CDR3");
|
||||
cell[2] = record.get("Alpha CDR1");
|
||||
cell[3] = record.get("Beta CDR1");
|
||||
distinctCells.add(cell);
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ public class CellFileReader {
|
||||
}
|
||||
|
||||
//get CDR1 frequency
|
||||
ArrayList<Integer> cdr1Alphas = new ArrayList<>();
|
||||
for (Integer[] cell : distinctCells) {
|
||||
ArrayList<String> cdr1Alphas = new ArrayList<>();
|
||||
for (String[] cell : distinctCells) {
|
||||
cdr1Alphas.add(cell[3]);
|
||||
}
|
||||
double count = cdr1Alphas.stream().distinct().count();
|
||||
@@ -62,14 +62,4 @@ public class CellFileReader {
|
||||
}
|
||||
|
||||
public String getFilename() { return filename;}
|
||||
|
||||
//Refactor everything that uses this to have access to a Cell Sample and get the cells there instead.
|
||||
public List<Integer[]> getListOfDistinctCellsDEPRECATED(){
|
||||
return distinctCells;
|
||||
}
|
||||
|
||||
public Integer getCellCountDEPRECATED() {
|
||||
//Refactor everything that uses this to have access to a Cell Sample and get the count there instead.
|
||||
return distinctCells.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
public class CellFileWriter {
|
||||
|
||||
private String[] headers = {"Alpha CDR3", "Beta CDR3", "Alpha CDR1", "Beta CDR1"};
|
||||
List<Integer[]> cells;
|
||||
List<String[]> cells;
|
||||
String filename;
|
||||
Integer cdr1Freq;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CellFileWriter {
|
||||
printer.printComment("Sample contains 1 unique CDR1 for every " + cdr1Freq + "unique CDR3s.");
|
||||
printer.printRecords(cells);
|
||||
} catch(IOException ex){
|
||||
System.out.println("Could not make new file named "+filename);
|
||||
System.out.println("Could not make new file named " + filename);
|
||||
System.err.println(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class CellSample {
|
||||
|
||||
private List<Integer[]> cells;
|
||||
private List<String[]> cells;
|
||||
private Integer cdr1Freq;
|
||||
|
||||
public CellSample(Integer numDistinctCells, Integer cdr1Freq){
|
||||
@@ -24,28 +24,28 @@ public class CellSample {
|
||||
|
||||
//Each cell represented by 4 values
|
||||
//two CDR3s, and two CDR1s. First two values are CDR3s (alpha, beta), second two are CDR1s (alpha, beta)
|
||||
List<Integer[]> distinctCells = new ArrayList<>();
|
||||
List<String[]> distinctCells = new ArrayList<>();
|
||||
for(int i = 0; i < numbersCDR3.size() - 1; i = i + 2){
|
||||
//Go through entire CDR3 list once, make pairs of alphas and betas
|
||||
Integer tmpCDR3a = numbersCDR3.get(i);
|
||||
Integer tmpCDR3b = numbersCDR3.get(i+1);
|
||||
//Go through (likely shorter) CDR1 list as many times as necessary, make pairs of alphas and betas
|
||||
Integer tmpCDR1a = numbersCDR1.get(i % numbersCDR1.size());
|
||||
Integer tmpCDR1b = numbersCDR1.get((i+1) % numbersCDR1.size());
|
||||
String tmpCDR3a = numbersCDR3.get(i).toString();
|
||||
String tmpCDR3b = numbersCDR3.get(i+1).toString();
|
||||
//Go through the (likely shorter) CDR1 list as many times as necessary, make pairs of alphas and betas
|
||||
String tmpCDR1a = numbersCDR1.get(i % numbersCDR1.size()).toString();
|
||||
String tmpCDR1b = numbersCDR1.get((i+1) % numbersCDR1.size()).toString();
|
||||
//Make the array representing the cell
|
||||
Integer[] tmp = {tmpCDR3a, tmpCDR3b, tmpCDR1a, tmpCDR1b};
|
||||
String[] tmp = {tmpCDR3a, tmpCDR3b, tmpCDR1a, tmpCDR1b};
|
||||
//Add the cell to the list of distinct cells
|
||||
distinctCells.add(tmp);
|
||||
}
|
||||
this.cells = distinctCells;
|
||||
}
|
||||
|
||||
public CellSample(List<Integer[]> cells, Integer cdr1Freq){
|
||||
public CellSample(List<String[]> cells, Integer cdr1Freq){
|
||||
this.cells = cells;
|
||||
this.cdr1Freq = cdr1Freq;
|
||||
}
|
||||
|
||||
public List<Integer[]> getCells(){
|
||||
public List<String[]> getCells(){
|
||||
return cells;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GraphWithMapData implements java.io.Serializable {
|
||||
private Integer[] wellPopulations;
|
||||
private Integer alphaCount;
|
||||
private Integer betaCount;
|
||||
private final Map<Integer, Integer> distCellsMapAlphaKey;
|
||||
private final Map<String, String> distCellsMapAlphaKey;
|
||||
// private final Map<Integer, Integer> plateVtoAMap;
|
||||
// private final Map<Integer, Integer> plateVtoBMap;
|
||||
// private final Map<Integer, Integer> plateAtoVMap;
|
||||
@@ -25,7 +25,7 @@ public class GraphWithMapData implements java.io.Serializable {
|
||||
private final Duration time;
|
||||
|
||||
public GraphWithMapData(SimpleWeightedGraph graph, Integer numWells, Integer[] wellConcentrations,
|
||||
Map<Integer, Integer> distCellsMapAlphaKey, Integer alphaCount, Integer betaCount, Duration time){
|
||||
Map<String, String> distCellsMapAlphaKey, Integer alphaCount, Integer betaCount, Duration time){
|
||||
|
||||
// Map<Integer, Integer> plateVtoAMap,
|
||||
// Map<Integer,Integer> plateVtoBMap, Map<Integer, Integer> plateAtoVMap,
|
||||
@@ -66,7 +66,7 @@ public class GraphWithMapData implements java.io.Serializable {
|
||||
return betaCount;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getDistCellsMapAlphaKey() {
|
||||
public Map<String, String> getDistCellsMapAlphaKey() {
|
||||
return distCellsMapAlphaKey;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ public class MatchingResult {
|
||||
private final List<String> comments;
|
||||
private final List<String> headers;
|
||||
private final List<List<String>> allResults;
|
||||
private final Map<Integer, Integer> matchMap;
|
||||
private final Map<String, String> matchMap;
|
||||
private final Duration time;
|
||||
|
||||
public MatchingResult(Map<String, String> metadata, List<String> headers,
|
||||
List<List<String>> allResults, Map<Integer, Integer>matchMap, Duration time){
|
||||
List<List<String>> allResults, Map<String, String>matchMap, Duration time){
|
||||
/*
|
||||
* POSSIBLE KEYS FOR METADATA MAP ARE:
|
||||
* sample plate filename *
|
||||
@@ -57,7 +57,7 @@ public class MatchingResult {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getMatchMap() {
|
||||
public Map<String, String> getMatchMap() {
|
||||
return matchMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class Plate {
|
||||
private CellSample cells;
|
||||
private String sourceFile;
|
||||
private String filename;
|
||||
private List<List<Integer[]>> wells;
|
||||
private List<List<String[]>> wells;
|
||||
private final Random rand = BiGpairSEQ.getRand();
|
||||
private int size;
|
||||
private double error;
|
||||
@@ -48,13 +48,13 @@ public class Plate {
|
||||
}
|
||||
|
||||
//constructor for returning a Plate from a PlateFileReader
|
||||
public Plate(String filename, List<List<Integer[]>> wells) {
|
||||
public Plate(String filename, List<List<String[]>> wells) {
|
||||
this.filename = filename;
|
||||
this.wells = wells;
|
||||
this.size = wells.size();
|
||||
|
||||
List<Integer> concentrations = new ArrayList<>();
|
||||
for (List<Integer[]> w: wells) {
|
||||
for (List<String[]> w: wells) {
|
||||
if(!concentrations.contains(w.size())){
|
||||
concentrations.add(w.size());
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class Plate {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillWellsExponential(List<Integer[]> cells, double lambda){
|
||||
private void fillWellsExponential(List<String[]> cells, double lambda){
|
||||
this.lambda = lambda;
|
||||
exponential = true;
|
||||
int numSections = populations.length;
|
||||
@@ -74,17 +74,17 @@ public class Plate {
|
||||
int n;
|
||||
while (section < numSections){
|
||||
for (int i = 0; i < (size / numSections); i++) {
|
||||
List<Integer[]> well = new ArrayList<>();
|
||||
List<String[]> well = new ArrayList<>();
|
||||
for (int j = 0; j < populations[section]; j++) {
|
||||
do {
|
||||
//inverse transform sampling: for random number u in [0,1), x = log(1-u) / (-lambda)
|
||||
m = (Math.log10((1 - rand.nextDouble()))/(-lambda)) * Math.sqrt(cells.size());
|
||||
} while (m >= cells.size() || m < 0);
|
||||
n = (int) Math.floor(m);
|
||||
Integer[] cellToAdd = cells.get(n).clone();
|
||||
String[] cellToAdd = cells.get(n).clone();
|
||||
for(int k = 0; k < cellToAdd.length; k++){
|
||||
if(Math.abs(rand.nextDouble()) < error){//error applied to each seqeunce
|
||||
cellToAdd[k] = -1;
|
||||
cellToAdd[k] = "-1";
|
||||
}
|
||||
}
|
||||
well.add(cellToAdd);
|
||||
@@ -95,7 +95,7 @@ public class Plate {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillWells( List<Integer[]> cells, double stdDev) {
|
||||
private void fillWells( List<String[]> cells, double stdDev) {
|
||||
this.stdDev = stdDev;
|
||||
int numSections = populations.length;
|
||||
int section = 0;
|
||||
@@ -103,16 +103,16 @@ public class Plate {
|
||||
int n;
|
||||
while (section < numSections){
|
||||
for (int i = 0; i < (size / numSections); i++) {
|
||||
List<Integer[]> well = new ArrayList<>();
|
||||
List<String[]> well = new ArrayList<>();
|
||||
for (int j = 0; j < populations[section]; j++) {
|
||||
do {
|
||||
m = (rand.nextGaussian() * stdDev) + (cells.size() / 2);
|
||||
} while (m >= cells.size() || m < 0);
|
||||
n = (int) Math.floor(m);
|
||||
Integer[] cellToAdd = cells.get(n).clone();
|
||||
String[] cellToAdd = cells.get(n).clone();
|
||||
for(int k = 0; k < cellToAdd.length; k++){
|
||||
if(Math.abs(rand.nextDouble()) < error){//error applied to each sequence
|
||||
cellToAdd[k] = -1;
|
||||
cellToAdd[k] = "-1";
|
||||
}
|
||||
}
|
||||
well.add(cellToAdd);
|
||||
@@ -143,23 +143,23 @@ public class Plate {
|
||||
return error;
|
||||
}
|
||||
|
||||
public List<List<Integer[]>> getWells() {
|
||||
public List<List<String[]>> getWells() {
|
||||
return wells;
|
||||
}
|
||||
|
||||
//returns a map of the counts of the sequence at cell index sIndex, in all wells
|
||||
public Map<Integer, Integer> assayWellsSequenceS(int... sIndices){
|
||||
public Map<String, Integer> assayWellsSequenceS(int... sIndices){
|
||||
return this.assayWellsSequenceS(0, size, sIndices);
|
||||
}
|
||||
|
||||
//returns a map of the counts of the sequence at cell index sIndex, in a specific well
|
||||
public Map<Integer, Integer> assayWellsSequenceS(int n, int... sIndices) {
|
||||
public Map<String, Integer> assayWellsSequenceS(int n, int... sIndices) {
|
||||
return this.assayWellsSequenceS(n, n+1, sIndices);
|
||||
}
|
||||
|
||||
//returns a map of the counts of the sequence at cell index sIndex, in a range of wells
|
||||
public Map<Integer, Integer> assayWellsSequenceS(int start, int end, int... sIndices) {
|
||||
Map<Integer,Integer> assay = new HashMap<>();
|
||||
public Map<String, Integer> assayWellsSequenceS(int start, int end, int... sIndices) {
|
||||
Map<String, Integer> assay = new HashMap<>();
|
||||
for(int sIndex: sIndices){
|
||||
for(int i = start; i < end; i++){
|
||||
countSequences(assay, wells.get(i), sIndex);
|
||||
@@ -168,11 +168,11 @@ public class Plate {
|
||||
return assay;
|
||||
}
|
||||
//For the sequences at cell indices sIndices, counts number of unique sequences in the given well into the given map
|
||||
private void countSequences(Map<Integer, Integer> wellMap, List<Integer[]> well, int... sIndices) {
|
||||
for(Integer[] cell : well) {
|
||||
private void countSequences(Map<String, Integer> wellMap, List<String[]> well, int... sIndices) {
|
||||
for(String[] cell : well) {
|
||||
for(int sIndex: sIndices){
|
||||
//skip dropout sequences, which have value -1
|
||||
if(cell[sIndex] != -1){
|
||||
if(!"-1".equals(cell[sIndex])){
|
||||
wellMap.merge(cell[sIndex], 1, (oldValue, newValue) -> oldValue + newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class PlateFileReader {
|
||||
|
||||
private List<List<Integer[]>> wells = new ArrayList<>();
|
||||
private List<List<String[]>> wells = new ArrayList<>();
|
||||
private String filename;
|
||||
|
||||
public PlateFileReader(String filename){
|
||||
@@ -32,17 +32,17 @@ public class PlateFileReader {
|
||||
CSVParser parser = new CSVParser(reader, plateFileFormat);
|
||||
){
|
||||
for(CSVRecord record: parser.getRecords()) {
|
||||
List<Integer[]> well = new ArrayList<>();
|
||||
List<String[]> well = new ArrayList<>();
|
||||
for(String s: record) {
|
||||
if(!"".equals(s)) {
|
||||
String[] intString = s.replaceAll("\\[", "")
|
||||
String[] sequences = s.replaceAll("\\[", "")
|
||||
.replaceAll("]", "")
|
||||
.replaceAll(" ", "")
|
||||
.split(",");
|
||||
//System.out.println(intString);
|
||||
Integer[] arr = new Integer[intString.length];
|
||||
for (int i = 0; i < intString.length; i++) {
|
||||
arr[i] = Integer.valueOf(intString[i]);
|
||||
//System.out.println(sequences);
|
||||
String[] arr = new String[sequences.length];
|
||||
for (int i = 0; i < sequences.length; i++) {
|
||||
arr[i] = sequences[i];
|
||||
}
|
||||
well.add(arr);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.*;
|
||||
|
||||
public class PlateFileWriter {
|
||||
private int size;
|
||||
private List<List<Integer[]>> wells;
|
||||
private List<List<String[]>> wells;
|
||||
private double stdDev;
|
||||
private double lambda;
|
||||
private Double error;
|
||||
@@ -40,13 +40,13 @@ public class PlateFileWriter {
|
||||
}
|
||||
|
||||
public void writePlateFile(){
|
||||
Comparator<List<Integer[]>> listLengthDescending = Comparator.comparingInt(List::size);
|
||||
Comparator<List<String[]>> listLengthDescending = Comparator.comparingInt(List::size);
|
||||
wells.sort(listLengthDescending.reversed());
|
||||
int maxLength = wells.get(0).size();
|
||||
List<List<String>> wellsAsStrings = new ArrayList<>();
|
||||
for (List<Integer[]> w: wells){
|
||||
for (List<String[]> w: wells){
|
||||
List<String> tmp = new ArrayList<>();
|
||||
for(Integer[] c: w) {
|
||||
for(String[] c: w) {
|
||||
tmp.add(Arrays.toString(c));
|
||||
}
|
||||
wellsAsStrings.add(tmp);
|
||||
|
||||
@@ -12,9 +12,6 @@ import java.text.NumberFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static java.lang.Float.*;
|
||||
|
||||
//NOTE: "sequence" in method and variable names refers to a peptide sequence from a simulated T cell
|
||||
public class Simulator implements GraphModificationFunctions {
|
||||
@@ -26,7 +23,7 @@ public class Simulator implements GraphModificationFunctions {
|
||||
//even if not directed.
|
||||
public static GraphWithMapData makeGraph(CellSample cellSample, Plate samplePlate, boolean verbose) {
|
||||
Instant start = Instant.now();
|
||||
List<Integer[]> distinctCells = cellSample.getCells();
|
||||
List<String[]> distinctCells = cellSample.getCells();
|
||||
int[] alphaIndices = {SequenceType.CDR3_ALPHA.ordinal()};
|
||||
int[] betaIndices = {SequenceType.CDR3_BETA.ordinal()};
|
||||
|
||||
@@ -34,13 +31,13 @@ public class Simulator implements GraphModificationFunctions {
|
||||
|
||||
if(verbose){System.out.println("Making cell maps");}
|
||||
//HashMap keyed to Alphas, values Betas
|
||||
Map<Integer, Integer> distCellsMapAlphaKey = makeSequenceToSequenceMap(distinctCells, 0, 1);
|
||||
Map<String, String> distCellsMapAlphaKey = makeSequenceToSequenceMap(distinctCells, 0, 1);
|
||||
if(verbose){System.out.println("Cell maps made");}
|
||||
|
||||
if(verbose){System.out.println("Making well maps");}
|
||||
|
||||
Map<Integer, Integer> allAlphas = samplePlate.assayWellsSequenceS(alphaIndices);
|
||||
Map<Integer, Integer> allBetas = samplePlate.assayWellsSequenceS(betaIndices);
|
||||
Map<String, Integer> allAlphas = samplePlate.assayWellsSequenceS(alphaIndices);
|
||||
Map<String, Integer> allBetas = samplePlate.assayWellsSequenceS(betaIndices);
|
||||
int alphaCount = allAlphas.size();
|
||||
if(verbose){System.out.println("All alphas count: " + alphaCount);}
|
||||
int betaCount = allBetas.size();
|
||||
@@ -63,17 +60,17 @@ public class Simulator implements GraphModificationFunctions {
|
||||
//distinct indices between the rows and columns. vertexStartValue lets me track where I switch
|
||||
//from numbering rows to columns, so I can assign unique numbers to every vertex, and then
|
||||
//subtract the vertexStartValue from betas to use their vertex labels as array indices
|
||||
Integer vertexStartValue = 0;
|
||||
int vertexStartValue = 0;
|
||||
//keys are sequential integer vertices, values are alphas
|
||||
Map<Integer, Integer> plateVtoAMap = makeVertexToSequenceMap(allAlphas, vertexStartValue);
|
||||
Map<Integer, String> plateVtoAMap = makeVertexToSequenceMap(allAlphas, vertexStartValue);
|
||||
//new start value for vertex to beta map should be one more than final vertex value in alpha map
|
||||
vertexStartValue += plateVtoAMap.size();
|
||||
//keys are sequential integers vertices, values are betas
|
||||
Map<Integer, Integer> plateVtoBMap = makeVertexToSequenceMap(allBetas, vertexStartValue);
|
||||
Map<Integer, String> plateVtoBMap = makeVertexToSequenceMap(allBetas, vertexStartValue);
|
||||
//keys are alphas, values are sequential integer vertices from previous map
|
||||
Map<Integer, Integer> plateAtoVMap = invertVertexMap(plateVtoAMap);
|
||||
Map<String, Integer> plateAtoVMap = invertVertexMap(plateVtoAMap);
|
||||
//keys are betas, values are sequential integer vertices from previous map
|
||||
Map<Integer, Integer> plateBtoVMap = invertVertexMap(plateVtoBMap);
|
||||
Map<String, Integer> plateBtoVMap = invertVertexMap(plateVtoBMap);
|
||||
if(verbose){System.out.println("Vertex maps made");}
|
||||
|
||||
//make adjacency matrix for bipartite graph generator
|
||||
@@ -81,9 +78,9 @@ public class Simulator implements GraphModificationFunctions {
|
||||
//for a bipartite graph, and all the SimpleWeightedBipartiteGraphMatrixGenerator class expects.)
|
||||
if(verbose){System.out.println("Creating adjacency matrix");}
|
||||
//Count how many wells each alpha sequence appears in
|
||||
Map<Integer, Integer> alphaWellCounts = new HashMap<>();
|
||||
Map<String, Integer> alphaWellCounts = new HashMap<>();
|
||||
//count how many wells each beta sequence appears in
|
||||
Map<Integer, Integer> betaWellCounts = new HashMap<>();
|
||||
Map<String, Integer> betaWellCounts = new HashMap<>();
|
||||
//the adjacency matrix to be used by the graph generator
|
||||
double[][] weights = new double[plateVtoAMap.size()][plateVtoBMap.size()];
|
||||
countSequencesAndFillMatrix(samplePlate, allAlphas, allBetas, plateAtoVMap,
|
||||
@@ -101,7 +98,7 @@ public class Simulator implements GraphModificationFunctions {
|
||||
//List<Integer> alphaVertices = new ArrayList<>(plateVtoAMap.keySet()); //This will work because LinkedHashMap preserves order of entry
|
||||
List<Vertex> alphaVertices = new ArrayList<>();
|
||||
//start with map of all alphas mapped to vertex values, get occupancy from the alphaWellCounts map
|
||||
for (Integer seq : plateAtoVMap.keySet()) {
|
||||
for (String seq : plateAtoVMap.keySet()) {
|
||||
Vertex alphaVertex = new Vertex(SequenceType.CDR3_ALPHA, seq, alphaWellCounts.get(seq), plateAtoVMap.get(seq));
|
||||
alphaVertices.add(alphaVertex);
|
||||
}
|
||||
@@ -112,7 +109,7 @@ public class Simulator implements GraphModificationFunctions {
|
||||
//the list of beta vertices
|
||||
//List<Integer> betaVertices = new ArrayList<>(plateVtoBMap.keySet());//This will work because LinkedHashMap preserves order of entry
|
||||
List<Vertex> betaVertices = new ArrayList<>();
|
||||
for (Integer seq : plateBtoVMap.keySet()) {
|
||||
for (String seq : plateBtoVMap.keySet()) {
|
||||
Vertex betaVertex = new Vertex(SequenceType.CDR3_BETA, seq, betaWellCounts.get(seq), plateBtoVMap.get(seq));
|
||||
betaVertices.add(betaVertex);
|
||||
}
|
||||
@@ -147,7 +144,7 @@ public class Simulator implements GraphModificationFunctions {
|
||||
int numWells = data.getNumWells();
|
||||
//Integer alphaCount = data.getAlphaCount();
|
||||
//Integer betaCount = data.getBetaCount();
|
||||
Map<Integer, Integer> distCellsMapAlphaKey = data.getDistCellsMapAlphaKey();
|
||||
Map<String, String> distCellsMapAlphaKey = data.getDistCellsMapAlphaKey();
|
||||
Set<Vertex> alphas = new HashSet<>();
|
||||
Set<Vertex> betas = new HashSet<>();
|
||||
for(Vertex v: graph.vertexSet()) {
|
||||
@@ -228,7 +225,7 @@ public class Simulator implements GraphModificationFunctions {
|
||||
int trueCount = 0;
|
||||
int falseCount = 0;
|
||||
boolean check;
|
||||
Map<Integer, Integer> matchMap = new HashMap<>();
|
||||
Map<String, String> matchMap = new HashMap<>();
|
||||
while(weightIter.hasNext()) {
|
||||
e = weightIter.next();
|
||||
Vertex source = graph.getEdgeSource(e);
|
||||
@@ -637,14 +634,14 @@ public class Simulator implements GraphModificationFunctions {
|
||||
// }
|
||||
|
||||
//Remove sequences based on occupancy
|
||||
public static void filterByOccupancyThresholds(Map<Integer, Integer> wellMap, int low, int high){
|
||||
List<Integer> noise = new ArrayList<>();
|
||||
for(Integer k: wellMap.keySet()){
|
||||
public static void filterByOccupancyThresholds(Map<String, Integer> wellMap, int low, int high){
|
||||
List<String> noise = new ArrayList<>();
|
||||
for(String k: wellMap.keySet()){
|
||||
if((wellMap.get(k) > high) || (wellMap.get(k) < low)){
|
||||
noise.add(k);
|
||||
}
|
||||
}
|
||||
for(Integer k: noise) {
|
||||
for(String k: noise) {
|
||||
wellMap.remove(k);
|
||||
}
|
||||
}
|
||||
@@ -652,35 +649,35 @@ public class Simulator implements GraphModificationFunctions {
|
||||
//Counts the well occupancy of the row peptides and column peptides into given maps, and
|
||||
//fills weights in the given 2D array
|
||||
private static void countSequencesAndFillMatrix(Plate samplePlate,
|
||||
Map<Integer,Integer> allRowSequences,
|
||||
Map<Integer,Integer> allColumnSequences,
|
||||
Map<Integer,Integer> rowSequenceToVertexMap,
|
||||
Map<Integer,Integer> columnSequenceToVertexMap,
|
||||
Map<String, Integer> allRowSequences,
|
||||
Map<String, Integer> allColumnSequences,
|
||||
Map<String, Integer> rowSequenceToVertexMap,
|
||||
Map<String, Integer> columnSequenceToVertexMap,
|
||||
int[] rowSequenceIndices,
|
||||
int[] colSequenceIndices,
|
||||
Map<Integer, Integer> rowSequenceCounts,
|
||||
Map<Integer,Integer> columnSequenceCounts,
|
||||
Map<String, Integer> rowSequenceCounts,
|
||||
Map<String, Integer> columnSequenceCounts,
|
||||
double[][] weights){
|
||||
Map<Integer, Integer> wellNRowSequences = null;
|
||||
Map<Integer, Integer> wellNColumnSequences = null;
|
||||
Map<String, Integer> wellNRowSequences = null;
|
||||
Map<String, Integer> wellNColumnSequences = null;
|
||||
int vertexStartValue = rowSequenceToVertexMap.size();
|
||||
int numWells = samplePlate.getSize();
|
||||
for (int n = 0; n < numWells; n++) {
|
||||
wellNRowSequences = samplePlate.assayWellsSequenceS(n, rowSequenceIndices);
|
||||
for (Integer a : wellNRowSequences.keySet()) {
|
||||
for (String a : wellNRowSequences.keySet()) {
|
||||
if(allRowSequences.containsKey(a)){
|
||||
rowSequenceCounts.merge(a, 1, (oldValue, newValue) -> oldValue + newValue);
|
||||
}
|
||||
}
|
||||
wellNColumnSequences = samplePlate.assayWellsSequenceS(n, colSequenceIndices);
|
||||
for (Integer b : wellNColumnSequences.keySet()) {
|
||||
for (String b : wellNColumnSequences.keySet()) {
|
||||
if(allColumnSequences.containsKey(b)){
|
||||
columnSequenceCounts.merge(b, 1, (oldValue, newValue) -> oldValue + newValue);
|
||||
}
|
||||
}
|
||||
for (Integer i : wellNRowSequences.keySet()) {
|
||||
for (String i : wellNRowSequences.keySet()) {
|
||||
if(allRowSequences.containsKey(i)){
|
||||
for (Integer j : wellNColumnSequences.keySet()) {
|
||||
for (String j : wellNColumnSequences.keySet()) {
|
||||
if(allColumnSequences.containsKey(j)){
|
||||
weights[rowSequenceToVertexMap.get(i)][columnSequenceToVertexMap.get(j) - vertexStartValue] += 1.0;
|
||||
}
|
||||
@@ -691,27 +688,27 @@ public class Simulator implements GraphModificationFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<Integer, Integer> makeSequenceToSequenceMap(List<Integer[]> cells, int keySequenceIndex,
|
||||
int valueSequenceIndex){
|
||||
Map<Integer, Integer> keySequenceToValueSequenceMap = new HashMap<>();
|
||||
for (Integer[] cell : cells) {
|
||||
private static Map<String, String> makeSequenceToSequenceMap(List<String[]> cells, int keySequenceIndex,
|
||||
int valueSequenceIndex){
|
||||
Map<String, String> keySequenceToValueSequenceMap = new HashMap<>();
|
||||
for (String[] cell : cells) {
|
||||
keySequenceToValueSequenceMap.put(cell[keySequenceIndex], cell[valueSequenceIndex]);
|
||||
}
|
||||
return keySequenceToValueSequenceMap;
|
||||
}
|
||||
|
||||
private static Map<Integer, Integer> makeVertexToSequenceMap(Map<Integer, Integer> sequences, Integer startValue) {
|
||||
Map<Integer, Integer> map = new LinkedHashMap<>(); //LinkedHashMap to preserve order of entry
|
||||
private static Map<Integer, String> makeVertexToSequenceMap(Map<String, Integer> sequences, Integer startValue) {
|
||||
Map<Integer, String> map = new LinkedHashMap<>(); //LinkedHashMap to preserve order of entry
|
||||
Integer index = startValue; //is this necessary? I don't think I use this.
|
||||
for (Integer k: sequences.keySet()) {
|
||||
for (String k: sequences.keySet()) {
|
||||
map.put(index, k);
|
||||
index++;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<Integer, Integer> invertVertexMap(Map<Integer, Integer> map) {
|
||||
Map<Integer, Integer> inverse = new HashMap<>();
|
||||
private static Map<String, Integer> invertVertexMap(Map<Integer, String> map) {
|
||||
Map<String, Integer> inverse = new HashMap<>();
|
||||
for (Integer k : map.keySet()) {
|
||||
inverse.put(map.get(k), k);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.io.Serializable;
|
||||
public class Vertex implements Serializable, Comparable<Vertex> {
|
||||
private SequenceType type;
|
||||
private Integer vertexLabel;
|
||||
private Integer sequence;
|
||||
private String sequence;
|
||||
private Integer occupancy;
|
||||
private Integer readCount;
|
||||
private Double potential;
|
||||
@@ -18,14 +18,14 @@ public class Vertex implements Serializable, Comparable<Vertex> {
|
||||
this.vertexLabel = Integer.parseInt((vertexLabel));
|
||||
}
|
||||
|
||||
public Vertex(SequenceType type, Integer sequence, Integer occupancy, Integer vertexLabel) {
|
||||
public Vertex(SequenceType type, String sequence, Integer occupancy, Integer vertexLabel) {
|
||||
this.type = type;
|
||||
this.vertexLabel = vertexLabel;
|
||||
this.sequence = sequence;
|
||||
this.occupancy = occupancy;
|
||||
}
|
||||
|
||||
public Vertex(SequenceType type, Integer sequence, Integer occupancy, Integer vertexLabel, Integer readCount) {
|
||||
public Vertex(SequenceType type, String sequence, Integer occupancy, Integer vertexLabel, Integer readCount) {
|
||||
this.type = type;
|
||||
this.vertexLabel = vertexLabel;
|
||||
this.sequence = sequence;
|
||||
@@ -50,13 +50,12 @@ public class Vertex implements Serializable, Comparable<Vertex> {
|
||||
this.vertexLabel = Integer.parseInt(label);
|
||||
}
|
||||
|
||||
public Integer getSequence() {
|
||||
|
||||
public String getSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public void setSequence(String sequence) {
|
||||
this.sequence = Integer.parseInt(sequence);
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
public Integer getOccupancy() {
|
||||
|
||||
Reference in New Issue
Block a user