本文整理汇总了C++中Genome::addGene方法的典型用法代码示例。如果您正苦于以下问题:C++ Genome::addGene方法的具体用法?C++ Genome::addGene怎么用?C++ Genome::addGene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Genome
的用法示例。
在下文中一共展示了Genome::addGene方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: simulateGenome
void PANSEModel::simulateGenome(Genome &genome)
{
for (unsigned geneIndex = 0; geneIndex < genome.getGenomeSize(); geneIndex++)
{
unsigned mixtureElement = getMixtureAssignment(geneIndex);
Gene gene = genome.getGene(geneIndex);
double phi = parameter->getSynthesisRate(geneIndex, mixtureElement, false);
Gene tmpGene = gene;
for (unsigned codonIndex = 0; codonIndex < 61; codonIndex++)
{
std::string codon = SequenceSummary::codonArray[codonIndex];
unsigned alphaCat = parameter->getMutationCategory(mixtureElement);
unsigned lambdaPrimeCat = parameter->getSelectionCategory(mixtureElement);
double alpha = getParameterForCategory(alphaCat, PANSEParameter::alp, codon, false);
double lambdaPrime = getParameterForCategory(lambdaPrimeCat, PANSEParameter::lmPri, codon, false);
double alphaPrime = alpha * gene.geneData.getCodonCountForCodon(codon);
#ifndef STANDALONE
RNGScope scope;
NumericVector xx(1);
xx = rgamma(1, alphaPrime, 1.0/lambdaPrime);
xx = rpois(1, xx[0] * phi);
tmpGene.geneData.setRFPValue(codonIndex, xx[0]);
#else
std::gamma_distribution<double> GDistribution(alphaPrime,1.0/lambdaPrime);
double tmp = GDistribution(Parameter::generator);
std::poisson_distribution<unsigned> PDistribution(phi * tmp);
unsigned simulatedValue = PDistribution(Parameter::generator);
tmpGene.geneData.setRFPValue(codonIndex, simulatedValue);
#endif
}
genome.addGene(tmpGene, true);
}
}
示例2: simulateGenome
void FONSEModel::simulateGenome(Genome & genome)
{
unsigned codonIndex;
std::string curAA;
std::string tmpDesc = "Simulated Gene";
for (unsigned geneIndex = 0; geneIndex < genome.getGenomeSize(); geneIndex++) //loop over all genes in the genome
{
if (geneIndex % 100 == 0) my_print("Simulating Gene %\n", geneIndex);
Gene gene = genome.getGene(geneIndex);
SequenceSummary sequenceSummary = gene.geneData;
std::string tmpSeq = "ATG"; //Always will have the start amino acid
unsigned mixtureElement = getMixtureAssignment(geneIndex);
unsigned mutationCategory = getMutationCategory(mixtureElement);
unsigned selectionCategory = getSelectionCategory(mixtureElement);
unsigned synthesisRateCategory = getSynthesisRateCategory(mixtureElement);
double phi = getSynthesisRate(geneIndex, synthesisRateCategory, false);
std::string geneSeq = gene.getSequence();
for (unsigned position = 1; position < (geneSeq.size() / 3); position++)
{
std::string codon = geneSeq.substr((position * 3), 3);
curAA = SequenceSummary::codonToAA(codon);
//TODO: Throw an error here instead
if (curAA == "X") {
if (position < (geneSeq.size() / 3) - 1) my_print("Warning: Internal stop codon found in gene % at position %. Ignoring and moving on.\n", gene.getId(), position);
continue;
}
unsigned numCodons = SequenceSummary::GetNumCodonsForAA(curAA);
double* codonProb = new double[numCodons](); //size the arrays to the proper size based on # of codons.
double* mutation = new double[numCodons - 1]();
double* selection = new double[numCodons - 1]();
if (curAA == "M" || curAA == "W")
{
codonProb[0] = 1;
}
else
{
getParameterForCategory(mutationCategory, FONSEParameter::dM, curAA, false, mutation);
getParameterForCategory(selectionCategory, FONSEParameter::dOmega, curAA, false, selection);
calculateCodonProbabilityVector(numCodons, position, mutation, selection, phi, codonProb);
}
codonIndex = Parameter::randMultinom(codonProb, numCodons);
unsigned aaStart, aaEnd;
SequenceSummary::AAToCodonRange(curAA, aaStart, aaEnd, false); //need the first spot in the array where the codons for curAA are
codon = sequenceSummary.indexToCodon(aaStart + codonIndex);//get the correct codon based off codonIndex
tmpSeq += codon;
}
std::string codon = sequenceSummary.indexToCodon((unsigned)Parameter::randUnif(61.0, 64.0)); //randomly choose a stop codon, from range 61-63
tmpSeq += codon;
Gene simulatedGene(tmpSeq, tmpDesc, gene.getId());
genome.addGene(simulatedGene, true);
}
}