Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
config_taxonomy.pl

Read in the taxonomy file.

#!/usr/local/bin/perl
##############################################################################
# file: config_taxonomy.pl #
# 'msparser' toolkit example code #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-2010 Matrix Science Limited All Rights Reserved. #
# #
##############################################################################
# $Source: parser/examples/test_perl/config_taxonomy.pl $ #
# $Author: villek@matrixscience.com $ #
# $Date: 2018-07-30 16:23:53 +0100 $ #
# $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
# $NoKeywords:: $ #
##############################################################################
use strict;
##############################################################################
use msparser;
if (!defined($ARGV[0])) {
print <<EOF;
The location of taxonomy file has to be specified as a parameter.
The location should either be the full path to the taxonomy file
or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi
EOF
exit 1;
}
# Note: $cs must not be lexically scoped; you need to keep it in scope
# for as long as you use $file. See "Using the toolkit from Perl, Java and
# Python" in Mascot Parser manual.
my ($file, $cs);
# A sessionID can optionally be passed as the second parameter.
# This will only be required if the 'file' is a URL.
if (defined($ARGV[1])) {
$cs = new msparser::ms_connection_settings;
$cs->setSessionID($ARGV[1]);
$file = new msparser::ms_taxonomyfile($ARGV[0], $cs);
} else {
$file = new msparser::ms_taxonomyfile($ARGV[0]);
}
if (!$file->isValid) {
print "There are errors. Cannot continue. The last error description:\n";
print $file->getLastErrorString(), "\n";
exit 1;
}
my $n = $file->getNumberOfEntries;
print "There are ", $n, " taxonomy choice entries configured:\n";
for my $i (0 .. $n-1) {
my $entry = $file->getEntryByNumber($i);
print $entry->getTitle() . "\n";
print "Include: ";
print join(', ',
map { $entry->getIncludeTaxonomy($_) }
0 .. $entry->getNumberOfIncludeTaxonomies - 1
);
print "\n";
print "Exclude: ";
print join(', ',
map { $entry->getExcludeTaxonomy($_) }
0 .. $entry->getNumberOfExcludeTaxonomies - 1
);
print "\n";
}
=pod
Running the program as
perl -I../bin config_taxonomy.pl ../config/taxonomy
will give the following output under Mascot Server 2.3:
There are 65 taxonomy choice entries configured:
All entries
Include: 1
Exclude: 0
. . Archaea (Archaeobacteria)
Include: 2157
Exclude:
. . Eukaryota (eucaryotes)
Include: 2759
Exclude:
. . . . Alveolata (alveolates)
Include: 33630
Exclude:
. . . . . . Plasmodium falciparum (malaria parasite)
Include: 5833
Exclude:
. . . . . . Other Alveolata
Include: 33630
Exclude: 5833
[ ... ]
=cut