本文整理汇总了C++中Items::at方法的典型用法代码示例。如果您正苦于以下问题:C++ Items::at方法的具体用法?C++ Items::at怎么用?C++ Items::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Items
的用法示例。
在下文中一共展示了Items::at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generic_worker_single_thr
/* static */
void Module_DMAP::generic_worker_single_thr(Module_DMAP * search, int id) {
Mask * sequences;
int read_seq;
vector<Mask> printable_solutions;
Transmitting_Result received;
if (search->my_rank == 0) {
sequences = new Mask[SEQUENCES_FOR_BLOCK];
read_seq = read_sequences(search->input_file1, SEQUENCES_FOR_BLOCK, sequences, search->fastqformat, search->gui_output);
} else {
received = search->receive_from_previous(id);
sequences = received.first;
read_seq = received.second;
}
while (read_seq != 0) {
Items solutions;
//ItemsGapped solutions_gapped;
t_errors calculated_errors;
for (int i = 0; i < read_seq; i++) {
Mask & s = sequences[i];
if (search->my_rank == 0 and search->trim) {
// check_routine(sequences[i], 0);
s.quality_trimming_MOTT(search->min_phred_value_MOTT,search->min_mean_quality,search->min_size);
}
if (s.status_discarded()) {
if (s.status_low_complexity())
s.low_complexity =true; //s.set_type(low_complexity);
else
s.low_quality = true; //s.set_type(quality_discarded);
printable_solutions.push_back(s);
continue;
}
if (search->auto_errors)
calculated_errors = round((double)s.get_good_length() / search->errors_rate);
else
calculated_errors = search->common_errors_allowed;
if (search->my_rank != 0 and s.algn > 0 and s.NM < calculated_errors)
calculated_errors = s.NM;
t_errors count = 0;
for (t_pattern_length i = s.get_good_region_start()-1; (i < s.get_good_region_stop()) and (count <= calculated_errors); i++)
if (s.sequence[i] == 'N' or s.sequence[i] == 'n')
count++;
if (count > calculated_errors) {
//s.set_type(alignments_not_found);
printable_solutions.push_back(s);
continue;
}
/** ALIGNMENT **/
solutions.clear();
if (search->my_rank == 0 and search->contamination_check) {
search->CR.search(s.get_good_sequence(),solutions,calculated_errors);
if (solutions.size() > 0)
s.contaminated = true;
}
if (not s.contaminated)
search->H.search(s.get_good_sequence(),solutions,calculated_errors);
if (solutions.size() == 0) {
/** Try gapped **/
/*
solutions_gapped.clear();
if (search->gap)
search->H.search_gapped(s.get_good_sequence(),solutions_gapped,search->seed_sizes,search->seed_errors,calculated_errors,search->max_gap);
*/
/*
if (solutions_gapped.size() == 0) {// size 0 means no alignment found
*/
//s.set_type(alignments_not_found);
printable_solutions.push_back(s);
continue;
/*
} else {
if (not search->printAll) {
Random_Choice_Result r;
bool improved = (s.NM + s.NM_gap) > (solutions_gapped.at(0).errors1 + solutions_gapped.at(0).errors2);
if (improved)
r = Search_MPI::random_choice_from_previous(0,solutions_gapped.size());
else
r = Search_MPI::random_choice_from_previous(s.algn,solutions_gapped.size());
if (not improved and r.first) {
// take the previous solution
s.algn += solutions_gapped.size();
} else {
// update solution
const ResultItemGapped & HM = solutions_gapped.at(r.second);
s.globalPosition = HM.GlobalPosition1;
if (improved)
s.algn = solutions_gapped.size();
else
s.algn += solutions_gapped.size();
s.HI = 1;
s.IH = 1;
s.primary = true;
s.strand = HM.strand;
//.........这里部分代码省略.........
示例2: decode
DecodeResults *
SegmentDecoder :: decode(Instance *inst, Parameter *param) {
Items *items = inst->items();
int len = items->size();
int numFeatures = m_Model->getAlphabet("FEATURES")->size();
int numLabels = m_Model->getAlphabet("LABELS")->size();
double **uniScoreCache = new double *[len];
for (int i = 0; i < len; ++ i) {
uniScoreCache[i] = new double[numLabels];
Item *item = items->at(i);
for (int label = 0; label < numLabels; ++ label) {
uniScoreCache[i][label] = 0.0;
int sz = item->size(label);
for (int j = 0; j < sz; ++ j) {
uniScoreCache[i][label] += param->value(item->at(j, label));
}
}
}
double **biScoreCache = new double *[numLabels + 1];
for (int prevLabel = 0; prevLabel <= numLabels; ++ prevLabel) {
biScoreCache[prevLabel] = new double[numLabels];
for (int currLabel = 0; currLabel < numLabels; ++ currLabel) {
biScoreCache[prevLabel][currLabel] = param->value(
numFeatures * numLabels
+ prevLabel * numLabels
+ currLabel);
}
}
KHeap<DecodeState> **states = new KHeap<DecodeState> *[len];
for (int i = 0; i < len; ++ i) {
states[i] = new KHeap<DecodeState>[numLabels];
for (int j = 0; j < numLabels; ++ j) {
states[i][j].setK(m_Agenda);
}
}
for (int i = 0; i < len; ++ i) {
// fprintf(stderr, "i=%d\n", i);
for (int currLabel = 0; currLabel < numLabels; ++ currLabel) {
if (i == 0) {
// fprintf(stderr, "!%d->%d\n", numLabels, currLabel);
if (m_Legal[numLabels][currLabel] == 0) {
continue;
}
double score = uniScoreCache[0][currLabel] + biScoreCache[numLabels][currLabel];
states[i][currLabel].insert(DecodeState(currLabel, score, NULL));
} else {
for (int prevLabel = 0; prevLabel < numLabels; ++ prevLabel) {
if (m_Legal[prevLabel][currLabel] == 0)
continue;
for (int j = 0; j < states[i - 1][prevLabel].size(); ++ j) {
DecodeState *prev = states[i - 1][prevLabel].at(j);
double score = prev->score +
uniScoreCache[i][currLabel] + biScoreCache[prevLabel][currLabel];
// printf("#%d->%d\n", prevLabel, currLabel);
states[i][currLabel].insert(DecodeState(currLabel, score, prev));
}
}
}
}
}
vector<DecodeState> result_cache;
for (int label = 0; label < numLabels; ++ label) {
for (int i = 0; i < states[len - 1][label].size(); ++ i) {
result_cache.push_back( *states[len - 1][label].at(i) );
}
}
sort( result_cache.begin(), result_cache.end() );
DecodeResults *ret = new CppDecodeResults();
for (int i = 0; ((i < m_Agenda) && (result_cache.size() - i > 0)); ++ i) {
Labels* single = new CppLabels(len);
int pos = len - 1;
DecodeState *now = &result_cache[result_cache.size() - i - 1];
//DecodeState *now = result_cache.at(i);
for (; pos >= 0; -- pos, now = now->prev) {
single->set(now->label, pos);
}
ret->append( single );
}
for (int i = 0; i < len; ++ i) { delete []uniScoreCache[i]; } delete []uniScoreCache;
for (int i = 0; i <= numLabels; ++ i) { delete []biScoreCache[i]; } delete []biScoreCache;
for (int i = 0; i < len; ++ i) { delete []states[i]; } delete []states;
return ret;
}