Last active
December 16, 2015 02:09
-
-
Save jrherr/5360038 to your computer and use it in GitHub Desktop.
I use this quick shell script (Mac OS X shell tools -- I don't have the linux 'shuf' installed) to take a smaller random sample of a fasta file. This can be modified for FASTQ files too.
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 name.fasta |\ # identify file name | |
awk '/^>/ { if(i>0) printf("\n"); i++; printf("%s\t",$0); next;} {printf("%s",$0);} END { printf("\n");}' |\ # read data | |
perl -MList::Util -e 'print List::Util::shuffle <>' |\ # random sample of sequences with shuffle | |
head -n 50000 |\ # break fasta file into sections of 50000 sequences in length | |
awk '{printf("%s\n%s\n",$1,$2)}' > name_1.fasta # write sequence output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment