Using -read_dist parameter in the API, the value is not parsed correctly. I tried:
use Grinder;
my $factory = Grinder->new( -reference_file => 'fungi_18S.fa',
-forward_reverse => 'fungi_primers.txt',
-length_bias => 0,
-unidirectional => 1,
-fastq_output => 1,
-qual_levels => '30 10',
-abundance_file => 'random_1_populations.txt',
-total_reads => 10000,
-read_dist => '150 normal 7',
-mutation_dist => 'poly4 3e-3 3.3e-8'
);
And when '150 normal 7' the parsing reach Grinder.pm subroutine '_initialize', the $self->{read_dist} variable contains an array with 1 element which value is '150 normal 7', instead of what the code expects that is an array with 3 elements '150', 'normal' and '7', so it cause troubles afterwards.
To fix it I added the following code after the first if, which converted the string into the 3 array elements:
if (ref $self->{read_dist} eq 'ARRAY' and scalar @{ $self->{read_dist} } == 1 and $self->{read_dist}[0] =~ m/\s/) {
@{ $self->{read_dist} } = split /\s+/, $self->{read_dist}[0];
}
Cheers,
Francisco J. Ossandon
Anonymous
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
I want to add that this problem is not exclusive of 'read_dist', I just realized that for 'mutation_dist' is the same (1-element array with all the text instead of separating them in the array), so the same fix code I put there should apply to 'mutation_dist'... Maybe the argparse subroutine is not parsing right?? On the other hand, 'qual_levels' is correctly converted into a 2-elements array, so my guess is the parsing is not working correctly for the 3-arguments parameters. :(
Hi Francisco,
I have added documentation to clarify what the intended usage is when passing multiple values to an option in API mode:
"The Grinder API allows to conveniently use Grinder within Perl scripts. The same
options as the CLI apply, but when passing multiple values to an options, you
will need to pass them as an array (not a scalar or arrayref)."
For example:
my $factory = Grinder->new( -reference_file => 'genomes.fna',
-read_dist => (100, 'uniform', 10) );
Hope this helps. Cheers,
Florent
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
I see, so I was putting it in the wrong format. I copy/pasted the text from the examples at http://sourceforge.net/projects/biogrinder/files/, maybe you want to update that README too!
I changed the string to array and it worked as intended, thanks for the clarification Florent!