-
Notifications
You must be signed in to change notification settings - Fork 16
/
functions.pl
127 lines (106 loc) · 3.01 KB
/
functions.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
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
#!/usr/bin/env perl
#####################################
## Robin van der Lee ##
## robinvanderlee AT gmail DOT com ##
############################################################################################################
## Genome-scale detection of positive selection in 9 primates predicts human-virus evolutionary conflicts ##
## Robin van der Lee, Laurens Wiel, Teunis J.P. van Dam, Martijn A. Huynen ##
############################################################################################################
use strict;
use warnings;
### PRINTING
sub newline{
if(defined $_[0]){
print "\n" x $_[0];
} else {
print "\n";
}
}
sub nl{
newline(@_);
}
sub printArray{
foreach(@_){
print;
newline();
}
}
sub printArray2{
foreach(@_){
print $_ . "\t";
}
print "\n";
}
sub printArrayofHashes{
foreach(@_){
my %tmphash = $_;
printHash(\%tmphash);
separator();
}
print "\n";
}
sub printHash{
my %hash = %{ $_[0] };
foreach(keys %hash){
print $_ . " - " . $hash{$_} . "\n";
}
}
sub printHashOfArrays{
my %hash = %{ $_[0] };
foreach(keys %hash){
my @array = @{ $hash{$_} };
print $_ . " - [ " . join(",", @array) . " ]\n";
}
}
### SEPARATORS
sub separator{
print generic_separator("=");
}
sub separator2{
print generic_separator("-");
}
sub separator3{
print generic_separator("~");
}
sub separator4{
print generic_separator("+");
}
sub separator5{
print generic_separator("\"");
}
sub separator6{
print generic_separator("#");
}
sub generic_separator{
my $character = shift;
my $separator_string = $character x 60 . "\n";
return $separator_string;
}
### TIME
sub getTimeAndDate{
my @Month_name = ( "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" );
( my $sec, my $min, my $hour, my $day, my $month, my $year ) = ( localtime ) [ 0, 1, 2, 3, 4, 5 ];
printf "%02d:%02d:%02d %02d %s %04d\n", $hour, $min, $sec, $day, $Month_name[$month], $year+1900;
}
# sub getTimestamp{
# ( my $sec, my $min, my $hour, my $day, my $month, my $year ) = ( localtime ) [ 0, 1, 2, 3, 4, 5 ];
# return sprintf "%04d%02d%02d-%02d%02d", $year+1900, $month + 1, $day, $hour, $min;
# }
sub getTimestampSec{
( my $sec, my $min, my $hour, my $day, my $month, my $year ) = ( localtime ) [ 0, 1, 2, 3, 4, 5 ];
return sprintf "%04d%02d%02d-%02d%02d%02d", $year+1900, $month + 1, $day, $hour, $min, $sec;
}
sub getTimestampMin{
( my $sec, my $min, my $hour, my $day, my $month, my $year ) = ( localtime ) [ 0, 1, 2, 3, 4, 5 ];
return sprintf "%04d%02d%02d-%02d%02d", $year+1900, $month + 1, $day, $hour, $min;
}
sub getTimestampHour{
( my $sec, my $min, my $hour, my $day, my $month, my $year ) = ( localtime ) [ 0, 1, 2, 3, 4, 5 ];
return sprintf "%04d%02d%02d-%02d", $year+1900, $month + 1, $day, $hour;
}
sub getTimestampDay{
( my $sec, my $min, my $hour, my $day, my $month, my $year ) = ( localtime ) [ 0, 1, 2, 3, 4, 5 ];
return sprintf "%04d%02d%02d", $year+1900, $month + 1, $day;
}
return 1;