File: plot_spectrum.inc

package info (click to toggle)
python-pymzml 2.5.2%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 27,792 kB
  • sloc: python: 6,495; pascal: 341; makefile: 233; sh: 30
file content (39 lines) | stat: -rwxr-xr-x 911 bytes parent folder | download | duplicates (3)
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
.. code-block:: python

	#!/usr/bin/env python
	# -*- coding: utf-8 -*-
	
	import os
	
	import pymzml
	
	
	def main():
	    """
	    This function shows how to plot a simple spectrum. It can be directly
	    plotted via this script or using the python console.
	
	    usage:
	
	        ./plot_spectrum.py
	
	    """
	
	    example_file = os.path.join(
	        os.path.dirname(__file__), os.pardir, "tests", "data", "example.mzML"
	    )
	    run = pymzml.run.Reader(example_file)
	    p = pymzml.plot.Factory()
	    for spec in run:
	        p.new_plot()
	        p.add(spec.peaks("centroided"), color=(0, 0, 0), style="sticks", name="peaks")
	        filename = "example_plot_{0}_{1}.html".format(
	            os.path.basename(example_file), spec.ID
	        )
	        p.save(filename=filename)
	        print("Plotted file: {0}".format(filename))
	        break
	
	
	if __name__ == "__main__":
	    main()