aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-08-18 11:20:37 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-08-18 11:20:37 -0700
commitda2f92077e0d773b065cea1b576d9f5171cd0091 (patch)
treee4c9a66fbe494d607373bf7dbd027f0e5b75f099
parentfe39e4fa983ace442e99a0e8811e69fef18c48d9 (diff)
fix: made window offset a global parameter in anticipation of a cli parameter
-rw-r--r--pangraph/graph.py7
-rw-r--r--pangraph/sequence.py3
2 files changed, 7 insertions, 3 deletions
diff --git a/pangraph/graph.py b/pangraph/graph.py
index 1664d03..a38a4e3 100644
--- a/pangraph/graph.py
+++ b/pangraph/graph.py
@@ -21,6 +21,7 @@ from .utils import Strand, as_string, parse_paf, panic, as_record, new_strand
# ------------------------------------------------------------------------
# globals
+WINDOW = 1000
EXTEND = 2500
pp = pprint.PrettyPrinter(indent=4)
@@ -495,12 +496,14 @@ class Graph(object):
delta = len(blk_list)-len(shared_blks)
if delta > 0 and num_seqs > 1:
print(f"LEN: {delta}", end="\t")
- for i, (left, right) in enumerate([(beg[0]-EXTEND,beg[0]), (end[1],end[1]+EXTEND)]):
+ for n, (left, right) in enumerate([(beg[0]-EXTEND,beg[0]+WINDOW), (end[1]-WINDOW,end[1]+EXTEND)]):
fd, path = tempfile.mkstemp()
try:
with os.fdopen(fd, 'w') as tmp:
for i, tag in enumerate(chain(ref.muts.keys(), qry.muts.keys())):
tmp.write(f">isolate_{i:04d}\n")
+ if left == right:
+ breakpoint("no difference")
blks = self.seqs[tag[0]][left:right]
for b in blks:
tmp.write(b.extract(*tag))
@@ -513,7 +516,7 @@ class Graph(object):
shell=True)
out, err = proc.communicate()
tree = Phylo.read(io.StringIO(out.decode('utf-8')), format='newick')
- print(f"-> NUM {i}: {tree.total_branch_length()}")
+ print(f"-> NUM {n}: {tree.total_branch_length()}")
finally:
os.remove(path)
else:
diff --git a/pangraph/sequence.py b/pangraph/sequence.py
index 6b9baba..c437602 100644
--- a/pangraph/sequence.py
+++ b/pangraph/sequence.py
@@ -173,7 +173,8 @@ class Path(object):
i = np.searchsorted(self.position, beg, side='right') - 1
j = np.searchsorted(self.position, end, side='left')
- assert i < j, f"not sorted, {beg}-{end}"
+ if i > j:
+ breakpoint(f"not sorted, {beg}-{end}")
return l + [n.blk for n in self.nodes[i:j]] + r
elif isinstance(index, int):
i = np.searchsorted(self.position, index, side='right') - 1