Skip to content

Instantly share code, notes, and snippets.

@l-modolo
Last active August 29, 2015 13:56
Show Gist options
  • Save l-modolo/8860090 to your computer and use it in GitHub Desktop.
Save l-modolo/8860090 to your computer and use it in GitHub Desktop.
split paired-end fastq file in the case where reads from the two ends are concatened (not interlaced)
#!/bin/sh
# split fastq file in two file for cases where paired-end are concatened (not interlaced)
(gzip -dc intput.fastq.gz) | awk -F"=" 'BEGIN {OFS = "\n"} {name = $0; getline seq; getline name2; getline phred; print name, substr(seq,0,int(length(seq)/2)), name2, substr(phred,0,int(length(seq)/2)) >> "intput-1.fastq"; print name, substr(seq,int(length(seq)/2)+1,length(seq)), name2, substr(phred,int(length(seq)/2)+1,length(seq)) >> "intput-2.fastq"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment