[Bioperl-l] Need some help with : Error "Use of uninitialized value"

Jason Stajich jason.stajich at gmail.com
Mon Apr 9 19:52:43 UTC 2012


You really want to create sequence object(s) an pass these into the BLAST factory. I also can't figure out why you are manually parsing the EMBL file and then using SeqIO later. Why not use SeqIO to parse the embl/genbank file?

You also don't report the line number of your current problem, but one can surmise it is here:

my $seq = $db->seq($id);
 print $seq,"\n";

The error indicates you are looking up a sequence ID that doesn't exist since you get an undefined sequence. I would suggest printing out  the name of the ID you are asking for to make sure it is correct. Typically we protect these queries like
if( my $seqstr = $db->seq($id) ) {
 print $seqstr, "\n";
} else {
 warn "cannot find $id in sequence db file\n");
}

I think you have not really structured your logic well enough in that loop - you only want to build Bio::DB::Fasta once, the whole point is index once and then query it multiple times.

You might consider starting with this code which does a lot of the stuff you are trying to do to extract annotated features.
https://github.com/bioperl/bioperl-live/blob/master/scripts/seq/bp_extract_feature_seq.pl

I think you are also use tr wrong - if you want to replace replace a string with an empty string you should use s/// and you also need to escape the | character since it has special meaning.

I guess in your case you just want the sequence - you would use use Bio::SeqIO to read in your sequence and then pass this back out as FASTA to give to getorf.  I don't know if we have a wrapper for EMBOSS's getorf.

There are probably a lot more things that need some attention but you should start on these. 
Jason
On Apr 8, 2012, at 6:35 PM, Bradyjoel wrote:

> 
> Hi all,
> 
> I have little experiences in programming with Perl/Bioperl. I'm currently
> working on a script that takes a whole genome from a bacteria as input,
> converts it into a multiple fasta file containing all the open reading
> frames and blast it against a multiple protein fasta file with know
> proteins. When I get a hit I want to combine the header of the known protein
> with the orf sequence, here it gives an error when I try to go through the
> orf file and extract the right corresponding sequence. The error it gives is
> : Use of uninitialized value $seq in print at blastscript.pl line .. 
> Is there someone who has an idea what caused this error, and can help me
> with solving it?
> 
> Regards, Joel (I put my script in the attachment) 
> http://old.nabble.com/file/p33653318/blastscript.pl blastscript.pl 
> -- 
> View this message in context: http://old.nabble.com/Need-some-help-with-%3A-Error-%22Use-of-uninitialized-value%22-tp33653318p33653318.html
> Sent from the Perl - Bioperl-L mailing list archive at Nabble.com.
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

Jason Stajich
jason.stajich at gmail.com
jason at bioperl.org





More information about the Bioperl-l mailing list