Nov-11-2023, 01:41 PM
I am new at python and I am trying to do my homewrok . I have to write 1000 long DNA seq. and I have to find start and stop codons then I have detect if there is a overlapping genes and I have exclude it . I write these codes but I don't know how to do overlapping part
# Re-use the codes above to find all genes in a sequence (genes cannot overlap in this genome) import random seq='' bases = ['A','T','G','C'] for i in range(0,1000): seqi = random.randint(0,3) #choose a random number that represents a base seq = seq + bases[seqi] #add the base to sequence print(seq) start_codon = 'ATG' stop_codon = ['TAG','TAA','TGA'] genes = [] for i in range(len(seq)): if start_codon == seq[i:i + len(start_codon)]: gene_start_position = i print('Gene found at position', i) for j in range(gene_start_position, len(seq), 3): if seq[j:j + len(start_codon)] in stop_codon: gene_stop_position = j print('Gene is coded up to position', j) gene = seq[gene_start_position:j + len(start_codon)] # Extract the gene genes.append(gene) break[attachment=2638]