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

I have a large fasta file of microRNA where unique tag is there in form of

>sequence1_x5
AGCTAGCTAGCTAGCT
>sequence2_x15
ATCTATCTATCT

and i want to convert into individual fasta file as

>1
AGCTAGCTAGCTAGCT
>2
AGCTAGCTAGCTAGCT
>3
AGCTAGCTAGCTAGCT
>4
AGCTAGCTAGCTAGCT
>5
AGCTAGCTAGCTAGCT
>6
ATCTATCTATCT
>7
ATCTATCTATCT

and so on....

I am new to bioinformatics kindly help

rna-seq

its not taking the right format i have asked question in fasta format but some error is there while posting

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
code_formatting

Thank you!

This returns:

>1
AGCTAGCTAGCTAGCT
>2
ATCTATCTATCT

Without considering x5 and x15.

Indeed. Left here as an inspiration. Useful for anyone else who may find this thread by search.

1 answer

Hi manishbiotechie,

You can try:

$ cat input.fasta
>sequence1_x5
AGCTAGCTAGCTAGCT
>sequence2_x15
ATCTATCTATCT

$ cat input.fasta | awk 'BEGIN{RS=">"; i=1} NR>1 {gsub(".+_x", "", $1); {while ($1--) {print ">" i "\n" $2; i++}}}'
>1
AGCTAGCTAGCTAGCT
>2
AGCTAGCTAGCTAGCT
>3
AGCTAGCTAGCTAGCT
>4
AGCTAGCTAGCTAGCT
>5
AGCTAGCTAGCTAGCT
>6
ATCTATCTATCT
>7
ATCTATCTATCT
>8
ATCTATCTATCT
>9
ATCTATCTATCT
>10
ATCTATCTATCT
>11
ATCTATCTATCT
>12
ATCTATCTATCT
>13
ATCTATCTATCT
>14
ATCTATCTATCT
>15
ATCTATCTATCT
>16
ATCTATCTATCT
>17
ATCTATCTATCT
>18
ATCTATCTATCT
>19
ATCTATCTATCT
>20
ATCTATCTATCT

Log in to answer this question.