CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Help me match strings please!

 



alikto
Novice


Nov 24, 2008, 6:09 AM

Post #1 of 3 (505 views)
Help me match strings please! Can't Post

Hello!
I have a file (stored in a <FH> filehandle) in which i have a text like the following:

Structure 3: dG = -1.71 dH = -47.20 dS = -151.57 Tm = 38.3

External loop: ddG = -2.20 21 ss bases & 2 closing helices
Stack: ddG = -1.68 External closing pair is C( 25)-G( 32)
Helix: ddG = -1.68 2 base pairs.
Hairpin loop: ddG = +2.74 Closing pair is A( 26)-T( 31)
Stack: ddG = -1.66 External closing pair is G( 9)-C( 19)
Stack: ddG = -0.79 External closing pair is T( 10)-A( 18)
Stack: ddG = -1.49 External closing pair is A( 11)-T( 17)
Helix: ddG = -3.95 4 base pairs.
Hairpin loop: ddG = +3.39 Closing pair is G( 12)-C( 16)



Structure 5: dG = -6.28 dH = -59.20 dS = -176.30 Tm = 62.6

External loop: ddG = -1.13 6 ss bases & 1 closing helices
Stack: ddG = -1.68 External closing pair is C( 3)-G( 36)
Stack: ddG = -1.66 External closing pair is A( 4)-T( 35)
Stack: ddG = -2.44 External closing pair is C( 5)-G( 34)
Stack: ddG = -1.66 External closing pair is G( 6)-C( 33)
Stack: ddG = -1.68 External closing pair is T( 7)-A( 32)
Helix: ddG = -9.13 6 base pairs.
Hairpin loop: ddG = +3.97 Closing pair is G( 8)-C( 31)


I need a way to get the Structure number (eg 3 or 5), and put it in front of every "Helix" or "Hairpin" word. Then I want to be able to compare the lines that start with "Helix" or "Hairpin" and see if they are homologous in some way to the number of the bases for the Helix strings (eg 6 base pairs) and for the Hairpin strings i want to compare the Closing pair eg G,C in: G( 8)-C( 31) every time a have the same letters (NOT numbers though). Consider that I have a lot of "Structure X" in this text file, so i want the script finally to tell me: "Structure's 1 Helix matches with Structure's 5 Helix" or "Structure's 2 Hairpin loop matches with Structure's 32 Hairpin loop". Any help out there?


KevinR
Veteran


Nov 24, 2008, 8:34 AM

Post #2 of 3 (496 views)
Re: [alikto] Help me match strings please! [In reply to] Can't Post

What have you tried so far?
-------------------------------------------------


alikto
Novice


Nov 25, 2008, 5:30 AM

Post #3 of 3 (486 views)
Re: [KevinR] Help me match strings please! [In reply to] Can't Post

I tried the following:

Code
while (<FH>) { 
if (/^Structure/) {
@ids = split (/ +/);}
if (/^Helix/) {
print "$ids[1] $_";}
if (/^Hairpin loop/) {
print "$ids[1] $_";}
}

Code
 
but it only gives me the line which contains "Helix" or "Hairpin" with the number of the structures in front of the line, such as:
1: Helix: ddG = -4.11 3 base pairs.
1: Hairpin loop: ddG = +3.38 Closing pair is G( 8)-C( 19)
2: Helix: ddG = -3.83 4 base pairs.
2: Hairpin loop: ddG = +4.00 Closing pair is C( 8)-G( 28)
3: Helix: ddG = -1.68 2 base pairs.


So, can i put these in some kind of an array and then compare these? But how?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives