s/\n//g; # instead of
tr/A-Za-z-//cd;
in the script below? I thought it would be simpler to remove the newline characters from $_ which is all I really want to do. However, most of the time all I will see are "-" and letters which is why I set the tr function the way I did.
I just couldn't figure out why the substitution function wouldn't work in this case. How am I setting it up wrong?
-Thanks -Mike
>> BEGIN PERL SCRIPT<< #! /usr/bin/perl -w
use strict; use FileHandle;
my %organisms;
print "Enter in a list of files to be processed:\n";
# For example: # CytB.fasta # NADH1.fasta # ....
chomp (my @infiles = <STDIN>);
print "Enter in the name of the OUTFILE:\n"; chomp (my $outfile = <STDIN>); open(OUTFILE, ">$outfile") or die "Can't open OUTFILE: $!";
foreach my $infile (@infiles) { my $FASTA = new FileHandle; open ($FASTA, $infile) or die "Can't open INFILE: $!"; my $orgID;
while (defined($_ = <$FASTA>)) { chomp; print "\n<< Processing >>$_<<\n";
if (/\s*>(\w+)/) { $orgID = $1; print "Found a new organism start line ('$orgID')\n";
} else { tr/A-Za-z-//cd; # originally tried s/\n//g; print "Sequence data found: $_\n"; print "Appending data to $orgID\n";
$organisms{$orgID} .= $_; } } # do not forget to close the input file close ($FASTA) or die "could not close INFILE : $!"; }
# we've processed all input files...print the resulting hash print "\n****************************************\n"; while (my ($orgID, $sequence) = each(%organisms)) { print OUTFILE ">$orgID\n$sequence\n\n"; }
>> END PERL SCRIPT <<
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>