Skip to content

Instantly share code, notes, and snippets.

@nathanhaigh
Created November 14, 2014 04:09
Show Gist options
  • Save nathanhaigh/ba6264aa6ef70db4e743 to your computer and use it in GitHub Desktop.
Save nathanhaigh/ba6264aa6ef70db4e743 to your computer and use it in GitHub Desktop.
Convert a FASTA file containing multi-line (wrapped) sequences to occupy a single line
#!/bin/bash
# Convert a multi-line FASTA file into a single line FASTA file
# These are easier/faster to process using native UNIX tools like paste - - < in.fasta
dos2unix | awk 'BEGIN { RS = "\n>"; FS = "\n"; OFS = "" };
{
if (NR == 1) {
print $1
} else
if (NR > 1) {
print ">"$1
}
$1=""
print
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment