On Jun 14, Praedor Atrebates said:
$dnakmotif = '[KRH][L{3,}V{3,}I{3,}F{3,}Y{3,}A{3,}][KRH];
I am just learning as I go here but there are two problems with this, one of which I understand but the other I do not. First, the one I do not understand. My intent with the value set to $dnakmotif was to search for K or R or H in a sequence followed by a string of 3 or more of any of the contents of the second bracket pair (L V I F Y A). When I run the program and run a search for "dnak" I get a string of hits in my test sequence they don't match what I am after. I get a series of hits, for instance, of a K followed by ONE A or ONE V followed by an H instead of at LEAST 3 of any of L or V or I, etc. Why doesn't this work?
The [...] construct is a character class -- it represents a set of characters, any of which can match. Thus, [KRH] matches a 'K', an 'R', or an 'H'. But [A{3,}B{3,}] is really just the same as [AB3,{}] -- that is, an 'A', a 'B', a '3', a ',', a '{', or a '}'. What you want is
$dnakmotif = qr/[KRH](?:L{3,}|V{3,}|I{3,}|F{3,}|Y{3,}|A{3,})[KRH]/; That sounds like it should match what you're looking for.
The next problem is one I understand but have no idea how to correct. The value I set to $dnakmotif is too restrictive for the actual searches I need to do. What I want is to search for a sequence/character string with any of K or R or H on either end, but _between them_ any combination of L, V, I, F, A, or Y is OK, in repeats or all individually so long as the minimum number is 3 and the max number (any combination of the characters) is _no more_ than 5. How do I make this character search be much less restrictive than I've started out with?
Hrm, so the middle part must be NO LESS than 3 and NO MORE than 5, and is made up solely of L, V, I, F, Y, and A characters?
$dnakmotif = qr/[KRH][LVIFYA]{3,5}[KRH]/; looks like it does the trick. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ % -- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>