Bio-Grid-Run-SGE

 view release on metacpan or  search on metacpan

lib/Bio/Grid/Run/SGE/Master.pm  view on Meta::CPAN

    @inc_dirs = grep {$_} @inc_dirs;
    if ( @inc_dirs && @inc_dirs > 0 ) {
      say $fh '$ENV{PERL5LIB} //= "";';
      say $fh '$ENV{PERL5LIB} = "$ENV{PERL5LIB}:' . join( ':', @inc_dirs ) . '";';
      say $fh "use lib ('" . join( "','", @inc_dirs ) . "');";
    }
  }

  if ( exists $ENV{PATH} ) {

    my @dirs = uniq( grep {$_} split( /\Q$Config{path_sep}\E/, $ENV{PATH} ) );
    my $path = "'" . join( "','", @dirs ) . "'";
    print $fh <<EOS;
my \@path = do { my \%seen; grep { !\$seen{\$_}++ } ( $path, split(/:/, \$ENV{PATH})) };
\$ENV{PATH} = join(":", \@path);
EOS
  }

  print $fh <<'EOF';
my $cmd = shift;
unless ( my $return = do $cmd ) {
  warn "could not parse $cmd\n$@\n\n$!" if $@;
  warn "couldn't execute $cmd\n$!" unless defined $return;
  warn "couldn't run $cmd" unless $return;
}
exit;
EOF
  $fh->close;
}

sub queue_post_task {
  my ($self) = @_;

  my $conf = $self->config;
  my $env  = $self->env;

  my @cmd = ( $conf->{submit_bin} );
  push @cmd, '-S', $env->{perl_bin};
  push @cmd, '-N', join( '_', 'p' . $env->{job_id}, $env->{job_name_save} );
  push @cmd, '-e', $conf->{stderr_dir};
  push @cmd, '-o', $conf->{stdout_dir};

  my @hold_arg = ( '-hold_jid', $env->{job_id} );

  #push @cmd, @{ $self->submit_params };

  my @post_cmd = (
    $env->{worker_env_script},
    $env->{script_bin}, '--stage', 'post_task', '--job_id', $env->{job_id}, $env->{worker_config_file}
  );

  $self->log->info( "post processing: " . join( " ", @cmd, @hold_arg, @post_cmd ) );

  my $post_cmd_file
    = catfile( $conf->{tmp_dir}, sprintf( "post.%s.j%s.cmd", $env->{job_name_save}, $env->{job_id} ) );

  open my $post_fh, '>', $post_cmd_file or confess "Can't open filehandle: $!";
  say $post_fh join( " ", "cd", "'" . fastcwd . "'", '&&', @cmd, @post_cmd );
  $post_fh->close;

  chmod 0755, $post_cmd_file;

  system( @cmd, @hold_arg, @post_cmd ) == 0 or confess "post task system failed: $?";

  return;
}

1;

__END__

=head1 NAME



=head1 SYNOPSIS

  #wenn export, dann hier im qw()

=head1 DESCRIPTION

=over 4

=item B<< combinations_per_task >>

=item B<< num_parts >>

=back


=head1 OPTIONS

=head1 SUBROUTINES
=head1 METHODS

=head1 SEE ALSO

=head1 AUTHOR

jw bargsten, C<< <jwb at cpan dot org> >>

=cut



( run in 2.265 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )