Last active
August 29, 2015 14:02
-
-
Save inodb/dfe460b4aeb7e3ccee98 to your computer and use it in GitHub Desktop.
If you have a single fastq file that has single reads inbetween paris then this script can help you separate the pairs in r1, r2 and single reads.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat ../Batch1.fastq | \ | |
awk -v se=se.fastq -v r1=r1.fastq -v r2=r2.fastq ' | |
BEGIN {l5=0} | |
{ | |
if (l5 == 0) { | |
l1=$0; getline | |
} | |
else { | |
l1=l5 | |
} | |
l2=$0; getline; l3=$0; getline; l4=$0; | |
if (l1 ~ " 1:") { | |
getline; l5=$0; | |
if (l5 ~ " 2:") { | |
getline; l6=$0; getline; l7=$0; getline; l8=$0; | |
printf "%s\n%s\n%s\n%s\n", l1,l2,l3,l4 > r1; | |
printf "%s\n%s\n%s\n%s\n", l5,l6,l7,l8 > r2; l5=0; | |
} else { | |
printf "%s\n%s\n%s\n%s\n", l1,l2,l3,l4 > se; | |
} | |
} else { | |
printf "%s\n%s\n%s\n%s\n", l1,l2,l3,l4 > se; | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment