67 lines
2.6 KiB
Java
67 lines
2.6 KiB
Java
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.stream.IntStream;
|
|
|
|
public class CellSample {
|
|
|
|
private List<String[]> cells;
|
|
private Integer cdr1Freq;
|
|
private String filename;
|
|
|
|
public CellSample(Integer numDistinctCells, Integer cdr1Freq){
|
|
this.cdr1Freq = cdr1Freq;
|
|
List<Integer> numbersCDR3 = new ArrayList<>();
|
|
List<Integer> numbersCDR1 = new ArrayList<>();
|
|
Integer numDistCDR3s = 2 * numDistinctCells + 1;
|
|
//Assign consecutive integers for each CDR3. This ensures they are all unique.
|
|
IntStream.range(1, numDistCDR3s + 1).forEach(i -> numbersCDR3.add(i));
|
|
//After all CDR3s are assigned, start assigning consecutive integers to CDR1s
|
|
//There will usually be fewer integers in the CDR1 list, which will allow repeats below
|
|
IntStream.range(numDistCDR3s + 1, numDistCDR3s + 1 + (numDistCDR3s / cdr1Freq) + 1).forEach(i -> numbersCDR1.add(i));
|
|
//randomize the order of the numbers in the lists
|
|
Collections.shuffle(numbersCDR3);
|
|
Collections.shuffle(numbersCDR1);
|
|
|
|
//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<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
|
|
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
|
|
String[] tmp = {tmpCDR3a, tmpCDR3b, tmpCDR1a, tmpCDR1b};
|
|
//Add the cell to the list of distinct cells
|
|
distinctCells.add(tmp);
|
|
}
|
|
this.cells = distinctCells;
|
|
this.filename = filename;
|
|
}
|
|
|
|
public CellSample(List<String[]> cells, Integer cdr1Freq){
|
|
this.cells = cells;
|
|
this.cdr1Freq = cdr1Freq;
|
|
}
|
|
|
|
public List<String[]> getCells(){
|
|
return cells;
|
|
}
|
|
|
|
public Integer getCdr1Freq() {
|
|
return cdr1Freq;
|
|
}
|
|
|
|
public Integer getCellCount(){
|
|
return cells.size();
|
|
}
|
|
|
|
public String getFilename() { return filename; }
|
|
|
|
public void setFilename(String filename) { this.filename = filename; }
|
|
|
|
}
|