Amplicon read simualtor
Project description
Bygul: Amplicon & Metagenomics Read Simulator
Bygul is a Python 3 tool designed for simulating sequencing reads in wastewater surveillance and other metagenomic applications. It allows users to simulate complex multi-sample datasets with customizable proportions using industry-standard backends like wgsim and mason.
🏗 Installation
Bygul requires Python 3. Since it relies on external simulators (wgsim and mason), we recommend using Conda to manage dependencies.For more info on wgsim and mason simulator please check their documentations.
Option 1: Via Conda (Recommended)
conda create -n bygul bioconda::bygul
Option 2: Via PyPI
pip install bygul
Note: Some binary dependencies (wgsim/mason) may need to be installed manually or built from source if using this method.
Option 3: Local Build from Source
git clone [https://github.com/andersen-lab/Bygul](https://github.com/andersen-lab/Bygul)
cd Bygul
pip install -e .
🧬 Usage: Amplicon Sequencing Mode
Use this mode when simulating specific genomic regions defined by a primer set.
Basic Command
bygul simulate-proportions [SAMPLE1.fasta,SAMPLE2.fasta] --primers [primer.bed] --reference [reference.fasta] --proportions [0.8,0.2] --outdir [output_dir]
Advanced Examples
- Random Proportions & Mismatches:
Simulate with random proportions and allow up to 2 SNPs in primer regions.
bygul simulate-proportions sample1.fasta,sample2.fasta --primers primer.bed --reference reference.fasta --outdir results/ --maxmismatch 2
- Switching Simulators:
Use
masoninstead of the defaultwgsim.bygul simulate-proportions sample1.fasta,sample2.fasta --primers primer.bed --reference reference.fasta --simulator mason
- Custom Error Rates & Lengths:
Pass simulator-specific parameters (e.g. indel fraction
-R) directly.bygul simulate-proportions sample1.fasta,sample2.fasta --primers primer.bed --reference reference.fasta -R 0.01
🌍 Usage: Metagenomics Mode
Simulate reads from entire samples without requiring a primer BED file or a reference sequence.
Basic Metagenomics Simulation
bygul simulate-proportions sample1.fasta,sample2.fasta --outdir results/ --simulation_mode metagenomics
Metagenomics with Specific Parameters
bygul simulate-proportions sample1.fasta,sample2.fasta --proportions 0.5,0.5 --outdir results/ --simulation_mode metagenomics --simulator mason --illumina-read-length 200
📝 Technical Notes
Parameter Handling
Bygul acts as a wrapper. While most flags are passed directly to the underlying simulators, the following are managed directly by Bygul for more realistic simulations(amplicon simulation mode only):
--readcnt: Number of reads per amplicon.--wgsim_insert_size: Insert size for wgsim.--wgsim_read_length/--wgsim_error_rate.
To see all available backend flags, run:
wgsim --help
mason_simulator --help
Please note that some dependencies are not available through pypi. You need to install them using conda or build from source.
Amplicon sequencing mode
Example commands
Run the tool using the following command.
If you are just checking your primers without wanting to run the simulation, you can provide a multi-fasta file including all the sequences along with the primer file and the reference used to generate the primer file. This will create amplicon_stats.csv file as described below.
bygul check-primers sequences.fasta primer.bed reference.fasta
Example simualtion command
bygul simulate-proportions [SAMPLE1.fasta,SAMPLE2.fasta,..] --primers [primer.bed] --reference [reference.fasta] --proportions [0.8,0.2,..] --outdir [output_directory]
Simulate reads from different samples without defining proportions (will be assigned randomly, proportions can be found in results/sample_proportions.txt) and allowing upto 2 SNPs mistmatches in the primer regions.
bygul simulate-proportions sample.fasta,sample2.fasta --primers primer.bed --reference reference.fasta --outdir results/ --maxmismatch 2
Simulate reads with user-defined proportions and specifing read simulator. bygul uses wgsim as a simulator but you can change it to mason.
bygul simulate-proportions sample.fasta,sample2.fasta --primers primer.bed --reference reference.fasta --proportions 0.2,0.8 --simulator mason
Simulate reads with user-defined proportions and number of reads per amplicon.
bygul simulate-proportions sample.fasta,sample2.fasta --primers primer.bed --reference reference.fasta --proportions 0.2,0.8 --readcnt 1000
Simulate reads with additional parameters such as base error rate, read length and indels fraction
bygul simulate-proportions sample.fasta,sample2.fasta --primers primer.bed --reference reference.fasta --proportions 0.2,0.8 --readcnt 1000 -e 0.001 -1 400 -2 400 -R 0.01
Notes
Number of reads per amplicon
It is recommended to define the number of reads per amplicon to be greater than the number of contigs in your amplicon file. This is particularly important when your primers are designed for whole genome sequencing, where each amplicon may contain a substantial number of contigs. Setting too few reads per amplicon may result in empty read files for certain amplicons, leading to incomplete simulated reads.
Primer bed file
🧬 Input BED File Format
The pipeline expects a tab-delimited BED file where the first six columns represent standard genomic coordinates (chrom, chromStart, chromEnd, name, poolName, strand). Crucially, the fourth column (name) must follow a strict naming convention to prevent downstream parsing failures in variant-calling tools: [Scheme-Name]_[AmpliconNumber]_[Direction]_[OptionalSuffix] (e.g., SARS-CoV-2_3_LEFT or SARS-CoV-2_3_LEFT_alt). To ensure structural boundaries are parsed correctly, the prefix must not contain underscores, and any optional trailing modifiers must be restricted to standard alternative tags (_alt, _ALT1) or tracking indexes (_0, _1). Multi-level pool formatting, such as SARS-CoV-2_400_1_LEFT_1, is malformed and will fail validation.. The maximum number of mismatches allowed for each primer sequence is 1 SNP. To change this number, you may use the --maxmismatches flag.
Complete set of available parameters
To learn more about how to adjust other parameters for the simulator please read the documentation for wgsim and mason simulator. Users can pass any simulator parameter directly in their command. The only parameters set through bygul are --readcnt and --wgsim_insert_size for amplicon sequencing mode.
Simulated reads output
Simulated reads from all samples are located in provided_output_path/reads.fastq
Information about amplicon dropouts
In order to find more about amplicon dropouts, please refer to provided_output_path/sample_name/amplicon_stats.csv file. Please note that primer_seq_x and primer_seq_y define the left and right primer sequence whereas left_match and right_match shows the actual sequence found in the sample for a better comparison of mismatching bases in the primer sequence. Additionally, if there are any ambiguous bases present in the matching sequence, the ambiguous_bases value returns true.
Metagenomics mode
Users can now simulate reads from different samples in a metagenomics setting without specifying a primer bed file. Providing a reference sequence is not required for this setting.
Example commands
Simulate reads from different samples without defining proportions (will be assigned randomly, proportions can be found in results/sample_proportions.txt).
bygul simulate-proportions sample.fasta,sample2.fasta --outdir results/ --simulation_mode metagenomics
Specify proportions for each sample and add other simulator specific parameters. To access simulator parameters, please read wgsim and mason documentation.
bygul simulate-proportions sample.fasta,sample2.fasta --proportions 0.5,0.5 --outdir results/ --simulation_mode metagenomics --simulator mason --illumina-read-length 200
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bygul-3.2.0.tar.gz.
File metadata
- Download URL: bygul-3.2.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1f441441dd3cd3e2e5f07e2bb4812b785713dec1a8a32e7a94fb266db4b1e8d
|
|
| MD5 |
ea3347d5c96dbe6202dd8f0fb7bfbd24
|
|
| BLAKE2b-256 |
153cfd564f5460ca4e4fd34230b57710bd985d67cd1262cef22ee386dc818d9f
|
Provenance
The following attestation bundles were made for bygul-3.2.0.tar.gz:
Publisher:
github_actions.yml on andersen-lab/Bygul
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bygul-3.2.0.tar.gz -
Subject digest:
c1f441441dd3cd3e2e5f07e2bb4812b785713dec1a8a32e7a94fb266db4b1e8d - Sigstore transparency entry: 1770911849
- Sigstore integration time:
-
Permalink:
andersen-lab/Bygul@37800a5259306c7dfb359bae536973b0c0f7a88d -
Branch / Tag:
refs/tags/V3.2.0 - Owner: https://github.com/andersen-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
github_actions.yml@37800a5259306c7dfb359bae536973b0c0f7a88d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bygul-3.2.0-py3-none-any.whl.
File metadata
- Download URL: bygul-3.2.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
665db21ee2afc617ba81eeec22d43f58cc8d1336fb3baa9dd225262c7dae8fd0
|
|
| MD5 |
a0cea9059a49c6171af497269e2a6b6e
|
|
| BLAKE2b-256 |
32dc583d98ce68a29b3e92a4a065b01fbb3c4e0fe5987ca23a4ac3aa1797ffe2
|
Provenance
The following attestation bundles were made for bygul-3.2.0-py3-none-any.whl:
Publisher:
github_actions.yml on andersen-lab/Bygul
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bygul-3.2.0-py3-none-any.whl -
Subject digest:
665db21ee2afc617ba81eeec22d43f58cc8d1336fb3baa9dd225262c7dae8fd0 - Sigstore transparency entry: 1770912010
- Sigstore integration time:
-
Permalink:
andersen-lab/Bygul@37800a5259306c7dfb359bae536973b0c0f7a88d -
Branch / Tag:
refs/tags/V3.2.0 - Owner: https://github.com/andersen-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
github_actions.yml@37800a5259306c7dfb359bae536973b0c0f7a88d -
Trigger Event:
release
-
Statement type: