Extract first and last column of fasta-header
Hi everyone,
I have a multi-fasta file name multi.fasta with the following structure:
>A 124 B
ATCGTA...
>C 567 D
GTCAG...
My goal is to create a new file, with the new fasta-headers containing only the first and last column. If I use
awk -F" " '/>/ {print $1,$(NF)}' multi-fasta > modified_multi-fasta
This will print the fasta headers with the first and last columns, but won't print the nucleotide sequences. Can you guys please help me out?
• 2,073 views
•
link
3 answers
awk '/^>/ {print $1,$(NF);next;} {print;}'
• 0 views
•
link
$ awk '/^>/{$2 =""}1' test.fa
>A B
ATCGTA...
>C D
GTCAG...
$ awk '/^>/{print $1,$NF}!/>/' test.fa
$ cut -f1,3 -d" " test.fa
$ sed -r '/^>/ s/\s.*\s/ /1' test.fa
$ tr -d 0-9 <test.fa | tr -s " "
>A B
ATCGTA...
>C D
GTCAG...
• 0 views
•
link
You can use the "Rename header / Multipart header" operation of SEDA (https://www.sing-group.org/seda/manual/operations.html#multipart-header), it is very useful for this kind of FASTA headers.
• 0 views
•
link
Log in to answer this question.