Bowtie Mapping¶
Align spacer sequences against a reference genome using Bowtie. Handles index building, query generation, alignment, and result parsing.
Supports both standard mode (-v, sequence-space mismatches) and spy
mode (-n, seed-based alignment with PAM included in the query).
bowtie
¶
Alignment-based mapping via Bowtie 1.
Provides bowtie_map() which handles the full workflow: PAM scanning,
spacer extraction, FASTA/FASTQ creation, bowtie-build, bowtie alignment,
SAM parsing, coordinate normalization, and Region yielding.
Two alignment modes are supported:
- Standard mode (
-vmismatch counting): reports only the best unique hit per query. Used for on-target mapping. - Spy mode (
-nseed-based alignment): reports all hits up tomax_reported_hits, with PAM prepended to the query. Used for comprehensive off-target analysis.
Requires bowtie and bowtie-build on $PATH (installed via mamba).
bowtie_map
¶
bowtie_map(sequences: dict[str, str], pam: str, *, spacer_len: int = 20, pam_direction: str = 'downstream', mismatches: int = 0, align_pam_with_spacer: bool = False, seed_alignment: bool = False, seed_length: int | None = None, report_all_hits: bool = False, max_reported_hits: int | None = None, threads: int = 1, topologies: dict[str, str] | None = None) -> Iterator[Region]
Scan sequences for PAM sites and align via bowtie.
Scans genomes for PAM sites, extracts spacers, aligns them against a topological reference via bowtie, parses the SAM output, and yields Regions with alignment metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequences
|
dict[str, str]
|
Mapping of chromosome name to uppercase DNA string. |
required |
pam
|
str
|
PAM pattern in IUPAC notation (e.g. |
required |
spacer_len
|
int
|
Guide spacer length in bp. Defaults to |
20
|
pam_direction
|
str
|
|
'downstream'
|
mismatches
|
int
|
Number of allowed mismatches. Defaults to |
0
|
align_pam_with_spacer
|
bool
|
If |
False
|
seed_alignment
|
bool
|
If |
False
|
seed_length
|
int | None
|
Seed length for |
None
|
report_all_hits
|
bool
|
If |
False
|
max_reported_hits
|
int | None
|
Cap on reported alignments ( |
None
|
threads
|
int
|
Number of bowtie threads. Defaults to |
1
|
topologies
|
dict[str, str] | None
|
Mapping of chrom name to |
None
|
Yields:
| Type | Description |
|---|---|
Region
|
|
Region
|
|
Region
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Examples:
Source code in src/seqchain/operations/map/bowtie.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |