Commit 08cdddad authored by Lucianna's avatar Lucianna

Near complete rewrite of mRNA.py, authorship claimed as a result.

Moved some things that work better there from mapAIC.py, updating linking in mapAIC.py and modMappings.py
parent e6c7e898
......@@ -10,26 +10,6 @@ from util.mRNA import *
from struct import *
bases = ['A', 'U', 'G', 'C'];
def codonIndex(index:int) -> str:
result = bases[int(index/16)]
result += bases[int((index/4))%4]
result += bases[index%4]
return result
def indexCodon(codon:str) -> int:
result = bases.index(codon[0]) * 16
result += bases.index(codon[1]) * 4
result += bases.index(codon[2])
return result
def mapAICs(rna:mRNA) -> mRNA:
try:
......
......@@ -8,6 +8,7 @@
import sys
import argparse
from struct import *
from util.mRNA import *
try:
m_file = open('codonWeights.dat','r+b')
except OSError as e:
......@@ -15,7 +16,6 @@ except OSError as e:
+ "Constructing new file...", file=sys.stderr)
m_file = open('codonWeights.dat','x+b')
m_file.write(bytearray(pack('<' + 'd'*64, *([0.0]*64))))
from mapAIC import *
parser = argparse.ArgumentParser(description="A helper utility for populating "
......
# mRNA.py
#
# Representation of mRNA strand with a slew of metadata
#
# Authored by:
# Coauthored by: Lucianna Osucha (email:lucianna@vulpinedesigns.com)
# A representation of mRNA strand with a slew of metadata and utils for working
# with it
#
# Authored by: Lucianna Osucha (email:lucianna@vulpinedesigns.com)
bases = ['A', 'U', 'G', 'C'];
def codonIndex(index:int) -> str:
result = bases[int(index/16)]
result += bases[int((index/4))%4]
result += bases[index%4]
return result
def indexCodon(codon:str) -> int:
result = bases.index(codon[0]) * 16
result += bases.index(codon[1]) * 4
result += bases.index(codon[2])
return result
def indexRNA(code:str) -> list:
result = []
for i in range(len(code-2)):
result.append(indexCodon(code[i:i+3])
return result
class mRNA :
def __init__(self,cd:str,og:str,pal:int):
self.code: str = cd
self.code:list[int] = indexRNA(cd)
self.originGene:str = og
self.polyALength:int = pal
......@@ -27,7 +57,14 @@ class mRNA :
self.adjustedWeights:list[float] = []
self.processedBy:list[str] = []
def __string__(self) -> str:
result = ''
for i in range (0, len(self.code), 3):
result = result + codonIndex(self.code[i])
i = len(self.code) % 3
result = result[:-i] + codonIndex(self.code[-1])
return result
class Iterable(mRNA) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment