text
stringlengths
0
828
""""""Returns a ``Sii`` instance from ``self.container`` if it is valid,
if all elements of ``self.container[specfile][identifier] are
``Sii.isValid == False`` then ``None`` is returned.
:param specfile: a ms-run file name
:param identifier: item identifier ``Sii.id``
:returns: ``Sii`` or ``None``
""""""
for item in self.container[specfile][identifier]:
if item.isValid:
return item
else:
return None"
1953,"def _addSpecfile(self, specfile, path):
""""""Adds a new specfile entry to SiiContainer.info. See also
:class:`SiiContainer.addSpecfile()`.
:param specfile: the name of an ms-run file
:param path: filedirectory for loading and saving the ``siic`` files
""""""
self.info[specfile] = {'path': path, 'qcAttr': None, 'qcCutoff': None,
'qcLargerBetter': None, 'rankAttr': None,
'rankLargerBetter': None
}
self.container[specfile] = dict()"
1954,"def removeSpecfile(self, specfiles):
""""""Completely removes the specified specfiles from the ``SiiContainer``.
:param specfiles: the name of an ms-run file or a list of names.
""""""
for specfile in aux.toList(specfiles):
del self.container[specfile]
del self.info[specfile]"
1955,"def save(self, specfiles=None, compress=True, path=None):
""""""Writes the specified specfiles to ``siic`` files on the hard disk.
.. note::
If ``.save()`` is called and no ``siic`` 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.
:param compress: bool, True to use zip file compression
:param path: filedirectory to which the ``siic`` 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)
for specfile in specfiles:
if specfile not in self.info:
warntext = 'Error while calling ""SiiContainer.save()"": ""%s"" is'\
' not present in ""SiiContainer.info""!'\
% (specfile, )
warnings.warn(warntext)
continue
else:
path = self.info[specfile]['path'] if path is None else path
with aux.PartiallySafeReplace() as msr:
filename = specfile + '.siic'
filepath = aux.joinpath(path, filename)
with msr.open(filepath, mode='w+b') as openfile:
self._writeContainer(openfile, specfile, compress)"
1956,"def addSiInfo(self, msrunContainer, specfiles=None,
attributes=['obsMz', 'rt', 'charge']):
""""""Transfer attributes to :class:`Sii` elements from the corresponding
:class`Si` in :class:`MsrunContainer.sic <MsrunContainer>`. If an
attribute is not present in the ``Si`` the attribute value in the
``Sii``is set to ``None``.
Attribute examples: 'obsMz', 'rt', 'charge', 'tic', 'iit', 'ms1Id'
:param msrunContainer: an instance of :class:`MsrunContainer` which has
imported the corresponding specfiles
:param specfiles: the name of an ms-run file or a list of names. If None
all specfiles are selected.
:param attributes: a list of ``Si`` attributes that should be
transfered.
""""""
if specfiles is None:
specfiles = [_ for _ in viewkeys(self.info)]
else:
specfiles = aux.toList(specfiles)
for specfile in specfiles:
if specfile not in self.info:
warntext = 'Error while calling ""SiiContainer.addSiInfo()"": '\
'""%s"" is not present in ""SiiContainer.info""!'\
% (specfile, )
warnings.warn(warntext)
elif specfile not in msrunContainer.info:
warntext = 'Error while calling ""SiiContainer.addSiInfo()"": '\
'""%s"" is not present in ""MsrunContainer.info""'\
% (specfile, )