Debian Codegraph @

src/dr/oldevomodel/substmodel/CovarionGTR.java

raw symbols SCIP
1 /*
2 * CovarionGTR.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.oldevomodel.substmodel;
27
28 import dr.evolution.datatype.OldHiddenNucleotides;
29 import dr.oldevomodelxml.substmodel.CovarionGTRParser;
30 import dr.inference.model.Parameter;
31
32 /**
33 * A general time reversible model of nucleotide evolution with
34 * covarion hidden rate categories.
35 *
36 * @author Alexei Drummond
37 * @version $Id$
38 */
39 public class CovarionGTR extends AbstractCovarionDNAModel {
40 /**
41 * constructor
42 *
43 * @param dataType the data type
44 * @param freqModel the equlibrium frequencies
45 * @param hiddenRates the relative rates of the hidden categories
46 * (first hidden category has rate 1.0 so this parameter
47 * has dimension one less than number of hidden categories.
48 * @param rateACParameter the relative rate of A<->C substitutions
49 * @param rateAGParameter the relative rate of A<->G substitutions
50 * @param rateATParameter the relative rate of A<->T substitutions
51 * @param rateCGParameter the relative rate of C<->G substitutions
52 * @param rateCTParameter the relative rate of C<->T substitutions
53 * @param rateGTParameter the relative rate of G<->T substitutions
54 * each hidden category.
55 * @param switchingRates rates of switching between hidden rate classes
56 */
57 public CovarionGTR(
58 OldHiddenNucleotides dataType,
59 Parameter hiddenRates,
60 Parameter switchingRates,
61 Parameter rateACParameter,
62 Parameter rateAGParameter,
63 Parameter rateATParameter,
64 Parameter rateCGParameter,
65 Parameter rateCTParameter,
66 Parameter rateGTParameter,
67 FrequencyModel freqModel) {
68
69 super(CovarionGTRParser.GTR_COVARION_MODEL, dataType, hiddenRates, switchingRates, freqModel);
70 if (rateACParameter != null) {
71 addVariable(rateACParameter);
72 rateACParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
73 this.rateACParameter = rateACParameter;
74 }
75
76 if (rateAGParameter != null) {
77 addVariable(rateAGParameter);
78 rateAGParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
79 this.rateAGParameter = rateAGParameter;
80 }
81
82 if (rateATParameter != null) {
83 addVariable(rateATParameter);
84 rateATParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
85 this.rateATParameter = rateATParameter;
86 }
87
88 if (rateCGParameter != null) {
89 addVariable(rateCGParameter);
90 rateCGParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
91 this.rateCGParameter = rateCGParameter;
92 }
93
94 if (rateCTParameter != null) {
95 addVariable(rateCTParameter);
96 rateCTParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
97 this.rateCTParameter = rateCTParameter;
98 }
99
100 if (rateGTParameter != null) {
101 addVariable(rateGTParameter);
102 rateGTParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
103 this.rateGTParameter = rateGTParameter;
104 }
105 }
106
107 double[] getRelativeDNARates() {
108 double[] rr = new double[6];
109 for (int i = 0; i < rr.length; i++) {
110 rr[i] = 1.0;
111 }
112
113 if (rateACParameter != null) {
114 rr[0] = rateACParameter.getParameterValue(0);
115 }
116 if (rateAGParameter != null) {
117 rr[1] = rateAGParameter.getParameterValue(0);
118 }
119 if (rateATParameter != null) {
120 rr[2] = rateATParameter.getParameterValue(0);
121 }
122 if (rateCGParameter != null) {
123 rr[3] = rateCGParameter.getParameterValue(0);
124 }
125 if (rateCTParameter != null) {
126 rr[4] = rateCTParameter.getParameterValue(0);
127 }
128 if (rateGTParameter != null) {
129 rr[5] = rateGTParameter.getParameterValue(0);
130 }
131 return rr;
132 }
133
134 private Parameter rateACParameter = null;
135 private Parameter rateAGParameter = null;
136 private Parameter rateATParameter = null;
137 private Parameter rateCGParameter = null;
138 private Parameter rateCTParameter = null;
139 private Parameter rateGTParameter = null;
140 }