Пример #1
0
def test_rel_abundance(mzs):

    data = read_mzXML(get_mzXML_sample_path())
    mz, intensities, times = data["mz"], data["intensities"], data["times"]

    abun = get_relative_abundance(mz, intensities, mzs)
    npt.assert_equal(abun.shape[0], len(mzs))
    npt.assert_equal(abun.shape[1], intensities.shape[0])
Пример #2
0
def test_contourf_keep():
    # Test different keep_ith_scan settings
    # If we keep twice as many scans we don't exactly double the number of points
    # in the contour plot b/c each scan doesn't have the same number of points.
    # That being said it should be roughly double and we see that it is.
    # Test default settings
    data = read_mzXML(get_mzXML_sample_path())
    mz, intensities, times = data["mz"], data["intensities"], data["times"]
    X, Y, Z = contourf(mz, intensities, 50, 70, keep_ith_scan=2)
Пример #3
0
def test_contourf_def():
    # Test default settings
    data = read_mzXML(get_mzXML_sample_path())
    mz, intensities, times = data["mz"], data["intensities"], data["times"]
    n_scans = intensities.shape[0]
    X, Y, Z = contourf(mz, intensities, 50, 70, keep_ith_scan=1)
    npt.assert_equal(X.shape, Y.shape)
    npt.assert_equal(Y.shape, Z.shape)
    # print(intensities.shape, times.shape, X.shape)
    npt.assert_equal(X.shape[1], times.size)
Пример #4
0
def test_read_mzXML():
    data = read_mzXML(get_mzXML_sample_path())
    mz, intensities, times = data["mz"], data["intensities"], data["times"]
    npt.assert_equal(len(intensities.shape), 2)
    npt.assert_equal(times.size, intensities.shape[0])
    npt.assert_equal(mz.size, intensities.shape[1])
Пример #5
0
# mzXML_file = "/home/james/Downloads/20200228_1175.mzXML"
# labview_file = "20200612_TP.csv"
# mzXML_file = "20200612_2735.mzXML"

#
# Read CSV Data from LabView
#
cols = ["time", "b", "temp", "d", "e", "f", "g", "h"]
df = pd.read_csv(labview_file, names=cols)
df["time"] -= df["time"][0]
last_lv_time = np.array(df["time"])[-1]

#
# Read in mzXML
#
data = read_mzXML(mzXML_file)
mz, intensities, times = data["mz"], data["intensities"], data["times"]
# Only go as far as LabView data (which we are assuming is always shut off after the mass spec)
subset = np.where(times <= last_lv_time)[0]
times = times[subset]
intensities = intensities[subset]

#
# Use timestamps from mzXML and Labview to interpolate temperature for each scan
#
temp_interp = np.interp(times, df["time"], df["temp"])

#
# Select a subset of MZ range and plot intensities as a contour plot
#
mz_lb, mz_ub = (130, 180)
"""
This example shows how to read a mzXML file and plot the first spectra using matplotlib.

Author: James E. T. Smith <*****@*****.**>
Date: 12/12/19
"""

import matplotlib.pyplot as plt
import seaborn as sns

from msanalysis.data_extraction import read_mzXML
from msanalysis.sample_data import get_mzXML_sample_path

#
# Read in CDF
#
data = read_mzXML(get_mzXML_sample_path())
mz, intensities, times = data["mz"], data["intensities"], data["times"]

#
# Plot
#
plt.figure()
sns.set_style("darkgrid")
plt.plot(mz, intensities[0], c="k")
plt.xlim((30, 125))
plt.xlabel("M/Z")
plt.ylabel("Intensity")
plt.tight_layout()
plt.savefig("figures/ex1.png", dpi=600)