This release is a pre-release and may not be stable for production use.
beastify: Generate input file for BEAST from whole-genome alignmennt
Background
Sometimes you want to partiion your alignment in to distinct codon positions (i.e., 1, 2, and 3), and you want to also model non-coding positions in your BEAST analysis.
beastify does that for you. It will:
- Figure out all the codon positions in your reference (including overlapping positions)
- Optionally, label your sequences with any metadata (e.g., dates)
- Optionally, allows you to remove one or more positions from the alignment
- Optionally, allows you to mask positions form the alignment
- Optionally, allows you to sub-sample the alignment (if you want to work on a smaller dataset to test your models before throwing the whole kitchen at BEAST).
- Output a NEXUS files with the partitions ready for running BEAUTi.
Partitions are labelled:
- For the first codon position
- For the second codon position
- For the third codon position
- For any overlapping codons (sometimes CDS annotations overlap because sometimes bacterial genes will share codons)
- If position is not found in a CDS.
Installation
Dependencies
- Python >=3.6
- Click
- Pandas
- Numpy
- BioPython
Using pip
pip3 install beastify
Testing your installation
beastify --test
Input
- Genbank reference
snippy*.consensus.subs.fa files- List of genes to include in the final alignment
- N (optional) --- random number of genes to select and include
Command list
--out TEXT Outfile name (default: out.nexus)
--info TEXT Path to a tab-delimited file with two or more
columns. The first column has the isolate ID, and
other columns have dates, location, etc. The
information will be added to the isolate ID in the
same order as the columns
--inc_ref Whether to include the reference in the final out
file (default: False)
--aln_file TEXT A sequence alignment file to give in lieu of
folder with snippy output.
--aln_file_format TEXT If providing an alignment file with --aln_file,
set the format of the alignment. Any format
supported by BioPython:AlignIO could be valid.
Default: fasta. Tested: fasta.
--subsample INTEGER Subsample X number of bases at random from each
partition. default: all bases
--subsample_seed INTEGER Set the seed when subsampling sites. Default:42
--parts TEXT Comma-separated list of partitions to include.
default:1,2,3,4,5
--test Run beastify tests and exit
--mask TEXT A BED file indicating regions to mask from the
genome
--version Show the version and exit.
--help Show this message and exit.
Output
A nexus formatted file ready for beast.
Script outline
- Parse coordinates of genes from Genbank into a
GenesClass- Methods:
- load_features: a method to load the Genbank features into a dictionary. Method should check that there the length is a multiple of 3, and that the start and end codons are in place. stop codon should be stripped.
- parse_snippycore: a method to load the snippy core.tab data and identify all variable SNPs among the data that are in coding regions --- has options to return a 'random' sample of size N genes, 'top' genes with the most SNPs, with the N top genes with most SNPs.
- Data:
- features: a dictionary with key = genename and value set by seqFeature object --- IF N is provided, only keep a random set of genecoords of size _N
- Methods:
- Load
snippyalignment into anIsolateClass- Methods:
- load_fasta: will load the sequence into the object
- cat_genes: given an isolate id, and a genes object, return a concatenated sequence (NOT IMPLEMENTED YET)
- get_gene: return a string with the sequence for the gene specified
by gene_id using a
Genesobject - str: print the sequence ID and length, if there is one
- getitem: return the sequence string associated with the key
- add_dates: the user supplies a table of isolate IDs, and dates in a format suitable for BEAST, and the script adds them to the identifier
- Data:
- seq: A SeqRecord
- id: The isolate id
- genes: a dictionary with 'gene_name' as keys and sequence string as value
- Methods:
Collectionclass to store all theIsolateobjects- Methods:
- load_isolates: given a list of isolate files, creates
and stores individual
Isolateobjects for each. - gen_align: given a
Genesobject, generate the alignment --- usescat_genes - getitem: given an isolate ID as a key, return the
Isolateobject
- load_isolates: given a list of isolate files, creates
and stores individual
- Data:
- isolates: a dictionary with isolate id as keys and
Isolateobjects as values
- isolates: a dictionary with isolate id as keys and
- Methods:
Metadata
Release files for beastify 0.2.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| beastify-0.2.0a0.tar.gz | 601.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beastify-0.2.0a0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.2 MB
Release files / beastify-0.2.0a0.tar.gz
| Download URL | beastify-0.2.0a0.tar.gz |
|---|---|
| Size | 601.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f39e6fe7155a4811b9f68f96a3da168aecd3936c80e5417b6e68f9f928dd701d
|
|
BLAKE2b-256 checksum How to use checksums |
40e09758280d8eca480a1fae4df6aba419d2d102d3879d464086faab4e721065
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|
Release files / beastify-0.2.0a0-py3-none-any.whl
| Download URL | beastify-0.2.0a0-py3-none-any.whl |
|---|---|
| Size | 614.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d7c4ac923c45fa412916e6e1e99591882e1dd22526bcf027f3f55b41ba9ba2c
|
|
BLAKE2b-256 checksum How to use checksums |
c6fcab2fe4c20707d20947909938aaaf2144645a7c430bd27160e98041efc923
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|
Security for beastify 0.2.0a0
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.