[Bioperl-l] get_nof_contigs returns undef

Wes Barris wes.barris at csiro.au
Fri Sep 23 01:16:57 EDT 2005


Wes Barris wrote:

> Hi,
> 
> The "get_nof_contigs" function does not appear to work.  The following code
> results in an error when trying to print the number of contigs in the
> assembly.
> 
> #!/usr/bin/perl -w
> use strict;
> use Bio::Assembly::IO;
> my $usage = "Usage: $0 <infile.ace> <outdir> [cn#]\n";
> my $infile = shift or die $usage;
> my $io = new Bio::Assembly::IO(-file=>$infile, -format=>'ace');
> my $assembly = $io->next_assembly();    # Bio::Assembly::ScaffoldI
> my @contigIds = $assembly->get_contig_ids;
> my $nContigs = $assembly->get_nof_contigs;
> print("Contig IDs: @contigIds\n");
> print("N contigs: $nContigs\n");
> 
> 
> wes at bioserver> ~/soft/ace/test.pl fasta/cl.00001.fa.cap.ace
> Contig IDs: 1
> Use of uninitialized value in concatenation (.) or string at 
> /home/wes/soft/ace/test.pl line 11, <GEN0> line 243.
> N contigs:

I don't know enough about scalars and array refs to explain this, but
a fix for the above problem is:

Old Bio/Assembly/Scaffold.pm code:

sub get_nof_contigs {
     my $self = shift;
     return scalar( $self->get_contig_ids() );
}

New Bio/Assembly/Scaffold.pm code:

sub get_nof_contigs {
     my $self = shift;
     my @junk = $self->get_contig_ids;
     return scalar( @junk );
#   return scalar( $self->get_contig_ids() );
}

-- 
Wes Barris
E-Mail: Wes.Barris at csiro.au


More information about the Bioperl-l mailing list