line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Proch::Seqfu; |
2
|
|
|
|
|
|
|
#ABSTRACT: Helper module to support Seqfu tools |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
2145
|
use 5.014; |
|
3
|
|
|
|
|
22
|
|
5
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
110
|
|
6
|
3
|
|
|
3
|
|
35
|
use Carp qw(confess); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
211
|
|
7
|
3
|
|
|
3
|
|
1242
|
use Data::Dumper; |
|
3
|
|
|
|
|
14446
|
|
|
3
|
|
|
|
|
235
|
|
8
|
3
|
|
|
3
|
|
1894
|
use Term::ANSIColor qw(:constants); |
|
3
|
|
|
|
|
28408
|
|
|
3
|
|
|
|
|
5733
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$Proch::Seqfu::VERSION = '1.5.6'; |
12
|
|
|
|
|
|
|
$Proch::Seqfu::fu_linesize = 0; |
13
|
|
|
|
|
|
|
$Proch::Seqfu::fu_verbose = 0; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
16
|
|
|
|
|
|
|
our @EXPORT = qw(rc fu_printfasta fu_printfastq verbose has_seqfu seqfu_version); |
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw($fu_linesize $fu_verbose); # symbols to export on request |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub fu_printfasta { |
21
|
0
|
|
|
0
|
1
|
0
|
my ($name, $comment, $seq) = @_; |
22
|
0
|
|
|
|
|
0
|
my $print_comment = ''; |
23
|
0
|
0
|
|
|
|
0
|
if (defined $comment) { |
24
|
0
|
|
|
|
|
0
|
$print_comment = ' ' . $comment; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
say '>', $name, $print_comment; |
28
|
0
|
|
|
|
|
0
|
print split_string($seq); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fu_printfastq { |
32
|
0
|
|
|
0
|
1
|
0
|
my ($name, $comment, $seq, $qual) = @_; |
33
|
0
|
|
|
|
|
0
|
my $print_comment = ''; |
34
|
0
|
0
|
|
|
|
0
|
if (defined $comment) { |
35
|
0
|
|
|
|
|
0
|
$print_comment = ' ' . $comment; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
say '@', $name, $print_comment; |
39
|
0
|
|
|
|
|
0
|
print split_string($seq) , "+\n", split_string($qual); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Print verbose info |
44
|
|
|
|
|
|
|
sub verbose { |
45
|
0
|
0
|
|
0
|
1
|
0
|
if ($Proch::Seqfu::fu_verbose) { |
46
|
0
|
|
|
|
|
0
|
say STDERR " - ", $_[0]; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub rc { |
52
|
1
|
|
|
1
|
1
|
83
|
my $sequence = reverse($_[0]); |
53
|
1
|
50
|
|
|
|
4
|
if (is_seq($sequence)) { |
54
|
1
|
|
|
|
|
4
|
$sequence =~tr/ACGTacgt/TGCAtgca/; |
55
|
1
|
|
|
|
|
3
|
return $sequence; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub is_seq { |
61
|
3
|
|
|
3
|
1
|
527
|
my $string = $_[0]; |
62
|
3
|
100
|
|
|
|
15
|
if ($string =~/[^ACGTRYSWKMBDHVN]/i) { |
63
|
1
|
|
|
|
|
7
|
return 0; |
64
|
|
|
|
|
|
|
} else { |
65
|
2
|
|
|
|
|
10
|
return 1; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub split_string { |
71
|
0
|
|
|
0
|
1
|
0
|
my $input_string = $_[0]; |
72
|
0
|
|
|
|
|
0
|
my $formatted = ''; |
73
|
0
|
|
|
|
|
0
|
my $line_width = $Proch::Seqfu::fu_linesize; # change here |
74
|
0
|
0
|
|
|
|
0
|
return $input_string. "\n" unless ($line_width); |
75
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < length($input_string); $i += $line_width) { |
76
|
0
|
|
|
|
|
0
|
my $frag = substr($input_string, $i, $line_width); |
77
|
0
|
|
|
|
|
0
|
$formatted .= $frag."\n"; |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
0
|
return $formatted; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub seqfu_version { |
84
|
2
|
|
|
2
|
1
|
5218
|
my $cmd = `seqfu version`; |
85
|
2
|
|
|
|
|
243
|
chomp($cmd); |
86
|
2
|
50
|
|
|
|
76
|
if ($cmd =~/^(\d).(\d).(\d)$/) { |
87
|
0
|
|
|
|
|
0
|
return $cmd; |
88
|
|
|
|
|
|
|
} else { |
89
|
2
|
|
|
|
|
47
|
return -1; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub has_seqfu { |
95
|
1
|
|
|
1
|
1
|
40
|
my $ver = seqfu_version(); |
96
|
1
|
50
|
|
|
|
27
|
if ($ver == -1) { |
|
|
0
|
|
|
|
|
|
97
|
1
|
|
|
|
|
20
|
return 0 |
98
|
|
|
|
|
|
|
} elsif (length($ver) > 0) { |
99
|
0
|
|
|
|
|
|
return 1 |
100
|
|
|
|
|
|
|
} else { |
101
|
0
|
|
|
|
|
|
return undef; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=pod |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=encoding UTF-8 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Proch::Seqfu - Helper module to support Seqfu tools |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 VERSION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
version 1.5.6 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 Proch::Seqfu |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
a legacy module for Seqfu utilities |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 fu_printfasta(name, comment, seq) |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This function prints a sequence in fasta format |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 fu_printfastq(name, comment, seq, qual) |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This function prints a sequence in FASTQ format |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 verbose(msg) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Print a text if $fu_verbose is set to 1 |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 rc(dna) |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Return the reverse complement of a string [degenerate base not supported] |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 is_seq(seq) |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Check if a string is a DNA sequence, including degenerate chars. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 split_string(dna) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Add newlines using $Proch::Seqfu::fu_linesize as line width |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 seqfu_version() |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Check if a `seqfu` binary is present and returns its version if found. |
149
|
|
|
|
|
|
|
Note this will require SeqFu > 1.13 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 has_seqfu() |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
If SeqFu is detected returns 1, 0 otherwise, I when detection of SeqFu version fails. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Andrea Telatin |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This software is Copyright (c) 2018-2022 by Andrea Telatin. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This is free software, licensed under: |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
The MIT (X11) License |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
__END__ |