i have an output like this having 2 sets of alignments.. in this, i want the first 4 lines of the 1st set of alignment and the first 4 lines of the 2nd set of alignment in an array. The same way, The alignment part of the 1st and the 2nd set in an array. The two sets of alignments are seperated by a '>' symbol.
>1gmz_B mol:protein length:122 PHOSPHOLIPASE A2 Length = 122 Score = 103 bits (233), Expect = 9e-23 Identities = 56/124 (45%), Positives = 67/124 (54%), Gaps = 12/124 (9 +%) Query: 2 LWQFNGMIKCKIPSSEPLLDFNNYGCYCGLGGSGTPVDDLDRCCQTHDNCYKQAKKLDS +C 61 LWQF MI K P + YGCYCG+GG G P D DRCC HD CY KL S +C Sbjct: 2 LWQFGKMI-LKETGKLPFPYYVTYGCYCGVGGRGGPKDATDRCCFVHDCCY---GKLTS +C 57 Query: 62 KVLVDNPYTNNYSYSCSNNEITCSSENNACEAFICNCDRNAAICFSK--VPYNKEHKNL +D 119 K P T+ YSYS + I C EN+ C IC CD+ AA+CF + YNK++ + + Sbjct: 58 K-----PKTDRYSYSRKDGTIVC-GENDPCRKEICECDKAAAVCFRENLDTYNKKYMSY +L 111 Query: 120 KKNC 123 K C Sbjct: 112 KSLC 115 >1b4w_A mol:protein length:122 PROTEIN (PHOSPHOLIPASE A2) Length = 122 Score = 95.7 bits (215), Expect = 2e-20 Identities = 46/105 (43%), Positives = 61/105 (58%), Gaps = 10/105 (9 +%) Query: 2 LWQFNGMIKCKIPSSEPLLDFNNYGCYCGLGGSGTPVDDLDRCCQTHDNCYKQAKKLDS +C 61 L QF MIK K+ EP++ + YGCYCG GG G P D DRCC HD CY +K+ +C Sbjct: 2 LLQFRKMIK-KMTGKEPVVSYAFYGCYCGSGGRGKPKDATDRCCFVHDCCY---EKVTG +C 57 Query: 62 KVLVDNPYTNNYSYSCSNNEITCSSENNACEAFICNCDRNAAICF 106 +P ++Y+YS N I C + + C+ +C CD+ AAICF Sbjct: 58 -----DPKWDDYTYSWKNGTIVCGGD-DPCKKEVCECDKAAAICF 96
i have now done this :
#!/usr/bin/perl open FILE, "/home/guest/align.txt"; my @arr123; local $/ = ''; @arr123 = <FILE>; #output file. print "<pre>"; #print @arr123; $array=join('',@arr123); @arr=split(/\n/,$array); foreach $a(@arr){ if($a=~/>/ || $a=~ /Length/ || $a=~ /Score/ || $a=~ /Identities/){ +push (@header,$a);} #header information. if($a=~/^Query/||$a=~/ /||$a=~/^Sbjct/){push(@lin,$a);} + } foreach(@header){print $_,"\n";} foreach(@lin){print $_,"\n";}
i m sure there are better ways to do it.....and also tell me which is the best website to learn perl?

In reply to how to split by heidi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.