本文整理汇总了Java中dr.evolution.datatype.Codons类的典型用法代码示例。如果您正苦于以下问题:Java Codons类的具体用法?Java Codons怎么用?Java Codons使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Codons类属于dr.evolution.datatype包,在下文中一共展示了Codons类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCodonSimulation
import dr.evolution.datatype.Codons; //导入依赖的package包/类
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: PCACodonModel
import dr.evolution.datatype.Codons; //导入依赖的package包/类
/**
* constructor
*
* @param codonDataType Data type as Codons.UNIVERSAL
* @param pcaType Rate matrix with PCs, means, scale factors
* @param pcaDimensionParameter Scalars for PCs
* @param freqModel Frequency model
*/
public PCACodonModel(Codons codonDataType,
AbstractPCARateMatrix pcaType,
Parameter pcaDimensionParameter,
FrequencyModel freqModel)
{
super(PCACodonModelParser.PCA_CODON_MODEL, codonDataType, freqModel);
this.rateMatrix = pcaType;
// initialize scalars for principal components
this.pcFactors = pcaDimensionParameter;
double[] startFacs = pcaType.getStartFacs();
double facSum = 0.0;
for(int i=0; i<pcFactors.getDimension(); i++) {
facSum += startFacs[i];
}
for(int i=0; i<pcFactors.getDimension(); i++) {
pcFactors.setParameterValueQuietly(i, startFacs[i]/facSum);
}
addVariable(pcFactors);
pcFactors.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
pcFactors.getDimension()));
}
示例3: YangCodonModel
import dr.evolution.datatype.Codons; //导入依赖的package包/类
/**
* Constructor
*/
public YangCodonModel(Codons codonDataType,
Parameter omegaParameter,
Parameter kappaParameter,
FrequencyModel freqModel)
{
super(YangCodonModelParser.YANG_CODON_MODEL, codonDataType, freqModel);
this.omegaParameter = omegaParameter;
addVariable(omegaParameter);
omegaParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
omegaParameter.getDimension()));
this.kappaParameter = kappaParameter;
addVariable(kappaParameter);
kappaParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
kappaParameter.getDimension()));
constructRateMap();
addStatistic(synonymousRateStatistic);
}
示例4: sequence2intArray
import dr.evolution.datatype.Codons; //导入依赖的package包/类
private int[] sequence2intArray(Sequence sequence) {
int array[] = new int[partitionSiteCount];
if (dataType instanceof Codons) {
int k = 0;
for (int i = 0; i < partitionSiteCount; i++) {
array[i] = ((Codons) dataType).getState(sequence.getChar(k),
sequence.getChar(k + 1), sequence.getChar(k + 2));
k += 3;
}// END: replications loop
} else {
for (int i = 0; i < partitionSiteCount; i++) {
array[i] = dataType.getState(sequence.getChar(i));
}// END: replications loop
}// END: dataType check
return array;
}
示例5: CodonPartitionedRobustCounting
import dr.evolution.datatype.Codons; //导入依赖的package包/类
public CodonPartitionedRobustCounting(String name, TreeModel tree,
AncestralStateBeagleTreeLikelihood[] partition,
Codons codons,
CodonLabeling codonLabeling,
boolean useUniformization,
boolean includeExternalBranches,
boolean includeInternalBranches,
boolean doUnconditionalPerBranch,
boolean saveCompleteHistory,
boolean tryNewNeutralModel,
StratifiedTraitOutputFormat branchFormat,
StratifiedTraitOutputFormat logFormat,
String prefix) {
this(name, tree, partition, codons, codonLabeling, useUniformization, includeExternalBranches,
includeInternalBranches, doUnconditionalPerBranch, saveCompleteHistory, false, tryNewNeutralModel,
branchFormat, logFormat, prefix);
}
示例6: PCACodonModel
import dr.evolution.datatype.Codons; //导入依赖的package包/类
public PCACodonModel(Codons codonDataType,
AbstractPCARateMatrix pcaType,
Parameter pcaDimensionParameter,
FrequencyModel freqModel,
EigenSystem eigenSystem)
{
super(PCACodonModelParser.PCA_CODON_MODEL, codonDataType, freqModel, eigenSystem);
this.rateMatrix = pcaType;
this.pcFactors = pcaDimensionParameter;
addVariable(pcFactors);
pcFactors.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
pcFactors.getDimension()));
// initialize scalars for principal components
double[] startFacs = pcaType.getStartFacs();
double facSum = 0.0;
for(int i=0; i<pcFactors.getDimension(); i++) {
facSum += startFacs[i];
}
for(int i=0; i<pcFactors.getDimension(); i++) {
pcFactors.setParameterValueQuietly(i, startFacs[i]/facSum);
}
}
示例7: MG94CodonModel
import dr.evolution.datatype.Codons; //导入依赖的package包/类
public MG94CodonModel(Codons codonDataType,
Parameter alphaParameter,
Parameter betaParameter,
FrequencyModel freqModel, EigenSystem eigenSystem) {
super("MG94", codonDataType, freqModel, eigenSystem);
this.alphaParameter = alphaParameter;
addVariable(alphaParameter);
alphaParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
alphaParameter.getDimension()));
this.betaParameter = betaParameter;
addVariable(betaParameter);
betaParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
betaParameter.getDimension()));
numSynTransitions = getNumSynTransitions();
numNonsynTransitions = getNumNonsynTransitions();
}
示例8: MG94HKYCodonModel
import dr.evolution.datatype.Codons; //导入依赖的package包/类
public MG94HKYCodonModel(Codons codonDataType,
Parameter alphaParameter,
Parameter betaParameter,
Parameter kappaParameter,
// Parameter AtoC_Parameter,
// Parameter AtoG_Parameter,
// Parameter AtoT_Parameter,
// Parameter CtoG_Parameter,
// Parameter CtoT_Parameter,
// Parameter GtoT_Parameter,
FrequencyModel freqModel, EigenSystem eigenSystem) {
super(codonDataType, alphaParameter, betaParameter, freqModel, eigenSystem);
this.kappaParameter = kappaParameter;
addVariable(kappaParameter);
kappaParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
kappaParameter.getDimension()));
}
示例9: main
import dr.evolution.datatype.Codons; //导入依赖的package包/类
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));
}
示例10: expandToBase64
import dr.evolution.datatype.Codons; //导入依赖的package包/类
private byte[] expandToBase64(Codons codonDataType, byte[] in) {
final int stateCount = codonDataType.getStateCount();
byte[] intermediateOut = new byte[64 * 64];
int index = 0;
for (int i = 0; i < stateCount; i++) {
for (int j = i + 1; j < stateCount; j++) {
intermediateOut[codonDataType.getCanonicalState(i) * 64
+ codonDataType.getCanonicalState(j)] = in[index];
index++;
}
}
byte[] out = new byte[(64 * 63) / 2];
index = 0;
for (int i = 0; i < 64; i++) {
for (int j = i + 1; j < 64; j++) {
out[index] = intermediateOut[i * 64 + j];
index++;
}
}
return out;
}
示例11: getCodonPartitionedRobustCountings
import dr.evolution.datatype.Codons; //导入依赖的package包/类
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;
}
示例12: parseXMLObject
import dr.evolution.datatype.Codons; //导入依赖的package包/类
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;
}
示例13: AbstractCodonModel
import dr.evolution.datatype.Codons; //导入依赖的package包/类
public AbstractCodonModel(String name, Codons codonDataType, FrequencyModel freqModel)
{
super(name, codonDataType, freqModel);
this.codonDataType = codonDataType;
this.geneticCode = codonDataType.getGeneticCode();
}
示例14: EmpiricalCodonModel
import dr.evolution.datatype.Codons; //导入依赖的package包/类
/**
* constructor
*
* @param codonDataType Data type as Codons.UNIVERSAL
* @param omegaParam Parameter: Omega
* @param kappaParam Parameter: Kappa (multidimensional)
* @param mntParam Parameter: Multi-nt
* @param rMat Initial rate matrix and frequencies
* @param freqModel Frequency model
*/
public EmpiricalCodonModel(Codons codonDataType,
Parameter omegaParam,
Parameter kappaParam,
Parameter mntParam,
EmpiricalCodonRateMatrix rMat,
FrequencyModel freqModel)
{
super(EmpiricalCodonModelParser.EMPIRICAL_CODON_MODEL, codonDataType, freqModel);
// setup parameters
this.omegaParameter = omegaParam;
addVariable(omegaParameter);
omegaParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
omegaParameter.getDimension()));
if(kappaParam != null) {
this.kappaParameter = kappaParam;
addVariable(kappaParameter);
kappaParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
kappaParameter.getDimension()));
}
if(mntParam != null) {
this.multintParameter = mntParam;
addVariable(multintParameter);
multintParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0,
multintParameter.getDimension()));
}
this.rateMat = rMat;
constructRateMap();
checkForModelType();
}
示例15: PCARateMatrixMammalia
import dr.evolution.datatype.Codons; //导入依赖的package包/类
/**
* 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);
}