API Reference¶
Auto-generated reference for the public API, rendered by mkdocstrings.
For task-oriented examples see the Usage guide.
Package¶
A unified dataset framework for mass spectrometry.
DatasetNotFoundError
¶
Bases: Exception
Raised when the server returns 404 for a dataset.
DownloadError
¶
Bases: Exception
Raised on network or server failures during download.
ExtractionError
¶
Bases: DownloadError
Raised when a server-side extraction task fails.
Dataset
dataclass
¶
Result object returned by load_dataset.
Supports len(), indexing, and iteration over downloaded file paths.
RepoSource
¶
Bases: str, Enum
Supported repository sources for dataset imports.
download_dataset
¶
download_dataset(dataset_id: str, *, force_download: bool = False, show_progress: bool = True, max_workers: int = 4, filenames: list[str] | None = None, store_as: StoreFormat = 'mszx', output_dir: Path | None = None) -> Dataset
Download a dataset and return a Dataset pointing to local files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
Server-side dataset identifier (UUID). |
required |
force_download
|
bool
|
Re-download parts even if they already exist on disk. |
False
|
show_progress
|
bool
|
Show a |
True
|
max_workers
|
int
|
Maximum number of parallel downloads. |
4
|
filenames
|
list[str] | None
|
Optional list of filenames to include. When provided, the server returns a manifest containing only matching parts. |
None
|
store_as
|
StoreFormat
|
On-disk format for downloaded parts. Defaults to |
'mszx'
|
output_dir
|
Path | None
|
Optional destination directory. When set, files are written
directly here (no |
None
|
Source code in src/msdatasets/download.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
download_repo_dataset
¶
download_repo_dataset(source: RepoSource | str, accession: str, *, filenames: list[str] | None = None, force_download: bool = False, show_progress: bool = True, max_workers: int = 4, store_as: StoreFormat = 'mszx', output_dir: Path | None = None) -> Dataset
Trigger a repository import and download the resulting dataset.
Posts to /repositories/{source}/projects/{accession}/dataset to create
a dataset from a PRIDE or MassIVE project. The endpoint is
idempotent—calling it for an already-imported project returns the
existing dataset and job statuses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
RepoSource | str
|
Repository source ( |
required |
accession
|
str
|
Project accession (e.g. |
required |
filenames
|
list[str] | None
|
Optional list of specific filenames to import. When None, all files in the project are imported. |
None
|
force_download
|
bool
|
Re-download parts even if they already exist on disk. |
False
|
show_progress
|
bool
|
Show a |
True
|
max_workers
|
int
|
Maximum number of parallel downloads. |
4
|
store_as
|
StoreFormat
|
On-disk format for downloaded parts. See |
'mszx'
|
output_dir
|
Path | None
|
Optional destination directory. See |
None
|
Source code in src/msdatasets/download.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
load_dataset
¶
load_dataset(dataset_id: str, *, force_download: bool = False, show_progress: bool = True, max_workers: int = 4) -> MSCompressDataset
Download a dataset and return an MSCompressDataset.
Convenience wrapper around download_dataset that loads the
downloaded files into an mscompress.datasets.torch.MSCompressDataset
ready for iteration. Requires PyTorch to be installed.
If dataset_id matches the pattern {source}/<accession> (e.g.
pride/PXD075509 or massive/MSV000078787), the repository import
flow is used instead. A specific filename subset may be specified in
square brackets: pride/PXD000001[file1.raw,file2.mzML].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
Server-side dataset identifier, or a repository specifier like
|
required |
force_download
|
bool
|
Re-download parts even if they already exist on disk. |
False
|
show_progress
|
bool
|
Show a |
True
|
max_workers
|
int
|
Maximum number of parallel downloads. |
4
|
Source code in src/msdatasets/download.py
load_repo_dataset
¶
load_repo_dataset(source: RepoSource | str, accession: str, *, filenames: list[str] | None = None, force_download: bool = False, show_progress: bool = True, max_workers: int = 4) -> MSCompressDataset
Trigger a repository import and return an MSCompressDataset once ready.
Convenience wrapper around download_repo_dataset that loads the
downloaded files into an mscompress.datasets.torch.MSCompressDataset.
Requires PyTorch to be installed.
Source code in src/msdatasets/download.py
Configuration¶
msdatasets.config
¶
Configuration: paths, URLs, and environment variables.
get_api_url
¶
Return the base API URL.
Resolution: MS_API_URL env var, or the default production URL.
get_cache_dir
¶
Return the root cache directory for downloaded datasets.
Resolution order:
1. MS_DATASETS_CACHE env var
2. MS_HOME env var + /datasets
3. ~/.ms/datasets