Giter VIP home page Giter VIP logo

bioc's Introduction

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.

bioc's People

Contributors

dependabot[bot] avatar jakelever avatar mart1nro avatar mevol avatar yfpeng avatar

Watchers

 avatar

Forkers

mevol

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.