This is a test version of Biostars. For the public version, visit https://www.biostars.org.
convert tabular data to fasta

Hello all,

I have a text file whose first column is the name of the transcript and the second column is the nucleotide sequence. My question is how to convert this text file to fasta in Linux ?

TCONS_00000128
CGTAACCTGAGGTTTATTCCGGATATGGCTCAGAGCAgtgatcattatcaaatgaGTTGTCAGCGTCAACAGTGATCTCGTTGAATTCTGGCATCCGGCAGCTGGTCTGGGGATTTCTGAAGA
TCONS_00000042
GATTGATGACCGTCGCCGAAGAGATAGTATTCCGGGTCCATTCGGCCTATACCGACGACGTTGACGGACTGGTGGCGATATAACTATCGAGGTTCCTCGTTCGAAGGTATCGGTTAT
linux fasta

2 answers

sed 's/^/>/;s/[ \t]/\n/' in.txt

Thank you for your response

$ seqkit -w 0 tab2fx <input.fa> -o <output.fa(.gz)>
$ awk -v OFS="\n" '{print ">"$1,$2}' test.txt
$ awk -v OFS="\n" '{$1=">"$1}1' test.txt
$ sed  's/^/>/;s/\t/\n/' test.txt 
$ sed -r 's/^(.*)\t(.*)/>\1\n\2/' test.txt
$ parallel --colsep '\t' echo '\>'{1}'\\n'{2} :::: test.txt

Thank you for your complete answer

Log in to answer this question.