What's the longest intron in the human genome?
Short answers: Based on gencode the longest intron for protein coding transcripts, is the intron 3-4 of the transcript ENST00000465127.1 with 1,240,120 bases.

Long answer:

Download the main annotation gff3 file from gencode first. Then run this script:

zcat gencode.v29.annotation.gff3.gz \ 
| awk -v FS="\t" -v OFS="\t" '$3=="exon" &amp;&amp; $9 ~ /transcript_type=protein_coding/ {match($0, "transcript_id=([^;]+)", transcript); print $0,transcript[1]}' \
| sort -k1,1V -k10,10 -k4,4g -k5,5g \                                                                                                        
| awk -v FS="\t" -v OFS="\t" 'BEGIN {transcript=""; max_d=0; max_line=""} \
 $10 != transcript  {transcript = $10; end = $5; next;} \
 {d=$4-end-1; end=$5; if(d&gt;max_d) {max_d=d; max_line=$0"\t"d;}} \
 END {print max_line}'


It will:


decompress the file
filter only lines that describes exons of protein coding transcripts
append the transcript id at the end of the line
sort by chromosome, transcript and position
calculate the distance between two exons of the same transcript
save the current maximum distance and the annotation line that belongs to it
print out the line of the exon which follows the longest intron. The last column contains the distance.


The output will be:

chrX    HAVANA  exon    38666121    38666309    .   +   .   ID=exon:ENST00000465127.1:4;Parent=ENST00000465127.1;gene_id=ENSG00000250349.3;transcript_id=ENST00000465127.1;gene_type=protein_coding;gene_name=AF241726.2;transcript_type=protein_coding;transcript_name=AF241726.2-201;exon_number=4;exon_id=ENSE00003644052.1;level=2;protein_id=ENSP00000417050.1;transcript_support_level=5;tag=basic,appris_principal_1,readthrough_transcript;havana_gene=OTTHUMG00000161009.1;havana_transcript=OTTHUMT00000363378.1  ENST00000465127.1   1240120


fin swimmer

EDIT:

gencode also includes transcripts that are only predicted, but never seen, or those where it is not sure that they exists. So you maybe want to just include transcripts having a certain transcript support level. For this you have to change the first awk line. E.g. to include only trasncripts with TSL1 change it to:

awk -v FS="\t" -v OFS="\t" '$3=="exon" &amp;&amp; $9 ~ /transcript_type=protein_coding/ &amp;&amp; $9 ~ /transcript_support_level=1/ {match($0, "transcript_id=([^;]+)", transcript); print $0,transcript[1]}'


You can also define a range, e.g 1-3:

awk -v FS="\t" -v OFS="\t" '$3=="exon" &amp;&amp; $9 ~ /transcript_type=protein_coding/ &amp;&amp; $9 ~ /transcript_support_level=[1-3]/ {match($0, "transcript_id=([^;]+)", transcript); print $0,transcript[1]}'


In both cases the result will change to intron 4-5 of ENST00000402655.6 with 1096453 bases.