Hi everyone,

I have the fastq files for some miRNA libraries prepared with the QIAseq miRNA Library Kit. I have to do the UMI extraction, but the problem is that the UMI is after a common sequence for all the reads, such as this:

> NNNNNNNNNNNNNNNNNNN**AACTGTAGGCACCATCAAT***XXXXXXXXXXXX*NNNNNNNNN

Where the N are the miRNA sequences, the **bold** part is the common sequence for all the reads and the part with all the X is the part with the UMI sequence.

How could I remove the bold part and append the UMI to the header of the fastq file?
The problem is that I have seen that around 3-5% of the reads don't have the common sequence, I suppose that there are sequencing errors and some part of this sequence is changed in some reads, but I don't know how to accept one letter change in the common part.

Thank you very much!
You should be able to do this with UMI tools using the regex UMI extraction mode. 

you can do something like:

```
umi_tools extract --extract-method=regex \
                  --bc-pattern=".+(?P<discard_1>AACTGTAGGCACCATCAAT){s<=2}(?P<umi_1>.{12}).+" \
                   -I input.fastq.gz \
                   -S processed.fastq.gz
```
The `{s<=2}` means "allow two mismatches in the common sequence". Note that this will leave both the Ns at the start of the sequence and the Ns at the end of the sequence intact. If you wish to remove the Ns at the end then you the regex:
`.+(?P<discard_1>AACTGTAGGCACCATCAAT){s<=2}(?P<umi_1>.{12})(?P<discard_2>.{9})`

See more details here:
https://umi-tools.readthedocs.io/en/latest/regex.html#regex-regular-expression-mode