Sequence interleaver
Merge R1 and R2 into one interleaved file, or split an interleaved file back into two.
Merge R1 and R2 into one interleaved file, or split an interleaved file back into two.
Paired-end sequencing gives two reads from the two ends of the same fragment, and a run is usually delivered as two files, R1 and R2, with the mates in the same order. An interleaved file puts them together in one stream instead: R1 of the first pair, R2 of the first pair, R1 of the second pair, and so on. Nothing about the reads changes, only how they are stored.
The read name is the header up to the first space, with a trailing /1 or /2removed. Everything after the space is ignored, which is what makes Illumina headers pair correctly: the mate number lives there.
If the two files are in the same order and every name agrees, the pairs are taken straight through. Otherwise reads are matched by name, in the order of the R1 file, and anything left over is reported by name instead of being dropped in silence. That matters, because a pair of files that has been trimmed read by read is often no longer aligned: one file loses a read, and from that point on every "pair" in a naive merge is two different fragments.
"Try an example" loads three FASTQ reads as R1 and their three mates as R2, with Illumina headers. The names agree, so the result is 3 pairs, an interleaved file of 6 reads and 24 lines, beginning with the R1 read of pair 1 followed by its R2 mate. Switch to De-interleave and the example is that interleaved file: it splits back into 3 pairs, and the R1 half is identical to the file you started with.
The format is taken from the first character of the file: @ for FASTQ, > for FASTA. FASTQ records are read strictly four lines at a time, which is the only safe way, since a quality line may itself begin with @ or +. FASTA records keep their own line wrapping. Sequences and quality strings are copied byte for byte; only the header is touched, and only if you ask for /1 and /2 to be added. To change a file between the two formats use FASTQ to FASTA orFASTA to FASTQ, and to tidy headers or line widths first use theFASTA cleaner.
An interleaved file holds both mates of every pair one after the other in a single file: read 1 of pair 1, read 2 of pair 1, read 1 of pair 2, and so on. Assemblers and mappers that read from standard input, such as SPAdes, BWA with -p and Velvet, take reads in this form, while most trimmers and QC tools expect the two files apart.
By read name: the header up to the first space, with a trailing /1 or /2 removed. Illumina headers carry the mate number after a space, as 1:N:0:INDEX and 2:N:0:INDEX, so that part is ignored and the names match. A read whose partner is missing is reported by name and left out of the output rather than being paired with the wrong mate.
No. If both files are in the same order, which is the normal case, the pairs are taken straight through. If they are not, reads are matched by name and the order of the R1 file decides the order of the output.
Both. The format is detected from the first character of the file, @ for FASTQ and > for FASTA, and the output is written in the same format. FASTQ records are read four lines at a time, so a quality line that begins with @ causes no trouble. Sequence and quality lines are copied unchanged.
Files are read in your browser and nothing is uploaded, so the limit is the memory of the tab: up to about 50 MB works comfortably. For a whole sequencing run use a command-line tool such as seqtk mergepe, reformat.sh from BBTools, or seqkit pair.