[Bioperl-l] Please help me with Footprinter

Ben Westover ben at cse.wustl.edu
Thu Aug 14 15:19:09 EDT 2003


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;

}



More information about the Bioperl-l mailing list