本文整理汇总了C++中SequenceSet::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ SequenceSet::remove方法的具体用法?C++ SequenceSet::remove怎么用?C++ SequenceSet::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SequenceSet
的用法示例。
在下文中一共展示了SequenceSet::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filter_max_sequence_length
void filter_max_sequence_length( SequenceSet& set, size_t max_length )
{
size_t index = 0;
while( index < set.size() ) {
if( set.at(index).length() > max_length ) {
set.remove(index);
} else {
++index;
}
}
}
示例2: filter_min_max_sequence_length
void filter_min_max_sequence_length( SequenceSet& set, size_t min_length, size_t max_length )
{
size_t index = 0;
while( index < set.size() ) {
auto len = set.at(index).length();
if( len < min_length || len > max_length ) {
set.remove(index);
} else {
++index;
}
}
}
示例3: merge_duplicate_sequences
void merge_duplicate_sequences(
SequenceSet& set,
MergeDuplicateSequencesCountPolicy count_policy,
std::string const& counter_prefix
) {
// Helper to keep track of which sequences (at position i in the set) occured how often.
struct Duplicate
{
size_t index;
size_t count;
};
// Find duplicates and count their occurences.
// TODO this is a very memory intense step. find an algo that does not need to copy all sites...
std::unordered_map< std::string, Duplicate > dup_map;
size_t i = 0;
while( i < set.size() ) {
auto& seq = set[i];
if( dup_map.count( seq.sites() ) == 0 ) {
// If it is a new sequence, init the map entry and move to the next sequence.
dup_map[ seq.sites() ].index = i;
dup_map[ seq.sites() ].count = 1;
++i;
} else {
// If we already saw that sequence, increment its counter, and remove the sequence
// from the set. Do not increment i - we deleted a sequence, so staying at the
// position automatically "moves" to the next one.
++dup_map[ seq.sites() ].count;
set.remove(i);
}
}
// We do not need to relabel sequences.
if( count_policy == MergeDuplicateSequencesCountPolicy::kDiscard ) {
return;
}
// Relabel using the counts.
for( size_t j = 0; j < set.size(); ++j ) {
auto& seq = set[j];
// The sequence needs to be in the map, as we added it in the previous step.
// It also needs to have the same index, as we never changed that.
assert( dup_map.count(seq.sites()) > 0 );
assert( dup_map[ seq.sites() ].index == j );
// Append the count to the label.
auto count = dup_map[ seq.sites() ].count;
if( count_policy == MergeDuplicateSequencesCountPolicy::kAppendToLabel ) {
auto new_label = seq.label() + counter_prefix + std::to_string(count);
seq.label( new_label );
} else {
// We already skipped the discard case, so this here should not happen.
assert( false );
}
}
}