This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Formatting Reads to fasta

Hi,

I have a file with reads and read counts like this:

CGTAGTTGAACTTGTGCTTCAT  8
ATCCCCGGCATCTCCGCCA 1
TGAGAATAGTGTGCATTT 52

I'd appreciate some help converting it to look like this:

>dme_1_count=8
CGTAGTTGAACTTGTGCTTCAT
>dme_2_count=1
ATCCCCGGCATCTCCGCCA
>dme_3_count=52
TGAGAATAGTGTGCATTT

count = number at the end of each read dme_x, x = unique number.

I also want to delete reads with count<=2. However, I want the processes separate.

Thank you!

sequence

You can modify this answer according to your task.

2 answers

perl -lane ' print ">dme_" . $n++ . "_count=$F[1]\n$F[0]" if ($F[1] > 2) ' < table > fasta

awk '($2 >2) {print ">dme_"NR"count="$2"\n"$1"\n"}' table > output.fasta

Log in to answer this question.