Skip to content

Commit

Permalink
Add bin/extract_taxid.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
hchiba1 committed Oct 17, 2024
1 parent 755d0b2 commit 6a7a9cb
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions bin/extract_taxid.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/perl -w
use strict;
use File::Basename;
use Getopt::Std;
my $PROGRAM = basename $0;
my $USAGE=
"Usage: $PROGRAM
";

my %OPT;
getopts('', \%OPT);

my %HASH;
while (<>) {
chomp;
if (/^#/) {
next;
}

my @f = split(/\t/, $_, -1);
if (@f != 5) {
die;
}

if ($f[0] !~ /^\d+$/) {
die;
}
my $taxid1 = $f[0];
$HASH{$taxid1} = 1;

if ($f[2] ne "Ortholog") {
die;
}
my $taxid2 = $f[3];
$HASH{$taxid2} = 1;
}

for my $taxid (sort {$a <=> $b} keys %HASH) {
print "$taxid\n";
}

0 comments on commit 6a7a9cb

Please sign in to comment.