forked from grubbybio/pRNASeqTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate_options.pm
executable file
·54 lines (49 loc) · 2.97 KB
/
validate_options.pm
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
#!/usr/bin/env perl
package validate_options;
use Modern::Perl;
use File::Path qw/make_path/;
use File::Copy qw/move/;
sub run {
my ($self, $option) = @_;
my %options=%$option;
die 'Output directory exists! Please specify another output directory!' if(defined $options{'outdir'} and -e $options{'outdir'});
make_path $options{'outdir'};
move "log_".$main::time.".txt", $options{'outdir'}."/";
chdir $options{'outdir'};
if(defined $options{'adaptor'}){
if($options{'adaptor'} eq "1"){
$options{'adaptor'} = "AGATCGGAAGAGC";
}elsif($options{'adaptor'} eq "2"){
$options{'adaptor'} = "TGGAATTCTCGGG";
}elsif($options{'adaptor'} eq "3"){
$options{'adaptor'} = "CTGTCTCTTATAC";
}
}
if(defined $options{'adaptor2'}){
if($options{'adaptor2'} eq "1"){
$options{'adaptor2'} = "AGATCGGAAGAGC";
}elsif($options{'adaptor2'} eq "2"){
$options{'adaptor2'} = "TGGAATTCTCGGG";
}elsif($options{'adaptor'} eq "3"){
$options{'adaptor'} = "CTGTCTCTTATA";
}
}
die 'Please use appropriate threads!' if(defined $options{'thread'} and $options{'thread'} =~ /[^1-9]/);
die 'Please use an appropriate P value!' if(defined $options{'pvalue'} and $options{'pvalue'} > 1);
die 'Please use an appropriate FDR value!' if(defined $options{'fdr'} and $options{'fdr'} > 1);
die 'Please use an appropriate fold change!' if(defined $options{'foldchange'} and $options{'foldchange'} < 1.5);
die 'Please use a supported strategy for mapping!' if(defined $options{'mmap'} and $options{'mmap'} =~ /[^ufrn]/);
die 'Please specify an appropriate length of preferred small RNAs!' if(defined $options{'length'} and ($options{'length'} < 18 || $options{'length'} > 42));
die 'Parameter conflict: nomapping and mappingonly!' if(defined $options{'no-mapping'} and defined $options{'mapping-only'} and $options{'no-mapping'} + $options{'mapping-only'} == 2);
die 'Method not supported!' if(defined $options{'DESeq2Norm'} and $options{'DESeq2Norm'} ne 'DESeq2' and $options{'DESeq2Norm'} ne 'RPM');
die 'Please specify an appropriate sequencing strategy!' if(defined $options{'seqStrategy'} and $options{'seqStrategy'} ne 'single' and $options{'seqStrategy'} ne 'paired');
die 'Please specify an fasta file for mask!' if(defined $options{'mask'} and $options{'mask'} !~ /fasta$|fa$/);
die 'Please specify an fasta file for spike-in!' if(defined $options{'spike-in'} and $options{'spike-in'} !~ /fasta$|fa$/);
die 'Please select the correct style!' if(defined $options{'style'} and $options{'style'} !~ /histone|factor|tss/);
die 'Cannot find the target list!' if(defined $options{'targets'} and $options{'targets'} ne "all" and !-e $options{'targets'});
die 'Please provide the library type when input files are in the bam format!' if(defined $options{'mode'} and $options{'mode'} eq '3' and !defined $options{'seqStrategy'});
die 'Cannot find the siRNA list in fasta file!' if(defined $options{'siRNAs'} and !-e $options{'siRNAs'});
return %options;
}
1;
__END__