This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How do I write the regex expression for the line?

How do I write the regex expression to know whether a line starts with the YBR069C and 690, and note that there are some spaces between YBR069C and 620

the line is like this:

YBR069C 620 
AUGGACGAUAGUGUCAGUUUCAUUGCCAAAGAGGCCAGUCCAGCACAAUAUUCGCACAGUUUGCAUGAAAGAACACACAGUG

Thank you

regex

Please post few more examples/lines or example input and expected output. It's not clear what you want to achieve here (to me).

1 answer

/^YBR069C\s+620/ is the regex expression to find "lines starting with YBR069C and having 620 separated by spaces", but your example line is not 1 line but 2, plus the image posted shows that the "starting with YBR069C" requirement is not well defined either. If you don't perfectly describe your input and your requirements you won't be able to find the appropriate results.

As it looks like you are interested in finding sequences with header lines structure of number label number, I would go for a printing flag solution to print every line under a desired header until the next undesidered header like this one:

perl -ne '/^\d/ and $p = 0; /^\d+\s+YBR069C\s+620$/ and $p = 1; print if $p' input.txt

Thank you it worked out

please honor replies that worked by accepting them as the correct answer

Log in to answer this question.