Matrix Science header

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: /vol/cvsroot/parser/examples/test_perl/config_taxonomy.pl,v $ #
#     $Author: villek $                                                      #
#       $Date: 2010/08/31 08:48:07 $                                         #
#   $Revision: 1.4 $                                                         #
# $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

Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:50