Pierre mate, I feel pretty silly given how simple the solution is. Thanks!
• 0 views
•
link
Hi, I have a string of a fasta file (see below). You can see it's already in a fasta format, but its got spaces in the ID, and has newline characters. I have a Perl solution for this, but it's a bit hokey. I was wondering if any of you have the bash skills to turn this into a regular fasta?
Input:
">GA1redu 691-707f 57.9 product 2894bp 2006\r\nGCAGGACTCGGCTTGCT\r\n>HIVRES2redu \r\nGCTCTTGATAAATTTGATATGTCCAT"
Ideal Output:
>GA1redu 691-707f 57.9 product 2894bp 2006
GCAGGACTCGGCTTGCT
>HIVRES2redu
GCTCTTGATAAATTTGATATGTCCAT
echo -e '>GA1redu 691-707f 57.9 product 2894bp 2006\r\nGCAGGACTCGGCTTGCT\r\n>HIVRES2redu \r\nGCTCTTGATAAATTTGATATGTCCAT' | tr -d '\r'
Pierre mate, I feel pretty silly given how simple the solution is. Thanks!
Or very easy change field separator "\r\n" to new one "\n" in awk like: echo -e '.....' | awk '$1=$1' FS="\r\n" OFS="\n" this is very easy to read and understand.
Log in to answer this question.
Another way is to use sed -
echo -e '.....' | sed 's/\r//g'- which remove "\r" in your text.