示例#1
0
	def get_spectrum_by_scan(self, scan_no: int) -> SpecData:
		"""
		Returns a :class:`pyms_agilent.mhdac.spectrum.SpecData` object for the given scan.

		:param scan_no: The scan number.

		:raises: :exc:`ValueError` if the scan number is out of range.
		"""

		# TODO: by number and scan type

		peak_filter = DataAnalysis.MsdrPeakFilter()

		if int(scan_no) < 0:
			raise ValueError("scan_no must be greater than or equal to 0")

		try:
			# Signature is scan_no, peakMSFilter, peakMSMSFilter
			return SpecData(self.interface(self.data_reader).GetSpectrum(int(scan_no), peak_filter, peak_filter))
		except NullReferenceException:
			raise ValueError("scan_no out of range")
示例#2
0
	def get_spectrum_by_time(
			self,
			retention_time: float,
			scan_type: MSScanType = MSScanType.All,
			ionization_polarity: int = 1,
			ionization_mode: IonizationMode = IonizationMode.Unspecified,
			) -> SpecData:
		"""
		Returns a :class:`pyms_agilent.mhdac.spectrum.SpecData` object for the spectrum at the given retention time.

		If no spectrum is found for the given parameters an empty
		:class:`pyms_agilent.mhdac.spectrum.SpecData` object will be returned.

		:param retention_time:
		:param scan_type:
		:param ionization_polarity: The ionization polarity. 1 = positive, -1 = negative, 0 = +-
		:param ionization_mode:

		:raises: :exc:`ValueError` if the retention time is less than zero or no such scan exists for the given parameters.

		If the requested retention time is beyond the end of the acquired time range the spectrum for
		the latest time will be returned.
		"""

		# TODO: centroid vs scan

		peak_filter = DataAnalysis.MsdrPeakFilter()

		if ionization_polarity is None:
			raise ValueError("'ionization_polarity' cannot be None.")
		elif ionization_polarity > 0:
			ionization_polarity = IonPolarity.Positive  # 0  # I really don't know why it is this way
		elif ionization_polarity < 0:
			ionization_polarity = IonPolarity.Negative  # 1
		elif ionization_polarity == 0:
			ionization_polarity = IonPolarity.Mixed  # 3
		else:
			raise ValueError(
					"Invalid value for 'ionization_polarity'. "
					"Expected a value from the IonPolarity enum."
					)

		if float(retention_time) < 0:
			raise ValueError("retention_time cannot be < 0")

		# try:
		data = SpecData(
				self.interface(self.data_reader).GetSpectrum(
						float(retention_time),
						scan_type,
						ionization_polarity,
						ionization_mode,
						peak_filter,
						)
				)

		try:
			data.scan_id
			return data
		except NullReferenceException:
			raise ValueError("No such scan.")