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

Should numbers greater than len raise errors in __get_item__? #162

Open
manulera opened this issue Nov 24, 2023 · 2 comments
Open

Should numbers greater than len raise errors in __get_item__? #162

manulera opened this issue Nov 24, 2023 · 2 comments
Labels

Comments

@manulera
Copy link
Collaborator

manulera commented Nov 24, 2023

I see that it does not raise an error on Seq, but what should it mean on a circular molecule?

  • Should it be made as if it was until the end like in Seq?
  • Should numbers greater than the length be folded (% len)?
  • Current behaviour
  • Raise an error?
print(Seq('AAAA')[0:8])
# AAAA

print(SeqRecord(Seq('AAAA'))[0:8].seq)
# AAAA

print(Dseq('AAAA', circular=False)[0:8])
# AAAA

print(Dseq('AAAA', circular=True)[0:8])
# empty sequence

print(Dseqrecord('AAAA', circular=False)[0:8].seq)
# AAAA

print(Dseqrecord('AAAA', circular=True)[0:8].seq)
# empty sequence
@BjornFJohansson
Copy link
Owner

I would expect this to return the sequence or going around as much as needed.
Perhaps the former as I cant think of a reason for the latter right now.
I agree that the empty string is wrong.

@manulera
Copy link
Collaborator Author

I think the going around would be good, but it should not be allowed to be more than a full circle, I think. For example, in a circular sequence:

seq = Dseq('ACGTA')

seq[3:6] # I would expect TAA
seq[3:8] # I would expect TAACG
seq[3:10] # I would expect TAACG or an error

I think this is more similar to what one would expect from a circular string

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

No branches or pull requests

2 participants