Skip to content

Commit

Permalink
fixed median calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
manojbhosale committed Jul 18, 2019
1 parent a3c3a9c commit a745eb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/hsutils/BAMParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,24 @@ public Integer getMedianAmplificationLevel(Integer[] inArr) {

Integer freqSum = inList.stream().mapToInt(e -> e).sum();

Integer middleVal = freqSum / 2;
Integer freqByLevel[] = new Integer[inArr.length];
int count = 1;
for (int i = 0; i < inList.size(); i++) {
freqByLevel[i] = count * inList.get(i);
count++;
}
Integer freqByLevelSum = sum(freqByLevel);

Integer middleVal = freqByLevelSum / 2;
Integer cumSum = 0, median = 0;

for (int i = 0; i < inArr.length; i++) {
System.out.println(freqByLevelSum+" "+middleVal);
for (int i = 0; i < freqByLevel.length; i++) {
if (cumSum > middleVal) {
System.out.println(cumSum);
break;
}
cumSum += inArr[i];
System.out.println(cumSum);
cumSum += freqByLevel[i];
median++;
}

Expand Down
Binary file modified target/classes/hsutils/BAMParser.class
Binary file not shown.

0 comments on commit a745eb3

Please sign in to comment.