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

Edge case in Anneal.products #197

Closed
manulera opened this issue Feb 5, 2024 · 0 comments
Closed

Edge case in Anneal.products #197

manulera opened this issue Feb 5, 2024 · 0 comments

Comments

@manulera
Copy link
Collaborator

manulera commented Feb 5, 2024

Hi @BjornFJohansson this is related to #191. Documenting it here just in case you can think of other places where similar things could happen.

In Anneal.products, this is the line that produces a new sequence based on where the primers anneal

prd = _Dseqrecord(fp) + tpl[fp.position : rp.position] + _Dseqrecord(rp).reverse_complement()

Because of what is described in #161 , previously when fp.position is equal to rp.position, this used to return an empty string for all values except when equal to zero (see below former behaviour of Dseqrecord.getitem).

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

print(Dseqrecord('AAAA', circular=True)[1:1].seq)
# Empty sequence <<<<<<<<<<<<<

Now, in a circular sequence if both indexes are equal, the whole linearised sequence is returned, which is not what you want in this case. This what happens with the following anneal below because of this

cacatacgatttaggtgacactatagaac
CACATCCGAACATAAACAACCCACATACGATTTAGGTGACACTATAGAAC
                             ggttgtttatgttcggatgtg

> What you would want: cacatacgatttaggtgacactatagaaccacatccgaacataaacaacc

> What you get: cacatacgatttaggtgacactatagaacCACATCCGAACATAAACAACCCACATACGATTTAGGTGACACTATAGAACcacatccgaacataaacaacc

To fix this, I have added an extra if statement in this case:

if fp.position == rp.position:
    prd = _Dseqrecord(fp) + _Dseqrecord(rp).reverse_complement()
else:
    # as before
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

1 participant