Skip to main content

bioc - Processing BioC, Brat, and PubTator with Python

Project description

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, 2022.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bioc-2.0.post3.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bioc-2.0.post3-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

Details for the file bioc-2.0.post3.tar.gz.

File metadata

  • Download URL: bioc-2.0.post3.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.49.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.3

File hashes

Hashes for bioc-2.0.post3.tar.gz
Algorithm Hash digest
SHA256 7e1c70d5520cc7adc425bfcc8b32a0b0ee798f7e4eb71a2173e8fc8e17adb687
MD5 871ac977ebac50649adeff06e2ea4f55
BLAKE2b-256 51db8d3308030b95155753b0c379c98f7c09eba1e092dc6c572ed55775f0e0ec

See more details on using hashes here.

File details

Details for the file bioc-2.0.post3-py3-none-any.whl.

File metadata

  • Download URL: bioc-2.0.post3-py3-none-any.whl
  • Upload date:
  • Size: 37.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.49.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.3

File hashes

Hashes for bioc-2.0.post3-py3-none-any.whl
Algorithm Hash digest
SHA256 0b27e987f96ce3df551868ec9e18f22932b8a68857fb3de01c72f09dad9fbe88
MD5 2acefef4cf4295c3f76d4efca7ae91ed
BLAKE2b-256 02db87fd208d7658c4458a9f3651baa6e307b741ec1dcf74090511f19344cf75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page