Skip to content

Instantly share code, notes, and snippets.

@klmr
Created February 15, 2013 14:23
Show Gist options
  • Save klmr/4960666 to your computer and use it in GitHub Desktop.
Save klmr/4960666 to your computer and use it in GitHub Desktop.
Read-group extraction without temporary buffer
while (getline(in, line)) {
if (line.compare(0, 4, "@RG\t") != 0) continue;
size_t start = line.find("\tID:");
if (start == string::npos) continue;
start += 4;
size_t end = line.find("\t", start);
if (end == string::npos or end == start) continue;
gids.emplace(string.begin() + start, string.begin() + end);
// Or, in C++03:
//gids.insert(line.substr(start, end - start));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment