-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_InterProScan.pl
More file actions
executable file
·106 lines (89 loc) · 2.41 KB
/
run_InterProScan.pl
File metadata and controls
executable file
·106 lines (89 loc) · 2.41 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl
## Pombert Lab, IIT, 2020
my $name = 'run_InterProScan.pl';
my $version = '0.1a';
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 Runs InterProScan 5 on FASTA file(s)
USAGE ${name} \\
-c 10 \\
-f *.fasta \\
-ip \\
-go \\
-pa \\
-d Interproscan/ \\
-l interproscan.log
OPTIONS:
-c (--cpu) Number of CPU cores to use [Default: 10]
-f (--fasta) FASTA file(s) to query
-ip (--iprlookup) Use InterPro's pre-calculated match lookup service
-go (--goterms) Gene ontology search (requires --iprlookup)
-pa (--pathways) KEGG pathways (requires --iprlookup)
-d (--dir) Output directory [Default: ./]
-l (--log) Log name [Default: interproscan.log]
OPTIONS
die "\n$usage\n" unless @ARGV;
my $cpu = 10;
my @fasta;
my $odir = './';
my $ipr;
my $go;
my $pa;
my $log = 'interproscan.log';
GetOptions(
'c|cpu=i' => \$cpu,
'f|fasta=s@{1,}' => \@fasta,
'd|dir=s' => \$odir,
'ip|iprlookup' => \$ipr,
'go|goterms' => \$go,
'pa|pathways' => \$pa,
'l|log=s' => \$log
);
my $iprlookup; my $goterms; my $pathways;
if (defined $ipr){$iprlookup = '-iprlookup';}
if ((defined $go) and (defined $ipr)){$goterms = '-goterms';}
if ((defined $pa) and (defined $ipr)){$pathways = '-pa';}
## 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";
open LOG, ">", "${odir}/$log" or die "Can't create file ${odir}/$log: $!\n";
## Working on fasta files
while (my $file = shift@fasta){
my ($fasta, $dir) = fileparse($file);
print "Working on file $fasta located in $dir\n";
my $sdate = `date`;
print LOG "InterProScan search on $fasta started on: $sdate\n";
system ("interproscan.sh \\
-cpu $cpu \\
-i $file \\
$iprlookup \\
$goterms \\
$pathways \\
-b ${odir}/$fasta.interpro") == 0 or checksig();
my $edate = `date`;
print LOG "InterProScan search on $fasta completed on: $edate\n";
}
### 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);
}
}