| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
package uk.ac.babraham.FastQC.Modules.GCModel; |
| 21 |
|
| 22 |
public class GCModel { |
| 23 |
|
| 24 |
public int readLength; |
| 25 |
public GCModelValue[][] models; |
| 26 |
|
| 27 |
public GCModel (int readLength) { |
| 28 |
|
| 29 |
int [] claimingCounts = new int [101]; |
| 30 |
this.readLength = readLength; |
| 31 |
models = new GCModelValue[readLength+1][]; |
| 32 |
|
| 33 |
for (int pos=0;pos<=readLength;pos++) { |
| 34 |
double lowCount = pos-0.5; |
| 35 |
double highCount = pos+0.5; |
| 36 |
|
| 37 |
if (lowCount < 0) lowCount = 0; |
| 38 |
if (highCount < 0) highCount = 0; |
| 39 |
if (highCount > readLength) highCount = readLength; |
| 40 |
if (lowCount > readLength) lowCount = readLength; |
| 41 |
|
| 42 |
int lowPercentage = (int)Math.round((lowCount*100) / readLength); |
| 43 |
int highPercentage = (int)Math.round((highCount*100) / readLength); |
| 44 |
|
| 45 |
for (int p=lowPercentage;p<=highPercentage;p++) { |
| 46 |
claimingCounts[p]++; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
for (int pos=0;pos<=readLength;pos++) { |
| 55 |
double lowCount = pos-0.5; |
| 56 |
double highCount = pos+0.5; |
| 57 |
|
| 58 |
if (lowCount < 0) lowCount = 0; |
| 59 |
if (highCount < 0) highCount = 0; |
| 60 |
if (highCount > readLength) highCount = readLength; |
| 61 |
if (lowCount > readLength) lowCount = readLength; |
| 62 |
|
| 63 |
int lowPercentage = (int)Math.round((lowCount*100) / readLength); |
| 64 |
int highPercentage = (int)Math.round((highCount*100) / readLength); |
| 65 |
|
| 66 |
GCModelValue [] modelValues = new GCModelValue [(highPercentage-lowPercentage)+1]; |
| 67 |
|
| 68 |
for (int p=lowPercentage;p<=highPercentage;p++) { |
| 69 |
modelValues[p-lowPercentage] = new GCModelValue(p, 1d/claimingCounts[p]); |
| 70 |
} |
| 71 |
models[pos] = modelValues; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
public GCModelValue [] getModelValues (int gcCount) { |
| 79 |
return models[gcCount]; |
| 80 |
} |
| 81 |
|
| 82 |
} |