Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
config_masses.py

Read in the masses file.

1#!/usr/bin/python
2
17
18import msparser
19import sys
20if len(sys.argv) < 3:
21 print("Usage: %s UNIMOD SCHEMA [SESSION_ID]" % sys.argv[0])
22 print("UNIMOD is the file path to the unimod.xml file, e.g., ../config/unimod.xml or a fully formed URL such as http://www.matrixscience.com/cgi .")
23 print("SCHEMA is the unimod schema file path, e.g., ../html/xmlns/schema/unimod_2/unimod_2.xsd")
24 print("SESSION_ID is the session id. Only needed if UNIMOD is a URL.")
25 sys.exit(1)
26
27def checkErrorHandler(obj) :
28 print("Last error description ")
29 print("=========================================")
30 print("Error: %s" % obj.getLastErrorString())
31 print("=========================================")
32 print("Testing the error handling... ")
33 print("=========================================")
34
35 err = obj.getErrorHandler()
36
37 for i in range(1, 1 + err.getNumberOfErrors()) :
38 print("Error number: %d (%d times): %s" % (
39 err.getErrorNumber(i),
40 err.getErrorRepeats(i) + 1,
41 err.getErrorString(i)
42 ))
43
44 print(" ")
45
46 obj.clearAllErrors()
47
48# A sessionID can optionally be passed as the second parameter.
49# This will only be required if the 'file' is a URL.
50if len(sys.argv) > 3:
51 cs = msparser.ms_connection_settings()
52 cs.setSessionID(sys.argv[3])
53 umodFile = msparser.ms_umod_configfile(sys.argv[1], sys.argv[2], cs)
54else :
55 umodFile = msparser.ms_umod_configfile(sys.argv[1], sys.argv[2])
56file = msparser.ms_masses(umodFile)
57
58
59if not file.isValid() :
60 print("Error when reading file: %s" % file.getFileName())
61 checkErrorHandler(file)
62 sys.exit(1)
63
64
65print("Name of the file: %s" % file.getFileName())
66print("-------------------------------------------------------------")
67print("--- Content of masses file ---")
68print("-------------------------------------------------------------")
69print("# Amino acid masses (monoisotopic and average)")
70
71for i in range(0, 26) :
72 res = chr(ord('A') + i)
73 print("%1s:%5.5f,%5.5f" % (
74 res,
75 file.getResidueMass(msparser.MASS_TYPE_MONO, res),
76 file.getResidueMass(msparser.MASS_TYPE_AVE, res)
77 ))
78
79print (" ")
80print("# Atomic masses used for terminus values")
81
82print("HYDROGEN:%5.5f,%5.5f" % (
83 file.getHydrogenMass(msparser.MASS_TYPE_MONO),
84 file.getHydrogenMass(msparser.MASS_TYPE_AVE)
85 ))
86
87print("CARBON:%5.5f,%5.5f" % (
88 file.getCarbonMass(msparser.MASS_TYPE_MONO),
89 file.getCarbonMass(msparser.MASS_TYPE_AVE)
90 ))
91
92print("NITROGEN:%5.5f,%5.5f" % (
93 file.getNitrogenMass(msparser.MASS_TYPE_MONO),
94 file.getNitrogenMass(msparser.MASS_TYPE_AVE)
95 ))
96
97print("OXYGEN:%5.5f,%5.5f" % (
98 file.getOxygenMass(msparser.MASS_TYPE_MONO),
99 file.getOxygenMass(msparser.MASS_TYPE_AVE)
100 ))
101
102print("ELECTRON:%5.7f" % (
103 file.getElectronMass()
104 ))
105
106
107
108
109"""
110
111Running the program as
112
113python config_masses.pl /usr/local/mascot/config/masses
114
115will give the following output under Mascot Server 2.3:
116
117
118Name of the file: /usr/local/mascot/config/masses
119-------------------------------------------------------------
120--- Content of masses file ---
121-------------------------------------------------------------
122# Amino acid masses (monoisotopic and average)
123A:71.03711,71.07790
124B:114.53494,114.59500
125C:103.00919,103.14290
126D:115.02694,115.08740
127E:129.04259,129.11400
128F:147.06841,147.17390
129G:57.02146,57.05130
130H:137.05891,137.13930
131I:113.08406,113.15760
132J:0.00000,0.00000
133K:128.09496,128.17230
134L:113.08406,113.15760
135M:131.04048,131.19610
136N:114.04293,114.10260
137O:0.00000,0.00000
138P:97.05276,97.11520
139Q:128.05858,128.12920
140R:156.10111,156.18570
141S:87.03203,87.07730
142T:101.04768,101.10390
143U:150.95363,150.03790
144V:99.06841,99.13110
145W:186.07931,186.20990
146X:111.00000,111.00000
147Y:163.06333,163.17330
148Z:128.55059,128.62160
149
150# Atomic masses used for terminus values
151HYDROGEN:1.00783,1.00794
152CARBON:12.00000,12.01070
153NITROGEN:14.00307,14.00670
154OXYGEN:15.99491,15.99940
155ELECTRON:0.0005490
156
157
158"""
159