text stringlengths 0 828 |
|---|
: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.sic[specfile], compress)" |
1937,"def _writeRmc(self, filelike, specfile): |
""""""Writes the ``.rmc`` container entry of the specified specfile as an |
human readable and pretty formatted xml string. |
:param filelike: path to a file (str) or a file-like object |
:param specfile: name of an ms-run file present in ``self.info`` |
"""""" |
xmlString = ETREE.tostring(self.rmc[specfile], pretty_print=True) |
filelike.write(xmlString)" |
1938,"def load(self, specfiles=None, rm=False, ci=False, smi=False, sai=False, |
si=False): |
""""""Import the specified datatypes from ``mrc`` files on the hard disk. |
: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 import ``mrc_rm`` (run metadata) |
:param ci: bool, True to import ``mrc_ci`` (chromatogram items) |
:param smi: bool, True to import ``mrc_smi`` (spectrum metadata items) |
:param sai: bool, True to import ``mrc_sai`` (spectrum array items) |
:param si: bool, True to import ``mrc_si`` (spectrum items) |
"""""" |
if specfiles is None: |
specfiles = [_ for _ in viewkeys(self.info)] |
else: |
specfiles = aux.toList(specfiles) |
#Select only specfiles which are present in the ``self.info``. |
selectedSpecfiles = list() |
for specfile in specfiles: |
if specfile not in self.info: |
warntext = 'Error while calling ""MsrunContainer.load()"": ""%s"" '\ |
'not present in MsrunContainer.info' % specfile |
warnings.warn(warntext) |
else: |
selectedSpecfiles.append(specfile) |
datatypes = self._processDatatypes(rm, ci, smi, sai, si) |
if len(datatypes) == 0: |
datatypes = ['rm', 'ci', 'smi', 'sai', 'si'] |
for specfile in selectedSpecfiles: |
msrunInfo = self.info[specfile] |
specfilePath = msrunInfo['path'] |
if 'rm' in datatypes: |
rmPath = aux.joinpath(specfilePath, specfile+'.mrc_rm') |
with open(rmPath, 'rb') as openfile: |
xmlString = openfile.read() |
self.rmc[specfile] = ETREE.fromstring(xmlString) |
msrunInfo['status']['rm'] = True |
if 'ci' in datatypes: |
ciPath = aux.joinpath(specfilePath, specfile+'.mrc_ci') |
self.cic[specfile] = aux.loadBinaryItemContainer(ciPath, |
Ci.jsonHook) |
msrunInfo['status']['ci'] = True |
if 'smi' in datatypes: |
smiPath = aux.joinpath(specfilePath, specfile+'.mrc_smi') |
with zipfile.ZipFile(smiPath, 'r') as containerZip: |
#Convert the zipfile data into a str object,necessary since |
#containerZip.read() returns a bytes object. |
jsonString = io.TextIOWrapper(containerZip.open('data'), |
encoding='utf-8' |
).read() |
self.smic[specfile] = json.loads(jsonString, |
object_hook=Smi.jsonHook |
) |
msrunInfo['status']['smi'] = True |
if 'sai' in datatypes: |
saiPath = aux.joinpath(specfilePath, specfile+'.mrc_sai') |
self.saic[specfile] = aux.loadBinaryItemContainer(saiPath, |
Sai.jsonHook |
) |
msrunInfo['status']['sai'] = True |
if 'si' in datatypes: |
siPath = aux.joinpath(specfilePath, specfile+'.mrc_si') |
with zipfile.ZipFile(siPath, 'r') as containerZip: |
#Convert the zipfile data into a str object, necessary since |
#containerZip.read() returns a bytes object. |
jsonString = io.TextIOWrapper(containerZip.open('data'), |
encoding='utf-8' |
).read() |
self.sic[specfile] = json.loads(jsonString, |
object_hook=Si.jsonHook |
) |
msrunInfo['status']['si'] = True" |
1939,"def _reprJSON(self): |
""""""Returns a JSON serializable represenation of a ``Ci`` class instance. |
Use :func:`maspy.core.Ci._fromJSON()` to generate a new ``Ci`` instance |
from the return value. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.