Commit 7c8fc606 authored by Lucianna Osucha's avatar Lucianna Osucha

Update to protloc et al

parent 31c18c23
......@@ -21,12 +21,34 @@ except OSError as e:
def mapAICs(rna:mRNA.mRNA) -> mRNA.mRNA:
rna.metadata["baseWeights"] = {}
def rankWeight(list_, weight, index):
for i in range(0, len(list_)):
if weight > list_[1]:
list_.insert(i, (index, weight))
i.append((index, weight))
def rankWeight(list_, weight, index):
for i in range(0, len(list_)):
if weight > list_[1]:
list_.insert(i, (index, weight))
i.append((index, weight))
for i in rna.code:
# Go to the desired entry in datafile
m_weights.seek(i * 4)
rna.metadata["baseWeights"].append(unpack('<f', m_weights.read(8))[0])
def insert
def mapAICs(rna:mRNA.mRNA) -> mRNA.mRNA:
rna.metadata["baseWeights"] = []
rna.metadata["baseWeightsOrdered"] = []
for i in rna.code:
# Go to the desired entry in datafile
m_weights.seek(i * 4)
weight = unpack('<f', m_weights.read(4))[0]
rna.metadata["baseWeights"].append(weight)
rankWeight(rna.metadata["baseWeightsOrdered"], weight, i)
return rna
......@@ -6,6 +6,7 @@
import sys
import os
import re
from __init__ import *
from util.AminoChain import *
from util.misc_util import *
......@@ -20,10 +21,16 @@ raise
locStrings = DoubleLinkedList(f_locstrings.readlines())
while locStrings.next != None
if locStrings.data.substring(0,1) == "#":
if re.match(r" {,3}#", locStrings.getData()):
locStrings = locStrings.remove()
else:
i = locStrings.getData().find("#")
if i != -1:
if locStrings.next().substring(0,1) == "#":
locStrings.remove()
#TODO
def tagLocStrings(aac:AminoAcidChain):
cur_loctags = []
for i in range(0, locStrings.len()):
......
......@@ -22,10 +22,11 @@ def deindexCodon(index:int) -> str:
def deindexRNA(code:list) -> str:
result = ''
for i in range (0, len(code), 3):
result = result + codonIndex(code[i])
result = result + deindexCodon(code[i])
i = len(code) % 3
result = result[:-i] + codonIndex(code[-1])
i = (len(code) - 1) % 3
if i != 0:
result = result + deindexCodon(code[-1])[-i:]
return result
......@@ -57,6 +58,7 @@ class mRNA:
self.code:list = cd
<<<<<<< Updated upstream
<<<<<<< Updated upstream
self.baseWeights:list = []
......@@ -76,6 +78,12 @@ class mRNA:
def __str__(self) -> str:
return rnaIndex(self.code) + "\n\n" + self.metadata
=======
self.metadata:dictionary = {}
def __str__(self) -> str:
return deindexRNA(self.code) + "\n\n" + self.metadata
>>>>>>> Stashed changes
class Iterable(mRNA) :
......
......@@ -43,20 +43,61 @@ class RobustLinkedList:
return cls(head, head, cur, len(m_list))
def setData(self, data, force=False):
self.validate(force).data =
def getData(self, force=False):
if self.curNode != None:
print("Current node unset, returning to head")
self.curNode = self.head
if force:
if self.curNode == None:
return None
return self.validate(force=False).data
def validate(self, rebuild=False):
if self.curNode == None:
print("Current node unset, attempting return to head")
if self.head == None:
print("Head unset, attempting set to foot")
if self.foot == None:
if rebuild:
print("Foot unset. Adding empty node...")
self.curNode = RobustLinkedList.ListNode(None)
return self.curNode
else:
print("Foot unset. Returning...")
return None
else:
return self.curNode.data
print ("Foot found!")
if rebuild:
rebuildIndex(True)
return self.curNode
else:
self.head = self.foot
self.curNode = self.foot
return self.curNode
else:
return None
rebuildIndex()
return self.curNode
else:
return self.curNode
def rebuildIndex(backwards=False):
output = "Attempting to rebuild from "
if backwards:
output += "foot"
else:
return self.curNode.data
output += "head"
print(output + "...")
if backwards and self.foot == None:
return False
else if !backwards and self.head == None
return False
if backwards:
self.curNode = self.foot
while self.curNode.prev != None:
self.curNode.next.prev = self.curNode
else:
self.curNode = self.foot
def insert(self, data, priorTo=False, ignoreType=False):
......
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