Matrix Science header

config_masses.pl

Read in the masses file.

#!/usr/local/bin/perl
##############################################################################
# file: config_masses.pl                                                     #
# This file illustrates how to use ms_masses-class from the Mascot perl      #
# module 'msparser'                                                          #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1998-2010 Matrix Science Limited  All Rights Reserved.           #
#                                                                            #
##############################################################################
#     $Source: parser/examples/test_perl/config_masses.pl $ #
#     $Author: villek@matrixscience.com $ #
#       $Date: 2018-07-30 16:23:53 +0100 $ #
#   $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_2_8_1-0-gea32989045 $ #
# $NoKeywords::                                                            $ #
##############################################################################
use strict;
##############################################################################

use msparser;

if (!defined($ARGV[0])) {
    print <<EOF;
The location of masses file has to be specified as a parameter.
The location should either be the full path to the masses 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_masses($ARGV[0], $cs);
} else {
    $file = new msparser::ms_masses($ARGV[0]);
}

# Unlike the other configuration files, it is possible to use ms_masses
# without specifying the filename - in which case it defaults to 
# '../config/masses'.

if (!$file->isValid) {
    print "Error when reading file: ", $file->getFileName(), "\n";
    checkErrorHandler($file);
    exit(1);
}

print "Name of the file: ", $file->getFileName(), "\n";
print "-------------------------------------------------------------\n";
print "---   Content of masses file                              ---\n";
print "-------------------------------------------------------------\n";
print "# Amino acid masses (monoisotopic and average)\n";

for my $i (0 .. 25) {
    my $res = chr(ord('A') + $i);
    printf(
        "%1s:%5.5f,%5.5f\n", 
        $res, 
        $file->getResidueMass($msparser::MASS_TYPE_MONO, $res),
        $file->getResidueMass($msparser::MASS_TYPE_AVE, $res)
   );
}  

print "\n";
print "# Atomic masses used for terminus values\n";

printf(
    "HYDROGEN:%5.5f,%5.5f\n", 
    $file->getHydrogenMass($msparser::MASS_TYPE_MONO),
    $file->getHydrogenMass($msparser::MASS_TYPE_AVE)
);

printf(
    "CARBON:%5.5f,%5.5f\n", 
    $file->getCarbonMass($msparser::MASS_TYPE_MONO),
    $file->getCarbonMass($msparser::MASS_TYPE_AVE)
);

printf(
    "NITROGEN:%5.5f,%5.5f\n", 
    $file->getNitrogenMass($msparser::MASS_TYPE_MONO),
    $file->getNitrogenMass($msparser::MASS_TYPE_AVE)
);

printf(
    "OXYGEN:%5.5f,%5.5f\n", 
    $file->getOxygenMass($msparser::MASS_TYPE_MONO),
    $file->getOxygenMass($msparser::MASS_TYPE_AVE)
);

printf(
    "ELECTRON:%5.7f\n", 
    $file->getElectronMass()
);


sub checkErrorHandler {
    my ($obj) = @_;

    print "Last error description                   \n";
    print "=========================================\n";
    print "Error: ", $obj->getLastErrorString(), "\n";
    print "=========================================\n";
    print "Testing the error handling...            \n";
    print "=========================================\n";

    my $err = $obj->getErrorHandler();
    my $i;

    for my $i (1 .. $err->getNumberOfErrors) {
        print "Error number: ";
        print $err->getErrorNumber($i);
        print " (";
        print $err->getErrorRepeats($i) + 1;
        print " times) : ";
        print $err->getErrorString($i), "\n";
    }

    print "\n";

    $obj->clearAllErrors();
}

=pod

Running the program as 

perl -I../bin config_masses.pl ../config/masses

will give the following output under Mascot Server 2.3:


Name of the file: ../config/masses
-------------------------------------------------------------
---   Content of masses file                              ---
-------------------------------------------------------------
# Amino acid masses (monoisotopic and average)
A:71.03711,71.07790
B:114.53494,114.59500
C:103.00919,103.14290
D:115.02694,115.08740
E:129.04259,129.11400
F:147.06841,147.17390
G:57.02146,57.05130
H:137.05891,137.13930
I:113.08406,113.15760
J:0.00000,0.00000
K:128.09496,128.17230
L:113.08406,113.15760
M:131.04048,131.19610
N:114.04293,114.10260
O:0.00000,0.00000
P:97.05276,97.11520
Q:128.05858,128.12920
R:156.10111,156.18570
S:87.03203,87.07730
T:101.04768,101.10390
U:150.95363,150.03790
V:99.06841,99.13110
W:186.07931,186.20990
X:111.00000,111.00000
Y:163.06333,163.17330
Z:128.55059,128.62160

# Atomic masses used for terminus values
HYDROGEN:1.00783,1.00794
CARBON:12.00000,12.01070
NITROGEN:14.00307,14.00670
OXYGEN:15.99491,15.99940
ELECTRON:0.0005490

=cut


Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:29