tl;dr
Spliced aligners just make many small matches along the read pair or single read to determine splice junctions and output an alignment for the whole read, as long as it matches somewhere in the genome.
mRNA and translation
In the cell, after transcription, introns are spliced out of RNAs to become mature RNA. The protein-coding sequence does have sequence that is chimeric from cis-located portions of the same chromosome that do not actually exist.
|<<exon 1>>| intron |<<exon 2>|
Genome: ------ABCDEFGHIJKLmnopqrstuvwxYZ123456789------------------
mRNA : ----ABCDEFGHIJKLYZ123456789aaaaaaaaaaa
As you said, if we only even consider small stretches of DNA, the sequence JKLYZ
does not exist in the genome, only in the mRNA. So, we need a special way to map mRNA-seq reads to the genome that correctly splits at splice junctions.
How do we map mRNA-seq reads to a genome?
As a result, parts of the mRNA-seq reads will align well to one part of the genome, but only for part of the read. This requires a different alignment algorithm that considers multiple local high-score alignments for different parts of the read.
For example, see how a genomic aligner versus a splice aligner might treat the same mRNA-seq read on our example genome.
|<<exon 1>>| intron |<<exon 2>|
Genome: ------ABCDEFGHIJKLmnopqrstuvwxYZ123456789------------------
spliced aligner : ------ABCDEFGHIJKL------------YZ123456789
genomic aligner : ------ABCDEFGHIJKL
There is a possibility that the genomic aligner will not recognize that the second half of the read is an exon due to the large intron gap, and it may clip the alignment. Spliced aligners just take this into account and output several alignments for the same read regardless of gap size. The STAR algorithm, for example, uses many small matching pieces of a single read to determine where the splice junctions are. HiSat2 uses small approximate matches using a FM-index to find seeds for spliced alignment.