This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Split read based on conserved sequence repeat

I have reads that contain repeats of 10 nt (conserved sequence is known). I wish to split the reads into subunits, using the 10 nt as "marker" to know where to split.

As example (the conserved sequence is cccgggttta):

>
acagtacccgggtttaatcgatcgatcgtacccgggtttagtacgtacgatcgtcccgggtttatgctgtcgtc

To get:

>
acagtacccgggttta
>
atcgatcgatcgtacccgggttta
>
gtacgtacgatcgtcccgggttta
>
tgctgtcgtc

Help is appreciated, thank you

conserved repeat split-read

1 answer

I would write a Python program (this one uses BioPython) of the sorts:

from Bio import SeqIO

patt = "cccgggttta"

stream = SeqIO.parse("input.fa", format="fasta")

for rec in stream:

    pieces = rec.seq.split(patt)

    for piece in pieces[:-1]:
        print(">piece")
        print(piece + patt) 

    # Last piece does not have pattern
    print(">piece")
    print(pieces[-1])

when run produces:

>piece
acagtacccgggttta
>piece
atcgatcgatcgtacccgggttta
>piece
gtacgtacgatcgtcccgggttta
>piece
tgctgtcgtc

Log in to answer this question.