Skip to content

Commit

Permalink
bring anchorna on par with sugar commit 856f335
Browse files Browse the repository at this point in the history
  • Loading branch information
trichter committed Oct 24, 2024
1 parent 47f3bc0 commit 49982b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 2 additions & 5 deletions anchorna/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,12 @@ def _cmd_view(fname_anchor, fname, mode='aa', align=None, score_use_fluke=None):
else:
offsets_cds = None
if offsets_cds == offsets:
# seqs = seqs[:, 'cds']
# seqs.data = [seq.get('cds', gap='-') for seq in seqs]
seqs = seqs.get((slice(None), 'cds'), gap='-')
seqs = seqs.sl(gap='-')[:, 'cds']
if mode == 'aa':
seqs = seqs.translate(complete=True, final_stop=False)
else:
for seq in seqs:
seq.get(slice(offsets[seq.id], None), gap='-', inplace=True)
#seq.data = seq.data[offsets[seq.id]:]
seq.sl(gap='-', inplace=True)[offsets[seq.id]:]
if mode == 'aa':
seqs = seqs.translate(complete=True)
if align:
Expand Down
3 changes: 2 additions & 1 deletion anchorna/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ def export_dialign(anchors, seqids, mode='aa', score_use_fluke=None):
continue
assert f.len == f0.len
start = _apply_mode(f.start, f.offset, mode)
len_ = _apply_mode(f.len, f.offset, mode, islen=True)
content.append(
f'{i+1} {j+1} {start0+1} {start+1} {f.len} {f.score}\n'
f'{i+1} {j+1} {start0+1} {start+1} {len_} {f.score}\n'
)
return ''.join(content)

Expand Down
6 changes: 3 additions & 3 deletions anchorna/tests/test_anchorna.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_anchorna_workflow_subset():
seqs2 = cutout(seqs, anchors, 'start+10', 'a5^-5')
seqs3 = cutout(seqs, anchors, 'a5^-5', '*>')
seqs4 = cutout(seqs, anchors, '*>', 'end')
assert str(seqs[0, 10:]) == str(seqs2[0] + seqs3[0] + seqs4[0])
assert str(seqs[0, 10:]) == seqs2[0].data + seqs3[0].data + seqs4[0].data

fname = tmpdir / 'pesti_test_cutout.sjson'
assert '' == check(f'anchorna cutout anchors.gff a0> a2< -o {fname}')
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_anchorna_workflow_subset_poor():
seqs2 = cutout(seqs, anchors, 'start+10', 'a5^-5')
seqs3 = cutout(seqs, anchors, 'a5^-5', '*>')
seqs4 = cutout(seqs, anchors, '*>', 'end')
assert str(seqs[0, 10:]) == str(seqs2[0] + seqs3[0] + seqs4[0])
assert str(seqs[0, 10:]) == seqs2[0].data + seqs3[0].data + seqs4[0].data

_fix_open_log_file_on_windows()

Expand Down Expand Up @@ -225,7 +225,7 @@ def test_anchorna_workflow_subset_no_cds():
seqs2 = cutout(seqs, anchors, 'start+10', 'a5^-5')
seqs3 = cutout(seqs, anchors, 'a5^-5', '*>')
seqs4 = cutout(seqs, anchors, '*>', 'end')
assert str(seqs[0, 10:]) == str(seqs2[0] + seqs3[0] + seqs4[0])
assert str(seqs[0, 10:]) == seqs2[0].data + seqs3[0].data + seqs4[0].data

_fix_open_log_file_on_windows()

Expand Down

0 comments on commit 49982b6

Please sign in to comment.