creating a tab delimited file I am working on a project using a fasta file. I am writing my command in nano within command-line and executing using python, also within my command-line.
I would like my command to provide me with a tab delimited file with three columns: first column should contain my sequence name, second column should provide me with my sequence length, and the third column should show the sequence itself.
I have written the following command so far within nano:
from Bio import SeqIO
import sys
for hello_fasta in SeqIO.parse(sys.argv[1], &quot;fasta&quot;):

  list = hello_fasta.split(&quot;\t&quot;)

  print hello_fasta.description
  print (len(hello_fasta.seq))

For example, I would like my command to provide me with the desired output and with the following order: Gene name ; Gene length ; Gene seq
H0192X 26 FORUWOHRPPTRWFAWWEAKJNFWEJ
You can use a list and insert() to add an element in a specific order, then expand the list with *. Or you can use join().
from Bio import SeqIO
import sys

for hello_fasta in SeqIO.parse(sys.argv[1], &quot;fasta&quot;):
  sequences = []
  sequences.insert(0, hello_fasta.description)
  sequences.insert(1, len(hello_fasta.seq))
  sequences.insert(2, hello_fasta.seq)
  # option 1
  print(*sequences, sep='\t')
  # option 2
  print('\t'.join(map(str, sequences)))