Skip to content

Commit

Permalink
Merge pull request #16 from MannLabs/faims
Browse files Browse the repository at this point in the history
add CV support for FAIMS
  • Loading branch information
GeorgWa authored Oct 4, 2023
2 parents 6e1c8ee + ea51b3a commit 27a807b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions alpharaw/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def _import_batch(
precursor_charges = []
ms_order_list = []
ce_list = []
cv_list = []

for i in range(
start,
stop
Expand All @@ -68,12 +70,18 @@ def _import_batch(

if ms_order == 1:
ce_list.append(0)
cv_list.append(0)
precursor_mz_values.append(-1.0)
isolation_mz_lowers.append(-1.0)
isolation_mz_uppers.append(-1.0)
precursor_charges.append(0)
else:
ce_list.append(rawfile.GetCollisionEnergyForScanNum(i))
n_cvs = rawfile.GetNumberOfSourceFragmentsFromScanNum(i)
if n_cvs > 0:
cv_list.append(rawfile.GetSourceFragmentValueFromScanNum(i,0))
else:
cv_list.append(0)

isolation_center = rawfile.GetPrecursorMassForScanNum(i)
isolation_width = rawfile.GetIsolationWidthForScanNum(i)
Expand All @@ -95,6 +103,7 @@ def _import_batch(
isolation_mz_uppers.append(isolation_center + isolation_width / 2)
precursor_charges.append(charge)
rawfile.Close()

return {
'_peak_indices': _peak_indices,
'peak_mz': np.concatenate(mz_values),
Expand All @@ -106,6 +115,7 @@ def _import_batch(
'isolation_upper_mz': np.array(isolation_mz_uppers),
'ms_level': np.array(ms_order_list, dtype=np.int8),
'nce': np.array(ce_list, dtype=np.float32),
'cv': np.array(cv_list, dtype=np.float32),
}
class ThermoRawData(MSData_Base):
"""
Expand Down Expand Up @@ -173,6 +183,42 @@ def _import(self,
rawfile.Close()

return output_dict

def _set_dataframes(self, raw_data:dict):
self.create_spectrum_df(len(raw_data['rt']))
self.set_peak_df_by_indexed_array(
raw_data['peak_mz'],
raw_data['peak_intensity'],
raw_data['peak_indices'][:-1],
raw_data['peak_indices'][1:],
)
self.add_column_in_spec_df(
'rt', raw_data['rt']
)
self.add_column_in_spec_df(
'ms_level', raw_data['ms_level'],
dtype=np.int8
)
self.set_precursor_mz(
raw_data['precursor_mz']
)
self.add_column_in_spec_df(
'charge', raw_data['precursor_charge'],
dtype=np.int8
)
self.set_isolation_mz_windows(
raw_data['isolation_mz_lower'],
raw_data['isolation_mz_upper'],
)
self.add_column_in_spec_df(
"nce", raw_data["nce"],
dtype=np.float32,
)
self.add_column_in_spec_df(
"cv", raw_data["cv"],
dtype=np.float32,
)


def import_raw(self, _path: str):
super().import_raw(_path)
Expand Down

0 comments on commit 27a807b

Please sign in to comment.