sequence in different line
0
0
Entering edit mode
7.3 years ago
Bulbul Ahmed ▴ 20

I have fasta file in this format (one line)

>accession1     GGGGAGCTACGGCAGCGGCGGCGGGGTGCTGCCGCTGGCGTCGCTTAA
>accession2     TTCCGGTAGAAAATCCATTATTGCCAATGGAAGAAGTGA

How will i convert into the below format(seperate line for sequence) using perl script or any other way

>accession1     
GGGGAGCTACGGCAGCGGCGGCGGGGTGCTGCCGCTGGCGTCGCTTAA
>accession2     
TTCCGGTAGAAAATCCATTATTGCCAATGGAAGAAGTGA
RNA-Seq Perl • 2.6k views
ADD COMMENT
1
Entering edit mode

Substitute tab or space with newline use unix tr

ADD REPLY
0
Entering edit mode

which command should i use in rehat??

ADD REPLY
2
Entering edit mode
cat yourinput | tr '\t' '\n' > youroutput.fa

Although we can't see which whitespace is between your accession identifier and the actual sequence.

ADD REPLY
0
Entering edit mode

thank so much sir. i will try this, hopefully it will work

ADD REPLY
0
Entering edit mode

Maybe sed -r 's#\s+#\n#' input >output then?

ADD REPLY
0
Entering edit mode

Bah, I prefer:

sed -r 's|\s+|\n|' input >output
ADD REPLY
0
Entering edit mode

So, a different delimiter?

ADD REPLY
0
Entering edit mode

Exactly ;-)

[just some slight Friday night trolling]

ADD REPLY
0
Entering edit mode

Strictly speaking, this is not really bioinformatics.

ADD REPLY
2
Entering edit mode

I don't know... it seems like an awful lot of bioinformatics is just reformatting text files :)

Personally, in this case, I would copy and paste into Notepad++, which allows search/replace of \t for \n. But then I had never seen "tr" before, so I learned something from the thread!

ADD REPLY
1
Entering edit mode

tr is good, but I use it more for squeezing consecutive white spaces (tr -s) or for quick deletion (tr -d) than to replace. I prefer sed for all replace operations as it has better granular control.

ADD REPLY
0
Entering edit mode

I have fasta file in this format (one line)

Then it's not a FASTA. While it's not a bioinformatics question per se, the OP is at least using a file with sequence information.

ADD REPLY
0
Entering edit mode

Yeah, it satisfies that, but really? A find+replace operation?

ADD REPLY

Login before adding your answer.

Traffic: 3053 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