aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-08-11 11:54:13 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-08-11 11:54:13 -0700
commit211b47294d8e4a0371448c4121a292357d8c7fda (patch)
treec05be4a76ca63f7ccec23ecbb5ab33cf122347fa
parenteddc70e299ca2822680f8b4ac9f277d88af002e5 (diff)
fix: unpack and pack tuple on json serialization for block positions
-rw-r--r--pangraph/block.py4
-rw-r--r--pangraph/graph.py11
2 files changed, 10 insertions, 5 deletions
diff --git a/pangraph/block.py b/pangraph/block.py
index e3953bd..ad4cd7c 100644
--- a/pangraph/block.py
+++ b/pangraph/block.py
@@ -75,7 +75,7 @@ class Block(object):
B = Block()
B.id = d['id']
B.seq = as_array(d['seq'])
- B.pos = d['pos']
+ B.pos = {unpack(k):tuple(v) for k, v in d['pos'].items()}
B.muts = {unpack(k):v for k, v in d['muts'].items()}
return B
@@ -229,7 +229,7 @@ class Block(object):
return {'id' : self.id,
'seq' : "".join(str(n) for n in self.seq),
- 'pos' : self.pos,
+ 'pos' : {pack(k) : v for k,v in self.pos.items()},
'muts' : {pack(k) : fix(v) for k, v in self.muts.items()}}
def __len__(self):
diff --git a/pangraph/graph.py b/pangraph/graph.py
index 70fd102..4ae721d 100644
--- a/pangraph/graph.py
+++ b/pangraph/graph.py
@@ -418,9 +418,14 @@ class Graph(object):
# This is why in from_aln(aln) we set the start index to 0
ref = old_ref[hit['ref']['start']:hit['ref']['end']]
qry = old_qry[hit['qry']['start']:hit['qry']['end']]
- print(ref.positions)
- print(qry.positions)
- breakpoint("test positions")
+
+ # print(ref.positions)
+ # print(qry.positions)
+ # # TODO: check for out of bounds accesses
+ # for tag, item in ref.positions.items():
+ # blks = self.seqs[tag[0]][item-EXTEND:item+EXTEND]
+ # print(f"Isolate: {tag[0]} blocks: {blks}")
+ # breakpoint("test positions")
if hit["orientation"] == Strand.Minus:
qry = qry.rev_cmpl()