Skip to content

Instantly share code, notes, and snippets.

@fhennecker
Created March 6, 2015 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhennecker/ff956a2b07480d00b4e6 to your computer and use it in GitHub Desktop.
Save fhennecker/ff956a2b07480d00b4e6 to your computer and use it in GitHub Desktop.
ADN image reader, transciptor in python for Belgian CyberSecurity Challenge
import cv2
img = cv2.imread("image_oversaturated.jpg")
permut = [
{"r":"A", "g":"U", "y":"C", "b":"G"},
{"r":"U", "g":"A", "y":"C", "b":"G"},
{"r":"A", "g":"U", "y":"G", "b":"C"},
{"r":"U", "g":"A", "y":"G", "b":"C"}
]
for permutation in permut:
y = 11 #y+=28
sequence = ""
while y < 840:
x = 10
while x < 570:
color = img[y][x]
if color[0] > 230: # blue
sequence += permutation["b"]
elif color[1] > 230: # green, present in green and yellow
if color[2] > 230: # yellow
sequence += permutation["y"]
else: # green
sequence += permutation["g"]
elif color[2] > 230:
sequence += permutation["r"]
x+=19
y+=28
print sequence
aa = {"UUU":"F", "UUC":"F", "UUA":"L", "UUG":"L",
"UCU":"S", "UCC":"s", "UCA":"S", "UCG":"S",
"UAU":"Y", "UAC":"Y", "UAA":"STOP", "UAG":"STOP",
"UGU":"C", "UGC":"C", "UGA":"STOP", "UGG":"W",
"CUU":"L", "CUC":"L", "CUA":"L", "CUG":"L",
"CCU":"P", "CCC":"P", "CCA":"P", "CCG":"P",
"CAU":"H", "CAC":"H", "CAA":"Q", "CAG":"Q",
"CGU":"R", "CGC":"R", "CGA":"R", "CGG":"R",
"AUU":"I", "AUC":"I", "AUA":"I", "AUG":"M",
"ACU":"T", "ACC":"T", "ACA":"T", "ACG":"T",
"AAU":"N", "AAC":"N", "AAA":"K", "AAG":"K",
"AGU":"S", "AGC":"S", "AGA":"R", "AGG":"R",
"GUU":"V", "GUC":"V", "GUA":"V", "GUG":"V",
"GCU":"A", "GCC":"A", "GCA":"A", "GCG":"A",
"GAU":"D", "GAC":"D", "GAA":"E", "GAG":"E",
"GGU":"G", "GGC":"G", "GGA":"G", "GGG":"G",}
i = 0
prot = ""
while i<len(sequence)-3:
prot+=aa[sequence[i:i+3]]
i+=3
print prot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment