How to use the pyteomics.xml.unitfloat function in pyteomics

To help you get started, we’ve selected a few pyteomics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mobiusklein / ms_deisotope / ms_deisotope / tools / conversion.py View on Github external
include_software_entry=update_metadata)
    writer.copy_metadata_from(reader)
    if update_metadata:
        method = data_transformation.ProcessingMethod(software_id='ms_deisotope_1')
        if pick_peaks:
            method.add('MS:1000035')
        if correct_precursor_mz:
            method.add('MS:1000780')
        if reprofile:
            method.add('MS:1000784')
        method.add('MS:1000544')
        writer.add_data_processing(method)
    if default_activation is not None:
        if isinstance(default_activation, basestring):
            default_activation = activation_module.ActivationInformation(
                default_activation, unitfloat(0, 'electronvolt'))
        elif isinstance(default_activation, dict):
            default_activation = activation_module.ActivationInformation(**default_activation)
        else:
            click.secho("Could not convert %r into ActivationInformation" % (default_activation, ), err=1,
                        fg='yellow')
            default_activation = None
    if pick_peaks:
        try:
            writer.remove_file_contents("profile spectrum")
        except KeyError:
            pass
        writer.add_file_contents("centroid spectrum")
    n_spectra = len(reader)
    progbar = progress(
        label="Processed Spectra", length=n_spectra,
        item_show_func=lambda x: str(x.precursor.id if x.precursor else
github mobiusklein / ms_deisotope / ms_deisotope / data_source / xml_reader.py View on Github external
x: unitfloat
        A float representing a quantity of time annotated with a time unit

    Returns
    -------
    unitfloat:
        The time after conversion to minutes
    '''
    try:
        unit = x.unit_info
    except AttributeError:
        return x
    if unit == 'minute':
        return x
    elif unit == 'second':
        y = unitfloat(x / 60., 'minute')
        return y
    elif unit == 'hour':
        y = unitfloat(x * 60, 'minute')
        return y
    else:
        warnings.warn("Time unit %r not recognized" % unit)
    return x