1

I'm creating a code for "software" that'll ask the user how many sequences of DNA barcodes (n) they want and what is the length (size) of the DNA barcode he wants. And according to the user parameters it must generate a text file containing a total of n sequences of size-nucleotides long DNA barcodes. The file generated has to follow EXACT format showed-> barcode (sequence number): DNA barcode. What I am having trouble is creating a user input in asking how many sequences they want, what size they want the sequence.

    import io
#given a DNA(A,C,T,G) string and a 1-letter base string,
#returns number of occurences of base in the sequence
def dna_sequence():
    base_counter=0
    seq_len=len(seq)

    for index in range(0,seq_len):
        seq_base=seq[index]
        if seq_base==query_base:
            base_counter=base_counter+1
    return base_counter
#given a DNA(A,C,T,G) sequence string and returns GC content as float
def GC_content(seq):
    g_content=dna_sequence(seq,"G")
    c_content=dna_sequence(seq,"C")
    seq_len=len(seq)
    GC=(g_content+c_content)/float(seq_len)
    return GC
#opens file I want to create and loop over lines
f=io.open("barcode_generator.txt","rU")

for line in f:
    linestripped=line.strip()
    linelist=line.split("\t")
    id=linelist[0]
    sequence=linelist[1]
    seqgc=gc_content(sequence)
    print(id+"\t"+str(seqgc))
f.close()
mark122021
  • 61
  • 6

1 Answers1

0

I am not currently up to date with python as I just started myself but would you need the line of code choice=input("How many sequences do you want to generate?") and choice2=input("What is the size that you want your sequence?") to get both of your desired results for your text file?

Jake
  • 243
  • 2
  • 8
  • Wow thanks that actually helps but I don't know where to put that or where it belongs on this code but it seems like a step in the right direction! – mark122021 Mar 18 '21 at 22:04