| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::Tradis::RemoveTags; |
|
2
|
|
|
|
|
|
|
$Bio::Tradis::RemoveTags::VERSION = '1.3.2'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Remove tags from seqs a fastq file |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
100070
|
use Moose; |
|
|
3
|
|
|
|
|
386745
|
|
|
|
3
|
|
|
|
|
19
|
|
|
7
|
3
|
|
|
3
|
|
20225
|
use Bio::Tradis::Parser::Fastq; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
1192
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'fastqfile' => ( is => 'rw', isa => 'Str', required => 1 ); |
|
10
|
|
|
|
|
|
|
has 'tag' => ( is => 'rw', isa => 'Str', required => 1 ); |
|
11
|
|
|
|
|
|
|
has 'mismatch' => ( is => 'rw', isa => 'Int', required => 0 ); |
|
12
|
|
|
|
|
|
|
has 'outfile' => ( |
|
13
|
|
|
|
|
|
|
is => 'rw', |
|
14
|
|
|
|
|
|
|
isa => 'Str', |
|
15
|
|
|
|
|
|
|
required => 0, |
|
16
|
|
|
|
|
|
|
default => sub { |
|
17
|
|
|
|
|
|
|
my ($self) = @_; |
|
18
|
|
|
|
|
|
|
my $o = $self->bamfile; |
|
19
|
|
|
|
|
|
|
$o =~ s/\.fastq/\.rmtag\.fastq/; |
|
20
|
|
|
|
|
|
|
return $o; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub remove_tags { |
|
25
|
5
|
|
|
5
|
0
|
14
|
my ($self) = @_; |
|
26
|
5
|
|
|
|
|
108
|
my $tag = uc( $self->tag ); |
|
27
|
5
|
|
|
|
|
99
|
my $outfile = $self->outfile; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#set up fastq parser |
|
30
|
5
|
|
|
|
|
108
|
my $filename = $self->fastqfile; |
|
31
|
5
|
|
|
|
|
111
|
my $pars = Bio::Tradis::Parser::Fastq->new( file => $filename ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# create file handle for output |
|
34
|
5
|
|
|
|
|
270
|
open( OUTFILE, ">$outfile" ); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# loop through fastq |
|
37
|
5
|
|
|
|
|
31
|
while ( $pars->next_read ) { |
|
38
|
58
|
|
|
|
|
119
|
my @read = $pars->read_info; |
|
39
|
58
|
|
|
|
|
89
|
my $id = $read[0]; |
|
40
|
58
|
|
|
|
|
67
|
my $seq_string = $read[1]; |
|
41
|
58
|
|
|
|
|
67
|
my $qual_string = $read[2]; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# remove the tag |
|
44
|
58
|
|
|
|
|
65
|
my $rm = 0; |
|
45
|
58
|
100
|
|
|
|
940
|
if ( $self->mismatch == 0 ) { |
|
46
|
48
|
100
|
|
|
|
207
|
if ( $seq_string =~ m/^$tag/ ) { $rm = 1; } |
|
|
46
|
|
|
|
|
69
|
|
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
else { |
|
49
|
10
|
|
|
|
|
21
|
my $mm = $self->_tag_mismatch($seq_string); |
|
50
|
10
|
50
|
|
|
|
154
|
if ( $mm <= $self->mismatch ) { $rm = 1; } |
|
|
10
|
|
|
|
|
12
|
|
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
58
|
100
|
|
|
|
119
|
if ($rm) { |
|
54
|
56
|
|
|
|
|
106
|
my $l = length($tag); |
|
55
|
56
|
|
|
|
|
97
|
$seq_string = substr( $seq_string, $l ); |
|
56
|
56
|
|
|
|
|
77
|
$qual_string = substr( $qual_string, $l ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
58
|
|
|
|
|
139
|
print OUTFILE "\@$id\n"; |
|
60
|
58
|
|
|
|
|
80
|
print OUTFILE $seq_string . "\n+\n"; |
|
61
|
58
|
|
|
|
|
150
|
print OUTFILE $qual_string . "\n"; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
5
|
|
|
|
|
132
|
close OUTFILE; |
|
64
|
5
|
|
|
|
|
122
|
return 1; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _tag_mismatch { |
|
68
|
10
|
|
|
10
|
|
15
|
my ( $self, $seq_string ) = @_; |
|
69
|
10
|
|
|
|
|
188
|
my $tag_len = length( $self->tag ); |
|
70
|
|
|
|
|
|
|
|
|
71
|
10
|
|
|
|
|
145
|
my @tag = split( "", $self->tag ); |
|
72
|
10
|
|
|
|
|
27
|
my @seq = split( "", substr( $seq_string, 0, $tag_len ) ); |
|
73
|
10
|
|
|
|
|
14
|
my $mismatches = 0; |
|
74
|
10
|
|
|
|
|
19
|
foreach my $i ( 0 .. ( $tag_len - 1 ) ) { |
|
75
|
90
|
100
|
|
|
|
153
|
if ( $tag[$i] ne $seq[$i] ) { |
|
76
|
2
|
|
|
|
|
4
|
$mismatches++; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
10
|
|
|
|
|
27
|
return $mismatches; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
83
|
3
|
|
|
3
|
|
19
|
no Moose; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
18
|
|
|
84
|
|
|
|
|
|
|
1; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding UTF-8 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Bio::Tradis::RemoveTags - Remove tags from seqs a fastq file |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 1.3.2 |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Reads in a fastq file with tradis tags already attached to the start of the sequence |
|
103
|
|
|
|
|
|
|
Removes tags from the sequence and quality strings |
|
104
|
|
|
|
|
|
|
Outputs a file *.rmtag.fastq unless an out file is specified |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
use Bio::Tradis::RemoveTags; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $pipeline = Bio::Tradis::RemoveTags->new(fastqfile => 'abc', tag => 'abc'); |
|
109
|
|
|
|
|
|
|
$pipeline->remove_tags(); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 PARAMETERS |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 Required |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * C<fastqfile> - path to/name of file to filter |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * C<tag> - TraDIS tag to remove |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 Optional |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=over |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * C<mismatch> - number of mismatches to allow when removing the tag. Default = 0 |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * C<outfile> - defaults to C<file.rmtag.fastq> for and input file named C<file.fastq> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 METHODS |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
C<remove_tags> - output all reads with the tags removed to C<outfile> |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Carla Cummins <path-help@sanger.ac.uk> |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is free software, licensed under: |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |