I ve to Write a Python program that prints a random DNA sequence in Fasta format.

That program should ask for the length of the sequence and suggest a reasonable sequence name.

The session should look something like:
> python randomdna.py
Length: 34

The output must be in valid Fasta format.
I am trying this way:

import random

>>> ''.join([random.choice('AGTC') for x in range(10)])

>>> ''.join([random.choice('AGTC') for x in range(10)])

but how to print the length of that string and a seq name with fasta symbol ">"?any idea?
thanks in advance.

>>> import random
>>> my_seq = ''.join([random.choice('AGTC') for x in range(10)])
>>> my_seq
>>> len(my_seq)

I'm not quite sure what you mean by "printing in FASTA format with the > "

Here" >"symbols indicates that this is a fasta file.
My output should look like:

>my seq
atcggctatg(randomly printed,10 ,if length 20,then it should print 20 base randomly)

Welcome to daniweb!
Can you wrap your codes in tags please. Also define what FASTA FORMAT is. We are from different background, and not all of us knows Bios and Logos!

Thanks!do not worry about fasta..I have to print 4 letters A,T,G,C several times randomly,output will be like this
length : (no of ATGC)
>file name
AGTC..BLA... BLA...(same number,defined by length) if length is 5 then it will print randomly 5 letters among ATGC.say,AGCTA.

Is this what your talking about?

import random
count = input("How long shall the sequence be?")
seq = ''.join([random.choice('AGTC') for x in range(count)])
print "Length:",count
print ">",seq
This question has already been answered. Start a new discussion instead.