[Bioperl-l] Bio::SeqIO question

Chris Fields cjfields at illinois.edu
Mon Apr 26 18:20:24 EDT 2010


On Apr 26, 2010, at 1:12 AM, Chet Seligman wrote:

> Hi there. 
> I'm a student and brand new to this.
> I want to get a file (filename = protein.fa), which is a list of fasta
> sequences, starting with:
>> gi|255572219|ref|XP_002527049| retinoblastoma-binding protein, putative
> 
> Into a sequence object so I can BLAST the sequences
> According to  perldoc Bio::Perl, I should be able to:
> # reads an array of sequences
> @seq_object_array = read_all_sequences($filename, 'fasta');
> 
> But I get an exception:
> 
> ------------ EXCEPTION: Bio::Root::Exception -------------
> MSG: Could not open >gi|255572219|ref|XP_002527049| retinoblastoma-binding
> protein, putative
> : Invalid argument
> STACK: Error::throw
> STACK: Bio::Root::Root::throw C:/Perl/site/lib/Bio/Root/Root.pm:368
> STACK: Bio::Root::IO::_initialize_io C:/Perl/site/lib/Bio/Root/IO.pm:341
> STACK: Bio::SeqIO::_initialize C:/Perl/site/lib/Bio/SeqIO.pm:467
> STACK: Bio::SeqIO::fasta::_initialize C:/Perl/site/lib/Bio\SeqIO\fasta.pm:94
> STACK: Bio::SeqIO::new C:/Perl/site/lib/Bio/SeqIO.pm:360
> STACK: Bio::SeqIO::new C:/Perl/site/lib/Bio/SeqIO.pm:390
> 
> 
> STACK: C:/Perl/site/lib/Bio/Perl.pm:
> 
> Here's my program snippet:
> use strict;
> my @seq_object_array = ();
> my $blast_report = '';
> use Bio::Perl;
> use Bio::SeqIO;
> use Bio::Tools::Run::RemoteBlast;
> use Bio::SearchIO;
> use Bio::SearchIO::Writer::HTMLResultWriter;
> use Bio::AlignIO;
> use Data::Dumper;
> my $filename ='';
> open (INFILE, "protein.fa");
> $filename =<INFILE>;
> 
> #reads an array of sequences
> @seq_object_array = read_all_sequences($filename, 'fasta');
> 
> So what should I do differently?
> Thanks,
> Chet


Chet, 

You are passing in the first line of the file itself, via the readline off the filehandle here: '$filename =<INFILE>;'.  You just need to pass in the name of the file (aka the 'file name').  Do this:

@seq_object_array = read_all_sequences('protein.fa', 'fasta');

chris


More information about the Bioperl-l mailing list