コード例 #1
0
	def get_signal_listing(
			self,
			device_name: str,
			device_type: DeviceType,
			data_type: StoredDataType,
			ordinal: int = 1,
			) -> List[SignalInfo]:
		"""
		Returns a list of signals of the given type available for the given device.

		:param device_name: The name of the device that recorded the signal.
		:param device_type: The type of device that recorded the signal.
		:param data_type:
		:param ordinal:

		Most devices only have :py:enum:mem:`~pyms_agilent.enums.StoredDataType.InstrumentCurves` data,
		although devices such as :py:enum:mem:`~pyms_agilent.enums.DeviceType.VariableWavelengthDetector`
		also have :py:enum:mem:`~pyms_agilent.enums.StoredDataType.Chromatograms` available.

		Usually no data is available for Mass Spectrometry devices; that data is available from
		:meth:`MassSpecDataReader.get_ms_actuals`.
		"""

		device = DataAnalysis.IDeviceInfo(DataAnalysis.DeviceInfo())
		device.DeviceName = str(device_name)
		device.DeviceType = int(device_type)  # type: ignore
		device.OrdinalNumber = int(ordinal)

		signal_info_list = [
				SignalInfo(s, self.data_reader) for s in self.data_reader.GetSignalInfo(
						device,
						int(data_type),  # type: ignore
						)
				]
		return signal_info_list
コード例 #2
0
	def __init__(self, filename: PathLike):
		if not os.path.exists(filename):
			raise FileNotFoundError(filename)

		self.filename: str = str(filename)
		self.data_reader = DataAnalysis.MassSpecDataReader()
		self.interface = DataAnalysis.IMsdrDataReader

		try:
			if not self.interface.OpenDataFile(self.data_reader, self.filename):
				raise OSError(f"Could not open data file '{self.filename}'")  # pragma: no cover
		except FileNotFoundException as e:
			raise FileNotFoundError(str(e).split('\n')[0]) from None
コード例 #3
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")
コード例 #4
0
	def __init__(self, BDAMSScanFileInformation: DataAnalysis.BDAMSScanFileInformation):

		self.data_reader = BDAMSScanFileInformation
		self.interface = DataAnalysis.IBDAMSScanFileInformation(self.data_reader)
コード例 #5
0
    def __init__(self, data_reader: DataAnalysis.BDAChromData):

        self.data_reader = data_reader
        self.interface = DataAnalysis.IBDAChromData(self.data_reader)
コード例 #6
0
 def __init__(self, MSScanRecord: DataAnalysis.MSScanRecord):
     self.data_reader = MSScanRecord
     self.interface = DataAnalysis.IMSScanRecord(self.data_reader)
コード例 #7
0
 def __init__(self, SignalInfo: Union[DataAnalysis.SignalInfo,
                                      DataAnalysis.ISignalInfo],
              msdr: DataAnalysis.MassSpecDataReader):
     self.data_reader = SignalInfo
     self.interface = DataAnalysis.ISignalInfo(self.data_reader)
     self.msdr = msdr
コード例 #8
0
 def __init__(self, BDASpecData: "DataAnalysis.BDASpecData"):
     self.data_reader = BDASpecData
     self.interface: DataAnalysis.IBDASpecData = DataAnalysis.IBDASpecData(
         self.data_reader)
コード例 #9
0
	def __init__(self, BDADataAccess: Union[DataAnalysis.BDADataAccess, DataAnalysis.IBDAActuals]):
		self.data_reader = BDADataAccess
		self.interface = DataAnalysis.IBDAActuals(self.data_reader)
コード例 #10
0
	def has_actuals(self) -> bool:
		"""
		Returns whether the datafile contains MS Actuals data.
		"""

		return DataAnalysis.IBDAActuals(self.interface(self.data_reader).ActualsInformation).IsActualsPresent()
コード例 #11
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.")
コード例 #12
0
    def __init__(self,
                 data_reader: Union[DataAnalysis.BDAFileInformation,
                                    DataAnalysis.BDAMSScanFileInformation]):

        self.data_reader = data_reader
        self.interface = DataAnalysis.IBDAFileInformation(self.data_reader)