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

How to get antisense sequence from any strings ? #69

Open
galaxy001 opened this issue Aug 9, 2023 · 1 comment
Open

How to get antisense sequence from any strings ? #69

galaxy001 opened this issue Aug 9, 2023 · 1 comment

Comments

@galaxy001
Copy link

How to make a new Read object from string, so that I can call Read.antisense ?

fa = pyfastx.Fastx("x.fq")
for name,seq,_ in fa:
   seqF = seq[:100]

I want to get antisense of seqF.
However, fa[-1][:100] not working as "TypeError: 'Read' object is not subscriptable".

@lmdu
Copy link
Owner

lmdu commented Aug 9, 2023

Currently, the Read object of pyfastx could not support for slicing. You can implement a function for conversion like this:

def reverse_complement(s):
    bases = {'A': 'T', 'G': 'C', 'T': 'A', 'C': 'G', 'N': 'N'}
    return ''.join([bases[b] for b in s][::-1])

fa = pyfastx.Fastx("x.fq")
for name, seq, _ in fa:
   seqF = reverse_complement(seq[:100])

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

2 participants