Skip to content

Commit

Permalink
rename some methods to be more consistent with sugars naming
Browse files Browse the repository at this point in the history
  • Loading branch information
trichter committed Nov 26, 2024
1 parent f6a948d commit 4528ea7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion anchorna/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _cmd_view(fname_anchor, fname, mode='aa', align=None, score_use_fluke=None):
anchor = anchors[int(align.lower().removeprefix('a'))]
start = max(_apply_mode(fluke.start, fluke.offset, mode=mode) for fluke in anchor)
for seq in seqs:
fluke = anchor.d[seq.id]
fluke = anchor.sid[seq.id]
seq.data = '-' * (start - _apply_mode(fluke.start, fluke.offset, mode=mode)) + seq.data
seqs.write(fname_seq)
subprocess.run(f'jalview {fname_seq} --features {fname_export}'.split())
Expand Down
4 changes: 2 additions & 2 deletions anchorna/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def anchor_at_pos(i, aas, w, gseqid, search_range,
return
words = {gword}
todo = set(aas[1:].ids)
aas = aas.d
aas = aas.todict()
toadd = []
res = [(gscore, i, gseqid)]
nfails = 0
Expand Down Expand Up @@ -270,7 +270,7 @@ def _split_cutout_pos(pos, mode, seqs, anchors, defaultB='^'):
raise ValueError(f'{pos} only allowed in mode seq')
A = pos
if is_real_anchor := (A not in ('start', 'end', 'atg', '*')):
A = anchors[int(A.removeprefix('a'))].d
A = anchors[int(A.removeprefix('a'))].todict_seqid()
if len(ids := set(A.keys()) - set(seqs.keys())) > 0:
warn(f'Some anchor ids {ids} not present in sequences')
return A, B, C, is_real_anchor
Expand Down
12 changes: 6 additions & 6 deletions anchorna/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def id(self):
def __hash__(self):
return hash((self.guide.start, self.guide.len, self.guide.offset))

def todict(self):
def todict_seqid(self):
return {f.seqid: f for f in self}

@property
def d(self):
return self.todict()
def sid(self):
return self.todict_seqid()

@property
def ids(self):
def seqids(self):
return [f.seqid for f in self]

def tostr(self, i='', verbose=False, mode='aa'):
Expand All @@ -99,7 +99,7 @@ def key(f): return (False, '') if f.seqid == self.gseqid else (f.poor, f.seqid)

@property
def guide(self):
return self.d[self.gseqid]
return self.sid[self.gseqid]

@property
def minscore(self):
Expand Down Expand Up @@ -127,7 +127,7 @@ def nicely_overlaps_with(self, a2):
a1 = self.good_flukes
a2 = a2.good_flukes
return (max(a1.guide.start, a2.guide.start) <= min(a1.guide.stop, a2.guide.stop) and
set(a1.ids) == set(a2.ids) and
set(a1.seqids) == set(a2.seqids) and
all((f1.start - f2.start == a1.guide.start - a2.guide.start and f1.poor == f2.poor) for f1, f2 in zip(a1.sort(), a2.sort())))

def join_with(self, a2):
Expand Down

0 comments on commit 4528ea7

Please sign in to comment.