<commit_before>=head1 LICENSE

  Copyright (c) 1999-2012 The European Bioinformatics Institute and
  Genome Research Limited.  All rights reserved.

  This software is distributed under a modified Apache license.
  For license details, please see

    http://www.ensembl.org/info/about/code_licence.html

=head1 CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <<EMAIL>>.

  Questions may also be sent to the Ensembl help desk at
  <<EMAIL>>.

=head1 NAME

Bio::EnsEMBL::Compara::RunnableDB::MercatorPecan::BlastFactory 

=head1 SYNOPSIS


=head1 DESCRIPTION

Fetch sorted list of member_ids and create jobs for BlastAndParsePAF. 
Supported keys:
   'genome_db_id' => <number>
       Genome_db id. Obligatory

   'step' => <number>
       How many sequences to write into the blast query file. Default 1000



=cut

package Bio::EnsEMBL::Compara::RunnableDB::MercatorPecan::BlastFactory;

use strict;
use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable');

sub param_defaults {
    return {
        'step'  => 1000,
    }
}


sub fetch_input {
    my $self = shift @_;

    $self->param('genome_db_id') or die "'genome_db_id' is an obligatory parameter";
    $self->param('step') or die "'step' is an obligatory parameter";
}


sub write_output {
    my $self = shift @_;


    #Fetch members for genome_db_id
    my $sql = 'SELECT member_id FROM member WHERE genome_db_id = ? ORDER BY member_id';
    my $sth = $self->compara_dba->dbc->prepare( $sql );
    $sth->execute($self->param('genome_db_id'));
    
    my $member_id_list;
    while( my ($member_id) = $sth->fetchrow() ) {
	push @$member_id_list, $member_id;
    }

    my $step = $self->param('step');

    while (@$member_id_list) {
        my @job_array = splice(@$member_id_list, 0, $step);
        my $output_id = {'genome_db_id' => $self->param('genome_db_id'), 'start_member_id' => $job_array[0], 'end_member_id' => $job_array[-1] };
	    
        $self->dataflow_output_id($output_id, 2);
    }

}

1;
<commit_msg>Revert last commit<commit_after>=head1 LICENSE

  Copyright (c) 1999-2012 The European Bioinformatics Institute and
  Genome Research Limited.  All rights reserved.

  This software is distributed under a modified Apache license.
  For license details, please see

    http://www.ensembl.org/info/about/code_licence.html

=head1 CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <<EMAIL>>.

  Questions may also be sent to the Ensembl help desk at
  <<EMAIL>>.

=head1 NAME

Bio::EnsEMBL::Compara::RunnableDB::MercatorPecan::BlastFactory 

=head1 SYNOPSIS


=head1 DESCRIPTION

Fetch sorted list of member_ids and create jobs for BlastAndParsePAF. 
Supported keys:
   'genome_db_id' => <number>
       Genome_db id. Obligatory

   'step' => <number>
       How many sequences to write into the blast query file. Default 1000



=cut

package Bio::EnsEMBL::Compara::RunnableDB::MercatorPecan::BlastFactory;

use strict;
use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable');

sub fetch_input {
    my $self = shift @_;

	my $genome_db_id = $self->param('genome_db_id') || $self->param('genome_db_id', $self->param('gdb'))        # for compatibility
	  or die "'genome_db_id' is an obligatory parameter";

    if (!defined $self->param('step')) {
	$self->param('step', 1000);
    }
}


sub write_output {
    my $self = shift @_;


    #Fetch members for genome_db_id
    my $sql = 'SELECT member_id FROM member WHERE genome_db_id = ?';
    my $sth = $self->compara_dba->dbc->prepare( $sql );
    $sth->execute($self->param('genome_db_id'));
    
    my $member_id_list;
    while( my ($member_id) = $sth->fetchrow() ) {
	push @$member_id_list, $member_id;
    }

    my $step = $self->param('step');

    #Sort on member_id
    my $sorted_list;
    @$sorted_list = sort {$a <=> $b} @$member_id_list;
    
    my $start_member_id = $sorted_list->[0];
    my $offset = 0;
    my $batch_size;

    #Create jobs for BlastAndParsePAF
    for (my $i = 0; $i < @$sorted_list; $i++) {
	my $member_id = $sorted_list->[$i];

	if ($batch_size == $step) {
	    my $output_id = {'genome_db_id' => $self->param('genome_db_id'), 'start_member_id' => $start_member_id, 'offset' => $offset, 'batch_size' => $batch_size};
	    
	    $self->dataflow_output_id($output_id, 2);

	    $offset += $batch_size;
	    $batch_size = 0;
	    $start_member_id= $member_id;
	}
	$batch_size++;
    }

    my $output_id = {'genome_db_id' => $self->param('genome_db_id'), 'start_member_id' => $start_member_id, 'offset' => $offset, 'batch_size' => $batch_size};

    
   $self->dataflow_output_id($output_id, 2);


}
return 1;
{'fraction_non_alphanumeric': 0.1352336048006858, 'fraction_numerical': 0.011573081868838405, 'mean_word_length': 3.7817622950819674, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6721173', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1624, 'n_words': 417}