The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bio::Grid::Run::SGE::Util - Utility functions for Bio::Grid::Run::SGE

SYNOPSIS

    use Bio::Grid::Run::SGE::Util qw(
      my_glob
      my_sys
      MSG
      INFO
      delete_by_regex
      expand_path
      my_mkdir
      concat_files
      faiterate
      my_sys_non_fatal
      my_glob_non_fatal
      timer
      expand_path_rel
    );

DESCRIPTION

Provides utility functions for the Bio::Grid::Run::SGE module.

SUBROUTINES

$first_file = my_glob($pattern)
@all_files = my_glob($pattern)

See File::Glob::bsd_glob for an explanation of the $pattern. This function is for convenience only and takes care of some quirks of bsd_glob.

$first_file = my_glob_non_fatal($pattern)
@all_files = my_glob_non_fatal($pattern)

Same as my_glob, but does not die if glob result is empty.

$first_file = expand_path(\@files)
@files = expand_path(\@files)

Expands a path to its absoulte equivalent. Taks also care of paths beginning with '~'.

$first_file = expand_path_rel(\@files)
@files = expand_path_rel(\@files)

Expands the '~' at the beginning of a path to the home directory.

my_sys(@command)
my_sys($command)

Runs command eiter as array or as simple string (see also system) and dies if something goes wrong.

my_sys_non_fatal(@command)
my_sys_non_fatal($command)

Runs command eiter as array or as simple string (see also system) and gives a warning message if something goes wrong.

It returns undef is something went wrong and 1/true if the exit code of the program was ok.

my_mkdir($path)

Creates $path and dies if something goes wrong. See also "mkpath" in File::Path.

INFO(@text)

Prints @text concatenated by spaces indented by a <TAB> to standard error.

MSG(@text)

Just prints @text to standard error.

delete_by_regex($dir, $file_regex, $simulate)

Opens $dir and deletes all files that match $file_regex. If simulate is true, then just print the files that would be deleted.

concat_files($config)

Concatenates all result files in one file $c-{result_dir}/$c->{job_name}.j${job_id}.result.concat and deletes the single result files. Result files are determined by following regex:

  qr/\Q$c->{job_name}\E #job name
    \.j$c->{job_id} #the job id
    \.[0-9]+ #the sge task id
    \.t[\-0-9]+(?:\.[\w\-.#]+)? #my task id
    (?:\..*)? #suffix
    $/x;

If your toolwrapper makes use of it, you can also invoke it by hand. In the working dir of your job run:

    ~/script/<toolwrapper>.pl -p <job_id> <tmp>/<job_name>.config

TAKE CARE, IT DELETES THE RESULT FILES AND OVERWRITES THE LAST RESULT.CONCAT FILE

$timer = timer()

Time something. Usage:

  # get a timer
  my $timer = timer();

  # start
  my $start_time = $timer->();

  # stop
  my $stop_time = $timer->();
  my ($stop_time, $elapsed_time_as_string) = $timer->();

SEE ALSO

Bio::Grid::Run::SGE

AUTHOR

jw bargsten, <joachim.bargsten at wur.nl>