From 6a7a9cb48f41a72843d110f7fd58fa9ce5da5dc0 Mon Sep 17 00:00:00 2001 From: Hirokazu Chiba Date: Thu, 17 Oct 2024 19:14:32 +0900 Subject: [PATCH] Add bin/extract_taxid.pl --- bin/extract_taxid.pl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 bin/extract_taxid.pl diff --git a/bin/extract_taxid.pl b/bin/extract_taxid.pl new file mode 100755 index 0000000..781ff6d --- /dev/null +++ b/bin/extract_taxid.pl @@ -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"; +}