-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexcludeFastqSeqs.pl
executable file
·142 lines (106 loc) · 3.05 KB
/
excludeFastqSeqs.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/perl
#
# INGLÊS/ENGLISH
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# http://www.gnu.org/copyleft/gpl.html
#
#
# PORTUGUÊS/PORTUGUESE
# Este programa é distribuído na expectativa de ser útil aos seus
# usuários, porém NÃO TEM NENHUMA GARANTIA, EXPLÍCITAS OU IMPLÍCITAS,
# COMERCIAIS OU DE ATENDIMENTO A UMA DETERMINADA FINALIDADE. Consulte
# a Licença Pública Geral GNU para maiores detalhes.
# http://www.gnu.org/copyleft/gpl.html
#
# Copyright (C) 2010 Fundação Hemocentro de Ribeirão Preto
#
# Laboratório de Genética Molecular e Bioinformática
# Núcleo de Bioinformática
# BiT - Bioinformatics Team
# Fundação Hemocentro de Ribeirão Preto
# Rua Tenente Catão Roxo, 2501
# Ribeirão Preto - São Paulo
# Brasil
# CEP 14051-140
# Fone: 55 16 39639300 Ramal 9603
#
# Daniel Guariz Pinheiro
# http://lgmb.fmrp.usp.br
#
# $Id$
=head1 NAME
excludeFastqSeqs.pl - Exclude selected sequences from Fastq file.
=head1 SYNOPSIS
=head1 ABSTRACT
=head1 DESCRIPTION
Script to exclude the sequences with selected IDs from Fastq file.
=head1 AUTHOR
Daniel Guariz Pinheiro E<lt>[email protected]<gt>
Copyright (c) 2010 Regional Blood Center of Ribeirão Preto
=head1 LICENSE
GNU General Public License
http://www.gnu.org/copyleft/gpl.html
=cut
use strict;
use warnings;
use Getopt::Long;
my ($infile, $excfile);
Usage("Too few arguments") if $#ARGV < 0;
GetOptions( "h|?|help" => sub { &Usage(); },
"i|infile=s"=> \$infile,
"e|excfile=s"=> \$excfile
) or &Usage();
die "Missing input file" unless ($infile);
die "Wrong input file" unless (-e $infile);
die "Missing exclude file" unless ($excfile);
die "Wrong exclude file" unless (-e $excfile);
my %exclude;
open(EXC, "<", $excfile) or die $!;
while(<EXC>) {
chomp;
$exclude{$_}=undef;
}
close(EXC);
$| = 1;
open(IN, "<", $infile) or die $!;
my $set;
while(<IN>) {
chomp;
if ( ($. % 4) == 1) {
my ($id) = $_=~/^@(.+)/;
die "Wrong pattern ($_) not found an id" unless (defined $id);
if (exists $exclude{$id}) {
$set=undef;
}
else {
$set=1;
}
}
if ($set) {
print $_,"\n";
}
}
close(IN);
# Subroutines
sub Usage {
my ($msg) = @_;
my $USAGE = <<"END_USAGE";
Daniel Guariz Pinheiro (dgpinheiro\@gmail.com)
(c)2010 Regional Blood Center of Ribeirão Preto
Usage
$0 [-h/--help] [-i InputFastq.fastq
-e ExcludeIDs.fastq ]
Argument(s)
-h --help Help
-i --infile Input file (Original fastq file)
-e --excfile File with list of IDs to exclude
END_USAGE
print STDERR "\nERR: $msg\n\n" if $msg;
print STDERR qq[$0 ] . q[$Revision$] . qq[\n];
print STDERR $USAGE;
exit(1);
}