This repository has been archived by the owner on Sep 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
switchseq
executable file
·144 lines (127 loc) · 3.75 KB
/
switchseq
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use FindBin qw($Bin);
use lib "$Bin/lib";
use GetData;
use GetSwitch;
use Data::Dumper;
## get options
my %arguments;
$arguments{'help'}=0;
$arguments{'data_dir'}="./data";
$arguments{'out_dir'}="./html";
$arguments{'threshold_gexp'}=0.01;
$arguments{'threshold_breadth'}=50;
$arguments{'threshold_dominance'}=1;
$arguments{'tool'}="";
$arguments{'filt'}="NA";
GetOptions(
\%arguments,
'help|h',
'tool|t=s',
'data_dir|d:s',
'species|s:s',
'ensembl_v|e:i',
'input|i=s',
'out_dir|o=s',
'cond1|c1=s',
'cond2|c2=s',
'threshold_gexp|g=f',
'threshold_breadth|b=f',
'threshold_dominance|dom=f',
'filt|f=s'
) or die pod2usage(
-input => "$Bin/doc/switchseq.pod",
-verbose => 1
);
## process user options
if (defined($arguments{'tool'}) and $arguments{'tool'} eq "get_data") {
## check for required arguments
if ($arguments{'help'} or
!defined($arguments{'species'}) or
!defined($arguments{'ensembl_v'})) {
die pod2usage(
-input => "$Bin/doc/get_data.pod",
-verbose => 1
);
}
## check for species
unless ($arguments{'species'} eq "hsa"
or $arguments{'species'} eq "mmu"
or $arguments{'species'} eq "dre"
or $arguments{'species'} eq "rno") {
my $message="Pre-compiled data available only for human (hsa), mouse (mmu), rat (rno) and zebrafish (dre).\n".
"Refer to the project's wiki for further information on how to proceed with other species:\n".
"\thttps://github.com/mgonzalezporta/SwitchSeq/wiki/Tutorial\n";
die $message;
}
## finally, get the data
get_data(\%arguments);
} elsif (defined($arguments{'tool'}) and $arguments{'tool'} eq "get_switch") {
## check for required arguments
if ($arguments{'help'} or
!defined($arguments{'species'}) or
!defined($arguments{'ensembl_v'}) or
!defined($arguments{'input'}) or
!defined($arguments{'cond1'}) or
!defined($arguments{'cond2'})) {
die pod2usage(
-input => "$Bin/doc/get_switch.pod",
-verbose => 1
);
}
## check input arguments
unless (-e $arguments{'input'}) {
die("Cannot open $arguments{'input'}: $!\n");
}
my @cond1=split("-", $arguments{'cond1'});
my @cond2=split("-", $arguments{'cond2'});
unless ($arguments{'cond1'} =~ /\d+-\d+/ and
$arguments{'cond2'} =~ /\d+-\d+/ and
$cond1[0]<=$cond1[1] and
$cond2[0]<=$cond2[1]) {
my $message="Wrong format for column intervals.\n".
"Print help: switchseq -tool get_switch -h\n";
die $message;
}
unless ($cond1[0]>2) {
my $message="Invalid interval for --cond1: the first two columns must contain gene and transcript ids.\n".
"Print help: switchseq -tool get_switch -h\n";
die $message;
}
unless ($cond1[1]+1==$cond2[0]) {
my $message="Warning: Inconsistency detected in the column interval definitions.\n".
" Please check --cond1 and --cond2.\n";
warn $message;
}
unless ( -e $arguments{'data_dir'} and
-e "$arguments{'data_dir'}/$arguments{'species'}.$arguments{'ensembl_v'}" ) {
my $message="Cannot find data directory:\n".
" $arguments{'data_dir'}/$arguments{'species'}.$arguments{'ensembl_v'}\n".
"Data should be downloaded first:\n".
"\tswitchseq -t get_data -h\n".
"\thttps://github.com/mgonzalezporta/SwitchSeq/wiki/Tutorial\n";
die $message;
}
if ($arguments{'filt'} ne "NA" and
! -e $arguments{'filt'}) {
die("Cannot open $arguments{'input'}: $!\n");
}
## finally, find switch events
get_switch(\%arguments);
} elsif ($arguments{'help'}) {
## print doc - long version
die pod2usage(
-input => "$Bin/doc/switchseq.pod",
-verbose => 99,
-sections => "NAME|VERSION|SYNOPSIS|OPTIONS" );
} else {
## print doc - short version
die pod2usage(
-input => "$Bin/doc/switchseq.pod",
-verbose => 1
);
}