Skip to main content

bioc - Processing BioC, Brat, and PubTator with Python

Build status Latest version on PyPI Downloads License codecov

BioC XML / JSON format can be used to share text documents and annotations.

Brat standoff format is created by the brat annotation tool to store annotations on disk in a standoff format. annotations are stored separately from the annotated document text, which is never modified by the tool.

PubTator format is created by the PutTator Central system.

bioc exposes an API familiar to users of the standard library marshal and pickle modules.

Development of bioc happens on GitHub: https://github.com/bionlplab/bioc

Getting started

Installing bioc

$ pip install bioc

BioC

Encoding the BioC collection object collection:

from bioc import biocxml
# Serialize ``collection`` as a BioC formatted stream to ``fp``.
with open(filename, 'w') as fp:
    biocxml.dump(collection, fp)

Decoding the BioC XML file:

from bioc import biocxml
# Deserialize ``fp`` to a BioC collection object.
with open(filename, 'r') as fp:
    collection = biocxml.load(fp)

Brat

Encoding the Brat document

from bioc import brat
# Serialize ``doc`` as a brat formatted stream to ``text_fp`` and ``ann_fp``.
with open(annpath, 'w') as ann_fp, open(txtpath, 'w') as text_fp:
    brat.dump(doc, text_fp, ann_fp)

Decoding the Brat document:

from bioc import brat
# Deserialize two streams (text and ann) to a Brat document object.
with open(annpath) as ann_fp, open(txtpath) as text_fp:
    doc = brat.load(text_fp, ann_fp)

PubTator

Encoding the PubTator document object doc:

from bioc import pubtator
# Serialize ``collection`` as a BioC formatted stream to ``fp``.
with open(filename, 'w') as fp:
    pubtator.dump([doc], fp)

Decoding the PubTator file

from bioc import pubtator
# Deserialize ``fp`` to a PubTator object.
with open(filename, 'r') as fp:
    docs = pubtator.load(fp)

Documentation

You will find complete documentation at our Read the Docs site.

Contributing

You can find information about contributing to bioc at our Contribution page.

Reference

If you use bioc in your research, please cite the following paper:

  • Comeau DC, Doğan RI, Ciccarese P, Cohen KB, Krallinger M, Leitner F, Lu Z, Peng Y, Rinaldi F, Torii M, Valencia V, Verspoor K, Wiegers TC, Wu CH, Wilbur WJ. BioC: a minimalist approach to interoperability for biomedical text processing. Database (Oxford). 2013;2013:bat064. doi: 10.1093/database/bat064. Print 2013. PMID: 24048470; PMCID: PMC3889917

Acknowledgment

This work is supported by the National Library of Medicine under Award No. 4R00LM013001.

License

Copyright BioNLP Lab at Weill Cornell Medicine, 2023.

Distributed under the terms of the MIT license, bioc is free and open source software.

Release files for bioc 2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bioc 2.1
File Size Uploaded
bioc-2.1.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bioc 2.1
File Interpreter ABI Platform
bioc-2.1-py3-none-any.whl Python 3 none any Details

Total release size: 61.3 kB

Release files / bioc-2.1.tar.gz

Download URL bioc-2.1.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7d9248198bdae291b0ebb218de2dc653c96d32a7eac2fa0ef4ed0c74ce45aaaa
BLAKE2b-256 checksum
How to use checksums
449b90086bbbffcf4aaa267a71e94f92eab1cfe4142198708129b8495e16c73f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / bioc-2.1-py3-none-any.whl

Download URL bioc-2.1-py3-none-any.whl
Size 33.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1730d26821330f9f625058841612d6cfb616efb906fc682297fe04dd5d9398a
BLAKE2b-256 checksum
How to use checksums
4b05ae6dcab59673e2d498c645903ded6c5d76f7d44920386285feb96c517b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

2.1 This release

2 release files

2.0

1 release file

1.3.7

1 release file

1.3.6

1 release file

1.3.5

1 release file

1.3.4

1 release file

1.3.3

1 release file

1.3.2

1 release file

1.3.1

1 release file

1.3

1 release file

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2

1 release file

1.0

1 release file

1.0.dev26

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page