Window extractor

Cuts a sequence into fixed-length windows at the step you choose, each named by its coordinates.

Windows

What is a sliding window?

A sliding window walks along a sequence in fixed-length pieces. The first window starts at position 1, the next one starts a step further along, and so on to the end. When the step is smaller than the window, neighbouring windows overlap, which is how GC content, coverage, conservation and codon bias are plotted along a chromosome, and how overlapping peptide libraries are designed. This page writes the windows themselves as FASTA records, ready for BLAST, an aligner, a prediction server or a synthesis order.

Every window is named by the coordinates it came from, counted from 1 with both ends included: >contig_7_51-150 is the record contig_7, positions 51 to 150, 100 residues. A file with several records is windowed record by record.

How many windows do you get?

start of window i = 1 + (i − 1) × step
end of window i = start + size − 1, cut back to the length of the sequence
full windows = ⌊(length − size) ÷ step⌋ + 1

One more window follows when the last full window does not reach the end of the sequence. That final window is shorter than the rest, and "Last window" decides whether it is kept, which is the default, or dropped. Dropping it leaves the residues after the last full window out of the output, and the tool says how many they are.

Worked example

"Try an example" on the DNA tab loads a 280 nt assembly fragment. With the default size 100 and step 50 the result is 5 windows, 480 nt in all: 1-100, 51-150, 101-200, 151-250 and 201-280. The first four are 100 nt, the last is80 nt because the sequence ends there. Set "Last window" to "Drop it" and 4 windows of 100 nt remain, 400 nt, with the last 30 nt of the sequence left out.

On the Protein tab the example is the 110 aa human insulin precursor with size15 and step 5. That gives 20 peptides of 15 aa, from 1-15 to 96-110, each overlapping its neighbour by 10 residues, and none of them partial because 110 = 15 + 19 × 5.

Choosing a size and a step

PurposeSizeStep
GC or coverage profile100–1000 nthalf the size
Tiling for synthesis or capture120–200 ntsize, or size − overlap
Overlapping peptide library15 aa5 aa
MHC class I 9-mers9 aa1 aa
Non-overlapping chunksanyequal to the size

A step equal to the size gives chunks that cover the sequence exactly once. A step larger than the size skips the residues between neighbouring windows, which is sampling rather than scanning.

Windows or named ranges?

Use this page when the pieces are regular: one size, one step, right across the sequence. When you know which positions you want, for example 1-100 and 250-300, therange extractor cuts exactly those and can also trim a fixed number of residues off each end. To plot GC along a sequence instead of writing the windows out, use the GC content calculator, and to translate the windows you extract here, the translation tool.

Frequently asked questions

What is the difference between window size and step?

Size is how long each window is, step is how far the next window starts after the previous one. A step smaller than the size makes the windows overlap, which is what a sliding window means: size 100 with step 50 gives windows that share half their length. A step equal to the size gives tiles that touch but do not overlap, and a step larger than the size leaves gaps between them.

Are the coordinates 1-based?

Yes. The first residue is position 1 and both ends belong to the window, so 1-100 is the first 100 residues and 51-150 is the next 100. These are the coordinates GenBank, EMBL, GFF and most papers use. BED files and Python slices count from 0 and leave the end out, so the window written 1-100 here is 0-100 in a BED file.

What happens to the last window?

A sequence rarely divides evenly, so the final window is usually shorter than the others. It is kept by default and its header gives its real coordinates, so nothing is lost. Set "Last window" to "Drop it" when every record has to be exactly the same length, for example as input to a model or a microarray design; the residues after the last full window are then left out and the tool says how many.

Can I use it for peptide scanning?

Yes. Switch to Protein and use a size of 15 with a step of 5 for peptides that overlap by 10 residues, the usual layout for an overlapping peptide library or an epitope scan. Size 9 with step 1 gives every possible 9-mer for MHC class I binding prediction.

How many windows can it write?

Up to 20,000. A small step over a long sequence reaches that quickly: step 1 on a 100 kb sequence would be 100,000 windows. Raise the step, or split the sequence first. Files are read in your browser and nothing is uploaded.