bioc - Processing BioC, Brat, and PubTator with Python.
Slowing down. Last release over 3 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install biocbioc - Processing BioC, Brat, and PubTator with Python
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)