Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate DNA in C/C++

I am iterating over DNA sequences pulling out chunks of 5-15 bases at a time into C++ std::string objects. Occasionally, my string will contain a non ATCG base, and I want to take an action when this happens. For example, I might see:

CTACGGTACGRCTA

Because there is an 'R', I want to recognize this case. I am familiar with regex, but people seem to recommend several different libraries. I've seen Boost, TR1, and others. Can someone please suggest either a different way to catch my cases or tell me which library I should use and why?

Thanks

like image 387
nedblorf Avatar asked Apr 03 '11 17:04

nedblorf


1 Answers

A regular expression is overkill for this. You can use std::string::find_first_not_of().

like image 162
Oliver Charlesworth Avatar answered Sep 28 '22 05:09

Oliver Charlesworth