I'm working with DNA, RNA and protein sequences and QRegExp
doesn't work for me to detect if
the sequence contains only certain characters.
For example unambiguous contains only acgt :
seq.contains(QRegExp("[gatc]"))
Doesn't work for me. How can I correct that ?
You're looking for whether the sequence contains characters other than gatc
. You also shouldn't be using the deprecated QRegExp
in Qt 5. So:
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
QRegularExpression invalid("[^gatcGATC]");
#else
QRegExp invalid("[^gatcGATC]");
#endif
if (seq.contains(invalid)) {
qDebug() << "invalid sequence!";
...
}