本文整理汇总了C++中boom::String::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ String::c_str方法的具体用法?C++ String::c_str怎么用?C++ String::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boom::String
的用法示例。
在下文中一共展示了String::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: os
void BOOM::FastaWriter::writeFasta(const BOOM::String &defline,
const BOOM::String &sequence,
const BOOM::String &filename)
{
ofstream os(filename.c_str());
addToFasta(defline,sequence.c_str(),os);
}
示例2: generateModel
void Application::generateModel(const BOOM::String &filename,
const BOOM::String &startCodonModelFile)
{
// Create output file
ofstream os(filename.c_str());
os<<"SignalPeptide"<<endl;
// Copy the start codon model into the file
ifstream is(startCodonModelFile.c_str());
BOOM::String line;
while(!is.eof())
{
line.getline(is);
if(is.eof()) break;
os<<line<<endl;
}
// Write out each field separately
os<<numFields<<endl;
for(int fieldNum=0 ; fieldNum<numFields ; ++fieldNum)
{
Field &field=*fields[fieldNum];
// Count the number of codons (you just never know...)
BOOM::Map<char,float>::iterator aCur=field.aminoAcidFreqs.begin(),
aEnd=field.aminoAcidFreqs.end();
numCodons=0;
for(; aCur!=aEnd ; ++aCur)
{
char acid=(*aCur).first;
float &acidP=(*aCur).second;
BOOM::Map<BOOM::String,float> codons=codonFreqs[acid];
numCodons+=codons.size();
}
os<<field.fieldLength<<endl;
os<<numCodons<<endl;
aCur=field.aminoAcidFreqs.begin(); aEnd=field.aminoAcidFreqs.end();
for(; aCur!=aEnd ; ++aCur)
{
char acid=(*aCur).first;
float &acidP=(*aCur).second;
BOOM::Map<BOOM::String,float> codons=codonFreqs[acid];
BOOM::Map<BOOM::String,float>::iterator cur=codons.begin(),
end=codons.end();
for(; cur!=end ; ++cur)
{
BOOM::String codon=(*cur).first;
float codonP=(*cur).second;
float logP=log(acidP*codonP);
os<<codon<<" "<<logP<<endl;
}
}
}
}
示例3: counts
double BOOM::SequenceEntropy::entropy(const BOOM::String &str,
double &maxEntropy)
{
int len=str.length();
BOOM::StringMap<int> counts(hashTableSize(0));
const char *p=str.c_str();
int total=0;
for(int i=0 ; i<len ; ++i, ++p)
{
if(counts.isDefined(p,1))
++counts.lookup(p,1);
else
counts.lookup(p,1)=1;
++total;
}
double entropy=0;
StringMapIterator<int> cur=counts.begin(), end=counts.end();
for(; cur!=end ; ++cur)
{
int count=(*cur).second;
double p=count/double(total);
entropy-=p*lg(p);
}
maxEntropy=-lg(1.0/counts.size());
if(entropy>maxEntropy) entropy=maxEntropy;
return entropy;
}
示例4: save
bool IMM::save(const BOOM::String &filename)
{
ofstream os(filename.c_str());
if(!os.good()) throw BOOM::String("Error creating file ")+filename+
"in IMM::save()";
return save(os);
}
示例5: save
bool ThreePeriodicMarkovChain::save(const BOOM::String &filename)
{
ofstream os(filename.c_str());
if(!os.good()) throw BOOM::String("Error creating file ")+filename+
"in ThreePeriodicMarkovChain::save()";
return save(os);
}
示例6: String
double BOOM::SequenceEntropy::jointEntropy(const BOOM::String &str,
int order,
double &maxEntropy)
{
int len=str.length();
int gramSize=order+1;
if(gramSize>=len)
throw BOOM::String("Order ")+order+
" is too large for sequence of length "+len;
int numWindows=len-gramSize+1;
BOOM::StringMap<int> counts(hashTableSize(order));
const char *p=str.c_str();
int total=0;
for(int i=0 ; i<numWindows ; ++i, ++p)
{
if(counts.isDefined(p,gramSize))
++counts.lookup(p,gramSize);
else
counts.lookup(p,gramSize)=1;
++total;
}
double entropy=0;
StringMapIterator<int> cur=counts.begin(), end=counts.end();
for(; cur!=end ; ++cur)
{
int count=(*cur).second;
double p=count/double(total);
entropy-=p*lg(p);
}
maxEntropy=-lg(1.0/counts.size());
if(entropy>maxEntropy) entropy=maxEntropy;
return entropy;
}
示例7: writeHistogramFile
void Application::writeHistogramFile(BOOM::Vector<double> &scores,
const BOOM::String &filename)
{
ofstream os(filename.c_str());
BOOM::Vector<double>::iterator cur=scores.begin(), end=scores.end();
for(; cur!=end ; ++cur)
os<<*cur<<endl;
}
示例8: save
bool BranchAcceptor::save(const BOOM::String &filename)
{
ofstream os(filename.c_str());
if(!os.good())
throw BOOM::String("Error creating file ")+filename+
"in BranchPoint::save()";
return save(os);
}
示例9: addConsensus
void SignalSensor::addConsensus(const BOOM::String &s)
{
int len=s.length();
if(consensusLength>0 && consensusLength!=len)
throw BOOM::String(
"Consensus lengths differ in SignalSensor::addConsensus");
consensusLength=len;
consensuses.lookup(s.c_str(),len)=char(1);
}
示例10: is
IMM::IMM(const BOOM::String &filename)
: revComp(NULL), models(new BOOM::Vector<BOOM::StringMap<double>*>)
{
ifstream is(filename.c_str());
if(!is.good()) throw BOOM::String("Error opening file ")+filename
+" in IMM::IMM()";
BOOM::String modelType;
is >> modelType;
if(modelType!="IMM")
throw BOOM::String("Attempt to load an object of type ")+modelType+
" into an IMM";
load(is);
}
示例11: is
ThreePeriodicMarkovChain::ThreePeriodicMarkovChain(const BOOM::String &
filename)
{
ifstream is(filename.c_str());
if(!is.good()) throw BOOM::String("Error opening file ")+filename
+" in ThreePeriodicMarkovChain()";
BOOM::String modelType;
is >> modelType;
if(modelType!="3P")
throw BOOM::String("Attempt to load an object of type ")+modelType+
" into a ThreePeriodicMarkovChain (3P)";
load(is);
}
示例12: updateCodonFreqs
void Application::updateCodonFreqs(const BOOM::String &transcript)
{
const char *str=transcript.c_str();
int len=transcript.length();
const char *p=str;
for(int i=0 ; i<len ; i+=3, p+=3)
{
BOOM::String codon(p,3);
char acid=BOOM::ProteinTrans::mapCodon(codon.c_str());
BOOM::Map<BOOM::String,float> &counts=codonFreqs[acid];
if(!counts.isDefined(codon)) counts[codon]=1;
else ++counts[codon];
}
}
示例13: load
void EmpiricalDistribution::load(const BOOM::String &filename)
{
ifstream is(filename.c_str());
if(!is.good()) throw BOOM::String("Error opening file ")+filename+
" in EmpiricalDistribution::load()";
while(!is.eof())
{
unsigned x;
double y;
is >> x;
if(is.eof()) break;
is >> y;
v.push_back(new EmpiricalDistributionElement(x,y));
}
binSize=v[1]->first-v[0]->first;
}
示例14: is
BranchAcceptor::BranchAcceptor(GarbageCollector &gc,BOOM::String &filename)
: SignalSensor(gc),
branchPoint(NULL),
acceptor(NULL)
{
// ctor
ifstream is(filename.c_str());
if(!is.good()) throw BOOM::String("Error opening file ")+filename+
"in BranchAcceptor::BranchAcceptor()";
BOOM::String modelType;
is >> modelType;
if(modelType!="BranchAcceptor")
throw BOOM::String("Attempt to load an object of type ")+modelType+
"in into a BranchAcceptor";
load(is);
}
示例15: scoreSingleBase
double IMM::scoreSingleBase(const Sequence &seq,const BOOM::String &str,
int index,Symbol s,char c)
{
const char *p=str.c_str();
switch(getStrand())
{
case PLUS_STRAND:
{
int maxOrder=(index>N ? N : index);
for(int order=maxOrder ; order>=0 ; --order)
{
BOOM::StringMap<double> &model=*(*models)[order];
if(model.isDefined(p,index-order,order+1))
return model.lookup(p,index-order,order+1);
}
throw BOOM::String("IMM::scoreSingleBase('+',")+
index+",strlen="+strlen(p)+",str="+
str.substring(index,maxOrder)+")";
}
case MINUS_STRAND:
{
/*
On the minus strand we have to take our contexts from the
right (but only because we trained the model that way)
*/
int seqLen=str.length();
int maxOrder=seqLen-index-1;
if(maxOrder>N) maxOrder=N;
for(int order=maxOrder ; order>=0 ; --order)
{
BOOM::StringMap<double> &model=*(*models)[order];
if(model.isDefined(p,index,order+1))
return model.lookup(p,index,order+1);
}
throw BOOM::Stacktrace(
BOOM::String("IMM::scoreSingleBase('-',")+
index+",strlen="+strlen(p)+",str="+
str.substring(index,maxOrder)+")");
}
default: throw BOOM::String(__FILE__)+__LINE__;
}
}