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

msconvert not extracting full name of scans for first and last entries of .wiff file in v3.0.2 #3159

Open
ChristianIeritano opened this issue Sep 15, 2024 · 0 comments

Comments

@ChristianIeritano
Copy link

Hi proteowizard friends,

We use msconvert to convert scans saved to .wiff files (from a SCIEX instrument) to .mzML. The following script is part of a GUI we use to process UVPD data measured on a modified SCIEX 5500, which works fine w/ the msconvert.exe found in ProteoWizard 3.0.11392, but does not work for any v3.0.2 variant. Specifically, when processing a .wiff and associated .wiff.scan file, the full filename of the first and last scans is truncated. All other scans are extracted and named normally.

Note that the filenames contain some verbose info about the filenames and a -### before the .wiff(.scan) extension. An example .wiff file for testing can be found at our GitHub.

Thanks!

import os, traceback, subprocess, time
from PyQt6.QtWidgets import QApplication

def convert_wiff_to_mzml(wiff_file, directory, mzml_directory):
    ''' Function to convert .wiff files to .mzml using msconvert
    input is .wiff file, directory that contains .wiff files, and directory to output mzml files to'''
    
    #check if required files are present
    wiff_file_check = os.path.join(directory, wiff_file)
    scan_file_check = f'{os.path.join(directory, wiff_file)}.scan'
    
    if not os.path.exists(wiff_file_check):
        print(f'The corresponding .wiff file is missing from the directory. Please add the following file to the directory, and re-run the code:\n{os.path.basename(wiff_file_check)}\n\n')
        QApplication.processEvents()
        return False

    if not os.path.exists(scan_file_check):
        print(f'The corresponding .scan file is missing from the directory. Please add the following file to the directory, and re-run the code:\n{os.path.basename(scan_file_check)}\n\n')
        QApplication.processEvents()
        return False

    try:

        subprocess.run(['msconvert', os.path.join(directory, wiff_file), '-o', mzml_directory, '--mzML', '--64'])
        os.remove(temp_command_file)
        time.sleep(2)

        return True

    except FileNotFoundError:
        print("msconvert (Part of proteowizard) could not be found. Did you add the required directories to your system's PATH?\n")
        QApplication.processEvents()
        return False

    except subprocess.CalledProcessError as cpe:    
        print(f'Subprocess error converting {wiff_file} to mzML: {cpe}\nTraceback: {traceback.format_exc()}\n')
        QApplication.processEvents()
        return False

    except Exception as e: 
        print(f'Unexpected error converting {wiff_file} to mzML: {e}\nTraceback: {traceback.format_exc()}\n')
        QApplication.processEvents()
        return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant