0
Q:

7.8 LAB: Double Helix All the Way (Long)

#returns the upstream dna sequence
def find_upstream(dna_sequence):
    index = dna_sequence.find('ATG')
    return dna_sequence[0:index]

# finds and returns the gene sequence
def find_gene(dna_sequence):
    index = dna_sequence.find('ATG')
    return dna_sequence[index:]

# returns the second condon in the gene sequence
def second_condon(gene_sequence):
    return gene_sequence[3:6]

# returns the third condon in the gene sequence
def third_condon(gene_sequence):
    return gene_sequence[6:9]

# returns the complimentary nucleotide
def complementary_nucleotide(nucleotide):
    if nucleotide=='G':
        return 'C'
    elif nucleotide=='C':
        return 'G'
    elif nucleotide=='A':
        return 'T'
    elif nucleotide=='T':
        return 'A'

# returns the complimentary sequence
def complementary_sequence(dna_sequence):
    comp_seq=""
    for n in dna_sequence:
        comp_seq += complementary_nucleotide(n)
    return(comp_seq)

if __name__ == "__main__":
    # assuming string comprises only of C,T,A,G characters
    dna_sequence = input('Enter the DNA sequence:')
    print("Original sequence: "+ dna_sequence)

    gene_sequence = find_gene(dna_sequence)
    location_of_gene = dna_sequence.find(gene_sequence)+1
    print("\nATG condon at bp "+str(location_of_gene))
    print("\tfollowed by {0} at bp {1}".format(second_condon(gene_sequence),str(location_of_gene+3)))
    print("\tfollowed by {0} at bp {1}".format(third_condon(gene_sequence),str(location_of_gene+6)))

    upstream =find_upstream(dna_sequence)
    print('\nUpstream sequence: '+upstream)
    print('Upstream length:   {0} bp'.format(str(len(upstream))))

    print('\nGene sequence: '+gene_sequence)
    print('Gene length:   {0} bp'.format(str(len(gene_sequence))))
    print('[+ Strand]: '+gene_sequence)
    print('            '+'|'*len(gene_sequence))
    print('[+ Strand]: '+complementary_sequence(gene_sequence))
0

New to Communities?

Join the community