[Bioperl-l] Please help me with Footprinter

Jason Stajich jason at cgt.duhs.duke.edu
Thu Aug 14 17:20:58 EDT 2003


ugh there are some major bugs in the module's code.

It should be written like this:
     if( $outfile1 ) {
       open($tfh1, ">$outfile1") || $self->throw("$outfile1: $!");
     } else {
       ($tfh1,$outfile1) = $self->io->tempfile(-dir=>$self->tempdir);
     }

And at the bottom of the method it should be written:

     $out1->close; # close the SeqIO object
     close($tfh1); # close the filehandle just in case
     undef($tfh1); # really get rid of it
     return ($outfile1);

I'll make the necessary changes.  Quite possibly it was me who did this in
some sort of haste...  Updates coming to CVS in about 15 minutes...

-jason

On Thu, 14 Aug 2003, Ben Westover wrote:

> Dear Friends,
>
> I am relatively new to bioperl and I am having trouble when I try to run
> Footprinter.  When running what seems to be a fairly straightforward piece
> of code I found at
> http://docs.bioperl.org/bioperl-run/Bio/Tools/Run/FootPrinter.html
> I get the following error:
>
> Can't call method "close" on an undefined value at
> /usr/lib/perl5/site_perl/5.6.1/Bio/Tools/Run/FootPrinter.pm line 418.
>
> I am including the relevant bits of code/information in case anyone can
> help me out.  My main question is where does the filename in $tfh1 come
> from and how can I set it and why is it necessary?   Any help I can get
> would be greatly appreciated.
>
> Warm Regards,
> Ben
>
> The treefile is in the local directory and contains the following:
> (A,(B,(C,(D,E))))
>
> I created the array of sequences with a set of calls:
>
> my @seqs;
> for(my $i=0;$i<$n;$i++){
>   my $tmp = Bio::Seq->new(-display_id => $id[$i], -seq => $seq[$i]);
>   push(@seqs, $tmp);
> }
>
> *** Below is the code ***
>
> my @footprinter_params = (
> 		      'size'=>8,
> 		      'max_mutations_per_branch'=>4,
> 		      'sequence_type'=>'upstream',
> 		      'subregion_size'=>30,
> 		      'position_change_cost'=>3,
> 		      'triplet_filtering'=>1,
> 		      'pair_filtering'=>1,
> 		      'post_filtering'=>1,
> 		      'inversion_cost'=>1,
> 		      'max_mutations'=>4,
> 		      'program'=>"FootPrinter",
> 		      'tree'   =>"treefile",
> 		      'verbose'=>1);
> my $footprinter_factory =
> Bio::Tools::Run::FootPrinter->new(@footprinter_params);
>
> my @fp = $footprinter_factory->run(@seqs);
>
>
> *** The offending line is the call to $tfh1->close in _setinput, which is
> called from run as shown below. ***
>
> sub _setinput {
>     my ($self, at seq) = @_;
>     my ($tfh1,$outfile1);
>     $outfile1 = $self->outfile_name();
>     if (defined $outfile1) {
>     	$self->io()->_initialize_io(-file => $tfh1);
>     } else {
> 	($tfh1,$outfile1) = $self->io->tempfile(-dir=>$self->tempdir);
>     }
>     my $out1 = Bio::SeqIO->new(-fh=> $tfh1 , '-format' => 'Fasta');
>     foreach my $seq(@seq){
> 	$seq->isa("Bio::PrimarySeqI") || $self->throw("Need a Bio::PrimarySeq compliant object for FootPrinter");
> 	$out1->write_seq($seq);
>     }
>     $tfh1->close;
>     undef($tfh1);
>     return ($outfile1);
> }
>
> sub run {
>   my ($self, at seq) = @_;
>
>   #need at least 2 for comparative genomics duh.
>   $#seq > 0 || $self->throw("Need at least two sequences");
>   $self->tree || $self->throw("Need to specify a phylogenetic tree using -tree option");
>
>   my $infile = $self->_setinput(@seq);
>
>   my $param_string = $self->_setparams();
>   my @footprint_feats = $self->_run($infile,$self->tree,$param_string);
>   return @footprint_feats;
>
> }
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu


More information about the Bioperl-l mailing list