Example program for reading and manipulating the quantitation.xml file.
1
2
16
17import msparser
18import sys
19
20if len(sys.argv) < 2 :
21 print("""
22The location of quantitation.xml file has to be specified as a parameter.
23The location should either be the full path to the quantitation.xml file
24or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi
25""")
26 sys.exit(1)
27
28if len(sys.argv) < 3 :
29 print("""
30The location of schema file quantitation_XXX.xsd has to be specified as the
31second parameter. The location should only be a full or relative path to the
32quantitation_XXX.xsd file.
33""")
34 sys.exit(1)
35
36
37
38if len(sys.argv) > 3 :
39 cs = msparser.ms_connection_settings()
40 cs.setSessionID(sys.argv[3])
41 file = msparser.ms_quant_configfile(sys.argv[1], sys.argv[2], cs)
42else :
43 file = msparser.ms_quant_configfile(sys.argv[1], sys.argv[2])
44
45if not file.isValid() :
46 print("There are errors. Cannot continue. The last error description:")
47 print(file.getLastErrorString())
48 sys.exit(1)
49
50n = file.getNumberOfMethods()
51print("There are %d quantitation methods available:" % n)
52
53for i in range(n) :
54 print(file.getMethodByNumber(i).getName())
55
56
57errs = file.validateDocument()
58if errs :
59 print("Initial document validation errors: %s" % errs)
60
61
62schemaFile = msparser.ms_xml_schema()
63schemaFile.setFileName(sys.argv[2])
64schemaFile.read_file()
65
66if not schemaFile.isValid() :
67 print("Errors while reading schema-file. The last error description: %s" % schemaFile.getLastErrorString())
68 sys.exit(1)
69
70
71
72
73for i in range(n) :
74
75
76 pMethod = file.getMethodByNumber(i)
77
78 errs = pMethod.validateShallow(schemaFile)
79 if errs :
80 print("Shallow validation errors (method %s): %s" % (pMethod.getName(), errs))
81
82
83
84 errs = pMethod.validateDeep(schemaFile)
85 if errs :
86 print("Deep validation errors (method %s): %s" % (pMethod.getName(), errs))
87
88
89
90myMethodInvalid = msparser.ms_quant_method(file.getMethodByNumber(0))
91
92myMethodInvalid.setName("")
93
94
95errs = myMethodInvalid.validateShallow(schemaFile)
96if errs :
97 print("Shallow validation of a method: %s" % errs)
98
99errs = myMethodInvalid.validateDeep(schemaFile)
100if errs :
101 print("Deep validation of a method: %s" % errs)
102
103
104
105
106
107errs = schemaFile.validateComplexObject(myMethodInvalid, True)
108if errs :
109 print("Deep validation using schema-object: %s" % errs)
110
111
112
113
114errs = schemaFile.validateSimpleString(myMethodInvalid.getName(), myMethodInvalid.getNameSchemaType())
115if errs :
116 print("Attribute validation: %s" % errs)
117
118
119
120configFileInvalid = msparser.ms_quant_configfile()
121configFileInvalid.appendMethod(myMethodInvalid)
122
123errs = configFileInvalid.validateDocument()
124if errs :
125 print("Document validation errors: %s" % errs)
126
127
128
129if not configFileInvalid.isValid() :
130
131 print("Errors in config file object. The last error description: %s" % configFileInvalid.getLastErrorString())
132
133
134configFileInvalid.setFileName("quantitation_temp.xml")
135configFileInvalid.save_file()
136
137if not configFileInvalid.isValid() :
138 print("Failed to save: %s" % configFileInvalid.getLastErrorString())
139
140
141"""
142
143Running the program as
144
145python config_quantitation.pl /usr/local/mascot/config/quantitation.xml /usr/local/mascot/html/xmlns/schema/quantitation_2/quantitation_2.xsd
146
147will give the following output under Mascot Server 2.3 (depending on how
148quantitation methods have been configured):
149
150
151There are 26 quantitation methods available:
152None
153iTRAQ 4plex
154iTRAQ 8plex
155TMT 6plex
156TMT 2plex
15718O multiplex
158SILAC K+6 R+6 multiplex
159IPTL (Succinyl and IMID) multiplex
160ICPL duplex pre-digest [MD]
161ICPL duplex post-digest [MD]
162ICPL triplex pre-digest [MD]
16318O corrected [MD]
16415N Metabolic [MD]
16515N + 13C Metabolic [MD]
166SILAC K+6 R+10 [MD]
167SILAC K+6 R+10 Arg-Pro [MD]
168SILAC K+6 R+6 [MD]
169SILAC R+6 R+10 [MD]
170SILAC K+8 R+10 [MD]
171SILAC K+4 K+8 R+6 R+10 [MD]
172ICAT ABI Cleavable [MD]
173ICAT D8 [MD]
174Dimethylation [MD]
175NBS Shimadzu [MD]
176Label-free [MD]
177Average [MD]
178Deep validation of a method: Attribute 'name' -> String is shorter than minLength-limit
179Deep validation using schema-object: Attribute 'name' -> String is shorter than minLength-limit
180Attribute validation: String is shorter than minLength-limit
181
182
183"""
184