forked from fbreitwieser/krakenuniq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_gi_numbers.pl
executable file
·54 lines (46 loc) · 1.47 KB
/
verify_gi_numbers.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
#!/usr/bin/perl
# Copyright 2013-2015, Derrick Wood <[email protected]>
#
# This file is part of the Kraken taxonomic sequence classification system.
#
# Kraken 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 3 of the License, or
# (at your option) any later version.
#
# Kraken 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 Kraken. If not, see <http://www.gnu.org/licenses/>.
# Checks each sequence header to ensure it has a GI number to
# enable taxonomic ID lookup later. Also has some (very basic)
# FASTA-format checking.
use strict;
use warnings;
use File::Basename;
my $PROG = basename $0;
die "$PROG: must specify one filename!\n" if @ARGV != 1;
my $filename = shift;
open FASTA, "<", $filename
or die "$PROG: can't open $filename: $!\n";
my $seq_ct = 0;
my $errors = 0;
while (<FASTA>) {
next unless /^>/;
$seq_ct++;
if (! /^>(\S+)/) {
$errors++;
warn "file $filename, line $. lacks sequence ID\n";
}
if ($1 !~ /(^|\|)(gi|kraken:taxid)\|(\d+)/) {
$errors++;
warn "file $filename, line $.: sequence ID lacks GI number\n";
}
}
close FASTA;
if ($errors) {
exit 1;
}