in reply to parsing sequences from a file

Perhaps something along the lines of
#!/usr/bin/perl use warnings; use strict; my (@peptide, @cds); while (my $line = <DATA>){ next unless $line =~ /^>/; chomp $line; chomp(my $seq = <DATA>); if ($line =~ /peptide/){ push @peptide, $line, $seq; # or print to file handle } elsif ($line =~ /CDS/){ push @cds, $line, $seq; # or print to file handle } } print qq{$_\n} for @peptide; print qq{---\n}; print qq{$_\n} for @cds; __DATA__ GENSCAN 1.0 Date run: 11-Mar-109 Time: 00:29:37 Sequence scaffold_2 : 47583 bp : 37.42% C+G : Isochore 1 ( 0 - 100 C+G +%) Parameter matrix: test.smat Predicted genes/exons: Gn.Ex Type S .Begin ...End .Len Fr Ph I/Ac Do/T CodRg P.... Tscr.. ----- ---- - ------ ------ ---- -- -- ---- ---- ----- ----- ------ 1.01 Init - 2604 2462 143 0 2 77 96 184 0.883 20.81 1.00 Prom - 3677 3638 40 2.82 2.00 Prom + 4382 4421 40 1.62 2.01 Init + 6395 6399 5 1 2 73 84 0 0.122 -0.16 2.02 Intr + 8270 8412 143 2 2 74 82 110 0.141 12.00 2.03 Term + 8516 8523 8 0 2 46 46 0 0.473 -8.05 2.04 PlyA + 9723 9728 6 2.27 Predicted peptide sequence(s): Predicted coding sequence(s): >scaffold_2|GENSCAN_predicted_peptide_1|48_aa MDRSHQIWDEKLMDQKCVLYPVCLWHEQESEMNWEAEKAERLRTEQKX >scaffold_2|GENSCAN_predicted_CDS_1|144_bp atggatcggagtcatcagatatgggatgagaagctgatggatcagaagtgcgtcctctac cccgtctgcctctggcacgagcaggagagcgagatgaactgggaggctgagaaagctgag aggctaaggactgaacagaaaggn >scaffold_2|GENSCAN_predicted_peptide_2|51_aa MRKNEGVDDADPLIEGMKEITLKDSATPEDKDQEDKQDERGEEIQEQPQEM >scaffold_2|GENSCAN_predicted_CDS_2|156_bp atgaggaagaatgagggtgttgatgatgcagatccactaatagaaggtatgaaggagatc actctgaaagattcagcaactccagaagacaaggatcaagaagacaaacaagatgagaga ggtgaagaaattcaagaacaacctcaagagatgtag
>scaffold_2|GENSCAN_predicted_peptide_1|48_aa MDRSHQIWDEKLMDQKCVLYPVCLWHEQESEMNWEAEKAERLRTEQKX >scaffold_2|GENSCAN_predicted_peptide_2|51_aa MRKNEGVDDADPLIEGMKEITLKDSATPEDKDQEDKQDERGEEIQEQPQEM --- >scaffold_2|GENSCAN_predicted_CDS_1|144_bp atggatcggagtcatcagatatgggatgagaagctgatggatcagaagtgcgtcctctac >scaffold_2|GENSCAN_predicted_CDS_2|156_bp atgaggaagaatgagggtgttgatgatgcagatccactaatagaaggtatgaaggagatc

Replies are listed 'Best First'.
Re^2: parsing sequences from a file
by sugar (Beadle) on Mar 11, 2009 at 10:10 UTC
    It works fine. Thank you for the help. i will still investigate on the mistake i have done in my program, so that i wil not repeat again :)
Re^2: parsing sequences from a file
by sugar (Beadle) on Mar 11, 2009 at 15:30 UTC
    hi buddy...y is it printing only one line of the sequence. If there are 3 lines, only the first line of the sequence is getting printed :(