Thanks very much. Yep, if I have a consistent structure like you proposed, the first one works perfectly. Thanks again! But the issue is that I found out my fasta file doesn't have a consistent structure (see below), so do you have any solution for that?
ID-1
#new line#
Genus species
#new line#
sequence
#new line#
ID-2
#new line#
Genus species
#new line#
sequence
#new line#
sequence
#new line#
Use awk and operate on NR. Do that once for every first line and once for every second line in separate subshells, and
pastethe output from them with blank space as separator. To this, with a similar awk operating on every third line,pasteusing a unique delimiter that you then replace with a new line character usingsed.input:
Output:
Later in the thread, OP says that they could have multiple sequence lines, so
NR%xis not going to work. OP's data is quite mangled.Hello, everyone. If the sequences look like this, this is another story. How to add
>to the header and remove space? using before script, I couldn't add>at all. Sorry, I am a novice. I have many questions related to this. I really appreciate your effort.MT657978AAAGTTGTTGCAGTTAAAAAGCTCGTAGTTGAATTTCAB626044ACATACGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAHello, everyone. If the sequences look like this, this is another story. How to add > to the header and remove space? using before script, I couldn't add > at all. Sorry, I am a novice. I have many questions related to this. I really appreciate your effort.
Could you please post this as a new post? @ yaqinguo629
Yes, Sure. When I figured it out all. I will do summary and it's better to check it for others.
But
$ cat test.fathis command just get the same sequences with what I have, this can't remove space between each line. I used following command to remove the line break:then I used
this works perfectly, but with sed command, it's not working.
Thanks a lot.