Matrix Science header

config_modfile.pl

Read in the modifications file - modfile.

#!/usr/local/bin/perl
##############################################################################
# file: config_modfile.pl                                                    #
# 'msparser' toolkit example code                                            #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1998-2010 Matrix Science Limited  All Rights Reserved.           #
#                                                                            #
##############################################################################
#     $Source: /vol/cvsroot/parser/examples/test_perl/config_modfile.pl,v $ #
#     $Author: villek $                                                      #
#       $Date: 2010/08/31 08:48:07 $                                         #
#   $Revision: 1.5 $                                                         #
# $NoKeywords::                                                            $ #
##############################################################################
use strict;
##############################################################################

use msparser;

if (!defined($ARGV[0])) {
    print <<EOF;
The location of mod_file has to be specified as a parameter.
The location should either be the full path to the mod_file
or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi
EOF
    exit 1;
}

# We need an ms_masses object. In practice, it has to be read from a file but
# for simplicity, we will use default masses.
my $massesFile = new msparser::ms_masses;

# Note: $cs and $massesFile must not be lexically scoped; you need to keep them
# 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_modfile($ARGV[0], $massesFile, 0, $cs);
} else {
    $file = new msparser::ms_modfile($ARGV[0], $massesFile, 0);
}

if (!$file->isValid) {
    print "There are errors. Cannot continue. The last error description:\n";
    print $file->getLastErrorString(), "\n";
    exit 1;
}

my $n = $file->getNumberOfModifications();
print "There are ", $n, " modifications configured:\n";

for my $i (0 .. $n-1) {
    print $file->getModificationByNumber($i)->getTitle(), "\n";
}

# Now change Acetyl (K).
my $mod = $file->getModificationByName("Acetyl (K)");
$mod->setHidden(1);
$file->updateModificationByName("Acetyl (K)", $mod);

# And delete Methyl (R).
$file->deleteModificationByName("Methyl (R)");

# Finally, save the file under a new name.
$file->setFileName($ARGV[0] . ".new");
$file->save_file;

if (!$file->isValid) {
    print "Failed to save: ", $file->getLastErrorString, "\n";
} else {
    print $ARGV[0], ".new now has ", $file->getNumberOfModifications(), " modifications configured\n";
}


=pod

Running the program as 

perl -I../bin config_modfile.pl ../config/mod_file

will give the following output under Mascot Server 2.3:

There are 886 modifications configured:
15dB-biotin (C)
2-succinyl (C)
2HPG (R)
3-deoxyglucosone (R)
3sulfo (N-term)
4-ONE (C)
4-ONE (H)
4-ONE (K)
4-ONE+Delta:H(-2)O(-1) (C)
4-ONE+Delta:H(-2)O(-1) (H)
4-ONE+Delta:H(-2)O(-1) (K)
4AcAllylGal (C)
a-type-ion (C-term)
AccQTag (K)
AccQTag (N-term)
Acetyl (C)
    [ ... ]
Xlink:B10621 (C)
Xlink:DMP (K)
Xlink:DMP (Protein N-term)
Xlink:DMP-s (K)
Xlink:DMP-s (Protein N-term)
Xlink:novobiocin (N-term)
Xlink:SSD (K)
ZGB (K)
ZGB (N-term)
../config/mod_file.new now has 885 modifications configured


=cut

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