-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclfilterclass.pl
More file actions
executable file
·259 lines (214 loc) · 6.74 KB
/
clfilterclass.pl
File metadata and controls
executable file
·259 lines (214 loc) · 6.74 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
use strict;
use File::Spec;
my $buildno = '0.9.x';
# input/output
my @inputfiles;
my @otufiles;
my $outputfolder;
# options
my $mode = 'eliminate';
my $tagfile;
my $reversetagfile;
my $reversecomplement;
my $siglevel = 0.05;
my $tagjump = 'half';
my $tableformat = 'matrix';
# the other global variables
my $devnull = File::Spec->devnull();
my %table;
my %tag;
my $taglength;
my %reversetag;
my $reversetaglength;
my %blanklist;
my %ignorelist;
my $blanklist;
my $ignorelist;
my %samplenames;
my %sample2blank;
my %blanksamples;
my %otunames;
# file handles
my $filehandleinput1;
my $filehandleinput2;
my $filehandleinput3;
my $filehandleoutput1;
my $filehandleoutput2;
my $filehandleoutput3;
my $pipehandleinput1;
my $pipehandleinput2;
my $pipehandleoutput1;
my $pipehandleoutput2;
&main();
sub main {
# print startup messages
&printStartupMessage();
# get command line arguments
&getOptions();
# check variable consistency
&checkVariables();
}
sub printStartupMessage {
print(STDERR <<"_END");
clfilterclass $buildno
=======================================================================
Official web site of this script is
https://www.fifthdimension.jp/products/claident/ .
To know script details, see above URL.
Copyright (C) 2011-XXXX Akifumi S. Tanabe
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License.
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
_END
# display usage if command line options were not specified
unless (@ARGV) {
&helpMessage();
}
}
sub getOptions {
# get arguments
$outputfolder = $ARGV[-1];
my %inputfiles;
for (my $i = 0; $i < scalar(@ARGV) - 1; $i ++) {
if ($ARGV[$i] =~ /^-+tableformat=(.+)$/i) {
if ($1 =~ /^matrix$/i) {
$tableformat = 'matrix';
}
elsif ($1 =~ /^column$/i) {
$tableformat = 'column';
}
else {
&errorMessage(__LINE__, "\"$ARGV[$i]\" is unknown option.");
}
}
else {
my @temp = glob($ARGV[$i]);
if (scalar(@temp) > 0) {
foreach (@temp) {
if (!exists($inputfiles{$_})) {
$inputfiles{$_} = 1;
push(@inputfiles, $_);
}
else {
&errorMessage(__LINE__, "\"$_\" is doubly specified.");
}
}
}
else {
&errorMessage(__LINE__, "Input file does not exist.");
}
}
}
}
sub checkVariables {
if (!@inputfiles) {
&errorMessage(__LINE__, "No input file was specified.");
}
&errorMessage(__LINE__, "This command is under construction.");
}
# error message
sub errorMessage {
my $lineno = shift(@_);
my $message = shift(@_);
print(STDERR "ERROR!: line $lineno\n$message\n");
print(STDERR "If you want to read help message, run this script without options.\n");
exit(1);
}
sub helpMessage {
print(STDERR <<"_END");
Usage
=====
clfilterclass options inputfolder outputfolder
clfilterclass options inputfile outputfolder
Command line options
====================
--taxfile=FILENAME
Specify output of classigntax. (default: none)
--includetaxa=NAME(,NAME..)
Specify include taxa by scientific name. (default: none)
--excludetaxa=NAME(,NAME..)
Specify exclude taxa by scientific name. (default: none)
--otu=OTUNAME,...,OTUNAME
Specify output OTU names. The unspecified OTUs will be deleted.
--negativeotu=OTUNAME,...,OTUNAME
Specify delete OTU names. The specified OTUs will be deleted.
--sample=SAMPLENAME,...,SAMPLENAME
Specify output sample names. The unspecified samples will be deleted.
--negativesample=SAMPLENAME,...,SAMPLENAME
Specify delete sample names. The specified samples will be deleted.
--otulist=FILENAME
Specify output OTU list file name. The file must contain 1 OTU name
at a line.
--negativeotulist=FILENAME
Specify delete OTU list file name. The file must contain 1 OTU name
at a line.
--otuseq=FILENAME
Specify output OTU sequence file name. The file must contain 1 OTU
name at a line.
--negativeotuseq=FILENAME
Specify delete OTU sequence file name. The file must contain 1 OTU
name at a line.
--samplelist=FILENAME
Specify output sample list file name. The file must contain 1 sample
name at a line.
--negativesamplelist=FILENAME
Specify delete sample list file name. The file must contain 1 sample
name at a line.
--minnseqotu=INTEGER
Specify minimum number of sequences of OTU. If the number of
sequences of a OTU is smaller than this value at all samples, the
OTU will be omitted. (default: 0)
--minnseqsample=INTEGER
Specify minimum number of sequences of sample. If the number of
sequences of a sample is smaller than this value at all OTUs, the
sample will be omitted. (default: 0)
--minntotalseqotu=INTEGER
Specify minimum total number of sequences of OTU. If the total
number of sequences of a OTU is smaller than this value, the OTU
will be omitted. (default: 0)
--minntotalseqsample=INTEGER
Specify minimum total number of sequences of sample. If the total
number of sequences of a sample is smaller than this value, the sample
will be omitted. (default: 0)
--minpseqotu=DECIMAL
Specify minimum percentage of sequences of OTU. If the number of
sequences of a OTU / the total number of sequences of a OTU is
smaller than this value at all samples, the OTU will be omitted.
(default: 0)
--minpseqsample=DECIMAL
Specify minimum percentage of sequences of sample. If the number of
sequences of a sample / the total number of sequences of a sample is
smaller than this value at all OTUs, the sample will be omitted.
(default: 0)
--replicatelist=FILENAME
Specify the list file of PCR replicates. (default: none)
--minnreplicate=INTEGER
Specify the minimum number of \"presense\" replicates required for clean
and nonchimeric OTUs. (default: 2)
--minpreplicate=DECIMAL
Specify the minimum percentage of \"presense\" replicates per sample
required for clean and nonchimeric OTUs. (default: 1)
--minnpositive=INTEGER
The OTU that consists of this number of reads will be treated as true
positive in noise/chimera detection. (default: 1)
--minppositive=DECIMAL
The OTU that consists of this proportion of reads will be treated as true
positive in noise/chimera detection. (default: 0)
--runname=RUNNAME
Specify run name for replacing run name.
(default: given by sequence name)
--tableformat=COLUMN|MATRIX
Specify output table format. (default: MATRIX)
Acceptable input file formats
=============================
FASTA (uncompressed, gzip-compressed, or bzip2-compressed)
_END
exit;
}