Skip to main content

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)"

Metadata

Release files for gene-rule-parser 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gene-rule-parser 0.1.5
File Size Uploaded Provenance
gene_rule_parser-0.1.5.tar.gz 6.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gene-rule-parser 0.1.5
File Interpreter ABI Platform
gene_rule_parser-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / gene_rule_parser-0.1.5.tar.gz

Download URL gene_rule_parser-0.1.5.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3f49a9d827a1673f5b5a0d226ca62f63aa1fe90cd2d88fefd6b698f0a6e4d581
BLAKE2b-256 checksum
How to use checksums
d1ffd60df3448661076e61b5c37208252abad96f0c75ac4a222a7cc717328c41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-41-generic

Release files / gene_rule_parser-0.1.5-py3-none-any.whl

Download URL gene_rule_parser-0.1.5-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9e1f48740ffc1d54842010e0e8c0b5a8158b04d5b98c4a3aba0f19ff582ea63
BLAKE2b-256 checksum
How to use checksums
06d3c5f64cfd82924289b64ed28201bb474cb0c6d8ce7a42ade006162d1619f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-41-generic

Security for gene-rule-parser 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page