Skip to main content

DNA: a domain-specific language (transcription between UTF-8 text and DNA bases) based on YAML.

Project description

logo

DNA

GitHub Actions Workflow Status GitHub last commit PyPI - Python Version PyPI - Version PyPI - Wheel PyPI - Downloads GitHub License

A domain-specific language (transcription between UTF-8 text and DNA bases) based on YAML.

Transcoding

Please refer to coding.py:

DNA_TO_BIN = {
    "A": "00",
    "C": "01",
    "G": "10",
    "T": "11"
}

BIN_TO_DNA = {
    v: k
    for k, v in DNA_TO_BIN.items()
}

DNA_COMPLEMENT = {
    "A": "T",
    "T": "A",
    "C": "G",
    "G": "C"
}

Installation

DNA can be installed from PyPI:

pip install dnadsl

or download the repository and run:

pip install .

as of the repository root folder.

Usage

Run dna --help for help:

$ dna --help
usage: dna [-h] [-m {encode,decode}] [-i INPUT_FILE] [-o OUTPUT_FILE] [-v]

+--------------------------------------------------+
|                        DNA                       |
|            A domain-specific language            |
| (transcription between UTF-8 text and DNA bases) |
|                  based on YAML.                  |
+--------------------------------------------------+

options:
  -h, --help            show this help message and exit
  -m {encode,decode}, --mode {encode,decode}
                        Choose the mode of transcoding.
                        encode: UTF-8 to bases; decode: bases to UTF-8.
                        The default is: encode
  -i INPUT_FILE, --input-file INPUT_FILE
                        The path of the input YAML file.
  -o OUTPUT_FILE, --output-file OUTPUT_FILE
                        The path of the output YAML file.
  -v, --version         Print the version number of dna and exit.

Examples

  • The input UTF-8 text:

    text_utf8: 😄😊
    
  • The output DNA bases:

    text_utf8: 😄😊
    dna:
    positive_strand:
        sequence: TTAAGCTTGCGAGACATTAAGCTTGCGAGAGG
        binary: 11110000 10011111 10011000 10000100 11110000 10011111 10011000 10001010
        text: 😄😊
    negative_strand:
        sequence: AATTCGAACGCTCTGTAATTCGAACGCTCTCC
        binary: 00001111 01100000 01100111 01111011 00001111 01100000 01100111 01110101
        text: "\x0F`g{\x0F`gu"
    
  • The input DNA bases:

    positive_strand: TGAGGCTCGGCATGTTGTGAGATTTTAAGCTTGCAAGTCG
    
  • The output UTF-8 text:

    text_utf8: ❤️🐶
    dna:
    positive_strand:
        sequence: TGAGGCTCGGCATGTTGTGAGATTTTAAGCTTGCAAGTCG
        binary: 11100010 10011101 10100100 11101111 10111000 10001111 11110000 10011111
        10010000 10110110
        text: ❤️🐶
    negative_strand:
        sequence: ACTCCGAGCCGTACAACACTCTAAAATTCGAACGTTCAGC
        binary: 00011101 01100010 01011011 00010000 01000111 01110000 00001111 01100000
        01101111 01001001
        text: "\x1Db[\x10Gp\x0F`oI"
    

Packaging

The binaries are created with PyInstaller:

# Package it on Linux
pyinstaller --name DNA --onefile -p dna dna/__main__.py

# Package it on Windows
pyinstaller --name DNA --onefile --icon python.ico -p dna dna/__main__.py

Copyrights

DNA is a free, open-source software package (distributed under the GPLv3 license). The logo used in README.md is downloaded from Wikimedia Commons. The Python icon is downloaded from python.ico.

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

dnadsl-0.3.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dnadsl-0.3.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file dnadsl-0.3.0.tar.gz.

File metadata

  • Download URL: dnadsl-0.3.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dnadsl-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a1704e3b27821db77b9920f68d84607fe5afbaab78fdac460ddd822062992df2
MD5 699038f8084746cc348a900972785d08
BLAKE2b-256 c9d7a1aff459bce77586d32fbce07fd632b8ad3a1499ccfcad3328ec148cfdfd

See more details on using hashes here.

Provenance

The following attestation bundles were made for dnadsl-0.3.0.tar.gz:

Publisher: python-publish.yml on project-aico/dna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dnadsl-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: dnadsl-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dnadsl-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f9c8336281a61a692efe6de959881163f9c9e790e3cdecb1804019216bf886
MD5 7e259e11999c66ac3613eac3afe331d9
BLAKE2b-256 ec0c3271fbb3b83d96421be61821c9838c8cd155bbc10ef9acbb02e33959cbc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for dnadsl-0.3.0-py3-none-any.whl:

Publisher: python-publish.yml on project-aico/dna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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