Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a user interface on the console #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 119 additions & 15 deletions opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,127 @@
from lib import cc as virus
from vaccine.load import dat as vaccine
from corona import corona
from viralDNA import viralDNA

virus = virus.replace("T", "U")
vaccine = vaccine.replace("Ψ", "U")
print("\n\nWelcome to: Reverse engineering the coronavirus\n---------------------------")

"""
for i in range(len(virus)-len(vaccine)):
mm = virus[i:i+len(vaccine)]
mr = sum([c1 == c2 for c1,c2 in zip(mm, vaccine)]) / len(vaccine)
if mr > 0.5:
print(i, mr)
exit(0)
"""
# Allows a maximum of 25 gene snippit lengths to be provided
# These are later passed to the virualDNA prototype
vaccine_i = 21562

# vaccine starts at 21508 with a 67% match
# spike protein starts at 21562
vvirus = virus[21508:21508+len(vaccine)]
regions = {
"untranslated_region_f" : 265,
"orf1a_i" : 266 ,
"orf1a_f" : 13483,
"orf1b_i" : 13468,
"orf1b_f" : 21555,
"spike_gp_i" : 21563,
"spike_gp_f" : 25384,
"orf3a_i" : 25393,
"orf3a_f" : 26220,
"envelope_p_i" : 26245,
"envelope_p_f" : 26472,
"membrane_gp_i" : 26523,
"membrane_gp_f" : 27191,
"orf6_i" : 27202,
"orf6_f" : 27387,
"orf7a_i" : 27394,
"orf7a_f" : 27759,
"orf7b_i" : 27756,
"orf7b_f": 27887,
"orf8_i" : 27894,
"orf8_f" : 28259,
"n_p_i" : 28274,
"n_p_f" : 29533,
"orf10_i" : 29558,
"orf10_f" : 29674,
"new_region_i" : 0,
"new_region_f" : 0}

# User has 10 chances to change the regions
for i in range(10):
print("1 - Add a new gene region\n2 - Change a gene region value\n3 - Add the vaccine start index\n4 - Translate/GO")

# User wants to add a new gene region
user_action = int(input())
if (user_action == 1):
print("Press 0 to stop. Enter the start index of the new region: ?")
new_region_i = int(input())

if (new_region_i != 0):
print("Press 0 to stop. Enter the final index of the new region: ?")
new_region_f = int(input())

elif (user_action == 2):
# for region in region_names:
print("Which region do you want to change?\n")
print("Type 0 to go back to Main Menu. Type -1 to skip. Choose a menu option:")
print("1 - Start position of orf1a (Default = 266)\n")
print("2 - End position of orf1a (Default = 13483)\n")
print("3 - Start position of orf1b (Default = 13468)\n")
print("4 - End position of orf1b (Default = 21555)\n")
print("5 - Start position of spike glycoprotein (Default = 21563)\n")
print("6 - End position of spike glycoprotein (Default = 25384)\n")
print("7 - Start position of orf3a (Default = 25393)\n")
print("8 - End position of orf3a (Default = 26220)\n")
print("9 - Start position of envelope protein (Default = 26245)\n")
print("10 - End position of envelope protein (Default = 26472)\n")
print("11 - Start position of membrane glycoprotein (Default = 26523)\n")
print("12 - End position of membrane glycoprotein (Default = 27191)\n")
print("13 - Start position of orf6 (Default = 27202)\n")
print("14 - End position of orf6 (Default = 27387)\n")
print("15 - Start position of orf7a (Default = 27394)\n")
print("16 - End position of orf7a (Default = 27759)\n")
print("17 - Start position of orf7b (Default = 27756)\n")
print("18 - End position of orf7b (Default = 27887)\n")
print("19 - Start position of orf8 (Default = 27894)\n")
print("20 - End position of orf8 (Default = 28259)\n")
print("21 - Start position of nucleocapsid phosphoprotein (Default = 28274)\n")
print("22 - End position of nucleocapsid phosphoprotein (Default = 29533)\n")
print("23 - Start position of orf10 (Default = 29558)\n")
print("24 - End position of orf10 (Default = 29674)\n")
print("25 - Start position of vaccine (Default = 21508)\n")

region_to_change = int(input())

print("\nWhat is the new position?: \n")


try:
new_position = int(input())
regions[region_to_change] = new_position
print("\nChanged value:\n ------------\n " + str(regions[region_to_change]) + "\n")
except:
print("You must enter an integer value.")


elif (user_action == 3):
print("Start (index) of the vaccine: ?")
vaccine_i = int(input())

elif (user_action == 4):
viralDNA = viralDNA(regions)
virus = virus.replace("T", "U")
vaccine = vaccine.replace("Ψ", "U")

"""
for i in range(len(virus)-len(vaccine)):
mm = virus[i:i+len(vaccine)]
mr = sum([c1 == c2 for c1,c2 in zip(mm, vaccine)]) / len(vaccine)
if mr > 0.5:
print(i, mr)
exit(0)
"""

# vaccine starts at 21508 with a 67% match
# spike protein starts at 21562
vvirus = virus[vaccine_i:vaccine_i+len(vaccine)]

print("\n Vaccine in the Virus Gene Seqence \n ------------------------ \n")
print(vvirus)

print("\n Vaccine Gene Seqence \n ------------------------ \n")
print(vaccine)
#viralDNA = viralDNA(untranslated_region_f = untranslated_region_f, orf1a_i = orf1a_i, orf1a_f = orf1a_f, orf1b_i = orf1b_i,orf1b_f = orf1b_f, spike_gp_i = spike_gp_i, spike_gp_f = spike_gp_f, orf3a_i = orf3a_i, orf3a_f = orf3a_f, envelope_p_i = envelope_p_i, envelope_p_f = envelope_p_f, membrane_gp_i = membrane_gp_i, membrane_gp_f = membrane_gp_f, orf6_i = orf6_i, orf6_f = orf6_f, orf7a_i = orf7a_i, orf7a_f = orf7a_f, orf7b_i = orf7b_i, orf7b_f = orf7b_f, orf8_i = orf8_i, orf8_f = orf8_f, n_p_i = n_p_i, n_p_f = n_p_f, orf10_i = orf10_i, orf10_f = orf10_f, new_region_i = 0, new_region_f = 10)

print(vvirus)
print(vaccine)

167 changes: 167 additions & 0 deletions viralDNA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
from lib import cc, translate
import copy

class viralDNA:
# Defaults are set for corona virus
def __init__(self, regions):

untranslated_region_f = regions["untranslated_region_f"]
orf1a_i = regions["orf1a_i"]
orf1a_f = regions["orf1a_f"]
orf1b_i = regions["orf1b_i"]
orf1b_f = regions["orf1b_f"]
spike_gp_i = regions["spike_gp_i"]
spike_gp_f = regions["spike_gp_f"]
orf3a_i = regions["orf3a_i"]
orf3a_f = regions["orf3a_f"]
envelope_p_i = regions["envelope_p_i"]
envelope_p_f = regions["envelope_p_f"]
membrane_gp_i = regions["membrane_gp_i"]
membrane_gp_f = regions["membrane_gp_f"]
orf6_i = regions["orf6_i"]
orf6_f = regions["orf6_f"]
orf7a_i = regions["orf7a_i"]
orf7a_f = regions["orf7a_f"]
orf7b_i = regions["orf7b_i"]
orf7b_f = regions["orf7b_f"]
orf8_i = regions["orf8_i"]
orf8_f = regions["orf8_f"]
n_p_i = regions["n_p_i"]
n_p_f = regions["n_p_f"]
orf10_i = regions["orf10_i"]
orf10_f = regions["orf10_f"]
new_region_i = regions["new_region_i"]
new_region_f = regions["new_region_f"]

print("Initializing Custom viral DNA\n")

# in front "the untranslated leader sequence that ends with the Transcription Regulation Sequence"
self.untranslated_region = cc[0 : untranslated_region_f]

print("Translatng orf1a ... \n")
self.orf1a = translate(cc[orf1a_i - 1 : orf1a_f], True)

# cc[266-1+4398*3:13468] = 'TTT_TTA_AAC' aka 'X_XXY_YYZ'
# https://en.wikipedia.org/wiki/Ribosomal_frameshift
# Programmed −1 Ribosomal Frameshifting
# TODO: add this to the translate function with automatic detection
print("Translatng orf1b ... \n")
self.orf1b = translate(cc[orf1b_i - 1 : orf1b_f], False).strip("*") # chop off the stop, note this doesn't have a start

# exploit vector, this attaches to ACE2. also called "surface glycoprotein"
# https://www.ncbi.nlm.nih.gov/Structure/pdb/6VYB -- open state
# https://www.ncbi.nlm.nih.gov/Structure/pdb/6VXX -- closed state
# 1273 amino acids
# S1 = 14-685
# S2 = 686-1273
# S2' = 816-1273
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2750777/
print("Translatng spike glycoprotein ... \n")
self.spike_glycoprotein = translate(cc[spike_gp_i - 1 :spike_gp_f], True)

print("Translatng orf3 ... \n")
# Forms homotetrameric potassium sensitive ion channels (viroporin) and may modulate virus release.
self.orf3a = translate(cc[orf3a_i-1:orf3a_f], True)

print("Translatng envelope protein ... \n")
# These two characteristics stick out, used in assembly aka they package the virus
self.envelope_protein = translate(cc[envelope_p_i - 1 : envelope_p_f], True) # also known as small membrane

print("Translatng membrane glycoprotein ... \n")
print("membrane_gp_i : " + str(membrane_gp_i))
print("membrane_gp_f : " + str(membrane_gp_f))
self.membrane_glycoprotein = translate(cc[membrane_gp_i - 1 : membrane_gp_f], True)

print("Translatng orf6 ... \n")
self.orf6 = translate(cc[orf6_i - 1 : orf6_f], True)

print("Translatng orf7a ... \n")
self.orf7a = translate(cc[orf7a_i - 1 : orf7a_f], True)

print("Translatng orf7b ... \n")
self.orf7b = translate(cc[orf7b_i - 1 : orf7b_f], True) # is this one real?

print("Translatng orf8 ... \n")
self.orf8 = translate(cc[orf8_i - 1 : orf8_f], True)

# https://en.wikipedia.org/wiki/Capsid
# Packages the positive strand viral genome RNA into a helical ribonucleocapsid
# Includes the "internal" protein (from Coronavirus Pathogenesis)
# https://www.sciencedirect.com/topics/veterinary-science-and-veterinary-medicine/human-coronavirus-oc43
print("Translatng nucleocapsid phosphoprotein ... \n")
self.nucleocapsid_phosphoprotein = translate(cc[n_p_i - 1 : n_p_f], True)

print("Translatng orf10 ... \n")
# might be called the internal protein (Coronavirus Pathogenesis)
self.orf10 = translate(cc[orf10_i - 1 : orf10_f], True)



def __copy__(self):
"""
Shallow copy.
Call with copy.copy
Return value of copy.copy is new shallow copy
"""

# Copies of the class fields (nested objects)
untranslated_region = copy.copy(self.untranslated_region)
orf1a = copy.copy(self.orf1a)
orf1b = copy.copy(self.orf1b)
spike_glycoprotein = copy.copy(self.spike_glycoprotein)
orf3a = copy.copy(self.orf3a)
envelope_protein = copy.copy(self.envelope_protein)
membrane_glycoprotein = copy.copy(self.membrane_glycoprotein)
orf6 = copy.copy(self.orf6)
orf7a = copy.copy(self.orf7a)
orf7b = copy.copy(self.orf7b)
orf8 = copy.copy(self.orf8)
nucleocapsid_phosphoprotein = copy.copy(self.nucleocapsid_phosphoprotein)
orf10 = copy.copy(self.orf10)

new = self.__class__(
self.some_int, some_list_of_objects, some_circular_ref
)
new.__dict__.update(self.__dict__)

return new

def __deepcopy__(self, memo={}):
"""
Deep copy
Call with copy.deepcopy
Return value of copy.deepcopy is new deep copy
Memo is the dictionary used by the `deepcopy` library - prevents circular references.
"""
# Copies of the class fields (nested objects)
untranslated_region = copy.deepcopy(self.untranslated_region, memo)
orf1a = copy.deepcopy(self.orf1a, memo)
orf1b = copy.deepcopy(self.orf1b, memo)
spike_glycoprotein = copy.deepcopy(self.spike_glycoprotein, memo)
orf3a = copy.deepcopy(self.orf3a, memo)
envelope_protein = copy.deepcopy(self.envelope_protein, memo)
membrane_glycoprotein = copy.deepcopy(self.membrane_glycoprotein, memo)
orf6 = copy.deepcopy(self.orf6, memo)
orf7a = copy.deepcopy(self.orf7a, memo)
orf7b = copy.deepcopy(self.orf7b, memo)
orf8 = copy.deepcopy(self.orf8, memo)
nucleocapsid_phosphoprotein = copy.deepcopy(self.nucleocapsid_phosphoprotein, memo)
orf10 = copy.deepcopy(self.orf10, memo)

# Then, let's clone the object itself, using the prepared clones of the
# nested objects.
new = self.__class__(
self.untranslated_region, orf1a, orf1b, spike_glycoprotein, orf3a, envelope_protein, membrane_glycoprotein, orf6, orf7a, orf7b, orf8, nucleocapsid_phosphoprotein, orf10
)
new.__dict__ = copy.deepcopy(self.__dict__, memo)

return new


if __name__ == "__main__":
custom_viralDNA = viralDNA()

shallow_copied_viralDNA = copy.copy(custom_viralDNA)
deep_copied_viralDNA = copy.deepcopy(custom_viralDNA)