This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to slice or trim DNA sequence when it encounters NNNN or letters that represent ambiguity in the sequence?

How can I slice DNA sequence whenever NNN occurs and also letters that represent ambiguity? is there any available software tools I can use to do so?

For example:

>chr1:0-45
ATCGCTAGCTAGCTRCGAGCGTAGCNNNNNNCGATCGATCGATCAG

into

>chr1:0-13
ATCGCTAGCTAGCT
>chr1:15-24
CGAGCGTAGC
>chr1:31-45
CGATCGATCGATCAG
fasta sequence genome

1 answer

I don't know if there's any tool, I would write a very simple script to accomplish it. In Python, one can do

[(m.start(0), m.end(0)-1) for m in re.finditer('[ACTG]+', seq)]

where seq = 'ATCGCTAGCTAGCTRCGAGCGTAGCNNNNNNCGATCGATCGATCAG'

You're welcome. I hope it puts you in the right direction. Feel back to ask if you need additional help.

Log in to answer this question.