Created
June 12, 2023 19:38
-
-
Save cory-weller/58da08cf8a34992a7a666b7fd068b7e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # DETAILS: Functions by setting the field separator to a regular expression capturing ">", tab, and space. | |
| # For each row in the file, if it is a header (begins with ">"), update the value of variable s | |
| # to be equal to the first word in the header, and write a header line only containing that first word. | |
| # Every line is written to a file <first_word_in_header>.fa, splitting the file into separate contigs. | |
| awk -F "(^>|\t| )" '{if($0 ~ /^>/) {s=$2".fa"; print ">"$2 > s} else print > s}' ${inFasta} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment