This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to split/cut/restrict DNA strand

My goal is to split a sequence at a specific site into two separate sequences. Searching for the site should be a bit fuzzy due to sequencing-pipeline (basecalling on MinION) error.

Example:

Assume a sequence as below. X, Y, Q and Z are sequence nucleotides not necessary for understanding the problem but are useful for demonstration purposes.

XXXXXXXXXXXXXXYYYYYACTCATAQQQQQQQQQZZZZZZZZZZZZZ
                   |-----|

I would like to find site ACTCATA (with fuzzy matching) and split the sequence into

XXXXXXXXXXXXXXYYYYY

and

QQQQQQQQQZZZZZZZZZZZZZ

with optionally discarding the matched sequence.

Bonus points if this is done on fastq files where data on quality of reads is also split into new strings.

This could probably be accomplished the pedestrian way in biopython but was wondering if I missed a tool that does what I describe above.

fasta fastq manipulation python r

Thank you @WouterDeCoster. I may end up using this in another part of the pipeline.

1 answer

seqkit

$ cat read.fq
@seq
XXXXXXXXXXXXXXYYYYYACTCATAQQQQQQQQQZZZZZZZZZZZZZ
+
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

$ cat read.fq | seqkit locate -p ACTCATA
seqID   patternName     pattern strand  start   end     matched
seq     ACTCATA ACTCATA +       20      26      ACTCATA

$ cat read.fq | seqkit subseq -r 1:19
@seq
XXXXXXXXXXXXXXYYYYY
+
GGGGGGGGGGGGGGGGGGG

$ cat read.fq | seqkit subseq -r 27:-1
@seq
QQQQQQQQQZZZZZZZZZZZZZ
+
GGGGGGGGGGGGGGGGGGGGGG

for a file full of reads?

Writing a script is the better way for more than one reads :P

Doesn't this expect an exact match?

I'm curious if it's possible, in context of locate target random N mismatches in a string?

seqkit locate is based on regular expression matching not local sequence alignment. So random mismatches can not be achieved.

Log in to answer this question.