Change "peptide" references in code to "sequence", adding comments
This commit is contained in:
@@ -8,6 +8,9 @@ public abstract class Equations {
|
||||
return (int) ((Math.random() * (max - min)) + min);
|
||||
}
|
||||
|
||||
//pValue calculation as described in original pairSEQ paper.
|
||||
//Included for comparison with original results.
|
||||
//Not used by BiGpairSEQ for matching.
|
||||
public static double pValue(Integer w, Integer w_a, Integer w_b, double w_ab_d) {
|
||||
int w_ab = (int) w_ab_d;
|
||||
double pv = 0.0;
|
||||
@@ -18,6 +21,9 @@ public abstract class Equations {
|
||||
return pv;
|
||||
}
|
||||
|
||||
//Implementation of the (corrected) probability equation from pairSEQ paper.
|
||||
//Included for comparison with original results.
|
||||
//Not used by BiGpairSEQ for matching.
|
||||
private static double probPairedByChance(Integer w, Integer w_a, Integer w_b, Integer w_ab){
|
||||
BigInteger numer1 = choose(w, w_ab);
|
||||
BigInteger numer2 = choose(w - w_ab, w_a - w_ab);
|
||||
@@ -30,10 +36,9 @@ public abstract class Equations {
|
||||
return prob.doubleValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* This works because nC(k+1) = nCk * (n-k)/(k+1)
|
||||
* Since nC0 = 1, can start there and generate all the rest.
|
||||
*/
|
||||
|
||||
//This works because nC(k+1) = nCk * (n-k)/(k+1)
|
||||
//Since nC0 = 1, can start there and generate all the rest.
|
||||
public static BigInteger choose(final int N, final int K) {
|
||||
BigInteger nCk = BigInteger.ONE;
|
||||
for (int k = 0; k < K; k++) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Plate {
|
||||
}
|
||||
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
|
||||
if(Math.abs(rand.nextDouble()) < error){//error applied to each seqeunce
|
||||
cellToAdd[k] = -1;
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class Plate {
|
||||
n = (int) Math.floor(m);
|
||||
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
|
||||
if(Math.abs(rand.nextDouble()) < error){//error applied to each sequence
|
||||
cellToAdd[k] = -1;
|
||||
}
|
||||
}
|
||||
@@ -134,30 +134,30 @@ public class Plate {
|
||||
return wells;
|
||||
}
|
||||
|
||||
//returns a map of the counts of the peptide at cell index pIndex, in all wells
|
||||
public Map<Integer, Integer> assayWellsPeptideP(int... pIndices){
|
||||
return this.assayWellsPeptideP(0, size, pIndices);
|
||||
//returns a map of the counts of the sequence at cell index sIndex, in all wells
|
||||
public Map<Integer, Integer> assayWellsSequenceS(int... sIndices){
|
||||
return this.assayWellsSequenceS(0, size, sIndices);
|
||||
}
|
||||
|
||||
//returns a map of the counts of the peptide at cell index pIndex, in a specific well
|
||||
public Map<Integer, Integer> assayWellsPeptideP(int n, int... pIndices) { return this.assayWellsPeptideP(n, n+1, pIndices);}
|
||||
//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) { return this.assayWellsSequenceS(n, n+1, sIndices);}
|
||||
|
||||
//returns a map of the counts of the peptide at cell index pIndex, in a range of wells
|
||||
public Map<Integer, Integer> assayWellsPeptideP(int start, int end, int... pIndices) {
|
||||
//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<>();
|
||||
for(int pIndex: pIndices){
|
||||
for(int pIndex: sIndices){
|
||||
for(int i = start; i < end; i++){
|
||||
countPeptides(assay, wells.get(i), pIndex);
|
||||
countSequences(assay, wells.get(i), pIndex);
|
||||
}
|
||||
}
|
||||
return assay;
|
||||
}
|
||||
//For the peptides at cell indices pIndices, counts number of unique peptides in the given well into the given map
|
||||
private void countPeptides(Map<Integer, Integer> wellMap, List<Integer[]> well, int... pIndices) {
|
||||
//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) {
|
||||
for(int pIndex: pIndices){
|
||||
if(cell[pIndex] != -1){
|
||||
wellMap.merge(cell[pIndex], 1, (oldValue, newValue) -> oldValue + newValue);
|
||||
for(int sIndex: sIndices){
|
||||
if(cell[sIndex] != -1){
|
||||
wellMap.merge(cell[sIndex], 1, (oldValue, newValue) -> oldValue + newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public class Simulator {
|
||||
if(verbose){System.out.println("Cell maps made");}
|
||||
|
||||
if(verbose){System.out.println("Making well maps");}
|
||||
Map<Integer, Integer> allAlphas = samplePlate.assayWellsPeptideP(alphaIndex);
|
||||
Map<Integer, Integer> allBetas = samplePlate.assayWellsPeptideP(betaIndex);
|
||||
Map<Integer, Integer> allAlphas = samplePlate.assayWellsSequenceS(alphaIndex);
|
||||
Map<Integer, Integer> allBetas = samplePlate.assayWellsSequenceS(betaIndex);
|
||||
int alphaCount = allAlphas.size();
|
||||
if(verbose){System.out.println("All alphas count: " + alphaCount);}
|
||||
int betaCount = allBetas.size();
|
||||
@@ -296,8 +296,8 @@ public class Simulator {
|
||||
System.out.println("Cell maps made");
|
||||
|
||||
System.out.println("Making well maps");
|
||||
Map<Integer, Integer> allCDR3s = samplePlate.assayWellsPeptideP(cdr3Indices);
|
||||
Map<Integer, Integer> allCDR1s = samplePlate.assayWellsPeptideP(cdr1Indices);
|
||||
Map<Integer, Integer> allCDR3s = samplePlate.assayWellsSequenceS(cdr3Indices);
|
||||
Map<Integer, Integer> allCDR1s = samplePlate.assayWellsSequenceS(cdr1Indices);
|
||||
int CDR3Count = allCDR3s.size();
|
||||
System.out.println("all CDR3s count: " + CDR3Count);
|
||||
int CDR1Count = allCDR1s.size();
|
||||
@@ -591,26 +591,26 @@ public class Simulator {
|
||||
Map<Integer, Integer> rowSequenceCounts,
|
||||
Map<Integer,Integer> columnSequenceCounts,
|
||||
double[][] weights){
|
||||
Map<Integer, Integer> wellNRowPeptides = null;
|
||||
Map<Integer, Integer> wellNColumnPeptides = null;
|
||||
Map<Integer, Integer> wellNRowSequences = null;
|
||||
Map<Integer, Integer> wellNColumnSequences = null;
|
||||
int vertexStartValue = rowSequenceToVertexMap.size();
|
||||
int numWells = samplePlate.getSize();
|
||||
for (int n = 0; n < numWells; n++) {
|
||||
wellNRowPeptides = samplePlate.assayWellsPeptideP(n, rowSequenceIndices);
|
||||
for (Integer a : wellNRowPeptides.keySet()) {
|
||||
wellNRowSequences = samplePlate.assayWellsSequenceS(n, rowSequenceIndices);
|
||||
for (Integer a : wellNRowSequences.keySet()) {
|
||||
if(allRowSequences.containsKey(a)){
|
||||
rowSequenceCounts.merge(a, 1, (oldValue, newValue) -> oldValue + newValue);
|
||||
}
|
||||
}
|
||||
wellNColumnPeptides = samplePlate.assayWellsPeptideP(n, colSequenceIndices);
|
||||
for (Integer b : wellNColumnPeptides.keySet()) {
|
||||
wellNColumnSequences = samplePlate.assayWellsSequenceS(n, colSequenceIndices);
|
||||
for (Integer b : wellNColumnSequences.keySet()) {
|
||||
if(allColumnSequences.containsKey(b)){
|
||||
columnSequenceCounts.merge(b, 1, (oldValue, newValue) -> oldValue + newValue);
|
||||
}
|
||||
}
|
||||
for (Integer i : wellNRowPeptides.keySet()) {
|
||||
for (Integer i : wellNRowSequences.keySet()) {
|
||||
if(allRowSequences.containsKey(i)){
|
||||
for (Integer j : wellNColumnPeptides.keySet()) {
|
||||
for (Integer j : wellNColumnSequences.keySet()) {
|
||||
if(allColumnSequences.containsKey(j)){
|
||||
weights[rowSequenceToVertexMap.get(i)][columnSequenceToVertexMap.get(j) - vertexStartValue] += 1.0;
|
||||
}
|
||||
|
||||
@@ -681,7 +681,8 @@ public class UserInterface {
|
||||
System.out.println("This program simulates BiGpairSEQ, a graph theory based adaptation");
|
||||
System.out.println("of the pairSEQ algorithm for pairing T cell receptor sequences.");
|
||||
System.out.println();
|
||||
System.out.println("For full documentation, see: https://gitea.ejsf.synology.me/efischer/BiGpairSEQ");
|
||||
System.out.println("For full documentation, view readme.md file distributed with this code");
|
||||
System.out.println("or visit https://gitea.ejsf.synology.me/efischer/BiGpairSEQ.");
|
||||
System.out.println();
|
||||
System.out.println("pairSEQ citation:");
|
||||
System.out.println("Howie, B., Sherwood, A. M., et. al.");
|
||||
|
||||
Reference in New Issue
Block a user