NAME
NBI::Opts - A class for representing a the SLURM options for NBI::Slurm
VERSION
version 0.12.0
SYNOPSIS
SLURM Options for NBI::Slurm, to be passed to a NBI::Job object.
use
NBI::Opts;
my
$opts
= NBI::Opts->new(
-queue
=>
"short"
,
-threads
=> 4,
-memory
=>
"8GB"
,
-time
=>
"2h"
,
-opts
=> [],
);
DESCRIPTION
The NBI::Opts
module provides a class for representing the SLURM options used by NBI::Slurm for job submission. It allows you to set various options such as the queue, number of threads, allocated memory, execution time, input files, and more.
METHODS
new()
Create a new instance of NBI::Opts
. In this case this will imply using a job array over a list of files
my
$opts
= NBI::Opts->new(
-queue
=>
"short"
,
-threads
=> 4,
-memory
=>
"8GB"
,
-time
=>
"2h"
,
-opts
=> [
"--option=Value"
],
-tmpdir
=>
"/path/to/tmp"
,
-email_address
=>
"user@example.com"
,
-email_type
=>
"ALL"
,
-files
=> [
"file1.txt"
,
"file2.txt"
],
-placeholder
=>
"#FILE#"
);
This method creates a new NBI::Opts
object with the specified options. The following parameters are supported:
-queue (string, optional)
The SLURM queue to submit the job to. Default is "nbi-short".
-threads (integer, optional)
The number of threads to allocate for the job. Default is 1.
-memory (string or integer, optional)
The allocated memory for the job. It can be specified as a bare number representing megabytes (e.g., 1024), or with a unit suffix (e.g., "8GB"). Default is 100 megabytes.
-time (string or integer, optional)
The time limit for the job. It can be specified as hours (e.g., 2) or as a string with time units (e.g., "2h", "1d 12h"). Default is 1 hour.
-opts (arrayref, optional)
An array reference containing additional SLURM options to be passed to the job script.
-tmpdir (string, optional)
The temporary directory to use for job execution. Default is the system's temporary directory.
-email_address (string, optional)
The email address for job notifications.
-email_type (string, optional)
The type of email notifications to receive (e.g., "NONE", "BEGIN", "END", "FAIL", "ALL"). Default is "NONE".
-files (arrayref, optional)
An array reference containing input files or file patterns for the job.
-placeholder (string, optional)
A placeholder string to be used in the command for input files. Default is "#FILE#".
queue
Accessor method for the SLURM queue.
$opts
->queue =
"long"
;
my
$queue
=
$opts
->queue;
threads
Accessor method for the number of threads.
$opts
->threads = 8;
my
$threads
=
$opts
->threads;
memory
Accessor method for the allocated memory.
$opts
->memory =
"16GB"
;
my
$memory
=
$opts
->memory;
email_address
Accessor method for the email address.
$opts
->email_address =
"user@example.com"
;
my
$email_address
=
$opts
->email_address;
email_type
Accessor method for the email notification type.
$opts
->email_type =
"ALL"
;
my
$email_type
=
$opts
->email_type;
hours
Accessor method for the execution time in hours.
$opts
->hours = 24;
my
$hours
=
$opts
->hours;
tmpdir
Accessor method for the temporary directory.
$opts
->tmpdir =
"/path/to/tmpdir"
;
my
$tmpdir
=
$opts
->tmpdir;
opts
Accessor method for the additional SLURM options.
$opts
->opts = [
"--output=TestJob.out"
,
"--mail-user user@example.com"
];
my
$opts_array
=
$opts
->opts;
files
Accessor method for the input files or file patterns.
$opts
->files = [
"file1.txt"
,
"*.fasta"
];
my
$files
=
$opts
->files;
placeholder
Accessor method for the input file placeholder.
$opts
->placeholder =
"{INPUT}"
;
my
$placeholder
=
$opts
->placeholder;
add_option
Add an additional SLURM option.
$opts
->add_option(
"--output=TestJob.out"
);
opts_count
Get the number of additional SLURM options.
my
$count
=
$opts
->opts_count;
is_array
Check if the job is an array job (has multiple input files).
my
$is_array
=
$opts
->is_array;
view
Get a string representation of the options.
my
$str
=
$opts
->view;
header
Generate the SLURM header for the job script.
my
$header
=
$opts
->header;
timestring
Get the execution time as a formatted string.
my
$timestring
=
$opts
->timestring;
Returns the execution time in the format "DD-HH:MM:SS".
INTERNAL METHODS
_mem_parse_mb
Parse memory input and convert to megabytes.
_time_to_hour
Convert time input to hours.
AUTHOR
Andrea Telatin <proch@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2023-2025 by Andrea Telatin.
This is free software, licensed under:
The MIT (X11) License