Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Biopython
#1
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
   
buran write Nov-11-2023, 02:07 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
Please provide an example of an overlapping gene and describe how an overlapping gene can be identified.
Reply
#3
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
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020