Utilities for interactive work with pydna:
- Open DNA sequences in ApE or SnapGene.
- PCR primer list
- Restriction enzyme list
- Download and cache GenBank records and sequence regions.
Installation
Requires Python 3.12.7 or later but below 4.0.
pip install pydna-utils
Settings
Settings are stored in pydna_config.toml in the user configuration directory
chosen by platformdirs.
Normally:
~/.config/pydna_utils/pydna_config.tomlon Linux%LOCALAPPDATA%\pydna_utils\pydna_utils\pydna_config.tomlon Windows~/Library/Application Support/pydna_utils/pydna_config.tomlon MacOS
The recommended way to change settings is to open this file in your text editor and edit it directly:
from pydna_utils import open_config_file
open_config_file() # this opens the file in you default text editor
Set your email and the paths for the features you use:
pydna_email = "you@example.com"
pydna_primers = "/path/to/primers.fasta"
pydna_enzymes = "/path/to/enzymes.txt"
Set pydna_ape_cmd and pydna_snapgene_cmd to the commands that launch your
installed editors. The defaults contain machine-specific paths, so adjust them
before use. Restart your Python session after changing settings.
To display settings or open the default cache directory:
from pydna_utils import tabulate_settings, open_cache_folder
print(tabulate_settings())
Open a sequence in an editor
from pydna.dseqrecord import Dseqrecord
from pydna_utils.editor import ape, snapgene
sequence = Dseqrecord("GGATCC")
ape(sequence)
# snapgene(sequence)
Primer list
Set pydna_primers to a text file containing primers in a format pydna can
read, such as FASTA. Primers are loaded in reverse file order, so new primers
can be added at the top. List indices start at zero.
from pydna_utils.myprimers import PrimerList
primers = PrimerList()
primer = primers[0]
print(primer.format("fasta"))
# Generate code containing only the primers accessed in this session.
print(primers.code(primers.accessed))
Example primer list
>2_example_primer
GCTAGCTACGATCGATGCTA
>1_example_primer
CGATGTCGACTTAGATCTCAC
>0_example_primer
GATCGGCCGGATCCAAATGA
With this file, primers[0] returns 0_example_primer.
Shared restriction enzyme list
Set pydna_enzymes to a text file containing enzyme names recognized by
Biopython, separated by whitespace and or newlines, for example BamHI EcoRI HindIII.
from pydna_utils.myenzymes import myenzymes
print(myenzymes)
Example enzyme list
BamHI
EcoRI
HindIII
Cached GenBank access
Set pydna_email to your email address before downloading. Use an accession
including its version. Each call returns a fresh Dseqrecord.
from pydna_utils.genbank import genbank
record = genbank("CS570233.1")
fragment = genbank("CS570233.1", seq_start=3, seq_stop=7)
reverse = genbank("CS570233.1", seq_start=3, seq_stop=7, strand=2)
Coordinates are one-based and inclusive. Records are stored as GenBank files
in pydna_ncbi_cache_dir, normally ~/.cache/pydna_utils/ on Linux. Cached
records can serve requests for contained regions without another download.
Local slicing retains only features fully contained in the requested region.
Cached files do not expire or refresh automatically.
See GenBank cache details for cache behavior and how to refresh a record.
Metadata
Release files for pydna-utils 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydna_utils-0.0.7.tar.gz | 806.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydna_utils-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 822.6 kB
Release files / pydna_utils-0.0.7.tar.gz
| Download URL | pydna_utils-0.0.7.tar.gz |
|---|---|
| Size | 806.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6313524ee224f4c5f1ec6294fd956a8c47a863afc5ee6ac2075186738ec4afce
|
|
BLAKE2b-256 checksum How to use checksums |
fac6c2a1f27c829b025c937b7f8ab0d68c57b936cd555301ccc82f6827c4a039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pydna_utils-0.0.7-py3-none-any.whl
| Download URL | pydna_utils-0.0.7-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5f1a3b5c006f5dd108de768d3c55a02bade6b88af7b1db19ac8702024b10cfa
|
|
BLAKE2b-256 checksum How to use checksums |
0fea05a9a16ba395b696a97947e38dd5322e0ad4e49e3613a029bf6621777c8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|