How to check if a fastq file has single or paired end reads
By now I got some interesting answers in this question on Biostars

Basically what I did is the following:


First of all, I checked if Sequence Id contains paired end notation. As described in this wikipedia page, for Illumina reads there are two possible notation for single/paired end reads:

@HWUSI-EAS100R:6:73:941:1973#0/1

If the last number is /2 in some reads then the reads are paired end; otherwise they can be single end. 

The second notation is:

@EAS139:136:FC706VJ:2:2104:15343:197393 1:Y:18:ATCACG

If the first number in the second group is 2 in some reads then the reads are paired end; otherwise they can be single end;
Then I checked for multiple files. If a sample has two fastq files it is likely that the reads are paired end. It is to note however that with a single file it is not possible to exclude that paired end reads can be interleaved in one single file, even if it is not common (in my opinion);
The most general method is to cross check each single reads with the whole set of reads. If the first part of the sequence ID (in this case the field starting from @ and ending before the # - in the first notation - or the whitespace - in the second notation) is unique among all the reads (for each read) it is likely that the reads are single reads, otherwise - if can be found a duplicate for each reads - the reads are paired end.
In this case, on *nix systems it can be achieved with the following command (thanks to the biostars answers):

grep --no-filename @HWUSI-EAS100R:6:73:941:1973 *.fastq | cut -d' ' -f1 | sort | uniq -c | sort -rgk 1,1 | head

If the result shows in the first lines a result like this:

1        read1_ID

1        read2_ID

...

It is likely it is single end. Otherwise:

2        read1_ID

2        read2_ID

...

it is paired end.


I skim read BioPython API documentation but I cannot find something useful to do it.

Suggestions and corrections are welcomed.

Thanks