Read in the masses file.
import msparser
import sys
if len(sys.argv) < 2 :
print("""
The location of masses file has to be specified as a parameter.
The location should either be the full path to the masses file
or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi
""")
sys.exit(1)
def checkErrorHandler(obj) :
print("Last error description ")
print("=========================================")
print("Error: %s" % obj.getLastErrorString())
print("=========================================")
print("Testing the error handling... ")
print("=========================================")
err = obj.getErrorHandler()
for i in range(1, 1 + err.getNumberOfErrors()) :
print("Error number: %d (%d times): %s" % (
err.getErrorNumber(i),
err.getErrorRepeats(i) + 1,
err.getErrorString(i)
))
print(" ")
obj.clearAllErrors()
if len(sys.argv) > 2 :
cs = msparser.ms_connection_settings()
cs.setSessionID(sys.argv[2])
file = msparser.ms_masses(sys.argv[1], cs)
else :
file = msparser.ms_masses(sys.argv[1])
if not file.isValid() :
print("Error when reading file: %s" % file.getFileName())
checkErrorHandler(file)
sys.exit(1)
print("Name of the file: %s" % file.getFileName())
print("-------------------------------------------------------------")
print("--- Content of masses file ---")
print("-------------------------------------------------------------")
print("# Amino acid masses (monoisotopic and average)")
for i in range(0, 26) :
res = chr(ord('A') + i)
print("%1s:%5.5f,%5.5f" % (
res,
file.getResidueMass(msparser.MASS_TYPE_MONO, res),
file.getResidueMass(msparser.MASS_TYPE_AVE, res)
))
print (" ")
print("# Atomic masses used for terminus values")
print("HYDROGEN:%5.5f,%5.5f" % (
file.getHydrogenMass(msparser.MASS_TYPE_MONO),
file.getHydrogenMass(msparser.MASS_TYPE_AVE)
))
print("CARBON:%5.5f,%5.5f" % (
file.getCarbonMass(msparser.MASS_TYPE_MONO),
file.getCarbonMass(msparser.MASS_TYPE_AVE)
))
print("NITROGEN:%5.5f,%5.5f" % (
file.getNitrogenMass(msparser.MASS_TYPE_MONO),
file.getNitrogenMass(msparser.MASS_TYPE_AVE)
))
print("OXYGEN:%5.5f,%5.5f" % (
file.getOxygenMass(msparser.MASS_TYPE_MONO),
file.getOxygenMass(msparser.MASS_TYPE_AVE)
))
print("ELECTRON:%5.7f" % (
file.getElectronMass()
))
"""
Running the program as
python config_masses.pl /usr/local/mascot/config/masses
will give the following output under Mascot Server 2.3:
Name of the file: /usr/local/mascot/config/masses
-------------------------------------------------------------
--- Content of masses file ---
-------------------------------------------------------------
# Amino acid masses (monoisotopic and average)
A:71.03711,71.07790
B:114.53494,114.59500
C:103.00919,103.14290
D:115.02694,115.08740
E:129.04259,129.11400
F:147.06841,147.17390
G:57.02146,57.05130
H:137.05891,137.13930
I:113.08406,113.15760
J:0.00000,0.00000
K:128.09496,128.17230
L:113.08406,113.15760
M:131.04048,131.19610
N:114.04293,114.10260
O:0.00000,0.00000
P:97.05276,97.11520
Q:128.05858,128.12920
R:156.10111,156.18570
S:87.03203,87.07730
T:101.04768,101.10390
U:150.95363,150.03790
V:99.06841,99.13110
W:186.07931,186.20990
X:111.00000,111.00000
Y:163.06333,163.17330
Z:128.55059,128.62160
# Atomic masses used for terminus values
HYDROGEN:1.00783,1.00794
CARBON:12.00000,12.01070
NITROGEN:14.00307,14.00670
OXYGEN:15.99491,15.99940
ELECTRON:0.0005490
"""