Skip to content

Commit

Permalink
Fix similar qid and sid names
Browse files Browse the repository at this point in the history
  • Loading branch information
aziele committed Feb 27, 2025
1 parent 79b8654 commit e992233
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions psa.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import shutil
import random

__version__ = '1.0.2'
__version__ = '1.0.3'

# Check whether needle is on PATH and marked as executable.
assert shutil.which('needle'), "needle not found (is emboss installed?)"
Expand Down Expand Up @@ -373,11 +373,11 @@ def emboss_parse(handle: Iterable[str]) -> namedtuple:
score = float(cols[2])
# Parse alignment
else:
if line.startswith(qid):
if line.startswith(f'{qid} '):
qaln.append(cols[2])
qpos.append(int(cols[1]))
qpos.append(int(cols[3]))
elif line.startswith(sid):
elif line.startswith(f'{sid} '):
saln.append(cols[2])
spos.append(int(cols[1]))
spos.append(int(cols[3]))
Expand Down
13 changes: 12 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_stretcher_protein(self):
self.assertEqual(len(aln.qaln), len(aln.saln))
self.assertEqual(len(aln.qaln), aln.length)

def test_needle_dna_qid_sid(self):
def test_needle_dna_qid_sid_1(self):
qid = 'dna1'
sid = 'dna2'
qseq = 'ATGCTAGATA'
Expand All @@ -53,6 +53,17 @@ def test_needle_dna_qid_sid(self):
self.assertEqual(aln.qid, qid)
self.assertEqual(aln.sid, sid)

def test_needle_dna_qid_sid_2(self):
qid = 'query1'
sid = 'query10'
qseq = 'ATGCTAGATA'
sseq = 'ATGCTAGTTA'
aln = psa.needle(moltype='nucl', qseq=qseq, sseq=sseq, qid=qid, sid=sid)
self.assertEqual(len(aln.qaln), len(aln.saln))
self.assertEqual(len(aln.qaln), aln.length)
self.assertEqual(aln.qid, qid)
self.assertEqual(aln.sid, sid)


class TestPairwiseAlignment(unittest.TestCase):

Expand Down

0 comments on commit e992233

Please sign in to comment.