mirror of
https://github.com/Lukas0025/POC1-SIMD-DNA.git
synced 2025-04-06 23:52:10 +01:00
Added support for decode
This commit is contained in:
parent
dba8571de6
commit
2bedb2a82f
@ -60,15 +60,10 @@ class Assembly:
|
|||||||
elif ":" in ins and is_in:
|
elif ":" in ins and is_in:
|
||||||
break
|
break
|
||||||
elif is_in:
|
elif is_in:
|
||||||
reg = ins.split(" ")
|
reg = self.useMacros(ins).replace(" ", "")
|
||||||
|
|
||||||
if len(reg) > 1:
|
|
||||||
print("WARNING: ASM parsing data molecule with space. All after space is ignored!")
|
|
||||||
|
|
||||||
reg = reg[0]
|
|
||||||
|
|
||||||
if not reg.isspace() and len(reg) > 0:
|
if not reg.isspace() and len(reg) > 0:
|
||||||
datas.append(molecule.parse(self.useMacros(reg)))
|
datas.append(molecule.parse(reg))
|
||||||
|
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
@ -98,3 +93,13 @@ class Assembly:
|
|||||||
|
|
||||||
return gins
|
return gins
|
||||||
|
|
||||||
|
def decode(self, reg):
|
||||||
|
mol = molecule.encode(reg.mol)
|
||||||
|
|
||||||
|
for macro in self.macros:
|
||||||
|
mol = mol.replace(macro[1], macro[0])
|
||||||
|
|
||||||
|
return mol
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,3 +327,41 @@ def parse(notationStr):
|
|||||||
newMolecule.endPad()
|
newMolecule.endPad()
|
||||||
|
|
||||||
return newMolecule
|
return newMolecule
|
||||||
|
|
||||||
|
##
|
||||||
|
# Encode molecule to ASCII reprezentation
|
||||||
|
# @param mol moleculte to encode
|
||||||
|
# @retun STR of ascii reprezentation
|
||||||
|
# @todo support for overhangs
|
||||||
|
#
|
||||||
|
def encode(mol):
|
||||||
|
outstr = ""
|
||||||
|
lastClose = ""
|
||||||
|
lastChain = -1
|
||||||
|
lastBounded = None
|
||||||
|
|
||||||
|
for basePos in range(len(mol)):
|
||||||
|
bounded = False
|
||||||
|
for chainID in range(1, mol.chainsCount()):
|
||||||
|
if isComplementary(mol.getBase(chainID, basePos), mol.getBase(0, basePos)):
|
||||||
|
if not lastBounded or lastBounded is None or lastChain != chainID:
|
||||||
|
lastBounded = True
|
||||||
|
lastChain = chainID
|
||||||
|
outstr += lastClose + "["
|
||||||
|
lastClose = "]"
|
||||||
|
|
||||||
|
bounded = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if (not bounded and lastBounded) or lastBounded is None:
|
||||||
|
lastBounded = False
|
||||||
|
outstr += lastClose + "{"
|
||||||
|
lastClose = "}"
|
||||||
|
|
||||||
|
if mol.getBase(0, basePos) == nothing:
|
||||||
|
break
|
||||||
|
|
||||||
|
outstr += mol.getBase(0, basePos)
|
||||||
|
|
||||||
|
return (outstr + lastClose).replace("{}", "").replace("[]", "")
|
||||||
|
|
@ -69,4 +69,9 @@ for reg in regs:
|
|||||||
|
|
||||||
if args.decode:
|
if args.decode:
|
||||||
# todo: implement it
|
# todo: implement it
|
||||||
pass
|
print()
|
||||||
|
print("Decoded")
|
||||||
|
print("--------------------------------")
|
||||||
|
print()
|
||||||
|
for reg in regs:
|
||||||
|
print(asm.decode(reg))
|
Loading…
x
Reference in New Issue
Block a user