Skip to content

Commit

Permalink
Version 0.1.47
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed Apr 25, 2022
1 parent 5ca51af commit 8611787
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 35 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog][Keep a Changelog] and this project adheres to [Semantic Versioning][Semantic Versioning].

## [v0.1.47] - 2022-04-25

| Name | Version | Checksum |
| :---: | :---: | :---: |
| XLMOD.obo.gz | release/2019-10-28 | 4e577044551d277e4bbd62753fa15e08 |
| gno.obo.gz | 2022-02-23 | a397dc95d8d809acea44209818a0f77f |
| go.obo.gz | releases/2022-03-22 | b24ea119f8b86d8ab7c680ec23047f56 |
| pato.obo.gz | releases/2019-09-05 | 443de10a418cba2b0a6f4a9c3b73c60c |
| psi-mod.obo.gz | - | 921a87531252fbb49b73c92e0b201ab2 |
| psi-ms.obo.gz | 4.1.84 | ace0024e6845eec1d375b6e81a3e90e0 |
| unimod_tables.xml.gz | - | 523d0bb41eeb41bb1554fa405915e310 |
| unit.obo.gz | releases/2020-03-10 | 4e45267605698d1fcda533c27853a8fc |

### Added
1. Added an option to test if the environment variable `PSIMS_NO_PYNUMPRESS` to prevent loading the `pynumpress`
C extension library.


## [v0.1.46] - 2022-03-02

### CV Versions
Expand Down Expand Up @@ -158,8 +176,9 @@ The format is based on [Keep a Changelog][Keep a Changelog] and this project adh
[Semantic Versioning]: https://semver.org/

<!-- Versions -->
[Unreleased]: https://github.com/mobiusklein/psims/compare/v0.1.46...HEAD
[Unreleased]: https://github.com/mobiusklein/psims/compare/v0.1.47...HEAD
[Released]: https://github.com/mobiusklein/psims/releases
[v0.1.47]: https://github.com/mobiusklein/psims/releases/v0.1.47
[v0.1.46]: https://github.com/mobiusklein/psims/releases/v0.1.46
[v0.1.44]: https://github.com/mobiusklein/psims/releases/v0.1.44
[v0.1.43]: https://github.com/mobiusklein/psims/releases/v0.1.43
Expand Down
8 changes: 7 additions & 1 deletion psims/controlled_vocabulary/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def format(self, value):
return str(value)


class KeyOrAttributeError(KeyError, AttributeError):
pass


class Entity(Mapping):
'''Represent a term in a controlled vocabulary.
Expand Down Expand Up @@ -106,7 +109,10 @@ def __setitem__(self, key, value):
self.data[key] = value

def __getattr__(self, key):
return self[key]
try:
return self[key]
except KeyError:
raise KeyOrAttributeError(key) from None

def __setattr__(self, key, value):
if key in ("vocabulary", "children", "data"):
Expand Down
Binary file modified psims/controlled_vocabulary/vendor/XLMOD.obo.gz
Binary file not shown.
Binary file modified psims/controlled_vocabulary/vendor/gno.obo.gz
Binary file not shown.
Binary file modified psims/controlled_vocabulary/vendor/go.obo.gz
Binary file not shown.
Binary file modified psims/controlled_vocabulary/vendor/pato.obo.gz
Binary file not shown.
Binary file modified psims/controlled_vocabulary/vendor/psi-mod.obo.gz
Binary file not shown.
Binary file modified psims/controlled_vocabulary/vendor/psi-ms.obo.gz
Binary file not shown.
34 changes: 17 additions & 17 deletions psims/controlled_vocabulary/vendor/record.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"XLMOD.obo.gz": {
"checksum": "4e577044551d277e4bbd62753fa15e08",
"checksum": "4e577044551d277e4bbd62753fa15e08",
"version": "release/2019-10-28"
},
},
"gno.obo.gz": {
"checksum": "a397dc95d8d809acea44209818a0f77f",
"checksum": "a397dc95d8d809acea44209818a0f77f",
"version": "2022-02-23"
},
},
"go.obo.gz": {
"checksum": "122d68f6cf380a8cbb1abb4a74624416",
"version": "releases/2022-01-13"
},
"checksum": "b24ea119f8b86d8ab7c680ec23047f56",
"version": "releases/2022-03-22"
},
"pato.obo.gz": {
"checksum": "443de10a418cba2b0a6f4a9c3b73c60c",
"checksum": "443de10a418cba2b0a6f4a9c3b73c60c",
"version": "releases/2019-09-05"
},
},
"psi-mod.obo.gz": {
"checksum": "921a87531252fbb49b73c92e0b201ab2",
"checksum": "921a87531252fbb49b73c92e0b201ab2",
"version": null
},
},
"psi-ms.obo.gz": {
"checksum": "593ed9190e0d657b0eb249efc9a12e77",
"version": "4.1.72"
},
"checksum": "ace0024e6845eec1d375b6e81a3e90e0",
"version": "4.1.84"
},
"unimod_tables.xml.gz": {
"checksum": "61ac665064dd806b536c609fcb775920",
"checksum": "523d0bb41eeb41bb1554fa405915e310",
"version": null
},
},
"unit.obo.gz": {
"checksum": "4e45267605698d1fcda533c27853a8fc",
"checksum": "4e45267605698d1fcda533c27853a8fc",
"version": "releases/2020-03-10"
}
}
Binary file modified psims/controlled_vocabulary/vendor/unimod_tables.xml.gz
Binary file not shown.
Binary file modified psims/controlled_vocabulary/vendor/unit.obo.gz
Binary file not shown.
6 changes: 5 additions & 1 deletion psims/mzml/binary_encoding.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import base64
import zlib

Expand All @@ -12,7 +13,10 @@


try:
import pynumpress
if os.environ.get("PSIMS_NO_PYNUMPRESS"):
pynumpress = False
else:
import pynumpress
except ImportError:
pynumpress = None

Expand Down
30 changes: 18 additions & 12 deletions psims/mzml/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@
import numbers
import warnings

from collections import defaultdict
from typing import List, Optional, Dict, Tuple, Mapping, Iterable, BinaryIO, TypedDict, Union, DefaultDict

try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
from collections import defaultdict

import numpy as np

from psims.xml import XMLWriterMixin, XMLDocumentWriter
from psims.xml import CVParam, XMLWriterMixin, XMLDocumentWriter
from psims.utils import TableStateMachine

from .components import (
ComponentDispatcher, element,
ComponentDispatcher, Software, Spectrum, element,
default_cv_list, MzML, InstrumentConfiguration, IndexedMzML)

from .binary_encoding import (
Expand Down Expand Up @@ -85,6 +82,14 @@
]


class ArrayTypeSpec(TypedDict):
name: str
unit: Union[Mapping[str, str], CVParam]


ArrayType = Union[str, ArrayTypeSpec]


class DocumentSection(ComponentDispatcher, XMLWriterMixin):

def __init__(self, section, writer, parent_context, section_args=None, **kwargs):
Expand Down Expand Up @@ -268,7 +273,7 @@ def controlled_vocabularies(self):
self.state_machine.transition("controlled_vocabularies")
super(PlainMzMLWriter, self).controlled_vocabularies()

def software_list(self, software_list):
def software_list(self, software_list: Iterable[Union[Software, Mapping]]):
"""Writes the ``<softwareList>`` section of the document.
.. note::
Expand Down Expand Up @@ -465,11 +470,12 @@ def chromatogram_list(self, count, data_processing_method=None):
self.writer, self.context, count=count,
data_processing_method=data_processing_method)

def spectrum(self, mz_array=None, intensity_array=None, charge_array=None, id=None,
def spectrum(self, mz_array: Optional[np.ndarray] = None, intensity_array: Optional[np.ndarray] = None,
charge_array: Optional[np.ndarray] = None, id: Optional[str] = None,
polarity='positive scan', centroided=True, precursor_information=None,
scan_start_time=None, params=None, compression=COMPRESSION_ZLIB,
encoding=None, other_arrays=None, scan_params=None, scan_window_list=None,
instrument_configuration_id=None, intensity_unit=DEFAULT_INTENSITY_UNIT):
instrument_configuration_id=None, intensity_unit=DEFAULT_INTENSITY_UNIT) -> Spectrum:
'''Create a new :class:`~.Spectrum` instance to be written.
This method does not immediately write and close the spectrum element, leaving it
Expand Down Expand Up @@ -546,11 +552,11 @@ def spectrum(self, mz_array=None, intensity_array=None, charge_array=None, id=No
scan_window_list = list(scan_window_list)

if isinstance(encoding, Mapping):
encoding = defaultdict(lambda: np.float32, encoding)
encoding = DefaultDict(lambda: np.float32, encoding)
else:
# create new variable to capture in closure
_encoding = encoding
encoding = defaultdict(lambda: _encoding)
encoding = DefaultDict(lambda: _encoding)
if polarity is not None:
if isinstance(polarity, int):
if polarity > 0:
Expand Down
4 changes: 1 addition & 3 deletions psims/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
version = '0.1.47'

checkout = "$Id$".replace("Id:", '').replace("$", '').strip()
version = '0.1.47'

0 comments on commit 8611787

Please sign in to comment.