Debian Codegraph @

uk/ac/babraham/FastQC/Modules/GCModel/GCModel.java

raw symbols SCIP
1 /**
2 * Copyright Copyright 2010-17 Simon Andrews
3 *
4 * This file is part of FastQC.
5 *
6 * FastQC is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * FastQC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with FastQC; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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 // We now do a second pass to make up the model using the weightings
52 // we calculated previously.
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 }