Skip to content

Commit e4e1776

Browse files
update
1 parent d672d73 commit e4e1776

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/tdfextractor/mgf_exctractor.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def write_mgf_file(
3232
max_rt: Optional[float] = None,
3333
min_ccs: Optional[float] = None,
3434
max_ccs: Optional[float] = None,
35+
merge_precursors: bool = True,
36+
merge_tolerance: float = 5.0,
3537
):
3638

3739
start_time = time.time()
@@ -55,6 +57,8 @@ def write_mgf_file(
5557
max_rt=max_rt,
5658
min_ccs=min_ccs,
5759
max_ccs=max_ccs,
60+
merge_precursors=merge_precursors,
61+
merge_tolerance=merge_tolerance
5862
)
5963

6064
time.sleep(1)
@@ -66,8 +70,8 @@ def write_mgf_file(
6670
mgf_lines.append("BEGIN IONS")
6771
mgf_lines.append(
6872
f"TITLE={Path(analysis_dir).stem}.{spectrum.low_scan}.{spectrum.high_scan}.{spectrum.charge} "
69-
f'FILE="{Path(analysis_dir).stem}", NativeID="merged={spectrum.precursor_id} frame={spectrum.parent_id} '
70-
f'scanStart={spectrum.scan_begin} scanEnd={spectrum.scan_end}"'
73+
f'File="{Path(analysis_dir).stem}", NativeID="merged={spectrum.precursor_id} frame={spectrum.parent_id} '
74+
f'scanStart={spectrum.scan_begin} scanEnd={spectrum.scan_end} scan={spectrum.low_scan}"'
7175
)
7276
mgf_lines.append(f"RTINSECONDS={spectrum.rt}")
7377
mgf_lines.append(f"PEPMASS={spectrum.mass}")
@@ -76,7 +80,7 @@ def write_mgf_file(
7680
mgf_lines.append(f"{mz:.5f} {int(intensity)}")
7781
mgf_lines.append("END IONS")
7882

79-
file.write("\n".join(mgf_lines) + "\n")
83+
file.write("\n".join(mgf_lines) + "\n\n")
8084

8185
total_time = round(time.time() - start_time, 2)
8286
logger.info(f"Total Time: {total_time:.2f} seconds")

src/tdfextractor/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def get_ms2_dda_content(
145145
max_rt: Optional[float] = None,
146146
min_ccs: Optional[float] = None,
147147
max_ccs: Optional[float] = None,
148+
merge_precursors: bool = True,
149+
merge_tolerance: float = 5.0
148150
) -> Generator[Ms2Spectra, None, None]:
149151

150152
with timsdata.timsdata_connect(analysis_dir) as td:

0 commit comments

Comments
 (0)