Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CV support for FAIMS #16

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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