This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

BioC data structures and encoder/decoder for Python

Project Description

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

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

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

Getting started

Installing bioc

$ pip install --pre bioc

Encoding the BioC collection object collection:

import bioc
# Serialize ``collection`` to a BioC formatted ``str``.
bioc.dumps(collection)

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

Compact encoding:

import bioc
bioc.dumps(collection, pretty_print=False)

Incremental BioC serialisation:

import bioc
with bioc.iterwrite(filename, collection) as writer:
    for document in collection.documents:
        writer.writedocument(document)

Decoding the BioC XML file:

import json
# Deserialize ``s`` to a BioC collection object.
collection = json.loads(s)

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

Incrementally decoding the BioC XML file:

import bioc
with bioc.iterparse(filename) as parser:
    collection_info = parser.get_collection_info()
    for document in parser:
        # process document
        ...

get_collection_info can be called after the construction of the iterparse anytime.

Together with Python coroutines, this can be used to generate BioC XML in an asynchronous, non-blocking fashion.

import bioc
with bioc.iterparse(filename) as parser:
    with bioc.iterwrite(dst, parser.get_collection_info()) as writer:
        for document in parser:
            # modify the document
            ...
            writer.writedocument(document)

Requirements

Developers

Acknowledgment

Webpage

The official BioC webpage is available with all up-to-date instructions, code, and corpora in the BioC format, and other research on, based on and related to BioC.

Reference

  • Comeau,D.C., Doğan,R.I., Ciccarese,P., Cohen,K.B., Krallinger,M., Leitner,F., Lu,Z., Peng,Y., Rinaldi,F., Torii,M., Valencia,V., Verspoor,K., Wiegers,T.C., Wu,C.H., Wilbur,W.J. (2013) BioC: A minimalist approach to interoperability for biomedical text processing. Database: The Journal of Biological Databases and Curation.
  • Peng,Y., Tudor,C., Torii,M., Wu,C.H., Vijay-Shanker,K. (2014) iSimp in BioC standard format: Enhancing the interoperability of a sentence simplification system. Database: The Journal of Biological Databases and Curation.
  • Marques,M., Rinaldi,F. (2012) PyBioC: a python implementation of the BioC core. In Proceedings of BioCreative IV workshop.
Release History

Release History

This version
History Node

1.0

History Node

1.0.dev32

History Node

1.0.dev31

History Node

1.0.dev30

History Node

1.0.dev29

History Node

1.0.dev28

History Node

1.0.dev27

History Node

1.0.dev26

History Node

1.0.dev25

History Node

1.0.dev24

History Node

1.0.dev23

History Node

1.0.dev22

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
bioc-1.0-py2.py3-none-any.whl (13.7 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel May 9, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting