Skip to content

Commit

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

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

if (!@ARGV) {
print STDERR $USAGE;
exit 1;
}
my ($TAXID) = @ARGV;

my @TAXON = `spang spang taxid $TAXID | cut -f2`;
chomp(@TAXON);

my @OUT = ();
for (my $i=0; $i<@TAXON; $i++) {
my $taxon = $TAXON[$i];
$taxon =~ s/^"//;
$taxon =~ s/"$//;

if ($i == 0) {
if ($taxon ne "root") {
die $taxon;
}
next;
}

if ($i == 1) {
if ($taxon ne "cellular organisms") {
die $taxon;
}
next;
}

if ($taxon =~ /;/) {
die;
}
push @OUT, $taxon;
}

print $TAXID, "\t", join(";", @OUT)."\n";

0 comments on commit f458a4c

Please sign in to comment.