Re: Concatenating line into array problem

2004-06-11 Thread Zeus Odin
This works: ---BEGIN CODE--- #!/usr/bin/perl use warnings; use strict; $/ = '>'; while () { s/(.*?\n.*?)\n/$1/s; print; } __DATA__ > YNL331C CAATATGCGAGGGACCTACATGTTGA CATGACAATGAATTCTATTGAA > YKL071W ATAATTATTCCTGTTTCTTTAACCTG GTGTACAAACACTTAAGC ---END CODE---

Re: Concatenating line into array problem

2004-06-11 Thread John W. Krahn
"John W. Krahn" wrote: > > This should do what you want: > > $/ = '>'; > while ( <> ) { > next unless s/\s+\S.*//; > chomp; > tr/\n//d; > print "$_\n"; > } After seeing your data file change that to: $/ = '>'; while ( <> ) { next unless s/\S+.*\n//; chomp; tr/\n/

Re: Concatenating line into array problem

2004-06-11 Thread John W. Krahn
Edward Wijaya wrote: > > Hi groups, Hello, > I have a file which contain many many of this line (Fasta Format): > > > YNL331C > CAATATGCGAGGGACCTACATGTTGA > CATGACAATGAATTCTATTGAA > > > YKL071W > ATAATTATTCCTGTTTCTTTAACCTG > GTGTACAAACACTTAAGC > > What I would like to do is to con

RE: Concatenating line into array problem

2004-06-10 Thread Charles K. Clarkson
From: Edward Wijaya wrote: :: How about: :: :: my @crseq; :: while ( <> ) { :: next unless/^[ACGT]/; :: chomp; :: push @crseq, $_ . scalar <>; :: } :: print @crseq; :: : : Hi Charles, : : Thanks for your reply. : : Your code works for my example in e

Re: Concatenating line into array problem

2004-06-10 Thread Edward Wijaya
How about: my @crseq; while ( <> ) { next unless/^[ACGT]/; chomp; push @crseq, $_ . scalar <>; } print @crseq; Hi Charles, Thanks for your reply. Your code works for my example in email, but not the file with more lines, (please see attached file). So sorry if I didn't give precise

RE: Concatenating line into array problem

2004-06-10 Thread Charles K. Clarkson
From: Edward Wijaya wrote: : #---My Code -- : while (<>) { : if (/^>/) { : next; : } : chomp; : $line .= $_; : } : push (@crseq, $line); : print join("\n", @crseq), "\n"; How about: my @crseq; while ( <> ) { next unless

Re: Concatenating line into array problem

2004-06-10 Thread Edward Wijaya
On Thu, 10 Jun 2004 21:19:17 -0700, Tim Johnson <[EMAIL PROTECTED]> wrote: while (<>) { if (/^>/) { push (@crseq, $line); next; } chomp; $line .= $_; } shift @crseq; print join("\n", @crseq), "\n"; #

RE: Concatenating line into array problem

2004-06-10 Thread Tim Johnson
This might be closer to what you want. Just push the line onto the array every time you come to the '>' character. You'll get one empty line at the beginning, that's why I put the shift line in. while (<>) { if (/^>/) { push (@crseq, $line);