Skip to main content

Basic language to parse genetic rules to a structure

Project description

Gene Parser AST

A rule expression in genetics can be found like this relation of AND+OR:

rule = '(9045_AT1 and (B0783 and B0088)) or (3705_AT1 or (91012_AT1 and 55304_AT1))'

This module enables a a parser that convert an string expression that relates the genes in a object structure like this:

Or(
    left=And(left=Gene(name='9045_AT1'), right=And(left=Gene(name='B0783'), right=Gene(name='B0088'))),
    right=Or(
        left=Gene(name='3705_AT1'),
        right=And(left=Gene(name='91012_AT1'), right=Gene(name='55304_AT1'))
    )
)

To process this and obtain the representative value first is necessary use the parser method and then call tree_analysis. This last function reads recursively all the tree and obtain, given this rules, the final value:

  • or : sum([a,b])
  • and : min([a,b])

And, for UNKNOWN value:

  • Expression(UNKNOWN) :: mean([Expression(G_i)])

With this is possible to have the representative value for the gene rule expression.

Take a look on the examples on the tests directory.

How install this.

Call poetry

poetry install

Run the tests:

Basic example:

poetry run python tests/test_basic.py 

General Example:

poetry run python tests/test_parser_general.py 

Check then the parser.

Once installed you can check the for gene rule expressions using the command rule_parser.

rule_parser "1321A and 123123B and (123123B or 32312C)"

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

gene_rule_parser-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

gene_rule_parser-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file gene_rule_parser-0.1.0.tar.gz.

File metadata

  • Download URL: gene_rule_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-41-generic

File hashes

Hashes for gene_rule_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9587d4c566321bb59407a716e5133265f6e61bfab41bb82c0356da2b0be99229
MD5 1dd9c8b2a21f77cec1a7aa42f047047c
BLAKE2b-256 6d895d9a2958fb4c26e3a99c101d2a4ef6428def3d0514285ca51a7e800a7b9b

See more details on using hashes here.

File details

Details for the file gene_rule_parser-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gene_rule_parser-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-41-generic

File hashes

Hashes for gene_rule_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46d13927d0b3b9cf457c19b54c19c765943f10bf9151cc6406905ef3e329b28c
MD5 0594661a1036fa7fe64c7cdaa9aa54f0
BLAKE2b-256 037ea68e3779e3814c9391dc1c2916c0d31e8213362553f85d6f2bd8364a00f9

See more details on using hashes here.

Supported by

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