diff --git a/pyteomics/proforma.py b/pyteomics/proforma.py index 188a622..7d7713d 100644 --- a/pyteomics/proforma.py +++ b/pyteomics/proforma.py @@ -360,7 +360,7 @@ def resolve(self, name=None, id=None, **kwargs): return self._cache[cache_key].copy() value = self._resolve_impl(name, id, **kwargs) self._cache[cache_key] = value - return value.copy() + return value.copy() def __call__(self, name=None, id=None, **kwargs): return self.resolve(name, id, **kwargs) diff --git a/pyteomics/protxml.py b/pyteomics/protxml.py index 51dea03..7a514d9 100644 --- a/pyteomics/protxml.py +++ b/pyteomics/protxml.py @@ -75,6 +75,7 @@ from . import xml, auxiliary as aux, _schema_defaults import operator as op + class ProtXML(xml.MultiProcessingXML): """Parser class for protXML files.""" file_format = 'protXML' @@ -127,6 +128,7 @@ def _get_info_smart(self, element, **kwargs): info['unique_stripped_peptides'] = info['unique_stripped_peptides'].split('+') return info + def read(source, read_schema=False, iterative=True, **kwargs): """Parse `source` and iterate through protein groups. @@ -180,6 +182,7 @@ def _is_decoy_prefix(pg, prefix='DECOY_'): """ return all(p['protein_name'].startswith(prefix) for p in pg['protein']) + def _is_decoy_suffix(pg, suffix='_DECOY'): """Determine if a protein group should be considered decoy. @@ -201,6 +204,7 @@ def _is_decoy_suffix(pg, suffix='_DECOY'): """ return all(p['protein_name'].endswith(suffix) for p in pg['protein']) + is_decoy = _is_decoy_prefix fdr = aux._make_fdr(_is_decoy_prefix, _is_decoy_suffix) @@ -209,6 +213,7 @@ def _is_decoy_suffix(pg, suffix='_DECOY'): filter = aux._make_filter(chain, _is_decoy_prefix, _is_decoy_suffix, _key, qvalues) filter.chain = aux._make_chain(filter, 'filter', True) + def DataFrame(*args, **kwargs): """Read protXML output files into a :py:class:`pandas.DataFrame`. @@ -241,6 +246,7 @@ def DataFrame(*args, **kwargs): kwargs = kwargs.copy() sep = kwargs.pop('sep', None) pd_kwargs = kwargs.pop('pd_kwargs', {}) + def gen_items(): with chain(*args, **kwargs) as f: for item in f: @@ -260,6 +266,11 @@ def gen_items(): out['indistinguishable_protein'] = [p['protein_name'] for p in out['indistinguishable_protein']] else: out['indistinguishable_protein'] = sep.join(p['protein_name'] for p in out['indistinguishable_protein']) + if 'analysis_result' in out: + for ar in out['analysis_result']: + if ar['analysis'] == 'stpeter': + out.update(ar['StPeterQuant']) + yield out return pd.DataFrame(gen_items(), **pd_kwargs) diff --git a/tests/test_protxml.py b/tests/test_protxml.py index dce58bd..e81d849 100644 --- a/tests/test_protxml.py +++ b/tests/test_protxml.py @@ -66,5 +66,6 @@ def test_filter_df_suffix(self): fdf = protxml.filter_df(df, decoy_suffix='_SUF', **kw) self.assertEqual(fdf.shape, (1, 17)) + if __name__ == '__main__': unittest.main()