def _retrieve_masslist_centroids(self, scan_number, polarity): """Retrieves centroids from centroided data.""" # read masslist scan_number_l = ctypes.c_long(scan_number) mass_list_v = comtypes.automation.VARIANT() flags_v = comtypes.automation.VARIANT() size_l = ctypes.c_long() error = self._raw_reader.GetMassListFromScanNum( scan_number_l, comtypes.BSTR(''), # filter ctypes.c_long(0), # intensity cut-off mode ctypes.c_long(0), # intensity cut-off value ctypes.c_long(0), # max num of peaks ctypes.c_long(0), # centroided result ctypes.c_double(0), # centroid peak width mass_list_v, flags_v, size_l) if error: return None # get arrays mz_array = numpy.array(mass_list_v.value[0]) ai_array = numpy.array(mass_list_v.value[1]) # create centroids centroids = [] for i in range(len(mz_array)): if ai_array[i] > 0: centroids.append(Centroid(mz_array[i], ai_array[i])) return centroids
def _retrieve_profile(self, scan_number): """Retrieves profile data.""" # read masslist scan_number_l = ctypes.c_long(scan_number) mass_list_v = comtypes.automation.VARIANT() flags_v = comtypes.automation.VARIANT() size_l = ctypes.c_long() error = self._raw_reader.GetMassListFromScanNum( scan_number_l, comtypes.BSTR(''), # filter ctypes.c_long(0), # intensity cut-off mode ctypes.c_long(0), # intensity cut-off value ctypes.c_long(0), # max num of peaks ctypes.c_long(0), # centroid result ctypes.c_double(0), # centroid peak width mass_list_v, flags_v, size_l) if error: return None # get arrays mz_array = numpy.array(mass_list_v.value[0]) ai_array = numpy.array(mass_list_v.value[1]) # make profile profile = numpy.dstack((mz_array, ai_array))[0].copy() return profile
def _retrieve_scan_filter(self, scan_number): """Retrieves scan filter string.""" # get filter string filter_string_s = comtypes.BSTR() if self._raw_reader.GetFilterForScanNum(scan_number, filter_string_s): return None return filter_string_s.value
def _retrieve_instrument_model(self): """Retrieves instrument model value.""" # get instrument model instrument_model_s = comtypes.BSTR() if not self._raw_reader.GetInstModel(instrument_model_s): return instrument_model_s.value return None
def _retrieve_instrument_name(self): """Retrieves instrument name value.""" # get instrument name instrument_name_s = comtypes.BSTR() if not self._raw_reader.GetInstName(instrument_name_s): return instrument_name_s.value return None
def scan_lists(self): ''' Returns the mass and intensity scan lists from a given scan : GetMassListFromScanNum(long FAR* pnScanNumber, LPCTSTR szFilter, long nIntensityCutoffType, long nIntensityCutoffValue, long nMaxNumberOfPeaks, BOOL bCentroidResult, VARIANT FAR* pvarMassList, VARIANT FAR* pvarPeakFlags, long FAR* pnArraySize) -> np.array([401.66, ...]), np.array([4131.76, ...]) ''' num = ctypes.c_long(self.scan_num) null_filter = comtypes.BSTR() cutoff_none = ctypes.c_long(0) cutoff_value = ctypes.c_long() max_peaks = ctypes.c_long() centroided = self._centroided peak_width = ctypes.c_double(0) mass_list = comtypes.automation.VARIANT() peak_flags = comtypes.automation.VARIANT() size = ctypes.c_long() self.rawfile.GetMassListFromScanNum( num, null_filter, cutoff_none, cutoff_value, max_peaks, centroided, peak_width, mass_list, peak_flags, size ) with comtypes.safearray.safearray_as_ndarray: mzs, intensity = mass_list.value return mzs, intensity
def _retrieve_activation_energy(self, scan_number, method): """"Retrieves activation energy value.""" # get value from trailer label = "%s Energy eV:" % method activation_energy_v = comtypes.automation.VARIANT() if not self._raw_reader.GetTrailerExtraValueForScanNum( scan_number, label, activation_energy_v): if activation_energy_v.value: return float(activation_energy_v.value) # get filter string filter_string_s = comtypes.BSTR() if self._raw_reader.GetFilterForScanNum(scan_number, filter_string_s): return None # parse filter string matches = SCAN_FILTER_DISSOCIATION_PATTERN.findall( filter_string_s.value) if matches: return float(matches[-1][3]) return None