Skip to main content

fasta2png

CircleCI

This package includes two programs:

  • fna2png: generates PNG images from nucleic acid (na) / nucleotide sequences in FASTA format representing different nucleic acids with different colors.

  • faa2png: generates PNG images from amino acid (aa) / protein sequences in FASTA format representing different amino acids (codons) with different colors.

Both programs scan the file and generate an image containing solid squares (configurable size with --pixel-size) for each nucleotide bases or for each amino acids (codons) from top-left to bottom-right. The aspect ratio of the PNG is configurable (with --aspect-ratio). The PNG image is in RGBA format.

For nucleotide sequences, A, C, G, T is painted using different colors (U is same as T), and all other codes (N and others) are painted with white. The background of the image (meaning the remaining area in the image) is painted with black. These colors are also configurable.

For protein sequences, each amino acid/codon is painted using a different color. The gap (-) is painted as same as background. Only the background color is configurable, because there are so many (27) codes.

For nucleotide sequences, multi-FASTA format accepted and either a single image containing the (sequentially) combined sequence or one image for each sequence is generated. This is controlled with --multi-mode option.

For protein sequqnces, multi-FASTA format is not supported at the moment, an image only for the first sequence will be generated. If you require this feature, please create an issue.

Installation

pip install fasta2png

multi-FASTA format options

For fna files, --multi-mode can be set to:

  • f or first: only processes the first sequence (ignores the multi-FASTA format)
  • c or combined: creates a single image containing all sequences combined
  • s or separate: creates one image for each sequence

output options

For fna files, --output is optional. If it is not given, the name/identifier in the file is used as the output file name (with .png suffix automatically added).

If a multi-FASTA file is given with --multi-mode=s:

  • if --output is given, it is used as a prefix, and file names are formed as <prefix><seqnum>.png, and <seqnum> starts from 1.

  • if --output is not given, the name/identifier of the sequence is used and only .png is added.

Example: fna2png

NC_045512.2 is the SARS-CoV-2 (corona virus 2) complete genome sequenced by Chinese researchers in January 2020.

NC_045512.2.fna file below is https://www.ncbi.nlm.nih.gov/nuccore/NC_045512.2?report=fasta&log$=seqview&format=text.

$ fna2png --input NC_045512.2.fna --output NC_045512.2.png --pixel-size 8 --aspect-ratio 3 2

seqdesc: NC_045512.2 Severe acute respiratory syndrome coronavirus 2 isolate Wuhan-Hu-1, complete genome
seqlen: 29903

NC_045512.2.fna.png

Example: faa2png

This example is using the same SARS-CoV-2 sequence, but taking the sequence of the protein encoded by the first gene in its genome called ORF1ab.

YP_009724389.1.faa file below is https://www.ncbi.nlm.nih.gov/protein/YP_009724389.1?report=fasta&log$=seqview&format=text.

$ faa2png --input YP_009724389.1.faa --output YP_009724389.1.faa.png --pixel-size 4 --aspect-ratio 3 2

seqdesc: YP_009724389.1 orf1ab polyprotein [Severe acute respiratory syndrome coronavirus 2]
seqlen: 7096

YP_009724389.1.faa.png

Changes

  • v8: Pillow updated to 9.3.0. multi-FASTA format supported for fna files.
  • v7: Pillow updated to 9.1.1, CI config updated.
  • v6: Pillow updated to 9.0.1.
  • v5: Pillow updated to 8.2.0.
  • v4: dont use.
  • v3: Pillow updated to v8.0.1.

Metadata

Release files for fasta2png 8

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

Source distribution (sdist)

Source distribution for fasta2png 8
File Size Uploaded Provenance Actions
fasta2png-8.tar.gz 17.7 kB Without provenance Details for fasta2png-8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fasta2png 8
File Interpreter ABI Platform Actions
fasta2png-8-py3-none-any.whl Python 3 none any Details for fasta2png-8-py3-none-any.whl

Total release size: 36.6 kB

Release files / fasta2png-8.tar.gz

Download URL fasta2png-8.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
85c14409b1f738c7caefa468bd64f9fffdaa20ff82a4e8987bc2dbf8837a59b3
BLAKE2b-256 checksum
How to use checksums
fb7905c746e00456acfd68975741b4be3c15c8fe5497d55f82f22ed80bc5a3c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / fasta2png-8-py3-none-any.whl

Download URL fasta2png-8-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31f6d4eeaa0a897e17fd1654d1dfe3cbeea69ee8ea7b0319728e1f3a910f22b5
BLAKE2b-256 checksum
How to use checksums
27c72b5c9421b43a746867495fd2edba127cefe890b7f72b84a6e12100eca821
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for fasta2png 8

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