Created
September 6, 2015 03:20
-
-
Save michvaldes001/34292ada056ffd2cf59b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
AT_image = cv2.imread("AT.jpg") | |
TA_image = cv2.imread("TA.jpg") | |
CG_image = cv2.imread("CG.jpg") | |
GC_image = cv2.imread("GC.jpg") | |
dna_render_list = [] | |
input_str = raw_input("Please Enter Something to Encode ") | |
encode = (str(''.join(format(ord(x), 'b') for x in input_str))) | |
print input_str, " in binary is: " | |
print encode | |
print input_str, " in DNA base pairs is: " | |
for base_num, base_num2 in zip(encode[::2], encode[1::2]): | |
base_index = int(base_num + base_num2) | |
if base_index == 00: | |
print "A-T" | |
dna_render_list.append(AT_image) | |
elif base_index == 01: | |
print "T-A" | |
dna_render_list.append(TA_image) | |
elif base_index == 10: | |
print "C-G" | |
dna_render_list.append(CG_image) | |
else: | |
print "G-C" | |
dna_render_list.append(GC_image) | |
stacked_img = np.hstack((dna_render_list)) | |
cv2.imshow("preview", stacked_img) | |
cv2.imwrite('encoded_DNA.jpg',stacked_img) | |
cv2.waitKey() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment