paola82 has asked for the wisdom of the Perl Monks concerning the following question:
.I'll paste only the part of the script that I need to parse..I want to extract the residue that do hydrophobic and hydrogen bond..
%!PS-Adobe-3.0 %%Creator: Ligplot v.4.1 %%DocumentNeededResources: font Times-Roman Symbol %%BoundingBox: (atend) %%Pages: 1 %%EndComments %%BeginProlog .... #a lot of settings of the background .... % Hydrophobic contact Hydrophname_col Zero_linewidth W G Background_col 189.17 329.15 189.17 317.71 235.30 317.71 235.30 329.15 Pl4 212.23 323.43 moveto (Trp 401(A)) Hydrophnam_size Center (Trp 401(A)) Hydrophnam_size Print % Hydrophobic contact Hydrophname_col Zero_linewidth W G Background_col 404.14 338.82 404.14 327.38 450.28 327.38 450.28 338.82 Pl4 427.21 333.10 moveto (Val 440(A)) Hydrophnam_size Center (Val 440(A)) Hydrophnam_size Print % Hydrophobic contact Hydrophname_col Zero_linewidth W G Background_col 280.94 601.38 280.94 589.94 327.08 589.94 327.08 601.38 Pl4 304.01 595.66 moveto (Gly 463(A)) Hydrophnam_size Center (Gly 463(A)) Hydrophnam_size Print .... #a lot of setting .... % Residue names gsave Ligresname_col 244.91 185.50 moveto (Atp 1) Ligresname_size Center (Atp 1) Ligresname_size Print Nligresname_col 139.01 612.49 moveto (Lys 464(A)) Nligresnam_size Center (Lys 464(A)) Nligresnam_size Print Nligresname_col 133.08 424.57 moveto (Thr 465(A)) Nligresnam_size Center (Thr 465(A)) Nligresnam_size Print Nligresname_col 448.11 410.46 moveto (Ser 466(A)) Nligresnam_size Center (Ser 466(A)) Nligresnam_size Print Nligresname_col 447.88 472.27 moveto (Gly 461(A)) Nligresnam_size Center (Gly 461(A)) Nligresnam_size Print Nligresname_col 395.22 557.76 moveto (Thr 460(A)) Nligresnam_size Center (Thr 460(A)) Nligresnam_size Print Nligresname_col 271.30 555.87 moveto ( MG 2) Nligresnam_size Center ( MG 2) Nligresnam_size Print Nligresname_col 112.85 502.47 moveto (Ala 462(A)) Nligresnam_size Center (Ala 462(A)) Nligresnam_size Print grestore .... ....
paste the correct code to help beginners like me
#!/usr/local/bin/perl use strict; use warnings; use LWP::Simple; open (DATA, "</your_path/your_file.pl") || die "impossibile apr +ire il file"; my ( @hydrophobic , @residue ); while ( my $r = <DATA> ) { if ( $r=~ m/Hydrophnam_size Center/ .. $r =~ /Hydrophnam_size/ ) { push @hydrophobic , $r; next; } if( $r=~ m/Nligresnam_size Center/ .. $r =~ /Nligresnam_size/) { push @residue , $r; } } printf "legami idrofobici: %s\n" , join '' , @hydrophobic; printf "legami idrogeno: %s\n" , join '' , @residue; __DATA__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problems with pattern match
by linuxer (Curate) on Apr 21, 2009 at 09:29 UTC | |
by paola82 (Sexton) on Apr 21, 2009 at 10:11 UTC | |
|
Re: problems with pattern match
by parv (Parson) on Apr 21, 2009 at 11:07 UTC | |
by paola82 (Sexton) on Apr 21, 2009 at 11:49 UTC | |
by parv (Parson) on Apr 21, 2009 at 11:57 UTC |