-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5da7b3d
commit 40c6dd5
Showing
24 changed files
with
6,037 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,57 @@ | ||
********** | ||
Python API | ||
********** | ||
---------- | ||
|
||
.. automodule:: mzspeclib | ||
:members: | ||
|
||
Spectrum Libraries | ||
================== | ||
|
||
.. autoclass:: SpectrumLibrary | ||
|
||
Library Spectra | ||
================ | ||
|
||
.. autoclass:: Spectrum | ||
|
||
|
||
Components of Spectra | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. autoclass:: Analyte | ||
|
||
.. autoclass:: InterpretationCollection | ||
|
||
.. autoclass:: Interpretation | ||
|
||
.. autoclass:: InterpretationMember | ||
|
||
|
||
Controlled Vocabulary Attributes | ||
================================ | ||
|
||
.. automodule:: mzspeclib.attributes | ||
:members: Attribute, AttributeManager, AttributedEntity | ||
|
||
|
||
Indexing | ||
======== | ||
|
||
.. automodule:: mzspeclib.index | ||
:members: | ||
:imported-members: | ||
|
||
Backends | ||
======== | ||
|
||
.. automodule:: mzspeclib.backends | ||
:members: | ||
:imported-members: | ||
:exclude-members: BlibIndex, EncyclopediaIndex | ||
|
||
Validation | ||
========== | ||
|
||
.. automodule:: mzspeclib.validate | ||
:members: | ||
:imported-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from mzspeclib import SpectrumLibrary | ||
|
||
# Open a spectrum library | ||
lib = SpectrumLibrary(filename="examples/fetal_brain_tiny.mzlib.txt") | ||
print(lib) | ||
|
||
# Get the number of spectra in the library | ||
n_spectra = len(lib) | ||
print(n_spectra) | ||
|
||
# Get a specific spectrum from the library | ||
spec = lib.get_spectrum(spectrum_number=3) | ||
print(f"Key={spec.key}; Name={spec.name}; Num Peaks={len(spec.peak_list)}") | ||
print(spec.get_interpretation('1')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import logging | ||
import sys | ||
|
||
from typing import List, DefaultDict | ||
|
||
from mzspeclib import SpectrumLibrary | ||
from mzspeclib.validate import * | ||
|
||
logging.basicConfig(level=logging.DEBUG, stream=sys.stderr) | ||
logger = logging.getLogger() | ||
|
||
library = SpectrumLibrary(filename="examples/fetal_brain_tiny.mzlib.txt") | ||
|
||
chain = load_default_validator() | ||
chain.validate_library(library) | ||
|
||
by_level: DefaultDict[RequirementLevel, List[ValidationError]] = DefaultDict(list) | ||
for message in chain.error_log: | ||
by_level[message.requirement_level].append(message) | ||
|
||
for level, bucket in sorted(by_level.items()): | ||
log_level = logging.WARN | ||
if level == RequirementLevel.may: | ||
log_level = logging.DEBUG | ||
logger.log(log_level, f"Found {len(bucket)} violations for {level.name.upper()} rules") | ||
for err in bucket: | ||
logger.log(log_level, f"... {err.message}") |
Oops, something went wrong.