Skip to content

Instantly share code, notes, and snippets.

@l-modolo
Created May 12, 2014 09:38
Show Gist options
  • Select an option

  • Save l-modolo/e6f8a044b5526085b5fd to your computer and use it in GitHub Desktop.

Select an option

Save l-modolo/e6f8a044b5526085b5fd to your computer and use it in GitHub Desktop.
list of sequence_id sequence_length from a fasta file
#!/bin/sh
# return a list of sequence_id sequence_length from a fasta file
awk 'BEGIN {OFS = "\n"}; /^>/ {print(substr(sequence_id, 2)" "sequence_length); sequence_length = 0; sequence_id = $0}; /^[^>]/ {sequence_length += length($0)}; END {print(substr(sequence_id, 2)" "sequence_length)}' file.fasta
@clemgoub

Copy link
Copy Markdown

Just wanted to let you know that 10+ years later I'm still coming back here to get this one liner 😘

@clemgoub

Copy link
Copy Markdown

Still loving it!

@l-modolo

Copy link
Copy Markdown
Author

Still loving it!

😘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment