Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/source/loading.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,25 @@ To load remote WebDatasets via HTTP, pass the URLs instead:
>>> dataset = load_dataset("webdataset", data_files={"train": urls}, split="train", streaming=True)
```

### GenBank

[GenBank](https://www.ncbi.nlm.nih.gov/genbank/) is a text-based format from NCBI for nucleotide and protein sequences together with their annotations. Files use the `.gb`, `.gbk`, or `.genbank` extension (optionally compressed), and each record's `FEATURES` section is decoded into structured objects.

To load GenBank files:

```py
>>> from datasets import load_dataset
>>> dataset = load_dataset("genbank", data_files="*.gb", split="train")
```

You can try it on a small example dataset of real NCBI records (one of them is gzipped to show that compressed files load transparently):

```py
>>> from datasets import load_dataset
>>> dataset = load_dataset("ermiaazarkhalili/datasets-genbank-test", data_files="*.gb*", split="train")
>>> dataset[0]["locus_name"], dataset[0]["organism"], dataset[0]["length"]
```

## Remote files

If you have remote files likely stored as a `csv`, `json`, `txt`, `parquet` or any supported format, the [`load_dataset`] function can load load them if you specify their remote paths:
Expand Down
5 changes: 5 additions & 0 deletions src/datasets/packaged_modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .conll import conll
from .csv import csv
from .eval import eval
from .genbank import genbank
from .hdf5 import hdf5
from .iceberg import iceberg
from .imagefolder import imagefolder
Expand Down Expand Up @@ -63,6 +64,7 @@ def _hash_python_lines(lines: list[str]) -> str:
"lance": (lance.__name__, _hash_python_lines(inspect.getsource(lance).splitlines())),
"tsfile": (tsfile.__name__, _hash_python_lines(inspect.getsource(tsfile).splitlines())),
"iceberg": (iceberg.__name__, _hash_python_lines(inspect.getsource(iceberg).splitlines())),
"genbank": (genbank.__name__, _hash_python_lines(inspect.getsource(genbank).splitlines())),
}

# get importable module names and hash for caching
Expand Down Expand Up @@ -99,6 +101,9 @@ def _hash_python_lines(lines: list[str]) -> str:
".eval": ("eval", {}),
".lance": ("lance", {}),
".tsfile": ("tsfile", {}),
".gb": ("genbank", {}),
".gbk": ("genbank", {}),
".genbank": ("genbank", {}),
}
_EXTENSION_TO_MODULE.update({ext: ("imagefolder", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ("imagefolder", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
Expand Down
Empty file.
Loading