本文整理汇总了C++中Seq类的典型用法代码示例。如果您正苦于以下问题:C++ Seq类的具体用法?C++ Seq怎么用?C++ Seq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Seq类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EqIgnoreCase
bool Seq::EqIgnoreCase(const Seq &s) const
{
const unsigned n = Length();
if (n != s.Length())
{
return false;
}
for (unsigned i = 0; i < n; ++i)
{
const char c1 = at(i);
const char c2 = s.at(i);
if (IsGap(c1))
{
if (!IsGap(c2))
return false;
}
else
{
if (toupper(c1) != toupper(c2))
{
return false;
}
}
}
return true;
}
示例2: read_test_data
void CWSInput1WithFeatureModelHandler<RNNDerived, I1Model>::predict(std::istream &is, std::ostream &os)
{
std::vector<Seq> raw_instances;
std::vector<IndexSeq> sents ;
std::vector<CWSFeatureDataSeq> cws_feature_seqs;
read_test_data(is, raw_instances, sents, cws_feature_seqs );
BOOST_LOG_TRIVIAL(info) << "do prediction on " << raw_instances.size() << " instances .";
BasicStat stat(true);
stat.start_time_stat();
for (unsigned int i = 0; i < raw_instances.size(); ++i)
{
Seq &raw_sent = raw_instances.at(i);
if (0 == raw_sent.size())
{
os << "\n";
continue;
}
IndexSeq &sent = sents.at(i) ;
CWSFeatureDataSeq &cws_feature_seq = cws_feature_seqs.at(i);
IndexSeq pred_tag_seq;
dynet::ComputationGraph cg;
i1m->predict(cg, sent, cws_feature_seq, pred_tag_seq);
Seq words ;
CWSTaggingSystem::static_parse_chars_indextag2word_seq(raw_sent, pred_tag_seq, words) ;
os << words[0] ;
for( size_t i = 1 ; i < words.size() ; ++i ) os << OutputDelimiter << words[i] ;
os << "\n";
stat.total_tags += pred_tag_seq.size() ;
}
stat.end_time_stat() ;
BOOST_LOG_TRIVIAL(info) << stat.get_stat_str("predict done.") ;
}
示例3: empty
operator Seq<U,CA,A>() const
{
Seq<U,CA,A> result;
result.transfer( result.end(), values_ );
BOOST_ASSERT( empty() );
return result;
}
示例4: size
std::size_t size(const Seq& seq)
{
std::size_t d = 0;
for (typename Seq::const_iterator it=seq.begin(); it!=seq.end(); ++it)
d += boost::asio::buffer_size(*it);
return d;
}
示例5: emit_sep
void emit_sep(
Seq const &s, std::size_t step, Printer &&p
)
{
auto iter(s.begin());
std::size_t c(0);
auto lc(std::min(s.size(), c + step));
if (lc) {
auto xc(c);
printf("\t\t");
p(*iter++);
for (++xc; xc < lc; ++xc) {
printf(", ");
p(*iter++);
}
}
c += lc;
for (; c < s.size(); c += step) {
printf(",\n");
lc = std::min(s.size(), c + step);
if (!lc)
break;
auto xc(c);
printf("\t\t");
p(*iter++);
for (++xc; xc < lc; ++xc) {
printf(", ");
p(*iter++);
}
}
}
示例6: EstringOp
unsigned EstringOp(const short es[], const Seq &sIn, MSA &a)
{
unsigned uSymbols;
unsigned uIndels;
EstringCounts(es, &uSymbols, &uIndels);
assert(sIn.Length() == uSymbols);
unsigned uColCount = uSymbols + uIndels;
a.Clear();
a.SetSize(1, uColCount);
a.SetSeqName(0, sIn.GetName());
a.SetSeqId(0, sIn.GetId());
unsigned p = 0;
unsigned uColIndex = 0;
for (;;)
{
int n = *es++;
if (0 == n)
break;
if (n > 0)
for (int i = 0; i < n; ++i)
{
char c = sIn[p++];
a.SetChar(0, uColIndex++, c);
}
else
for (int i = 0; i < -n; ++i)
a.SetChar(0, uColIndex++, '-');
}
assert(uColIndex == uColCount);
return uColCount;
}
示例7: variance_pf
double variance_pf(Seq &sq) {
double av=0;
double var=0;
int h=0;
typename Seq::iterator it = sq.begin();
while(it != sq.end()) {
av+=*(it) * h;
var+=(*(it)) * h * h ;
it++;
h++;
}
var-=av*av;
if(var<1e-7)
return 0;
return var;
}
示例8: Clear
void SeqVect::FromFASTAFile(TextFile &File)
{
Clear();
FILE *f = File.GetStdioFile();
for (;;)
{
char *Label;
unsigned uLength;
char *SeqData = GetFastaSeq(f, &uLength, &Label);
if (0 == SeqData)
return;
Seq *ptrSeq = new Seq;
for (unsigned i = 0; i < uLength; ++i)
{
char c = SeqData[i];
ptrSeq->push_back(c);
}
ptrSeq->SetName(Label);
push_back(ptrSeq);
delete[] SeqData;
delete[] Label;
}
}
示例9: extract
static void extract(const jsonpack::value &v, char* json_ptr, Seq &value)
{
array_t arr = *v._arr;
value.clear();
for(const auto &it : arr)
{
#ifndef _MSC_VER
// Initialize before use
type_t val = {};
#else
type_t val;
#endif
if( json_traits<type_t&>::match_token_type(it) )
{
json_traits<type_t&>::extract(it, json_ptr, val);
value.insert(value.end(), val); //faster way in each container
}
else
{
throw type_error( "Array item type mismatch" );
}
}
}
示例10: variance_func
double variance_func(Seq &sq) {
if (sq.empty())
return 0;
double av=0;
double var=0;
typename Seq::iterator it = sq.begin();
while(it != sq.end()) {
av+=*(it);
var+=(*(it))*(*(it));
it++;
}
av=av/sq.size();
var=var/sq.size();
var-=av*av;
if(var<1e-7)
return 0;
return var;
}
示例11: purge
template<class Seq> void purge(Seq& c)
{
typename Seq::iterator i;
for(i = c.begin(); i != c.end(); ++i) {
delete *i;
*i = 0;
}
}
示例12: strings
inline Seq
strings (std::initializer_list<X> const& con)
{
Seq collected;
for (auto elm : con)
collected.push_back(elm);
return collected;
}
示例13: Length
void SeqVect::ToFASTAFile(TextFile &File) const
{
unsigned uSeqCount = Length();
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
Seq *ptrSeq = at(uSeqIndex);
ptrSeq->ToFASTAFile(File);
}
}
示例14: Subst
static SCORE Subst(const Seq &seqA, const Seq &seqB, unsigned i, unsigned j)
{
assert(i < seqA.Length());
assert(j < seqB.Length());
unsigned uLetterA = seqA.GetLetter(i);
unsigned uLetterB = seqB.GetLetter(j);
return VTML_SP[uLetterA][uLetterB] + g_scoreCenter;
}
示例15: string_compare
inline int string_compare(const Seq& s, const C* p)
{
std::size_t i = 0;
while((i < s.size()) && (p[i] == s[i]))
{
++i;
}
return (i == s.size()) ? -p[i] : s[i] - p[i];
}