Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fcunial committed Nov 12, 2023
1 parent c203abe commit e7adda0
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/de/mpi_cbg/revant/apps/RepeatAlphabet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ else if (mode==1) { // Counting
value=newKmers.get(key);
if (value!=null) {
value.count+=key.count;
value.countPartial+=key.countPartial;
value.countPartial+=key.countPartial;
value.sameReadCount=(short)Math.max(value.sameReadCount,(int)(key.count+key.countPartial));
}
}
Expand Down Expand Up @@ -3464,19 +3464,28 @@ public final int isUnique(int k, int nReads, int avgReadLength, int spanningBps,
if (surface>0 && count==0) return -1;
final double surfaceL = Math.max(alphabet[sequence[0]].getLength()-minAlignmentLength-minMissingLength,0);
final double surfaceR = Math.max(alphabet[sequence[k-1]].getLength()-minAlignmentLength-minMissingLength,0);
if (surface+surfaceL+surfaceR==0) return -1;
final double probFull = surface/genomeLength;
final double probPartial = (surfaceL+surfaceR==0?2:surfaceL+surfaceR)/genomeLength;
final double probPartial = (surfaceL+surfaceR)/genomeLength;
final int quantum = nReads/nHaplotypes;
for (i=0; i<nHaplotypes; i++) {
if (surface>0) {
distribution=PoissonDistribution.of(probFull*quantum*(i+1));
p=distribution.cumulativeProbability(count);
p=2.0*Math.min(p,1.0-p);
if (p<=significanceLevel) continue;
}
distribution=PoissonDistribution.of(probPartial*quantum*(i+1));
p=distribution.survivalProbability(countPartial);
if (p>significanceLevel) return i+1; // Excluding only repeats
if (surfaceL+surfaceR>0) {
distribution=PoissonDistribution.of(probPartial*quantum*(i+1));
p=distribution.survivalProbability(countPartial);
if (p>significanceLevel) return i+1; // Excluding only repeats
}
else return i+1;
}
else if (surfaceL+surfaceR>0) {
distribution=PoissonDistribution.of(probPartial*quantum*(i+1));
p=distribution.survivalProbability(countPartial);
if (p>significanceLevel) return i+1; // Excluding only repeats
}
}
return -1;
}
Expand Down Expand Up @@ -3504,7 +3513,8 @@ public final boolean isFrequent(int k, int nReads, int avgReadLength, int spanni
else {
final double surfaceL = Math.max(alphabet[sequence[0]].getLength()-minAlignmentLength-minMissingLength,0);
final double surfaceR = Math.max(alphabet[sequence[k-1]].getLength()-minAlignmentLength-minMissingLength,0);
final double probPartial = (surfaceL+surfaceR==0?2:surfaceL+surfaceR)/genomeLength;
if (surfaceL+surfaceR==0) return false;
final double probPartial = (surfaceL+surfaceR)/genomeLength;
distribution=PoissonDistribution.of(probPartial*quantum);
return distribution.cumulativeProbability(countPartial)>significanceLevel;
}
Expand Down Expand Up @@ -8697,16 +8707,15 @@ private static final void addSpacerSolutions(Spacer spacer, boolean fullyContain
* @return TRUE iff a fraction of all spacers have a solution after propagation.
*/
public static final boolean propagateSolutions(int distanceThreshold) {
final int CAPACITY = 10; // Arbitrary
final double THRESHOLD = 0.25; // Arbitrary
final int MAX_SOLUTIONS_PER_SPACER = 1000; // Arbitrary
final int MAX_SOLUTIONS_PER_SPACER = 10000; // Arbitrary
boolean orientation;
int i, j;
int top, last, currentSpacer, neighbor, nPropagated, nSolved;
SpacerSolution[] tmpArray;

// Compacting existing solutions
tmpArray = new SpacerSolution[CAPACITY];
tmpArray = new SpacerSolution[MAX_SOLUTIONS_PER_SPACER];
for (i=0; i<tmpArray.length; i++) tmpArray[i] = new SpacerSolution();
for (i=0; i<=lastSpacer; i++) {
spacers[i].breakpoint=-1; // Used as a flag
Expand Down

0 comments on commit e7adda0

Please sign in to comment.