-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_RNAmmer.pl
executable file
·76 lines (64 loc) · 1.58 KB
/
run_RNAmmer.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
## Pombert Lab, IIT, 2020
my $name = 'run_RNAmmer.pl';
my $version = '0.5b';
my $updated = '2022-05-27';
use strict;
use warnings;
use File::Basename;
use Getopt::Long qw(GetOptions);
## Defining options
my $usage = <<"OPTIONS";
NAME ${name}
VERSION ${version}
UPDATED ${updated}
SYNOPSIS Finds ribosomal RNAs using RNAmmer 1.2+ (requires hmmer 2.3.2)
USAGE ${name} \\
-k kingdom \\
-f *.fasta \\
-d rRNA/
OPTIONS:
-k (--kingdom) Kingdom; arc, bac or euk [Default: euk]
-f (--fasta) FASTA file(s) to annotate
-d (--dir) Output directory [Default: ./]
OPTIONS
die "\n$usage\n" unless @ARGV;
my $kingdom = 'euk';
my @fasta;
my $odir = './';
GetOptions(
'k|kingdom=s' => \$kingdom,
'f|fasta=s@{1,}' => \@fasta,
'd|dir=s' => \$odir
);
## Creating output directory
unless (-d $odir){
mkdir ($odir,0755) or die "Can't create folder $odir: $!\n";
}
print "\nOutput files will be located in directory $odir\n";
## Iterating through files
while (my $file = shift@fasta){
my ($fasta, $dir) = fileparse($file);
print "Working on file $fasta located in $dir\n";
system ("rnammer \\
-S $kingdom \\
-m tsu,ssu,lsu \\
-gff ${odir}/$fasta.gff2 \\
-h ${odir}/$fasta.hmm \\
-f ${odir}/$fasta.rRNAs \\
< $file") == 0 or checksig();
}
### Subroutine(s)
sub checksig {
my $exit_code = $?;
my $modulo = $exit_code % 255;
print "\nExit code = $exit_code; modulo = $modulo \n";
if ($modulo == 2) {
print "\nSIGINT detected: Ctrl+C => exiting...\n";
exit(2);
}
elsif ($modulo == 131) {
print "\nSIGTERM detected: Ctrl+\\ => exiting...\n";
exit(131);
}
}