On Feb 11, 2004, at 10:34 AM, Michael S. Robeson II wrote:
Hey, thanks again for the perl code.
You're welcome, but let's keep our discussion on the mailing list so we can all help and learn.
However, I forgot to take into account that the original input file can look one of two ways:
Ah, the old switcheroo. Gotcha. <laughs>
>bob atcgactagcatcgatcg acacgtacgactagcac
>fred actgactacgatcgaca acgcgcgatacggcat
or (as I posted originally)
>bob atcgactagcatcgatcgacacgtacgactagcac
>fred actgactacgatcgacaacgcgcgatacggcat
to be out put as:
R 1 42
a t c g a c t a g c a t c g a t c g a c a c g t a c g a c t a g c a c - - - - - - - bob
a c t g a c t a c g a t c g a c a a c g c g c g a t a c g g c a t - - - - - - - - - fred
How about this time I give you the code to parse the two types of input and you tie it in with the parts we've already figured out to get the right output? Just shout if you run into more problems.
James
#!/usr/bin/perl
use strict; use warnings;
local $/ = ''; # use "paragraph mode"
while (<DATA>) { unless (s/^>(.+?)\s*\n//) { # find and remove the name warn "Skipping unknown format: $_"; next; } my $name = $1; # save name tr/\n //d; # join multi-line sequences
print "Name: $name, Sequence: $_\n"; # show off our progess }
__DATA__ >bob atcgactagcatcgatcg acacgtacgactagcac
>fred actgactacgatcgaca acgcgcgatacggcat
>bob atcgactagcatcgatcgacacgtacgactagcac
>fred actgactacgatcgacaacgcgcgatacggcat
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>