in reply to Re: Parse DNA fasta file
in thread Parse DNA fasta file

"Would have been better for you if you showed us what you came up with ... but anyway, this is one way to do it

use Bio::SeqIO my $in = Bio::SeqIO->new(-file => "test.fa" , '-format' => 'Fasta'); my $out = Bio::SeqIO->new(-file => ">out.fa" , '-format' => 'Fasta'); while ( my $seq = $in->next_seq() ) { $out->write_seq($seq) if($seq->length > 500); } "

Thank you very much for suggesting this script and Bioperl. I have downloaded Bioperl and tried to get the script work with my FASTA file but it returns:

"Can't call method "next_seq" on an undefined value at parse_sequence_length.pl line 6".

Any suggestions?

Thanks!

Replies are listed 'Best First'.
Re^3: Parse DNA fasta file
by BrowserUk (Patriarch) on Nov 11, 2009 at 17:21 UTC

    Check the return value from the constructor invocations and see what that tells you:

    my $in = Bio::SeqIO->new(-file => "test.fa" , '-format' => 'Fasta') or die "Failed to open input file: $!";

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Parse DNA fasta file
by arun_kom (Monk) on Nov 12, 2009 at 09:07 UTC

    Probably your input fasta file cannot be found as it is not in the path ... try specifying the entire path to your file instead of the file name alone ... i missed it in my example code but BrowserUk's extension to it will help identify any error and is a good practice to always check so.