Exemple #1
0
def storePeakMap(pm, path=None):
    """ Stores peakmap *pm* in mzXML, mzML or mzData format.
        The used format depends on the file extension given
        in *path*. If no *path* is given, a dialog for
        choosing an output file name is opened.
    """

    # local import in order to keep namespaces clean
    import ms
    import sys
    from pyopenms import FileHandler

    if isinstance(path, unicode):
        path = path.encode(sys.getfilesystemencoding())
    elif path is None:
        path = ms.askForSave(extensions="mzML mzXML mzData".split())
        if path is None:
            return None

    if sys.platform == "win32":
        path = path.replace("/","\\") # needed for network shares

    experiment = pm.toMSExperiment()
    fh = FileHandler()
    fh.storeExperiment(path, experiment)
Exemple #2
0
def storePeakMap(pm, path=None):
    """ Stores peakmap *pm* in mzXML, mzML or mzData format.
        The used format depends on the file extension given
        in *path*. If no *path* is given, a dialog for
        choosing an output file name is opened.
    """

    # local import in order to keep namespaces clean
    import ms
    import sys
    from pyopenms import FileHandler

    if isinstance(path, unicode):
        path = path.encode(sys.getfilesystemencoding())
    elif path is None:
        path = ms.askForSave(extensions="mzML mzXML mzData".split())
        if path is None:
            return None

    if sys.platform == "win32":
        path = path.replace("/", "\\")  # needed for network shares

    experiment = pm.toMSExperiment()
    fh = FileHandler()
    fh.storeExperiment(path, experiment)
Exemple #3
0
def storeCSV(tab, path=None):
    """ Saves *tab* in a textual ``.csv`` file.
        If *path* is not provided, a file dialog opens
        for choosing the files name and location.
    """

    # local import in order to keep namespaces clean
    import ms
    import sys

    if isinstance(path, unicode):
        path = path.encode(sys.getfilesystemencoding())
    elif path is None:
        path = ms.askForSave(extensions=["csv"])
        if path is None:
            return None
    tab.storeCSV(path)
Exemple #4
0
def storeCSV(tab, path=None):
    """ Saves *tab* in a textual ``.csv`` file.
        If *path* is not provided, a file dialog opens
        for choosing the files name and location.
    """

    # local import in order to keep namespaces clean
    import ms
    import sys

    if isinstance(path, unicode):
        path = path.encode(sys.getfilesystemencoding())
    elif path is None:
        path = ms.askForSave(extensions=["csv"])
        if path is None:
            return None
    tab.storeCSV(path)
Exemple #5
0
def storeTable(tab, path=None, forceOverwrite=False):
    """ Saves *tab* in a binary ``.table`` file.
        If *path* is not provided, a file dialog opens
        for choosing the files name and location.

        *path* must have file extension ``.table``.
    """

    # local import in order to keep namespaces clean
    import ms
    import sys
    from libms.DataStructures.Table import compressPeakMaps

    compressPeakMaps(tab)

    if isinstance(path, unicode):
        path = path.encode(sys.getfilesystemencoding())
    elif path is None:
        startAt = tab.meta.get("loaded_from", "")
        path = ms.askForSave(extensions=["table"], startAt=startAt)
        if path is None:
            return None
    tab.store(path, forceOverwrite)
Exemple #6
0
def storeTable(tab, path=None, forceOverwrite=False):
    """ Saves *tab* in a binary ``.table`` file.
        If *path* is not provided, a file dialog opens
        for choosing the files name and location.

        *path* must have file extension ``.table``.
    """

    # local import in order to keep namespaces clean
    import ms
    import sys
    from libms.DataStructures.Table import compressPeakMaps

    compressPeakMaps(tab)

    if isinstance(path, unicode):
        path = path.encode(sys.getfilesystemencoding())
    elif path is None:
        startAt = tab.meta.get("loaded_from", "")
        path = ms.askForSave(extensions=["table"], startAt=startAt)
        if path is None:
            return None
    tab.store(path, forceOverwrite)