Skip to content
Snippets Groups Projects
batchAlignment.pl 6.97 KiB
#!/usr/bin/perl

use warnings;
use strict;
use Getopt::Long();
use POSIX qw(strftime);

sub usage($);
sub version($);

sub createBatchJob($$);
sub preparePath($$);
sub printSBatchHeader($$$$$$);
sub printSBatchScript($$$$$);


MAIN:
{
    # define inputs
    my $version_tag = "version 1.0, October 2018";
    my $version;
    my $help;
    my $path_fastq;
    my $path_genome_index;
    my $file_genome_annotation;
    my $path_output;
    my $opts;
    my $sbatch_nodes = 1;
    my $sbatch_partition = "cuttlefish";
    my $sbatch_time = "100:00:00";
    my $sbatch_ntasks = 1;
    my $sbatch_cpus = 16;
    my $sbatch_name = "braintest";
    
    
    # set-up paramters
    Getopt::Long::GetOptions(
        "f|fastq=s" => \$path_fastq,
        "o|output-dir=s" => \$path_output,
        "g|genome=s" => \$path_genome_index,
        "a|annotation=s" => \$file_genome_annotation,
        "x|opts=s" => \$opts,
        "n|nodes=i" => \$sbatch_nodes,
        "p|partition=s" => \$sbatch_partition,
        "t|time=s" => \$sbatch_time,
        "T|ntasks=i" => \$sbatch_ntasks,
        "c|cpus=i" => \$sbatch_cpus,
        "l|name=s" => \$sbatch_name,
        "h|help" => \$help,
        "v|version" => \$version
    ) or usage("Error::invalid command line options");
    
    # parse inputs
    version($version_tag) if($version);
    usage($version_tag) if($help);
    usage("Error::path to FastQ files is required") unless defined($path_fastq);
    usage("Error::path to output location is required") unless defined($path_output);
    usage("Error::path to genome index is required") unless defined($path_genome_index);
    usage("Error::genome annotation file is required") unless defined($file_genome_annotation);

    # create batch job
    my $batch_job = createBatchJob($path_fastq, $path_output);

    # print SBatch header
    printSBatchHeader($sbatch_nodes, 
                      $sbatch_partition, 
                      $sbatch_time, 
                      $sbatch_ntasks,
                      $sbatch_cpus,
                      $sbatch_name);