text stringlengths 0 828 |
|---|
:returns: [datatype1, ...] |
"""""" |
datatypes = list() |
for datatype, value in [('rm', rm), ('ci', ci), ('smi', smi), |
('sai', sai), ('si', si)]: |
if value: |
datatypes.append(datatype) |
return datatypes" |
1932,"def save(self, specfiles=None, rm=False, ci=False, smi=False, sai=False, |
si=False, compress=True, path=None): |
""""""Writes the specified datatypes to ``mrc`` files on the hard disk. |
.. note:: |
If ``.save()`` is called and no ``mrc`` files are present in the |
specified path new files are generated, otherwise old files are |
replaced. |
:param specfiles: the name of an ms-run file or a list of names. If None |
all specfiles are selected. |
:type specfiles: None, str, [str, str] |
:param rm: bool, True to select ``self.rmc`` (run metadata) |
:param ci: bool, True to select ``self.cic`` (chromatogram items) |
:param smi: bool, True to select ``self.smic`` (spectrum metadata items) |
:param sai: bool, True to select ``self.saic`` (spectrum array items) |
:param si: bool, True to select ``self.sic`` (spectrum items) |
:param compress: bool, True to use zip file compression |
:param path: filedirectory to which the ``mrc`` files are written. By |
default the parameter is set to ``None`` and the filedirectory is |
read from ``self.info[specfile]['path']`` |
"""""" |
if specfiles is None: |
specfiles = [_ for _ in viewkeys(self.info)] |
else: |
specfiles = aux.toList(specfiles) |
datatypes = self._processDatatypes(rm, ci, smi, sai, si) |
if len(datatypes) == 0: |
datatypes = ['rm', 'ci', 'smi', 'sai', 'si'] |
for specfile in specfiles: |
if specfile not in self.info: |
warntext = 'Error while calling ""MsrunContainer.save()"": ""%s"" '\ |
'is not present in ""MsrunContainer.info""!'\ |
% (specfile, ) |
warnings.warn(warntext) |
continue |
else: |
msrunInfo = self.info[specfile] |
specfilePath = msrunInfo['path'] if path is None else path |
with aux.PartiallySafeReplace() as msr: |
for datatype in datatypes: |
filename = specfile + '.mrc_' + datatype |
filepath = aux.joinpath(specfilePath, filename) |
with msr.open(filepath, 'w+b') as openfile: |
if datatype == 'rm': |
self._writeRmc(openfile, specfile) |
elif datatype == 'ci': |
self._writeCic(openfile, specfile, compress) |
elif datatype == 'si': |
self._writeSic(openfile, specfile, compress) |
elif datatype == 'smi': |
self._writeSmic(openfile, specfile, compress) |
elif datatype == 'sai': |
self._writeSaic(openfile, specfile, compress)" |
1933,"def _writeCic(self, filelike, specfile, compress): |
""""""Writes the ``.cic`` container entry of the specified specfile to the |
``mrc_cic`` format. For details see |
:func:`maspy.auxiliary.writeBinaryItemContainer()` |
:param filelike: path to a file (str) or a file-like object |
:param specfile: name of an ms-run file present in ``self.info`` |
:param compress: bool, True to use zip file compression |
"""""" |
aux.writeBinaryItemContainer(filelike, self.cic[specfile], compress)" |
1934,"def _writeSaic(self, filelike, specfile, compress): |
""""""Writes the ``.ssic`` container entry of the specified specfile to the |
``mrc_saic`` format. For details see |
:func:`maspy.auxiliary.writeBinaryItemContainer()` |
:param filelike: path to a file (str) or a file-like object |
:param specfile: name of an ms-run file present in ``self.info`` |
:param compress: bool, True to use zip file compression |
"""""" |
aux.writeBinaryItemContainer(filelike, self.saic[specfile], compress)" |
1935,"def _writeSmic(self, filelike, specfile, compress): |
""""""Writes the ``.smic`` container entry of the specified specfile to the |
``mrc_smic`` format. For details see |
:func:`maspy.auxiliary.writeJsonZipfile()` |
:param filelike: path to a file (str) or a file-like object |
:param specfile: name of an ms-run file present in ``self.info`` |
:param compress: bool, True to use zip file compression |
"""""" |
aux.writeJsonZipfile(filelike, self.smic[specfile], compress)" |
1936,"def _writeSic(self, filelike, specfile, compress): |
""""""Writes the ``.sic`` container entry of the specified specfile to the |
``mrc_sic`` format. For details see |
:func:`maspy.auxiliary.writeJsonZipfile()` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.