Skip to content

Instantly share code, notes, and snippets.

@opplatek
Created July 21, 2022 16:34
Show Gist options
  • Save opplatek/70db00079a05a8cb94d08c3d2a2fcd80 to your computer and use it in GitHub Desktop.
Save opplatek/70db00079a05a8cb94d08c3d2a2fcd80 to your computer and use it in GitHub Desktop.
Reformat RNA FASTA to DNA FASTA for reference
#!/bin/bash
#
# Get miRBase hairpin FASTA (multiline, with U instead of T) and reformat it to "normal" reference FASTA
#
wget ftp://mirbase.org/pub/mirbase/21/hairpin.fa.gz # Get the sequence
zcat hairpin.fa.gz | perl -pe '/^>/ ? print "\n" : chomp' \
| tail -n +2 | sed '/^[^>]/ y/uU/tT/' \
> hairpin.oneline.fasta # Convert to one-line fasta and replace all Us for Ts
grep -A1 "^>hsa" hairpin.oneline.fasta | sed '/^--$/d' \
> hsa_hairpin.fasta # Get only human hairpin sequences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment