Matrix Science header

config_fragrules.py

Read in the fragmentation_rules file.

#!/usr/bin/python
##############################################################################
# file: config_fragrules.py                                                  #
# 'msparser' toolkit example code                                            #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1998-2010 Matrix Science Limited  All Rights Reserved.           #
#                                                                            #
##############################################################################
#     $Source: /vol/cvsroot/parser/examples/test_python/config_fragrules.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 'fragmentation_rules' file has to be specified as a parameter.
The location should either be the full path to the 'fragmentation_rules' file
or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi
""")

    sys.exit(1)

# 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_fragrulesfile(sys.argv[1], cs)
else :
    file = msparser.ms_fragrulesfile(sys.argv[1])

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


n = file.getNumberOfInstruments()
print("%d instruments are configured:" % n)

for i in range(n) :
    print(file.getInstrumentName(i))


# Now change ESI-QUAD-TOF.
instrument = file.getInstrumentByName("ESI-QUAD-TOF")
instrument.setSeriesUsed(23, 1)  # Add v series
file.updateInstrumentByName("ESY-QUAD-TOF", instrument)

# And delete MALDI-QIT-TOF.
file.deleteInstrumentByName("MALDI-QIT-TOF")

# 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 instruments configured" % (sys.argv[1], file.getNumberOfInstruments()))

firstSeries = msparser.ms_fragmentationrules.getFirstSeries()

firstSeries = msparser.ms_fragmentationrules.getFirstSeries()
lastSeries  = msparser.ms_fragmentationrules.getLastSeries()

print("First series: %s" % firstSeries)
print("Last series : %s" % lastSeries)

for i in range(firstSeries, 1 + lastSeries) :
    print("--------- %d ---------" % i)
    print(msparser.ms_fragmentationrules.getSeriesName(i))
    print(msparser.ms_fragmentationrules.getSeriesDescription(i))


""" Running the program as 

python config_fragfules.py /usr/local/mascot/config/fragmentation_rules

will give the following output under Mascot Server 2.3:


14 instruments are configured:
Default
ESI-QUAD-TOF
MALDI-TOF-PSD
ESI-TRAP
ESI-QUAD
ESI-FTICR
MALDI-TOF-TOF
ESI-4SECTOR
FTMS-ECD
ETD-TRAP
MALDI-QUAD-TOF
MALDI-QIT-TOF
MALDI-ISD
CID+ETD
/usr/local/mascot/config/fragmentation_rules.new now has 13 instruments configured
First series: 4
Last series : 25
--------- 4 ---------
immonium
immonium
--------- 5 ---------
a
a series
--------- 6 ---------
a*
a - NH3 if a significant and fragment includes RKNQ
--------- 7 ---------
a0
a - H2O if a significant and fragment includes STED
--------- 8 ---------
b
b series
--------- 9 ---------
b*
b - NH3 if b significant and fragment includes RKNQ
--------- 10 ---------
b0
b - H2O if b significant and fragment includes STED
--------- 11 ---------
c
c series
--------- 12 ---------
x
x series
--------- 13 ---------
y
y series
--------- 14 ---------
y*
y - NH3 if y significant and fragment includes RKNQ
--------- 15 ---------
y0
y - H2O if y significant and fragment includes STED
--------- 16 ---------
z
z series
--------- 17 ---------
yb
internal yb < 700 Da
--------- 18 ---------
ya
internal ya < 700 Da
--------- 19 ---------
y must be significant
y or y++ must be significant
--------- 20 ---------
y must be highest score
y or y++ must be highest scoring series
--------- 21 ---------
z+1
z+1 series
--------- 22 ---------
d
d and d' series
--------- 23 ---------
v
v series
--------- 24 ---------
w
w and w' series
--------- 25 ---------
z+2
z+2 series

"""

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