Skip to content

Commit

Permalink
support reading from csv
Browse files Browse the repository at this point in the history
  • Loading branch information
picciama committed Oct 2, 2023
1 parent 0467c63 commit 1b4e47c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion oktoberfest/data/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,22 @@ def from_hdf5(cls: Type[SpectraT], input_file: Union[str, Path]) -> SpectraT:
"""
input_file = str(input_file)
spectra = cls()
spectra.spectra_data
spectra.add_columns(hdf5.read_file(input_file, hdf5.META_DATA_KEY))
spectra.add_matrix_from_hdf5(hdf5.read_file(input_file, f"sparse_{hdf5.INTENSITY_RAW_KEY}"), FragmentType.RAW)
spectra.add_matrix_from_hdf5(hdf5.read_file(input_file, f"sparse_{hdf5.MZ_RAW_KEY}"), FragmentType.MZ)

return spectra

@classmethod
def from_csv(cls: Type[SpectraT], input_file: Union[str, Path]) -> SpectraT:
"""
Read from hdf5 file.
:param input_file: path to input file
:return: a spectra instance
"""
input_file = str(input_file)
spectra = cls()
spectra.spectra_data = pd.read_csv(input_file)

return spectra

0 comments on commit 1b4e47c

Please sign in to comment.