Bio::Grid::Run::SGE::Iterator::AllvsAllNoRep - Runs all elements of one index against each other, without repetitions
use Bio::Grid::Run::SGE::Iterator::AllvsAllNoRep; use Bio::Grid::Run::SGE::Index; # the dummy index contains the letters a..c as elements my $index = Bio::Grid::Run::SGE::Index->new( format => 'Dummy', idx_file => undef, idx => [ 'a'..'c'] )->create; my $it = Bio::Grid::Run::SGE::Iterator::AllvsAllNoRep->new( indices => [$index] ); # run through all combinations my ($from, $to) = (0, $it->num_comb - 1); $it->range( [ $from, $to] ); my @result; my $i = $from; while ( my $comb = $it->next_comb ) { print "job " . $i++ . " -> " . join(" ", $comb->[0], $comb->[1] ) . "\n"; }
Runs all elements of the index against each other. Takes exactly one index. Results in (N * N)/2 jobs with N as number of elements in the index.
(N * N)/2
The difference to Bio::Grid::Run::SGE::Iterator::AllvsAll is that it assumes symmetry. Runing element x vs. y is the same as running y vs. x and therefore a repetition.
An index with 3 elements (a..c) combines to:
job 1 -> a b job 2 -> a c job 3 -> b c
--- ... mode: AllvsAllNoRep ...
--- input: - format: List elements: [ "a", "b", "c" ] job_name: AllvsAllNoRep_test mode: AllvsAllNoRep
#!/usr/bin/env perl use warnings; use strict; use 5.010; use Bio::Grid::Run::SGE; use File::Spec::Functions qw(catfile); use Bio::Grid::Run::SGE::Util qw(result_files); run_job( task => \&do_worker_stuff ); sub do_worker_stuff { my ( $c, $result_prefix, $elems_a, $elems_b ) = @_; # write results to result prefix (== result file) open my $fh, '>', $result_prefix or die "Can't open filehandle: $!"; # because we have list indices, $elems_a and $elems_b are (paired) array references # other indices might give file names instead, so check the documentation my $num_elems = @$elems_a; for ( my $i = 0; $i < @$elems_a; $i++ ) { say $fh join( " ", $elems_a->[$i], $elems_b->[$i] ); } $fh->close; # return 1 on success return 1; } 1;
Bio::Grid::Run::SGE::Role::Iterable, Bio::Grid::Run::SGE::Iterator
jw bargsten, <jwb at cpan dot org>
<jwb at cpan dot org>
To install Bio::Grid::Run::SGE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bio::Grid::Run::SGE
CPAN shell
perl -MCPAN -e shell install Bio::Grid::Run::SGE
For more information on module installation, please visit the detailed CPAN module installation guide.