fasta file title change
2
0
Entering edit mode
7.6 years ago
Sean Liang • 0

Hi there,

I have a fasta file with the format like this:

@t0000001 2137624

TGGAATGTAAAGAAGTATGTAT

@t0000002 926007

TGTGCACGGCACACACCACGTCGACGTT

@t0000003 854045

TGAGGTAGTAGGTTGTATAGTT

@t0000004 544348

TGTGAACGGCAGACACCACGTCAGTGTT

@t0000007 286256

TGTGAACGGCAGACACCACGTCAGTGTTG

@t0000005 261735

TGTGCACGGCACACACCACGTCGACGTTT

@t0000006 174866

TGTGCACGGCACACACCACGTCGACGTTC

@t0000011 135896

GGAACACCGGGTGCAGTAGACAT

now I would like to change the title into

@t0000001_hd_2137624

@t0000002_hd_926007

@t0000003_hd_854045

...

to meet the demands of fasta file format in mirdeep2,

is there any command line or software could do this ? I searched the internet but comes no solutions.

Thank you very much. Sean

RNA-Seq sequence • 1.4k views
ADD COMMENT
1
Entering edit mode
7.6 years ago
GenoMax 141k

That format it is not fasta (it is like fastq but with the quality lines missing). If you wish it to keep in that format then you can try this:

sed 's/\ /\_hd\_/g' your_file > new_file

If you need to convert the file to fasta format at the same time then do this

sed -e 's/\ /\_hd\_/g' -e 's/^@t/>t/g' your_file > new_file
ADD COMMENT
0
Entering edit mode

Thanks verymuch genomax2, i followed your command but no changes happened to my file (as below), could you please help figure out the problem?

enter image description here

ADD REPLY
1
Entering edit mode

it seems a tab separated headers, just replace single space to regular expression, sed -e 's/\s/\_hd\_/g' -e 's/^@t/>t/g' your_file > new_file

ADD REPLY
0
Entering edit mode

It works, thank you so much Ptasad, :)

ADD REPLY
0
Entering edit mode

BTW, could you pls tell me why you what the \s represents in the 's/\s/_hd_/g' command?

ADD REPLY
0
Entering edit mode

it is representation for all type of spaces

ADD REPLY

Login before adding your answer.

Traffic: 2700 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6