Matrix Science header

config_modfile.py

Read in the modifications file - modfile.

#!/usr/bin/python
##############################################################################
# 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_python/config_modfile.py,v $ #
#     $Author: neilr $                                                      #
#       $Date: 2016/03/22 10:13:16 $                                         #
#   $Revision: 1.3 $                                                         #
# $NoKeywords::                                                            $ #
##############################################################################

import msparser
import sys

if len(sys.argv) < 2 :
    print("""
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
""")
    sys.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.
massesFile = msparser.ms_masses()

# A sessionID can optionally be passed as the second parameter.
# This will only be required if the 'file' is a URL.
if len(sys.argv) > 2 :
    cs = msparser.ms_connection_settings()
    cs.setSessionID(sys.argv[2])
    file = msparser.ms_modfile(sys.argv[1], massesFile, 0, cs)
else :
    file = msparser.ms_modfile(sys.argv[1], massesFile, 0)

if not file.isValid() :
    print("There are errors. Cannot continue. The last error description:")
    print(file.getLastErrorString())
    sys.exit(1)

n = file.getNumberOfModifications()
print("There are %d modifications configured:" % n)

for i in range(n) :
    print(file.getModificationByNumber(i).getTitle())


# Now change Acetyl (K).
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(sys.argv[1] + ".new")
file.save_file()

if not file.isValid() :
    print("Failed to save: %s" % file.getLastErrorString())
else :
    print("%s.new now has %d modifications configured" % (sys.argv[1], file.getNumberOfModifications()))



"""

Running the program as 

python config_modfile.pl /usr/local/mascot/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)
/usr/local/mascot/config/mod_file.new now has 885 modifications configured


"""

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