Created
August 22, 2015 16:42
-
-
Save gabefinch/43dc84141c954e022144 to your computer and use it in GitHub Desktop.
This file contains 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
#! /usr/bin/env python | |
#define acceptable input | |
rna = ['a','u','g','c','A','U','G','C',] | |
boxb = 'CCGGGAAAAAGUCCCGG' | |
#convert t to u | |
def makerna(seq): | |
for x in range(len(seq)): | |
if seq[x] == 't': | |
seq[x] ='u' | |
elif seq[x] == 'T': | |
seq[x] = 'U' | |
return seq | |
#check that all characters are acceptable rna code | |
def checkrna(seq): | |
for char in list(seq): | |
if char in rna: | |
pass | |
else: | |
print "Something went wrong: Unexpected input(ACGU only please)!" | |
sys.exit(0) | |
#take input of target | |
target = raw_input("Enter the target sequence (5'-3' up to 80bp): ") | |
target = makerna(target) | |
checkrna(target) | |
#take input of guide | |
guide = raw_input("Enter the Editase guide sequence (5'-3'): ") | |
guide = makerna(guide) | |
checkrna(guide) | |
#pt guide into correct orientation | |
revguide = guide[::-1] | |
#find boxB motif | |
boxbpos = revguide.find(boxb) | |
if boxbpos == -1: | |
print "Something went wrong: No boxB motif was found in your guide!" | |
sys.exit(0) | |
print "boxb offset:", boxbpos | |
row = guide[:boxbpos] + " " + guide[boxbpos + 17:] | |
for x in range(len(revguide)): | |
if revguide[x] == 'a' or 'A': | |
compareguide[x] = 'U' | |
elif revguide[x] == 'u' or 'U': | |
compareguide[x] = 'A' | |
elif revguide[x] == 'c' or 'C': | |
compareguide[x] = 'G' | |
elif revguide[x] == 'g' or 'G': | |
compareguide[x] = 'C' | |
#distance into target that guide starts | |
best = 0 | |
count = 0 | |
for allign in range(len(target)-len(compareguide)): | |
for x in range(len(compareguide)): | |
if target[x] == compareguide[x]: | |
count += 1 | |
if count > best: | |
best = count | |
offset = allign | |
print target | |
print str(offset * ' '),revguide |
This file contains 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
#!/usr/bin/env python3 | |
import os | |
file = open('unreplaced.txt', 'r') | |
i=0 | |
for bits in file: | |
file.seek(i) | |
current = file.read(1) | |
if current == 'A' or current =='T' or current == 'C' or current == 'G': | |
i += 1 | |
else: | |
print (current) | |
print (i) | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment