in reply to Extracting DNA sequences from FASTA files

to reverse the bases:
my %ibase; $ibase{"A"} = "T"; $ibase{"T"} = "A"; $ibase{"C"} = "G"; $ibase{"G"} = "C"; $ibase{"N"} = "N"; sub seq_inverse { my ($nseq) = @_; my @seq = split(m//,$nseq); my $lim = @seq; my $inv = ""; $inv .= $ibase{$seq[$lim]} while($lim > 0 and $lim--); return $inv; }

Replies are listed 'Best First'.
Re^2: Extracting DNA sequences from FASTA files
by educated_foo (Vicar) on Jun 29, 2009 at 15:36 UTC
    It's easier when you work *with* Perl rather than against it:
    sub reverse_complement { local $_ = shift; y/ACGT/TGCA/; reverse; }
    As for the OP's question, FASTA is a pretty simple format other than the various stuff people put in the sequence labels. So your code will probably look something like this:
    while (<FASTA>) { chomp; if (/^>\s*(.*)/) { # it's a sequence label $name = $1; } else { # it's sequence data } }