use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class ClockModelListInputEditor method setUpOperator.
/**
* set up relative weights and parameter input *
*/
private void setUpOperator() {
String weights = "";
List<RealParameter> parameters = operator.parameterInput.get();
parameters.clear();
double commonClockRate = -1;
boolean isAllClocksAreEqual = true;
try {
for (int i = 0; i < doc.alignments.size(); i++) {
Alignment data = doc.alignments.get(i);
int weight = data.getSiteCount();
BranchRateModel.Base clockModel = (BranchRateModel.Base) doc.clockModels.get(i);
RealParameter clockRate = clockModel.meanRateInput.get();
// clockRate.m_bIsEstimated.setValue(true, clockRate);
if (clockRate.isEstimatedInput.get()) {
if (commonClockRate < 0) {
commonClockRate = clockRate.valuesInput.get().get(0);
} else {
if (Math.abs(commonClockRate - clockRate.valuesInput.get().get(0)) > 1e-10) {
isAllClocksAreEqual = false;
}
}
weights += weight + " ";
parameters.add(clockRate);
}
// doc.autoSetClockRate = false;
}
if (!fixMeanRatesCheckBox.isSelected()) {
fixMeanRatesValidateLabel.setVisible(false);
return;
}
if (parameters.size() == 0) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.red;
fixMeanRatesValidateLabel.setToolTipText("The model is invalid: At least one clock rate should be estimated.");
return;
}
IntegerParameter weightParameter = new IntegerParameter(weights);
weightParameter.setID("weightparameter");
weightParameter.isEstimatedInput.setValue(false, weightParameter);
operator.parameterWeightsInput.setValue(weightParameter, operator);
if (!isAllClocksAreEqual) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.orange;
fixMeanRatesValidateLabel.setToolTipText("Not all clocks are equal. Are you sure this is what you want?");
} else if (parameters.size() == 1) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.orange;
fixMeanRatesValidateLabel.setToolTipText("At least 2 clock models should have their rate estimated");
} else if (parameters.size() < doc.alignments.size()) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.orange;
fixMeanRatesValidateLabel.setToolTipText("Not all partitions have their rate estimated");
} else {
fixMeanRatesValidateLabel.setVisible(false);
}
repaint();
// doc.autoSetClockRate = true;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class FilteredAlignmentTest method testIndividualsFiltered.
@Test
public void testIndividualsFiltered() throws Exception {
Alignment data = getAlignment();
FilteredAlignment data2 = new FilteredAlignment();
data2.initByName("data", data, "filter", "1");
assertEquals(1, data2.getSiteCount());
data2.initByName("data", data, "filter", "2,5");
assertEquals(2, data2.getSiteCount());
data2.initByName("data", data, "filter", "2,5,3,4");
assertEquals(4, data2.getSiteCount());
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class FilteredAlignmentTest method getAlignment2.
public static Alignment getAlignment2() throws Exception {
// reordered from getAlignment()
Sequence human = new Sequence("0human", "AAAACCCCTTTTGGGG");
Sequence chimp = new Sequence("1chimp", "ACTGACGTACGTACGT");
Alignment data = new Alignment();
data.initByName("sequence", human, "sequence", chimp, "dataType", "nucleotide");
return data;
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class FilteredAlignmentTest method testConstantSites.
@Test
public void testConstantSites() throws Exception {
Alignment data = getAlignment();
FilteredAlignment data2 = new FilteredAlignment();
// missing one weight for constant sites (nucleotide data)
try {
data2.initByName("data", data, "filter", "-", "constantSiteWeights", "11232 2 3");
throw new Exception("Should have failed by now");
} catch (RuntimeException e) {
System.err.println(e.getMessage());
}
// filter alignment with constant sites
data2 = new FilteredAlignment();
data2.initByName("data", data, "filter", "-", "constantSiteWeights", "11232 2 3 4");
String weights = Arrays.toString(data2.getWeights());
System.err.println(weights);
assertEquals("[11233, 1, 1, 1, 1, 3, 1, 1, 1, 1, 4, 1, 1, 1, 1, 5]", weights);
// filter alignment with constant sites, so some constant sites are missing from the original alignment
data2 = new FilteredAlignment();
data2.initByName("data", data, "filter", "-8", "constantSiteWeights", "11232 2 3 4");
weights = Arrays.toString(data2.getWeights());
System.err.println(weights);
assertEquals("[11233, 1, 1, 1, 1, 3, 1, 1, 3, 4]", weights);
// add constant sites to ordinary alignment and strip constant sites
data2 = new FilteredAlignment();
data2.initByName("data", data, "filter", "-8", "constantSiteWeights", "11232 2 3 4", "strip", true);
weights = Arrays.toString(data2.getWeights());
System.err.println(weights);
assertEquals("[11232, 1, 1, 1, 1, 2, 1, 1, 3, 4]", weights);
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class FilteredAlignmentTest method getAlignment.
public static Alignment getAlignment() throws Exception {
Sequence human = new Sequence("0human", "AAAACCCCGGGGTTTT");
Sequence chimp = new Sequence("1chimp", "ACGTACGTACGTACGT");
Alignment data = new Alignment();
data.initByName("sequence", human, "sequence", chimp, "dataType", "nucleotide");
return data;
}
Aggregations