Execute the msConvert tool on Windows operating systems.

    :param filelocation: input file path
    :param outformat: output format, must be one of the following: ms1, ms2, ms3, mgf
    :param outdir: path of the output directory
    :param log: #TODO
    :param executable: must specify the complete file path of the RawConverter.exe
        if its location is not in the ``PATH`` environment variable.

    .. note:
        Specifying the complete path to the executable is probably always
        necessary because RawConverter looks for the file "AveragineTable.txt"
        in the working directory.

def execute(filelocation, outformat, outdir, log=False,
            executable='RawConverter.exe'):
    """Execute the msConvert tool on Windows operating systems.

    :param filelocation: input file path
    :param outformat: output format, must be one of the following: ms1, ms2, ms3, mgf
    :param outdir: path of the output directory
    :param log: #TODO
    :param executable: must specify the complete file path of the RawConverter.exe
        if its location is not in the ``PATH`` environment variable.

    .. note:
        Specifying the complete path to the executable is probably always
        necessary because RawConverter looks for the file "AveragineTable.txt"
        in the working directory.
    """
    assert outformat in ['ms1', 'ms2', 'ms3', 'mgf']

    args = [executable, filelocation, '--'+outformat, '--out_folder', outdir,
            '--select_mono_prec']

    ## run it ##
    proc = subprocess.Popen(args, cwd=os.path.dirname(executable),
                            stderr=subprocess.PIPE)

    ## But do not wait till netstat finish, start displaying output immediately ##
    while True:
        out = proc.stderr.read(1)
        if out == '' and proc.poll() != None:
            break
        if out != '':
            sys.stdout.write(out)
            sys.stdout.flush()