PrincePerl has asked for the wisdom of the Perl Monks concerning the following question:
New to perl, started coding 2 months ago. I have a slight problem.
my $filename; my $accession_id; my $sequence_id = ""; my %accession; my $seq; print "Please enter in the filename: "; chomp($filename = <STDIN>); print "Please enter in the accession_ID: "; chomp($accession_id = <STDIN>); open(FILENAME, $filename) or die "cannot open file: $! "; while($_ = <FILENAME>){ if($_ =~ />/) { $seq = $_; } else { $accession{$seq} .= $_; } } foreach my $g (keys %accession) { if ($accession{$g} =~ m/$accession_id/i){ print "$g\n $accession{$g}\n"; } }
I am parsing a fasta file looking for a specific accession#, if the user enters in an accession #, the script finds it and spits out the sequence attached to it.
>gi|YP_8384858.1
ashthfhthfhthghtht
ehshehfhfhghghhhghg
hfhfhfhghghghghghg
I am trying to store the id accesion # in the $seq variable and store the sequence in the hash. I keep getting the use of uninitialized value.
Any help would be greatly appreciated. I am not looking for folks to solve it for me. its just frustrating that i can't get it to work. Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fasta file
by BrowserUk (Patriarch) on Sep 26, 2011 at 22:51 UTC | |
by PrincePerl (Novice) on Sep 29, 2011 at 20:29 UTC | |
|
Re: fasta file
by molecules (Monk) on Sep 26, 2011 at 23:03 UTC | |
|
Re: fasta file
by tospo (Hermit) on Sep 27, 2011 at 08:20 UTC | |
|
Re: fasta file
by pvaldes (Chaplain) on Sep 27, 2011 at 08:59 UTC |