Edward Wijaya wrote:
> 
> Hi groups,

Hello,

> I have a file which contain many many of this line (Fasta Format):
> 
> > YNL331C
> CAATATGCGAGGGACCTACATGTTGA
> CATGACAATGAATTCTATTGAAAAAA
> 
> > YKL071W
> ATAATTATTCCTGTTTCTTTAACCTG
> GTAAAAAAAAGTACAAACACTTAAGC
> 
> What I would like to do is to concatenate the line below >
> into one single string.
> Such as the output would be:
> 
> CAATATGCGAGGGACCTACATGTTGAGCATGACAATGAATTCTATTGAAAAA
> ATAATTATTCCTGTTTCTTTAACCTGGTAAAAAAAAGTACAAACACTTAAGC
> 
> The current code I created now seem to work but doesn't
> gie the result I want. Since it concatenates all into 1 single line.
> I thought there must be a very simple way to do this.
> But I can't seem to figure out how to achieve that.
> 
> #---My Code --------------
> while (<>) {
>      if (/^>/) {
>          next;
>      }
>      chomp;
>      $line .= $_;
> }
> push (@crseq, $line);
> print join("\n", @crseq), "\n";

This should do what you want:

$/ = '>';
while ( <> ) {
    next unless s/\s+\S.*//;
    chomp;   
    tr/\n//d;
    print "$_\n";
    }



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to