Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

q_pos and r_pos indexing #11

Open
paulaberry opened this issue Mar 10, 2021 · 2 comments
Open

q_pos and r_pos indexing #11

paulaberry opened this issue Mar 10, 2021 · 2 comments

Comments

@paulaberry
Copy link

The outputs from alignment.dump() indicate a 1-indexed position number for the start and end of the matching region of the query and reference sequence. However, the output from alignment.r_pos and alignment.q_pos are 0-indexed. The output from alignment.r_end and alignment.q_end are the same as in the output from alignment.dum() and so appear to be 1-indexed. Is this expected behavior and output?

@vpradeep07
Copy link

vpradeep07 commented Feb 19, 2024

Yes, I noticed this as well, and I agree that the 1-indexed printout of the query position is confusing, especially since the internal state variable q_pos is 0-indexed. While I'm not the author (I'm a new user of swalign), I believe this 1-indexing is expected behavior. See code snippet below:

swalign/swalign/__init__.py

Lines 446 to 458 in df1f7f4

q_pre = 'Query: %%%ss ' % maxlen
r_pre = 'Ref : %%%ss ' % maxlen
m_pre = ' ' * (8 + maxlen)
rpos = self.r_pos
if not self.rc:
qpos = self.q_pos
else:
qpos = self.q_end
while q and r and m:
if not self.rc:
out.write(q_pre % (qpos + 1)) # pos is displayed as 1-based

As shown, the author explicitly is adding +1 to the query pos to make it print 1-indexed.

@mbreese
Copy link
Owner

mbreese commented Feb 20, 2024

Yes, you're correct. This is the expected behavior. Typically coordinates that are human readable are reported out as 1-based values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants