Python Forum

Full Version: Biopython
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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]
Please provide an example of an overlapping gene and describe how an overlapping gene can be identified.
Are you defining an overlapping gene as finding a start codon before the corresponding end codon in a gene? I think in truth it is more complicated, but for a programming exercise that may be the method?

Overlapping of Genes in the Human Genome