[Bioperl-l] (no subject)
Roy Chaudhuri
roy.chaudhuri at gmail.com
Mon Oct 22 09:21:53 UTC 2012
Hi Alexey,
I think the problem here is that you're calling the sub directly using
RandomOrders::generate, but the sub expects to be called as a method,
which implicitly puts the class name as the first argument in @_. So try
something like:
my $dataset=RandomOrders->generate(\@names, $avg_length, 100);
which is equivalent to:
my $dataset=RandomOrders::generate('RandomOrders', \@names, $avg_length,
100);
See perldoc perlobj for full details.
Cheers,
Roy.
On 22/10/12 09:46, Alexey Morozov wrote:
> Dear colleagues, need help. I have this little snippet of code:
>
> ....more code.... my @names; foreach(1..$taxa_amount) { push @names,
> "Taxa$_"; } my
> $dataset=RandomOrders::generate(\@names,$avg_length,100); ....more
> code....
>
> And it throws an exception:
>
> ------------- EXCEPTION: Bio::Root::Exception ------------- MSG: Must
> specify a valid ARRAY reference to the parameter -TAXA, did you
> forget a leading '\'? for 5 STACK: Error::throw STACK:
> Bio::Root::Root::throw /usr/share/perl5/Bio/Root/Root.pm:472 STACK:
> Bio::Tree::RandomFactory::new
> /usr/share/perl5/Bio/Tree/RandomFactory.pm:170 STACK:
> RandomOrders::generate RandomOrders.pm:38 STACK: ./simulator:145
> -----------------------------------------------------------
>
> OK, so it must be fault of RandomOrders.pm. Let's look there:
>
> sub generate { #Generates random Order_set objects. Is a class
> method my ($class, $names, $mean, $seq_length)=@_; my
> $factory=Bio::Tree::RandomFactory->new(-samples=>$names); my
> $tree=$factory->next_tree; .....more code.... }
>
> So main script passes an arrayref to &generate, &generate puts it to
> scalar and passes said scalar (ie arrayref) to
> Bio::Tree::RandomFactory. It must all work perfectly, but it does
> not. Where am I wrong?
>
> Alexey Morozov LIN SB RAS Irkutsk, Russia
> _______________________________________________ Bioperl-l mailing
> list Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
More information about the Bioperl-l
mailing list