import pymzml
import sys

mzml_path = "/home/user/LabData/XianghuData/Test_incremental_2000/results/batch_26_results/consensus.mzML"
if len(sys.argv) > 1:
    mzml_path = sys.argv[1]

count = 0
all_count = 0
with pymzml.run.Reader(mzml_path) as run:
    for spec in run:
        all_count += 1
        scan_id_str = str(spec.ID)
        if '_' in scan_id_str:
            continue
        try:
            if "scan=" in scan_id_str:
                scan_id = int(scan_id_str.split("scan=")[-1].split()[0])
            else:
                scan_id = int(scan_id_str)
            count += 1
        except Exception:
            continue

print(f"Total spectra: {all_count}")
print(f"Integer scan id spectra: {count}") 