Authors: Francisco Picazo, Dalila Zovko Date: October 10, 2025 TO DO: 1 CHANGE THE 'FIRST LENGTH' AND 'SECOND LENGTH' TO BE 'PRIMER LENGTH' AND MAKE IT SO THAT THIS VALUE CAN BE A RANGE AND IT APPLIES TO BOTH FIRST AND SECOND LENGTH. ONE INPUT, TWO OUTPUTS (TWO LENGTHS BEFORE AND AFTER). 2 CHANGE 'MIDDLE LENGTH' TO BE TWO SEQUENCES, ONE BEING 'UNIVERSAL TARGET SEQUENCE' WHICH IS CONSERVED, THE SECOND BEING 'UNIQUE TARGET SEQUENCE'. THESE NEED TO BE RIGHT NEXT TO EACH OTHER, BUT, EITHER CAN BE FIRST, SO MAKE SURE 'UNIVERSAL TARGET SEQUENCE' CAN BE EITHER THE FIRST OR SECOND ONE. 3 NEW ADDITION: 'MAX DISTANCE BETWEEN PRIMER AND TARGET SEQUENCES', THIS IS HOW FAR THE 'PRIMER LENGTH' CAN BE FROM THE MIDDLE SECTIONS 'UNIVERSAL TARGET SEQUENCE' AND 'UNIQUE TARGET SEQUENCE'. 4 FOR SIMPLICITY, THIS IS HOW AN EXAMPLE SHOULD LOOK: [PRIMER 20-30NT] [SPACE 0-200NT] [UNIVERSAL TARGET SEQUENCE OR UNIQUE TARGET SEQUENCE][UNIVERSAL TARGET SEQUENCE OR UNIQUE TARGET SEQUENCE][SPACE 0-200NT][PRIMER 20-30NT]
The file find_regions.py scans a CLUSTAL Omega multiple-sequence alignment and
finds stretches of DNA that follow this pattern:
- Several consecutive alignment columns where every sequence shows the exact same nucleotide (no gaps, no differences).
- A middle block where at least one sequence differs (a mutation, gap, or ambiguous base).
- Another block of perfectly conserved columns.
Every matching stretch is reported with 1-based column positions (the first column in the alignment is position 1) so that you can line up results with the alignment file you opened in your viewer.
- Script: a small program you run with the Python interpreter. Think of it as a recipe of instructions stored in a text file.
- Terminal / Command Prompt: the place where you type commands (for example, “Terminal” on macOS or “Command Prompt” / “PowerShell” on Windows).
- Alignment file: the
.alnor.aln-clustal_numfile you already have.
- Install Python 3.8 or newer. On macOS and Linux it is often available as
python3. On Windows you can download it from https://www.python.org. - Know where the alignment file lives on your computer (note the folder path).
- Download or clone this project so that
find_regions.pyis stored somewhere you can reach from the terminal.
-
Open a terminal window.
- macOS: open Spotlight (⌘+Space), type
Terminal, press Enter. - Windows: press the Windows key, type
cmdorPowerShell, press Enter. - Linux: search for “Terminal” in your application menu.
- macOS: open Spotlight (⌘+Space), type
-
Move to the folder that contains
find_regions.py.- Use the
cdcommand (short for “change directory”). - Example on macOS/Linux:
cd /Users/yourname/Downloads/DNA_Sequencing - Example on Windows:
cd C:\Users\yourname\Downloads\DNA_Sequencing - If you prefer, you can skip this step and give Python the full path to the script in the next command.
- Use the
-
Choose three lengths.
first_length: number of consecutive conserved columns to find first.middle_length: size of the region that must contain at least one change.second_length: number of consecutive conserved columns to find after the middle region.
-
Run the script.
- Use
python3on macOS/Linux; on Windows the command may bepython. - Basic command structure:
python3 find_regions.py <alignment_file> <first_length> <middle_length> <second_length>
- If your alignment file is in another folder, provide the full path. Example:
or, from any folder:
python3 find_regions.py sample.aln-clustal_num 20 14 20
python3 /full/path/to/find_regions.py /full/path/to/sample.aln-clustal_num 20 14 20
- Use
-
Read the output.
- The script lists every pattern that matches your lengths.
- For each match you’ll see:
- A “First conserved region” line with start–end positions and the aligned bases for every sequence.
- A “Mutation region” section showing the differing block.
- A “Second conserved region” section showing the conserved columns after the mutation block.
- If nothing matches, you’ll see
No matching regions found..
- Unsure about the exact command? Run
python3 find_regions.py -hto see the help message and parameter descriptions. - On Windows, if
python3is not recognized, trypythoninstead. - You can copy and paste commands into the terminal. Make sure to adjust the paths so that they point to the correct folders on your computer.
- If you work with multiple Python projects, consider creating a virtual
environment:
python3 -m venv .venv source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1