line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Tradis::Map; |
2
|
|
|
|
|
|
|
$Bio::Tradis::Map::VERSION = '1.3.3'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Perform mapping |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
110564
|
use Moose; |
|
3
|
|
|
|
|
424177
|
|
|
3
|
|
|
|
|
20
|
|
7
|
3
|
|
|
3
|
|
19730
|
use Bio::Tradis::Parser::Fastq; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1286
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'fastqfile' => ( is => 'rw', isa => 'Str', required => 1 ); |
10
|
|
|
|
|
|
|
has 'reference' => ( is => 'rw', isa => 'Str', required => 1 ); |
11
|
|
|
|
|
|
|
has 'refname' => |
12
|
|
|
|
|
|
|
( is => 'rw', isa => 'Str', required => 0, default => 'ref.index' ); |
13
|
|
|
|
|
|
|
has 'outfile' => |
14
|
|
|
|
|
|
|
( is => 'rw', isa => 'Str', required => 0, default => 'mapped.sam' ); |
15
|
|
|
|
|
|
|
has 'smalt_k' => ( is => 'rw', isa => 'Maybe[Int]', required => 0 ); |
16
|
|
|
|
|
|
|
has 'smalt_s' => ( is => 'rw', isa => 'Maybe[Int]', required => 0 ); |
17
|
|
|
|
|
|
|
has 'smalt_y' => ( is => 'rw', isa => 'Maybe[Num]', required => 0, default => 0.96 ); |
18
|
|
|
|
|
|
|
has 'smalt_r' => ( is => 'rw', isa => 'Maybe[Int]', required => 0, default => -1 ); |
19
|
|
|
|
|
|
|
has 'smalt_n' => ( is => 'rw', isa => 'Maybe[Int]', required => 0, default => 1 ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub index_ref { |
22
|
4
|
|
|
4
|
1
|
13
|
my ($self) = @_; |
23
|
4
|
|
|
|
|
111
|
my $ref = $self->reference; |
24
|
4
|
|
|
|
|
90
|
my $refname = $self->refname; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Calculate index parameters |
27
|
4
|
|
|
|
|
82
|
my $pars = Bio::Tradis::Parser::Fastq->new( file => $self->fastqfile ); |
28
|
4
|
|
|
|
|
26
|
$pars->next_read; |
29
|
4
|
|
|
|
|
27
|
my @read = $pars->read_info; |
30
|
4
|
|
|
|
|
17
|
my $read_len = length($read[1]); |
31
|
4
|
|
|
|
|
23
|
my ( $k, $s ) = $self->_calculate_index_parameters($read_len); |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
23
|
my $cmd = "smalt index -k $k -s $s $refname $ref > /dev/null 2>&1"; |
34
|
4
|
|
|
|
|
14712
|
system($cmd); |
35
|
4
|
|
|
|
|
427
|
return $cmd; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _calculate_index_parameters { |
39
|
4
|
|
|
4
|
|
17
|
my ($self, $read_len) = @_; |
40
|
4
|
|
|
|
|
9
|
my ( $k, $s ); |
41
|
|
|
|
|
|
|
|
42
|
4
|
100
|
|
|
|
96
|
if( defined $self->smalt_k ){ $k = $self->smalt_k; } |
|
1
|
|
|
|
|
16
|
|
43
|
3
|
|
|
|
|
13
|
else{ $k = $self->_smalt_k_default($read_len); } |
44
|
|
|
|
|
|
|
|
45
|
4
|
100
|
|
|
|
210
|
if( defined $self->smalt_s ){ $s = $self->smalt_s; } |
|
1
|
|
|
|
|
15
|
|
46
|
3
|
|
|
|
|
18
|
else{ $s = $self->_smalt_s_default($read_len); } |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
14
|
return ( $k, $s ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _smalt_k_default { |
52
|
3
|
|
|
3
|
|
10
|
my ($self, $read_len) = @_; |
53
|
3
|
50
|
|
|
|
17
|
if($read_len < 100){ return 13; } |
|
3
|
|
|
|
|
10
|
|
54
|
0
|
|
|
|
|
0
|
else{ return 20; } |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _smalt_s_default { |
58
|
3
|
|
|
3
|
|
10
|
my ( $self, $read_len ) = @_; |
59
|
3
|
50
|
|
|
|
10
|
if( $read_len < 70 ){ return 4; } |
|
3
|
0
|
|
|
|
10
|
|
60
|
0
|
|
|
|
|
0
|
elsif( $read_len > 100 ){ return 13; } |
61
|
0
|
|
|
|
|
0
|
else{ return 6; } |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub do_mapping { |
65
|
4
|
|
|
4
|
1
|
780
|
my ($self) = @_; |
66
|
4
|
|
|
|
|
119
|
my $fqfile = $self->fastqfile; |
67
|
4
|
|
|
|
|
97
|
my $refname = $self->refname; |
68
|
4
|
|
|
|
|
243
|
my $outfile = $self->outfile; |
69
|
4
|
|
|
|
|
117
|
my $y = $self->smalt_y; |
70
|
4
|
|
|
|
|
86
|
my $r = $self->smalt_r; |
71
|
4
|
|
|
|
|
84
|
my $n = $self->smalt_n; |
72
|
|
|
|
|
|
|
|
73
|
4
|
|
|
|
|
70
|
my $smalt = "smalt map -n $n -x -r $r -y $y $refname $fqfile 1> $outfile 2> smalt.stderr"; |
74
|
|
|
|
|
|
|
|
75
|
4
|
|
|
|
|
12256
|
system($smalt); |
76
|
4
|
|
|
|
|
552
|
unlink('smalt.stderr'); |
77
|
|
|
|
|
|
|
|
78
|
4
|
|
|
|
|
280
|
return $smalt; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
82
|
3
|
|
|
3
|
|
22
|
no Moose; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
16
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=encoding UTF-8 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Bio::Tradis::Map - Perform mapping |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 VERSION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
version 1.3.3 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SYNOPSIS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Takes a reference genome and indexes it. |
102
|
|
|
|
|
|
|
Maps given fastq files to ref. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use Bio::Tradis::Map; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $pipeline = Bio::Tradis::Map->new(fastqfile => 'abc', reference => 'abc'); |
107
|
|
|
|
|
|
|
$pipeline->index_ref(); |
108
|
|
|
|
|
|
|
$pipeline->do_mapping(); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 PARAMETERS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 Required |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * C<fastqfile> - path to/name of file containing reads to map to the reference |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * C<reference> - path to/name of reference genome in fasta format (.fa) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 Optional |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * C<refname> - name to assign to the reference index files. Default = ref.index |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * C<outfile> - name to assign to the mapped SAM file. Default = mapped.sam |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 METHODS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * C<index_ref> - create index files of the reference genome. These are required |
137
|
|
|
|
|
|
|
for the mapping step. Only skip this step if index files already |
138
|
|
|
|
|
|
|
exist. -k and -s options for referencing are calculated based |
139
|
|
|
|
|
|
|
on the length of the reads being mapped as per table: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=for html <table> |
142
|
|
|
|
|
|
|
<tr><th>Read length</th><th>k</th><th>s</th></tr> |
143
|
|
|
|
|
|
|
<tr><td><70</td><td>13</td><td>4<td></tr> |
144
|
|
|
|
|
|
|
<tr><td>>70 and <100</td><td>13</td><td>6<td></tr> |
145
|
|
|
|
|
|
|
<tr><td>>100</td><td>20</td><td>6<td></tr> |
146
|
|
|
|
|
|
|
</table> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * C<do_mapping> - map C<fastqfile> to C<reference>. Options used for mapping are: C<-r -1 -x -y 0.96> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
For more information on the mapping and indexing options discussed here, see the L<SMALT manual|ftp://ftp.sanger.ac.uk/pub4/resources/software/smalt/smalt-manual-0.7.4.pdf> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Carla Cummins <path-help@sanger.ac.uk> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This is free software, licensed under: |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |