本文整理汇总了Java中dr.evolution.datatype.Codons.UNIVERSAL属性的典型用法代码示例。如果您正苦于以下问题:Java Codons.UNIVERSAL属性的具体用法?Java Codons.UNIVERSAL怎么用?Java Codons.UNIVERSAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类dr.evolution.datatype.Codons
的用法示例。
在下文中一共展示了Codons.UNIVERSAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCodonSimulation
public void testCodonSimulation() {
Parameter kappa = new Parameter.Default(1, 2.0);
Parameter omega = new Parameter.Default(1, 5.0); // Expect many more non-syn changes
Codons codons = Codons.UNIVERSAL;
int stateCount = codons.getStateCount();
double[] p = new double[stateCount];
for (int i = 0; i < stateCount; i++) {
p[i] = 1.0 / (double) stateCount;
}
Parameter pi = new Parameter.Default(p);
FrequencyModel f = new FrequencyModel(codons, pi);
GY94CodonModel codonModel = new GY94CodonModel(codons, omega, kappa, f);
Parameter mu = new Parameter.Default(1, 0.5);
Parameter alpha = new Parameter.Default(1, 0.5);
GammaSiteRateModel siteModel = new GammaSiteRateModel("gammaModel", mu, alpha, 4, null);
siteModel.setSubstitutionModel(codonModel);
BranchRateModel branchRateModel = new DefaultBranchRateModel();
double analyticResult = TreeUtils.getTreeLength(tree, tree.getRoot()) * mu.getParameterValue(0);
int nSites = 100;
double[] synRegMatrix = CodonLabeling.getRegisterMatrix(CodonLabeling.SYN, codons, false); // use base 61
double[] nonSynRegMatrix = CodonLabeling.getRegisterMatrix(CodonLabeling.NON_SYN, codons, false); // use base 61
runSimulation(tree, siteModel, branchRateModel, nSites,
new double[][] {synRegMatrix, nonSynRegMatrix}, analyticResult);
}
示例2: main
public static void main(String[] args) {
GY94CodonModel codonModel = new GY94CodonModel(Codons.UNIVERSAL,
new Parameter.Default(1.0), new Parameter.Default(2.0),
new FrequencyModel(Codons.UNIVERSAL, new Parameter.Default(61, 1.0 / 61.0)));
EigenDecomposition ed1 = codonModel.getEigenDecomposition();
// double[][] q = codonModel.getQ();
// System.err.println("matrixQ = \n"+codonModel.printQ());// new Matrix(q));
FrequencyModel freqModel = new FrequencyModel(HiddenCodons.UNIVERSAL_HIDDEN_2, new Parameter.Default(122, 1.0 / 122.0));
System.err.println("freq = " + new Vector(freqModel.getFrequencies()));
// System.exit(-1);
MarkovModulatedGY94CodonModel mmCodonModel = new MarkovModulatedGY94CodonModel(HiddenCodons.UNIVERSAL_HIDDEN_2,
new Parameter.Default(2, 5.0), new Parameter.Default(2, 1.0),
new Parameter.Default(2.0), freqModel
);
EigenDecomposition ed2 = mmCodonModel.getEigenDecomposition();
System.err.println("matrixQ = \n" + mmCodonModel.printQ());// new Matrix(q));
}
示例3: getCodonPartitionedRobustCountings
private static RootConditionedCodonPartitionedRobustCounting[] getCodonPartitionedRobustCountings(final TreeModel treeModel, final AncestralStateBeagleTreeLikelihood[] treeLikelihoods) {
RootConditionedCodonPartitionedRobustCounting[] robustCounts = new RootConditionedCodonPartitionedRobustCounting[2];
String[] type = new String[]{"S", "N"};
StratifiedTraitOutputFormat branchFormat = StratifiedTraitOutputFormat.SUM_OVER_SITES;
StratifiedTraitOutputFormat logFormat = StratifiedTraitOutputFormat.SUM_OVER_SITES;
for (int i = 0; i < 2; i++) {
robustCounts[i] = new RootConditionedCodonPartitionedRobustCounting(
type[i],
treeModel,
treeLikelihoods,
Codons.UNIVERSAL,
CodonLabeling.parseFromString(type[i]),
true, // uniformization
true, // external branches
true, // internal branches
true, // unconditional per branch
false, // complete history
branchFormat,
logFormat);
}
return robustCounts;
}
示例4: parseXMLObject
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Codons codons = Codons.UNIVERSAL;
if (xo.hasAttribute(GeneticCode.GENETIC_CODE)) {
String codeStr = xo.getStringAttribute(GeneticCode.GENETIC_CODE);
codons = Codons.findByName(codeStr);
}
Parameter omegaParam = (Parameter)xo.getElementFirstChild(OMEGA);
Parameter kappaParam = (Parameter)xo.getElementFirstChild(KAPPA);
FrequencyModel freqModel = (FrequencyModel)xo.getChild(FrequencyModel.class);
GY94CodonModel codonModel = new GY94CodonModel(codons, omegaParam, kappaParam, freqModel);
// codonModel.printRateMap();
return codonModel;
}
示例5: PCARateMatrixMammalia
/**
* constructor
*
* @param nrOfPCs Number of PCs to use
* @param dir Directory which includes the rate matrix csv files
*/
public PCARateMatrixMammalia(int nrOfPCs, String dir) {
super("mammalia", Codons.UNIVERSAL, dir);
// reading data files:
setupMeans();
setupFreqs();
setupScales();
setupStartFacs();
setupPCs(nrOfPCs);
}
示例6: createDataType
public DataType createDataType() {
DataType dataType = null;
if (this.dataTypeIndex == 0) { // Nucleotide
dataType = Nucleotides.INSTANCE;
} else if (this.dataTypeIndex == 1) { // Codon
dataType = Codons.UNIVERSAL;
} else if (this.dataTypeIndex == 2) { // AminoAcid
dataType = AminoAcids.INSTANCE;
} else {
System.out.println("Not yet implemented");
}
return dataType;
}
示例7: simulateRandomBranchAssignment
static void simulateRandomBranchAssignment() {
try {
System.out.println("Test case I dunno which: simulate random branch assignments");
MathUtils.setSeed(666);
int sequenceLength = 10;
ArrayList<Partition> partitionsList = new ArrayList<Partition>();
File treeFile = new File("/home/filip/Dropbox/BeagleSequenceSimulator/SimTree/SimTree.figtree");
Tree tree = Utils.importTreeFromFile(treeFile);
TreeModel treeModel = new TreeModel(tree);
// create Frequency Model
Parameter freqs = new Parameter.Default(Utils.UNIFORM_CODON_FREQUENCIES);
FrequencyModel freqModel = new FrequencyModel(Codons.UNIVERSAL,
freqs);
// create base subst model
Parameter omegaParameter = new Parameter.Default("omega", 1, 1.0);
Parameter kappaParameter = new Parameter.Default("kappa", 1, 1.0);
GY94CodonModel baseSubModel = new GY94CodonModel(Codons.UNIVERSAL, omegaParameter, kappaParameter, freqModel);
RandomBranchModel substitutionModel = new RandomBranchModel(treeModel, baseSubModel, 0.25, false, -1);
// create site model
GammaSiteRateModel siteRateModel = new GammaSiteRateModel(
"siteModel");
// create branch rate model
BranchRateModel branchRateModel = new DefaultBranchRateModel();
// create partition
Partition partition1 = new Partition(treeModel, //
substitutionModel,//
siteRateModel, //
branchRateModel, //
freqModel, //
0, // from
sequenceLength - 1, // to
1 // every
);
// Sequence ancestralSequence = new Sequence();
// ancestralSequence.appendSequenceString("TCAAGTGAGG");
// partition1.setRootSequence(ancestralSequence);
partitionsList.add(partition1);
// feed to sequence simulator and generate data
BeagleSequenceSimulator simulator = new BeagleSequenceSimulator(
partitionsList);
SimpleAlignment alignment = simulator.simulate(simulateInPar, true);
// alignment.setOutputType(SimpleAlignment.OutputType.NEXUS);
alignment.setOutputType(SimpleAlignment.OutputType.XML);
System.out.println(alignment.toString());
} catch (Exception e) {
e.printStackTrace();
}// END: try-catch
}
示例8: PCARateMatrixMammalia
public PCARateMatrixMammalia(int nrOfPCs, String dir) {
super("mammalia", Codons.UNIVERSAL, dir);
// reading data files
setupMeans();
setupFreqs();
setupScales();
setupStartFacs();
setupPCs(nrOfPCs);
}
示例9: parseXMLObject
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Codons codons = Codons.UNIVERSAL;
if (xo.hasAttribute(GeneticCode.GENETIC_CODE)) {
String codeStr = xo.getStringAttribute(GeneticCode.GENETIC_CODE);
codons = Codons.findByName(codeStr);
}
Parameter omegaParameter = (Parameter)xo.getElementFirstChild(OMEGA);
int dim = omegaParameter.getDimension();
double value = omegaParameter.getParameterValue(dim - 1);
if(value < 0) {
throw new RuntimeException("Negative Omega parameter value " + value);
}//END: negative check
Parameter kappaParameter = (Parameter)xo.getElementFirstChild(KAPPA);
dim = kappaParameter.getDimension();
value = kappaParameter.getParameterValue(dim - 1);
if(value < 0) {
throw new RuntimeException("Negative kappa parameter value value " + value);
}//END: negative check
FrequencyModel freqModel = (FrequencyModel)xo.getChild(FrequencyModel.class);
GY94CodonModel codonModel = new GY94CodonModel(codons, omegaParameter, kappaParameter, freqModel);
// codonModel.printRateMap();
return codonModel;
}
示例10: testCodonSimulation
public void testCodonSimulation() {
Parameter kappa = new Parameter.Default(1, 2.0);
Parameter omega = new Parameter.Default(1, 5.0); // Expect many more non-syn changes
Codons codons = Codons.UNIVERSAL;
int stateCount = codons.getStateCount();
double[] p = new double[stateCount];
for (int i = 0; i < stateCount; i++) {
p[i] = 1.0 / (double) stateCount;
}
Parameter pi = new Parameter.Default(p);
FrequencyModel f = new FrequencyModel(codons, pi);
GY94CodonModel codonModel = new GY94CodonModel(codons, omega, kappa, f);
Parameter mu = new Parameter.Default(1, 0.5);
Parameter alpha = new Parameter.Default(1, 0.5);
GammaSiteRateModel siteModel = new GammaSiteRateModel("gammaModel", mu, alpha, 4, null);
siteModel.setSubstitutionModel(codonModel);
BranchRateModel branchRateModel = new DefaultBranchRateModel();
double analyticResult = Tree.Utils.getTreeLength(tree, tree.getRoot()) * mu.getParameterValue(0);
int nSites = 100;
double[] synRegMatrix = CodonLabeling.getRegisterMatrix(CodonLabeling.SYN, codons, false); // use base 61
double[] nonSynRegMatrix = CodonLabeling.getRegisterMatrix(CodonLabeling.NON_SYN, codons, false); // use base 61
runSimulation(tree, siteModel, branchRateModel, nSites,
new double[][] {synRegMatrix, nonSynRegMatrix}, analyticResult);
}
示例11: Defects
public Defects(Alignment alignment) {
Codons codons = Codons.UNIVERSAL;
Nucleotides nucs = Nucleotides.INSTANCE;
Alignment codonAlignment = new ConvertAlignment(codons, alignment);
sequenceCount = codonAlignment.getSequenceCount();
for (int i = 0; i < codonAlignment.getSequenceCount(); i++) {
for (int j = 0; j < codonAlignment.getSiteCount(); j++) {
int state = codonAlignment.getState(i, j);
if (codons.isStopCodon(state)) {
//System.out.print("*");
// System.out.println("Found stop codon: " + triplet + " in sequence " + codonAlignment.getTaxonId(i) + " at site " + j);
addDefect(STOP, i, j);
totalReads += 1;
} else if (codons.isGapState(state)) {
//System.out.print("?");
// go back to original alignment and check
int start = j*3;
int state1 = alignment.getState(i,start);
int state2 = alignment.getState(i,start+1);
int state3 = alignment.getState(i,start+2);
if (nucs.isGapState(state1) && nucs.isGapState(state2) && nucs.isGapState(state3)) {
// real gap
} else {
// defect
// System.out.println("Found gap in sequence " + codonAlignment.getTaxonId(i) + " at site " + j);
addDefect(INDEL, i, j);
//totalReads += 1;
}
} else {
//System.out.print(" ");
totalReads += 1;
}
}
//System.out.println();
}
}
示例12: parseXMLObject
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Codons codons = Codons.UNIVERSAL;
if (xo.hasAttribute(GeneticCode.GENETIC_CODE)) {
String codeStr = xo.getStringAttribute(GeneticCode.GENETIC_CODE);
if (codeStr.equals(GeneticCode.UNIVERSAL.getName())) {
codons = Codons.UNIVERSAL;
} else if (codeStr.equals(GeneticCode.VERTEBRATE_MT.getName())) {
codons = Codons.VERTEBRATE_MT;
} else if (codeStr.equals(GeneticCode.YEAST.getName())) {
codons = Codons.YEAST;
} else if (codeStr.equals(GeneticCode.MOLD_PROTOZOAN_MT.getName())) {
codons = Codons.MOLD_PROTOZOAN_MT;
} else if (codeStr.equals(GeneticCode.INVERTEBRATE_MT.getName())) {
codons = Codons.INVERTEBRATE_MT;
} else if (codeStr.equals(GeneticCode.CILIATE.getName())) {
codons = Codons.CILIATE;
} else if (codeStr.equals(GeneticCode.ECHINODERM_MT.getName())) {
codons = Codons.ECHINODERM_MT;
} else if (codeStr.equals(GeneticCode.EUPLOTID_NUC.getName())) {
codons = Codons.EUPLOTID_NUC;
} else if (codeStr.equals(GeneticCode.BACTERIAL.getName())) {
codons = Codons.BACTERIAL;
} else if (codeStr.equals(GeneticCode.ALT_YEAST.getName())) {
codons = Codons.ALT_YEAST;
} else if (codeStr.equals(GeneticCode.ASCIDIAN_MT.getName())) {
codons = Codons.ASCIDIAN_MT;
} else if (codeStr.equals(GeneticCode.FLATWORM_MT.getName())) {
codons = Codons.FLATWORM_MT;
} else if (codeStr.equals(GeneticCode.BLEPHARISMA_NUC.getName())) {
codons = Codons.BLEPHARISMA_NUC;
} else if (codeStr.equals(GeneticCode.NO_STOPS.getName())) {
codons = Codons.NO_STOPS;
}
}
Parameter omegaParam = (Parameter)xo.getElementFirstChild(OMEGA);
Parameter kappaParam = (Parameter)xo.getElementFirstChild(KAPPA);
FrequencyModel freqModel = (FrequencyModel)xo.getChild(FrequencyModel.class);
// codonModel.printRateMap();
return new YangCodonModel(codons, omegaParam, kappaParam, freqModel);
}
示例13: parseXMLObject
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Codons codons = Codons.UNIVERSAL;
if (xo.hasAttribute(GeneticCode.GENETIC_CODE)) {
String codeStr = xo.getStringAttribute(GeneticCode.GENETIC_CODE);
if (codeStr.equals(GeneticCode.UNIVERSAL.getName())) {
codons = Codons.UNIVERSAL;
} else if (codeStr.equals(GeneticCode.VERTEBRATE_MT.getName())) {
codons = Codons.VERTEBRATE_MT;
} else if (codeStr.equals(GeneticCode.YEAST.getName())) {
codons = Codons.YEAST;
} else if (codeStr.equals(GeneticCode.MOLD_PROTOZOAN_MT.getName())) {
codons = Codons.MOLD_PROTOZOAN_MT;
} else if (codeStr.equals(GeneticCode.INVERTEBRATE_MT.getName())) {
codons = Codons.INVERTEBRATE_MT;
} else if (codeStr.equals(GeneticCode.CILIATE.getName())) {
codons = Codons.CILIATE;
} else if (codeStr.equals(GeneticCode.ECHINODERM_MT.getName())) {
codons = Codons.ECHINODERM_MT;
} else if (codeStr.equals(GeneticCode.EUPLOTID_NUC.getName())) {
codons = Codons.EUPLOTID_NUC;
} else if (codeStr.equals(GeneticCode.BACTERIAL.getName())) {
codons = Codons.BACTERIAL;
} else if (codeStr.equals(GeneticCode.ALT_YEAST.getName())) {
codons = Codons.ALT_YEAST;
} else if (codeStr.equals(GeneticCode.ASCIDIAN_MT.getName())) {
codons = Codons.ASCIDIAN_MT;
} else if (codeStr.equals(GeneticCode.FLATWORM_MT.getName())) {
codons = Codons.FLATWORM_MT;
} else if (codeStr.equals(GeneticCode.BLEPHARISMA_NUC.getName())) {
codons = Codons.BLEPHARISMA_NUC;
} else if (codeStr.equals(GeneticCode.NO_STOPS.getName())) {
codons = Codons.NO_STOPS;
}
}
// get number of PCs
Parameter pcaDimensionParameter = (Parameter)xo.getElementFirstChild(PCA_DIMENSION);
// get directory with pca rate matrix files; fallback to default "pcadata"
String dirString = "pcadata";
if(xo.hasAttribute(PCA_DATA_DIR)) {
dirString = xo.getStringAttribute(PCA_DATA_DIR);
}
// get type of rate matrix; fallback to mammalia pca
AbstractPCARateMatrix pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
// check for other type of pca
if(xo.hasAttribute(PCATYPE)) {
String pcaTypeString = xo.getStringAttribute(PCATYPE);
if(pcaTypeString.equals(PCARateMatrixMammalia.getName())) {
pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
}
}
// decide if getting frequencies from csv or estimating from MSA
FrequencyModel freqModel = null;
if (xo.getChild(FrequencyModel.class) != null) {
freqModel = (FrequencyModel)xo.getChild(FrequencyModel.class);
} else {
freqModel = createNewFreqModel(codons, pcaType);
}
return new PCACodonModel(codons, pcaType, pcaDimensionParameter, freqModel);
}
示例14: parseXMLObject
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Codons codons = Codons.UNIVERSAL;
if (xo.hasAttribute(GeneticCode.GENETIC_CODE)) {
String codeStr = xo.getStringAttribute(GeneticCode.GENETIC_CODE);
if (codeStr.equals(GeneticCode.UNIVERSAL.getName())) {
codons = Codons.UNIVERSAL;
} else if (codeStr.equals(GeneticCode.VERTEBRATE_MT.getName())) {
codons = Codons.VERTEBRATE_MT;
} else if (codeStr.equals(GeneticCode.YEAST.getName())) {
codons = Codons.YEAST;
} else if (codeStr.equals(GeneticCode.MOLD_PROTOZOAN_MT.getName())) {
codons = Codons.MOLD_PROTOZOAN_MT;
} else if (codeStr.equals(GeneticCode.INVERTEBRATE_MT.getName())) {
codons = Codons.INVERTEBRATE_MT;
} else if (codeStr.equals(GeneticCode.CILIATE.getName())) {
codons = Codons.CILIATE;
} else if (codeStr.equals(GeneticCode.ECHINODERM_MT.getName())) {
codons = Codons.ECHINODERM_MT;
} else if (codeStr.equals(GeneticCode.EUPLOTID_NUC.getName())) {
codons = Codons.EUPLOTID_NUC;
} else if (codeStr.equals(GeneticCode.BACTERIAL.getName())) {
codons = Codons.BACTERIAL;
} else if (codeStr.equals(GeneticCode.ALT_YEAST.getName())) {
codons = Codons.ALT_YEAST;
} else if (codeStr.equals(GeneticCode.ASCIDIAN_MT.getName())) {
codons = Codons.ASCIDIAN_MT;
} else if (codeStr.equals(GeneticCode.FLATWORM_MT.getName())) {
codons = Codons.FLATWORM_MT;
} else if (codeStr.equals(GeneticCode.BLEPHARISMA_NUC.getName())) {
codons = Codons.BLEPHARISMA_NUC;
} else if (codeStr.equals(GeneticCode.NO_STOPS.getName())) {
codons = Codons.NO_STOPS;
}
}
// get number of PCs
Parameter pcaDimensionParameter = (Parameter)xo.getElementFirstChild(PCA_DIMENSION);
// get directory with pca rate matrix files; fallback to default "pcadata"
String dirString = "pcadata";
if(xo.hasAttribute(PCA_DATA_DIR)) {
dirString = xo.getStringAttribute(PCA_DATA_DIR);
}
// get type of rate matrix; fallback to mammalia pca
AbstractPCARateMatrix pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
// check for other type of pca
if(xo.hasAttribute(PCATYPE)) {
String pcaTypeString = xo.getStringAttribute(PCATYPE);
if(pcaTypeString.equals(PCARateMatrixMammalia.getName())) {
pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
}
}
// decide if getting frequencies from csv or estimating from MSA
FrequencyModel freqModel = null;
if (xo.getChild(FrequencyModel.class) != null) {
freqModel = (FrequencyModel)xo.getChild(FrequencyModel.class);
} else {
freqModel = createNewFreqModel(codons, pcaType);
}
return new PCACodonModel(codons, pcaType, pcaDimensionParameter, freqModel);
}
示例15: setUp
public void setUp() {
codons = Codons.UNIVERSAL;
geneticCode = codons.getGeneticCode();
}