1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
.. code-block:: python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import pymzml
from pymzml.plot import Factory
def main(mzml_file):
"""
Plots a chromatogram for the given mzML file. File is saved as
'chromatogram_<mzml_file>.html'.
usage:
./plot_chromatogram.py <path_to_mzml_file>
"""
run = pymzml.run.Reader(mzml_file)
mzml_basename = os.path.basename(mzml_file)
pf = Factory()
pf.new_plot()
pf.add(run["TIC"].peaks(), color=(0, 0, 0), style="lines", title=mzml_basename)
pf.save(
"chromatogram_{0}.html".format(mzml_basename),
layout={"xaxis": {"title": "Retention time"}, "yaxis": {"title": "TIC"}},
)
return
if __name__ == "__main__":
if len(sys.argv) < 2:
print(main.__doc__)
exit()
mzml_file = sys.argv[1]
main(mzml_file)
|