GithubHelp home page GithubHelp logo

seljaseppala / bratify Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 20 KB

Bratify is a program that produces Brat-formatted class hierarchy and labels from an OWL file.

License: GNU General Public License v3.0

Python 100.00%

bratify's Introduction

Bratify

DOI

Bratify is a program that produces Brat-formatted class hierarchy and labels from an OWL file.

Running the program

Edit the following information in the run_bratify.py file (see example below).

Specify the paths to:

  • the input OWL file
  • the output file formatted for brat visual.conf
  • the output file formatted for brat annotation.conf

Specify the output format (1 or 2) of the labels for Brat's system and for visualization.conf.

1 = brat_syst_format | normal term format | ID

For example:

Matthew-Wood_syndrome | Matthew-Wood syndrome | DOID_0050819

2 = ID | normal term format

For example:

DOID_0050819 | Matthew-Wood syndrome

Specify the SPARQL query to get the labels and the PURLs for each class in the OWL file.

Run bratify.py for the specified ontology by adding a call to the function.

Example

def name_of_ontology():

    # Specify the paths to:
    # - the input OWL file
    # - the output file formatted for brat visual.conf
    # - the output file formatted for brat annotation.conf
    owl = "./path_to/owl_file.owl"
    visualization_path = "./for_configuration_files/labels_for_visualization.txt"
    annotation_path = "./for_configuration_files/hierarchy_for_annotation.txt"
        
    # Specify the output format of the labels for Brat's system and for visualization.conf
    # 1 = brat_syst_format | normal term format | ID 
    # 2 = ID | normal term format 
    output_style = "1"

    # Specify the SPARQL query to get the labels and the PURLs for each class in the OWL file
    query = """ SELECT DISTINCT ?child_label ?child_id ?parent_label ?parent_id
                WHERE {
                    ?child rdfs:subClassOf ?parent .
                    ?child a owl:Class .
                    ?parent a owl:Class .
                    ?child rdfs:label ?child_label .
                    ?parent rdfs:label ?parent_label .
                    ?child oboInOwl:id ?child_id .
                    ?parent oboInOwl:id ?parent_id .

                    FILTER ( ?parent != ?child )
                }
                #LIMIT 10
            """

    # Run bratify.py for the specified ontology
    run_bratify(owl, query, visualization_path, annotation_path, output_style)

if __name__ == '__main__':
    name_of_ontology()

Output examples

Hierarchy

DOID_4
    DOID_630
        DOID_0050177
            DOID_14793
            DOID_0050738
            DOID_0050739
                DOID_0050736
                    DOID_14213
                    DOID_9467
                    DOID_14702

Labels

DOID_0001816 | angiosarcoma
DOID_0002116 | pterygium
DOID_0014667 | disease of metabolism
DOID_0050004 | seminal vesicle acute gonorrhea
DOID_0050012 | chikungunya
DOID_0050013 | carbohydrate metabolism disease
DOID_0050025 | human granulocytic anaplasmosis
DOID_0050026 | human monocytic ehrlichiosis
DOID_0050032 | mineral metabolism disease
DOID_0050035 | African tick-bite fever    

bratify's People

Contributors

seljaseppala avatar

Watchers

 avatar

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.