In [1]:
import sys
sys.path.append( '/Users/bpb/Data/programming/MetaboliteAtlas/metatlas2p0/metatlas/metatlas' )
import h5_query as h5q
import mzml_loader as mzml_loader
import numpy as np
import tables
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'svg'

In [2]:
mypath = '/Users/bpb/Downloads/20150326_BN6_BN7/'
# mypath = '/Users/bpb/Downloads/'

In [3]:
# import os
# for file in os.listdir(mypath):
#     if file.endswith(".mzML"):
#         filename = '%s%s' % (mypath,file)
#         mzml_loader.mzml_to_hdf(filename)
#         print filename

In [3]:
# myfile = '20141211_caj211_Ecoli_unlabelled_glucose_POS.h5'
# myfile = '2015326_pHILIC_ACN_POS_MSMS_BN7_1062_SAR11_media_WithPolyamines_PPLex_95_Run36.h5'
myfile = '2015326_pHILIC_ACN_POS_MSMS_BN6_1062_SAR11_media_NoOsmolytes_PPLex_26_Run32.h5'
filename = '%s%s' % (mypath,myfile)
fid = tables.open_file(filename)

In [5]:
mz_theor = 149.051024 + 1.007276
print mz_theor


150.0583

In [6]:
rt,intensity = h5q.get_XIC(fid, mz_theor - 0.1, mz_theor + 0.1, 1, 1)


Querying: (ms_level == 1) & (polarity == 1) & (mz >= 149.9583) & (mz <= 150.1583)

In [7]:
plt.plot(rt,intensity)
plt.xlim(7,10)
plt.show()



In [ ]:
#, min_precursor_MZ=0,max_precursor_MZ=102.1)#, bins=None):

In [6]:
mzEdges = np.linspace(mz_theor - 0.1, mz_theor + 0.1,100)
rtEdges = np.linspace(8,9,100)
ms_level = 1
polarity = 1
hMap = h5q.get_HeatMapRTMZ(fid,mzEdges,rtEdges,ms_level,polarity)
h5q.plot_heatmap(hMap['arr'],hMap['rt_bins'],hMap['mz_bins'],title='Methionine')
plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)


Querying: (ms_level == 1) & (polarity == 1)

In [10]:
mz_centroid = np.sum( np.multiply( np.sum(hMap['arr'],axis=1), hMap['mz_bins']) ) / np.sum( hMap['arr'] )
print "The measured centroid from this 2d hist is %5.5f" % mz_centroid


The measured centroid from this 2d hist is 150.05828

In [11]:
mzEdges = np.linspace(mz_theor - 0.05, mz_theor + 0.1, 100)
rtEdges = np.linspace(8,9,100)
ms_level = 1
polarity = 1
hMap = h5q.get_HeatMapRTMZ(fid,mzEdges,rtEdges,ms_level,polarity)
h5q.plot_heatmap(hMap['arr'],hMap['rt_bins'],hMap['mz_bins'],title='Methionine')
plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)


Querying: (ms_level == 1) & (polarity == 1)

In [12]:
mz_centroid = np.sum( np.multiply( np.sum(hMap['arr'],axis=1), hMap['mz_bins']) ) / np.sum( hMap['arr'] )
print "The measured centroid from this 2d hist is %5.5f" % mz_centroid


The measured centroid from this 2d hist is 150.05756

In [13]:
mzEdges = np.linspace(mz_theor - 0.1, mz_theor + 0.05,100)
rtEdges = np.linspace(8,9,100)
ms_level = 1
polarity = 1
hMap = h5q.get_HeatMapRTMZ(fid,mzEdges,rtEdges,ms_level,polarity)
h5q.plot_heatmap(hMap['arr'],hMap['rt_bins'],hMap['mz_bins'],title='Methionine')
plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)


Querying: (ms_level == 1) & (polarity == 1)

In [14]:
mz_centroid = np.sum( np.multiply( np.sum(hMap['arr'],axis=1), hMap['mz_bins']) ) / np.sum( hMap['arr'] )
print "The measured centroid from this 2d hist is %5.5f" % mz_centroid


The measured centroid from this 2d hist is 150.05749

In [17]:
print hMap['arr'].shape
print hMap['mz_bins'].shape
print hMap['rt_bins'].shape


(99, 99)
(99,)
(99,)

In [ ]: