Demo entry 2690706

Test

   

Submitted by anonymous on Sep 16, 2015 at 03:50
Language: Python. Code size: 954 Bytes.

"""
Author: Michael Thomas
Description: STOP Codon Count
File name: CountSTOPs.py
Date: 09/16/15
"""
import sys
#import numpy to convert list to array
import numpy

#import sequence as a string from text file
content_file = open(sys.argv[1] , 'r')
cont_str = content_file.read().strip()
cont_len = len(cont_str)

#split sequence into codons (groups of 3)
dic = [cont_str[i:i+3] for i in range(0, len(cont_str), 3)]
#convert dic from list to dic_a as an array
dic_a = numpy.asarray(dic)

#initialize variables
i = 0
STOP_count = 0

#while loop is used to check for stop codons, stop at length of array
while i < len(dic_a):
    if (dic_a[i] == 'tag') or (dic_a[i] == 'TAG'):
        STOP_count = STOP_count + 1
    elif (dic_a[i] == 'taa') or (dic_a[i] == 'TAA'):
        STOP_count = STOP_count + 1
    elif (dic_a[i] == 'tga') or (dic_a[i] == 'TGA'):
        STOP_count = STOP_count + 1
    i += 1
    
print STOP_count

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).