Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: substrings that consist of repeating characters

by LanX (Saint)
on Sep 27, 2020 at 23:33 UTC ( [id://11122277]=note: print w/replies, xml ) Need Help??


in reply to Re: substrings that consist of repeating characters
in thread substrings that consist of repeating characters

> For varieties sake the regex has changed slightly to be a little easier to grok:

Oh ... we got a one-liner :)

DB<56> $_ = "AAATTTAGTTCTTAAGGCTGACATCGGTTTACGTCAGCGTTACCCCCCAAGTTAT +TGGGGACTTT"; DB<57> $threshold = 3; DB<58> x sort { length($b) <=> length($a) } grep { length >= $thresh +old } /(A+|C+|G+|T+)/g 0 'CCCCCC' 1 'GGGG' 2 'AAA' 3 'TTT' 4 'TTT' 5 'TTT' DB<59>

EDIT

and for the original problem

DB<59> x sort { length($b) <=> length($a) } /(AA+|CC+|GG+|TT+)/g 0 'CCCCCC' 1 'GGGG' 2 'AAA' 3 'TTT' 4 'TTT' 5 'TTT' 6 'TT' 7 'TT' 8 'AA' 9 'GG' 10 'GG' 11 'TT' 12 'AA' 13 'TT' 14 'TT' DB<60>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11122277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-16 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found