How to create a fasta file from a list of sequences
I have a txt file with more than a thousand DNA sequences as follows:
seq-name1 DNA-sequence1
seq-name2 DNA-sequence2
seq-name3 DNA-sequence3
Does anyone know a code to transform this file into a fasta file?
>seq-name1
DNA-sequence1
>seq-name2
DNA-sequence2
>seq-name3
DNA-sequence3
• 2,129 views
•
link
3 answers
This command prints > followed by the contents of the first column, then a new line character (\n) followed by second column. It is a fairly trivial operation and should be easy to find many similar solutions by Googling this site or the whole internet.
awk '{print ">"$1"\n"$2}' input.txt > output.fas
• 0 views
•
link
You can try sed 's/\(seq-name[0-9]\)\s\(DNA-sequence[0-9]\)/>\1\n\2/g' input_file > output_file
• 0 views
•
link
perl: perl -ae 'print ">$F[0]\n$F[1]\n";' in >out.fa
• 0 views
•
link
Log in to answer this question.