<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.3 20210610//EN" "JATS-journalpublishing1-3-mathml3.dtd">
<article xml:lang="EN" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ali="http://www.niso.org/schemas/ali/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" dtd-version="1.3" article-type="research-article">
<front>
<journal-meta>
<journal-id journal-id-type="publisher-id">Front. Microbiol.</journal-id>
<journal-title-group>
<journal-title>Frontiers in Microbiology</journal-title>
<abbrev-journal-title abbrev-type="pubmed">Front. Microbiol.</abbrev-journal-title>
</journal-title-group>
<issn pub-type="epub">1664-302X</issn>
<publisher>
<publisher-name>Frontiers Media S.A.</publisher-name>
</publisher>
</journal-meta>
<article-meta>
<article-id pub-id-type="doi">10.3389/fmicb.2026.1748934</article-id>
<article-version article-version-type="Version of Record" vocab="NISO-RP-8-2008"/>
<article-categories>
<subj-group subj-group-type="heading">
<subject>Original Research</subject>
</subj-group>
</article-categories>
<title-group>
<article-title>Basecalling-free resistance gene identification using a hybrid transformer in raw nanopore signals</article-title>
</title-group>
<contrib-group>
<contrib contrib-type="author">
<name><surname>Jakubicek</surname> <given-names>Roman</given-names></name>
<xref ref-type="aff" rid="aff1"><sup>1</sup></xref>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Conceptualization" vocab-term-identifier="https://credit.niso.org/contributor-roles/conceptualization/">Conceptualization</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Data curation" vocab-term-identifier="https://credit.niso.org/contributor-roles/data-curation/">Data curation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Formal analysis" vocab-term-identifier="https://credit.niso.org/contributor-roles/formal-analysis/">Formal analysis</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Investigation" vocab-term-identifier="https://credit.niso.org/contributor-roles/investigation/">Investigation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Methodology" vocab-term-identifier="https://credit.niso.org/contributor-roles/methodology/">Methodology</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Software" vocab-term-identifier="https://credit.niso.org/contributor-roles/software/">Software</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Visualization" vocab-term-identifier="https://credit.niso.org/contributor-roles/visualization/">Visualization</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; original draft" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-original-draft/">Writing &#x2013; original draft</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; review &amp; editing" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-review-editing/">Writing &#x2013; review &#x00026; editing</role>
<uri xlink:href="https://loop.frontiersin.org/people/1833733"/>
</contrib>
<contrib contrib-type="author">
<name><surname>Vorochta</surname> <given-names>Jevhenij</given-names></name>
<xref ref-type="aff" rid="aff1"><sup>1</sup></xref>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Conceptualization" vocab-term-identifier="https://credit.niso.org/contributor-roles/conceptualization/">Conceptualization</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Data curation" vocab-term-identifier="https://credit.niso.org/contributor-roles/data-curation/">Data curation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Formal analysis" vocab-term-identifier="https://credit.niso.org/contributor-roles/formal-analysis/">Formal analysis</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Investigation" vocab-term-identifier="https://credit.niso.org/contributor-roles/investigation/">Investigation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Methodology" vocab-term-identifier="https://credit.niso.org/contributor-roles/methodology/">Methodology</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Software" vocab-term-identifier="https://credit.niso.org/contributor-roles/software/">Software</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Visualization" vocab-term-identifier="https://credit.niso.org/contributor-roles/visualization/">Visualization</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; original draft" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-original-draft/">Writing &#x2013; original draft</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; review &amp; editing" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-review-editing/">Writing &#x2013; review &#x00026; editing</role>
<uri xlink:href="https://loop.frontiersin.org/people/3369100"/>
</contrib>
<contrib contrib-type="author" corresp="yes">
<name><surname>Jakubickova</surname> <given-names>Marketa</given-names></name>
<xref ref-type="aff" rid="aff1"><sup>1</sup></xref>
<xref ref-type="aff" rid="aff2"><sup>2</sup></xref>
<xref ref-type="corresp" rid="c001"><sup>&#x0002A;</sup></xref>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Conceptualization" vocab-term-identifier="https://credit.niso.org/contributor-roles/conceptualization/">Conceptualization</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Data curation" vocab-term-identifier="https://credit.niso.org/contributor-roles/data-curation/">Data curation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Investigation" vocab-term-identifier="https://credit.niso.org/contributor-roles/investigation/">Investigation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Visualization" vocab-term-identifier="https://credit.niso.org/contributor-roles/visualization/">Visualization</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; original draft" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-original-draft/">Writing &#x2013; original draft</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; review &amp; editing" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-review-editing/">Writing &#x2013; review &#x00026; editing</role>
<uri xlink:href="https://loop.frontiersin.org/people/1147117"/>
</contrib>
<contrib contrib-type="author">
<name><surname>Bezdicek</surname> <given-names>Matej</given-names></name>
<xref ref-type="aff" rid="aff2"><sup>2</sup></xref>
<xref ref-type="aff" rid="aff3"><sup>3</sup></xref>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Data curation" vocab-term-identifier="https://credit.niso.org/contributor-roles/data-curation/">Data curation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Investigation" vocab-term-identifier="https://credit.niso.org/contributor-roles/investigation/">Investigation</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Resources" vocab-term-identifier="https://credit.niso.org/contributor-roles/resources/">Resources</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; review &amp; editing" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-review-editing/">Writing &#x2013; review &#x00026; editing</role>
<uri xlink:href="https://loop.frontiersin.org/people/1162671"/>
</contrib>
<contrib contrib-type="author">
<name><surname>Lengerova</surname> <given-names>Martina</given-names></name>
<xref ref-type="aff" rid="aff2"><sup>2</sup></xref>
<xref ref-type="aff" rid="aff3"><sup>3</sup></xref>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Resources" vocab-term-identifier="https://credit.niso.org/contributor-roles/resources/">Resources</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Supervision" vocab-term-identifier="https://credit.niso.org/contributor-roles/supervision/">Supervision</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; review &amp; editing" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-review-editing/">Writing &#x2013; review &#x00026; editing</role>
<uri xlink:href="https://loop.frontiersin.org/people/1193328"/>
</contrib>
<contrib contrib-type="author">
<name><surname>Vitkova</surname> <given-names>Helena</given-names></name>
<xref ref-type="aff" rid="aff1"><sup>1</sup></xref>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Conceptualization" vocab-term-identifier="https://credit.niso.org/contributor-roles/conceptualization/">Conceptualization</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Funding acquisition" vocab-term-identifier="https://credit.niso.org/contributor-roles/funding-acquisition/">Funding acquisition</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Supervision" vocab-term-identifier="https://credit.niso.org/contributor-roles/supervision/">Supervision</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; original draft" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-original-draft/">Writing &#x2013; original draft</role>
<role vocab="credit" vocab-identifier="https://credit.niso.org/" vocab-term="Writing &#x2013; review &amp; editing" vocab-term-identifier="https://credit.niso.org/contributor-roles/writing-review-editing/">Writing &#x2013; review &#x00026; editing</role>
<uri xlink:href="https://loop.frontiersin.org/people/3324617"/>
</contrib>
</contrib-group>
<aff id="aff1"><label>1</label><institution>Department of Biomedical Engineering, Brno University of Technology</institution>, <city>Brno</city>, <country country="cz">Czechia</country></aff>
<aff id="aff2"><label>2</label><institution>Division of Clinical Microbiology and Immunology, Department of Laboratory Medicine, University Hospital Brno</institution>, <city>Brno</city>, <country country="cz">Czechia</country></aff>
<aff id="aff3"><label>3</label><institution>Division of Clinical Microbiology and Immunology, Department of Laboratory Medicine, Faculty of Medicine, Masaryk University</institution>, <city>Brno</city>, <country country="cz">Czechia</country></aff>
<author-notes>
<corresp id="c001"><label>&#x0002A;</label>Correspondence: Marketa Jakubickova, <email xlink:href="mailto:jakubickova@vut.cz">jakubickova@vut.cz</email></corresp>
</author-notes>
<pub-date publication-format="electronic" date-type="pub" iso-8601-date="2026-02-18">
<day>18</day>
<month>02</month>
<year>2026</year>
</pub-date>
<pub-date publication-format="electronic" date-type="collection">
<year>2026</year>
</pub-date>
<volume>17</volume>
<elocation-id>1748934</elocation-id>
<history>
<date date-type="received">
<day>18</day>
<month>11</month>
<year>2025</year>
</date>
<date date-type="rev-recd">
<day>18</day>
<month>01</month>
<year>2026</year>
</date>
<date date-type="accepted">
<day>21</day>
<month>01</month>
<year>2026</year>
</date>
</history>
<permissions>
<copyright-statement>Copyright &#x000A9; 2026 Jakubicek, Vorochta, Jakubickova, Bezdicek, Lengerova and Vitkova.</copyright-statement>
<copyright-year>2026</copyright-year>
<copyright-holder>Jakubicek, Vorochta, Jakubickova, Bezdicek, Lengerova and Vitkova</copyright-holder>
<license>
<ali:license_ref start_date="2026-02-18">https://creativecommons.org/licenses/by/4.0/</ali:license_ref>
<license-p>This is an open-access article distributed under the terms of the <ext-link ext-link-type="uri" xlink:href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution License (CC BY)</ext-link>. The use, distribution or reproduction in other forums is permitted, provided the original author(s) and the copyright owner(s) are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.</license-p>
</license>
</permissions>
<abstract>
<p>Nanopore sequencing enables real-time access to raw signal data, which brings new possibilities for rapid genomic diagnostics. However, current workflows still primarily rely on basecalling, a computationally intensive step that slows subsequent analysis and limits real-time use. In addition, most current approaches that work with raw signals focus on simple read-level classification tasks and are not designed to detect and localize specific genes, particularly complex genomic features such as antibiotic resistance genes (ARGs). Here, we show that the hybrid convolutional-transformer model, NanoResFormer, can detect clinically relevant ARGs directly from raw nanopore signals without basecalling. The model captures both local and long-range signal patterns and employs a floating-window strategy to process inputs of varying lengths efficiently. In proof-of-concept experiments, NanoResFormer achieved a sensitivity of 92.6% and a precision of over 93%, with short latency, enabling real-time resistome profiling already during sequencing. The proposed approach, therefore, provides rapid access to crucial information, accelerating decision-making in clinical diagnostics and pathogen surveillance.</p></abstract>
<kwd-group>
<kwd>antimicrobial resistance</kwd>
<kwd>convolutional encoder</kwd>
<kwd>floating window approach</kwd>
<kwd><italic>Klebsiella pneumoniae</italic></kwd>
<kwd>real-time detection</kwd>
<kwd>self-attention model</kwd>
<kwd>squiggle</kwd>
</kwd-group>
<funding-group>
<award-group id="gs1">
<funding-source id="sp1">
<institution-wrap>
<institution>Grantov&#x000E1; Agentura &#x0010C;esk&#x000E9; Republiky</institution>
<institution-id institution-id-type="doi" vocab="open-funder-registry" vocab-identifier="10.13039/open_funder_registry">10.13039/501100001824</institution-id>
</institution-wrap>
</funding-source>
</award-group>
<funding-statement>The author(s) declared that financial support was received for this work and/or its publication. This work was supported by a grant project from the Czech Science Foundation [GA23-05845S] and Ministry of Health, Czech Republic &#x02013; conceptual development of research organization (FNBr, 65269705).</funding-statement>
</funding-group>
<counts>
<fig-count count="8"/>
<table-count count="1"/>
<equation-count count="0"/>
<ref-count count="13"/>
<page-count count="11"/>
<word-count count="6565"/>
</counts>
<custom-meta-group>
<custom-meta>
<meta-name>section-at-acceptance</meta-name>
<meta-value>Antimicrobials, Resistance and Chemotherapy</meta-value>
</custom-meta>
</custom-meta-group>
</article-meta>
</front>
<body>
<sec sec-type="introduction" id="s1">
<label>1</label>
<title>Introduction</title>
<p>Nanopore sequencing has emerged as a transformative technology for real-time, long-read analysis of DNA and RNA, eliminating the need for complex library preparation and enabling the continuous streaming of signal-level data as individual molecules pass through the nanopores (<xref ref-type="bibr" rid="B13">Wang et al., 2021</xref>). In a standard analytical workflow, raw current signals (referred to as &#x0201C;squiggles&#x0201D;) are first translated into nucleotide sequences through a process called basecalling. These sequences form the basis for downstream analyses, including alignment, variant calling, or gene annotation. However, basecalling is computationally demanding, often requiring GPU acceleration, which causes a delay in downstream analyses. Consequently, achieving genuine real-time data interpretation or diagnostics remains a significant challenge. Direct processing of raw nanopore signals makes it possible to bypass basecalling entirely and perform tasks such as squiggle classification or feature extraction already during sequencing. Although digital signal processing methods such as the Fourier transform or dynamic time warping might appear suitable for this purpose, their applicability is limited. In nanopore signals, individual current levels reflect k-mers rather than single nucleotides, and the signal is further distorted by noise and variable translocation speeds through the pore (<xref ref-type="bibr" rid="B9">Rang et al., 2018</xref>). As a result, traditional signal processing approaches are insufficient, and direct analysis of raw nanopore signals relies almost exclusively on machine learning methods.</p>
<p>In this context, recent advances in deep learning have enabled a paradigm shift in the field. One of the pioneering models, SquiggleNet, demonstrated the ability to classify nanopore reads directly from their electrical signals (e.g., distinguishing between reads from humans and bacteria) with high accuracy and minimal memory requirements, significantly accelerating decision-making compared to traditional alignment-based workflows (<xref ref-type="bibr" rid="B1">Bao et al., 2021</xref>). Building on this concept, the RawMap tool introduced CPU-efficient classifiers that utilize read prefixes in signal form, enabling real-time selective sequencing strategies such as read-until and the ejection of non-target reads (<xref ref-type="bibr" rid="B10">Sadasivan et al., 2023</xref>). Similarly, ReadCurrent employed a convolution-based architecture to achieve high-accuracy classification of target versus non-target DNA from raw nanopore signals in mixed datasets (human, yeast, bacteria, and viruses) while maintaining low computational requirements (<xref ref-type="bibr" rid="B3">Fan et al., 2024</xref>). Most recently, the Sigmoni tool extended this approach by enabling rapid multiclass classification of large pangenomes directly in the signal space, further demonstrating the potential of basecalling-free workflows for scalable genomic analysis (<xref ref-type="bibr" rid="B11">Shivakumar et al., 2024</xref>). Neural networks have also been applied to detect specific genomic regions directly in raw nanopore signals rather than classifying entire reads. NanoGeneNet, a hybrid convolutional-recurrent model, demonstrated accurate localization and classification of housekeeping genes used in multilocus sequencing typing (MLST) of <italic>Klebsiella pneumoniae</italic>, providing proof of concept for direct gene detection in signal space (<xref ref-type="bibr" rid="B8">Nykrynova et al., 2022</xref>).</p>
<p>A key application where direct signal-based analysis could have a significant impact is the rapid identification of antibiotic resistance genes (ARGs), as knowledge of antibiotic resistance profiles is essential for informed treatment decisions and effective infection control strategies. Unlike housekeeping loci, detecting ARGs is more complex. Resistance genes are highly diverse, may vary in copy number, and are often considerably longer. Thus, they must be recognized in their entirety to distinguish between closely related isoforms. Moreover, ARGs are not universally present in all genomes; thus, models must also reliably detect their absence. This variability in presence, copy number, and length means that the model must be able to recognize both small local patterns in the signal and broader dependencies that extend across thousands of signal samples.</p>
<p>For such complex tasks, transformer-based architectures (<xref ref-type="bibr" rid="B12">Vaswani et al., 2017</xref>) are well-suited. Initially developed for natural language processing, transformers offer distinct advantages when working with sequential data of varying lengths, including superior self-attention mechanisms and efficient parallelization. Compared to recurrent models like Long Short-Term Memory (LSTM) (<xref ref-type="bibr" rid="B4">Hochreiter and Schmidhuber, 1997</xref>), transformers excel at capturing long-range dependencies, an essential feature for identifying complete resistance genes that can span thousands of signal samples. In this context, the convolutional encoder serves to reduce dimensionality and extracts local motifs, while the transformer component models broader signal patterns corresponding to complete gene sequences.</p>
<p>In the present study, a hybrid transformer-based model was designed and tested to detect a panel of clinically relevant ARGs directly from raw nanopore signals. The selected genes cover several antibiotic classes, including &#x003B2;-lactamases (<italic>blaSHV, blaOXA</italic>), aminoglycoside-modifying enzymes (<italic>aac, aph</italic>), efflux pump genes associated with quinolone resistance (<italic>OqxA, OqxB</italic>), tetracycline resistance genes (<italic>tetA, tetD</italic>), and fosfomycin resistance genes (<italic>fosA</italic>) (<xref ref-type="bibr" rid="B6">Li et al., 2023</xref>). To evaluate this approach, raw nanopore sequencing data of <italic>K. pneumoniae</italic> were used, as these genes are frequently found in multidrug-resistant strains of this pathogen, which the WHO recognizes as a critical public health threat (<xref ref-type="bibr" rid="B6">Li et al., 2023</xref>). In proof-of-concept experiments, the transformer model achieved high sensitivity and specificity for gene detection in streaming mode, with minimal latency, making it suitable for real-time applications. By operating directly on raw signals and postponing or even bypassing basecalling, this approach enables the identification of resistance genes during the sequencing process itself. This approach paves the way for real-time resistome profiling in clinical workflows, offering clinicians earlier insights into resistance patterns, enabling more effective treatment selection, and reducing the risk of inappropriate empiric therapy and the spread of resistance in healthcare facilities. The proposed tool, called <italic>NanoResFormer</italic>, including all source code, is available on GitHub: <ext-link ext-link-type="uri" xlink:href="https://github.com/BioSys-BUT/NanoResFormer.git">BioSys-BUT/NanoResFormer.git</ext-link>.</p></sec>
<sec sec-type="materials|methods" id="s2">
<label>2</label>
<title>Materials and methods</title>
<sec>
<label>2.1</label>
<title>Sample collection and sequencing</title>
<p>A total of 61 <italic>K. pneumoniae</italic> isolates were collected between April 2018 and November 2023 from 13 departments at the University Hospital Brno (Brno, CZE). For DNA extraction, the DNeasy PowerSoil Pro Kit (Qiagen, Venlo, NL) was used, and DNA purity was measured using a NanoDrop spectrophotometer (Thermo Fisher Scientific, Waltham, MA, USA). The DNA concentration was checked using the Qubit 3.0 Fluorometer (Thermo Fisher Scientific, Wilmington, DE, USA). The sequencing library was prepared using the Rapid Barcoding Kit 96 V14 (Oxford Nanopore Technologies, Oxford, UK). Sequencing was performed using the PromethION 2 Solo sequencing platform (Oxford Nanopore Technologies, Oxford, UK) with R10.4.1 flow cells, and the obtained data were stored in POD5 format.</p></sec>
<sec>
<label>2.2</label>
<title>Signal dataset preparation</title>
<p>The signal dataset, comprising squiggles with and without target resistance genes, was prepared as follows. First, POD5 files were basecalled (using a super-accurate model) and demultiplexed with Dorado, integrated into MinKNOW (v23.11.5, <ext-link ext-link-type="uri" xlink:href="https://nanoporetech.com/community">nanoporetech.com/community</ext-link>). For each barcode, BAM files were converted to SAM format using Samtools (<xref ref-type="bibr" rid="B2">Danecek et al., 2021</xref>). Next, SAM files, together with POD5 files and FASTA files containing query genes, were processed using NANOSLAST (<xref ref-type="bibr" rid="B5">Jakubickova et al., 2025</xref>), which identifies squiggles containing target genes and their precise positions within the signal. Only squiggles containing the gene of interest that met empirically defined thresholds for minimum match length and alignment score, which reflect each gene&#x00027;s allelic variability, were stored. The thresholds range between 80%&#x02013;90% of the maximum alignment score and 80&#x02013;95% of the length of the searched gene (see <xref ref-type="supplementary-material" rid="SM1">Supplementary Table S1</xref>). Consequently, CSV files were generated containing nanopore signals with the genes of interest and the indices of their start and end points within the signals.</p>
<p>In total, 26,956 nanopore signals containing genes of interest were obtained (for detailed information, see <xref ref-type="supplementary-material" rid="SM1">Supplementary Table S2</xref>). The signal lengths ranged from 5,552 to 1.1 million samples, with average and median lengths of 120,590 and 95,361 samples, respectively. Nanopore signals exceeding 300,000 samples occurred only 1,397 times, accounting for 5.2% of the dataset. The mode signal length was 63,736 samples. The signal length histogram is shown in <xref ref-type="fig" rid="F1">Figure 1</xref>. The length of the selected genes (in the signal form) was, on average, 13,341 samples, with a median of 10,812 samples. As shown in <xref ref-type="fig" rid="F1">Figure 1</xref>, the <italic>OqxB</italic> gene has the longest signal segments, whereas the <italic>fosA</italic> gene has the shortest.</p>
<fig position="float" id="F1">
<label>Figure 1</label>
<caption><p>Box plots showing the distribution of individual gene lengths in the available signal database. Gene labels are displayed on the x-axis, with the corresponding number of genes indicated next to each label. The histogram in the upper-left corner illustrates the distribution of total reads (signals) across the database.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0001.tif">
<alt-text content-type="machine-generated">Box plot showing gene lengths across ten different gene labels. Most groups display similar gene length distributions, with the notable exception of OqxB, which exhibits substantially longer genes and numerous high outliers. An inset histogram above illustrates the distribution of signal lengths, showing a skew towards shorter lengths.</alt-text>
</graphic>
</fig>
<p>The obtained data were divided into training, validation, and test sets in a ratio of approximately 80:15:5, with the split performed at the isolate level (i.e., all signals from a given isolate were assigned to a single set). For batch learning, the training signals were randomly fragmented into segments using the data loader. Each segment was then assigned to one of the 11 classes (10 target genes plus a class with no gene of interest) based on its annotated gene content. Within each batch, segments containing gene information were randomly selected, ranging from 1 to the batch size (BS), and the batch was then supplemented with segments lacking any of the genes of interest. In addition, a database of signals without any genes of interest was created for the testing phase, corresponding to five percent of the total number of signals in the database.</p></sec>
<sec>
<label>2.3</label>
<title>Network architecture design</title>
<p>Given the nature of the processed signals described in Section 2.2, a hybrid network architecture was proposed, combining a convolutional neural network (CNN) subsampling followed by a transformer encoder block (see <xref ref-type="fig" rid="F2">Figure 2B</xref>). The CNN encoder extracts relevant features and substantially downsamples the signals (see <xref ref-type="table" rid="T1">Table 1</xref>). The resulting feature representation is then processed by the transformer encoder, which analyses the signal and assigns it to one of 11 classes via a fully connected classifier.</p>
<fig position="float" id="F2">
<label>Figure 2</label>
<caption><p>Graphical scheme of the proposed pipeline for gene detection in raw nanopore signals. <bold>(A)</bold> Overview of the floating-window approach: reads are divided into segments, processed by a neural network, and output as a classification table with segment-level probabilities. <bold>(B)</bold> Architecture of the proposed hybrid neural network, combining a CNN-based feature extractor with a classification transformer. <bold>(C)</bold> Example of network output: a series of class (gene) assignment probabilities for each segment, followed by backward rearrangement and interpolation of probabilities for each signal point. The real output is shown in <xref ref-type="fig" rid="F6">Figure 6</xref>.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0002.tif">
<alt-text content-type="machine-generated">Diagram with three main components:A) Signal segments are extracted from overlapping windows sliding along the nanopore signal and are then fed into a neural network to obtain gene classification probabilities. B) A feature extractor with convolution layers feeds into a transformer encoder, followed by a classification layer. C) A graph shows the classification probabilities of four genes over signal segments, with gene one and gene three highlighted.</alt-text>
</graphic>
</fig>
<table-wrap position="float" id="T1">
<label>Table 1</label>
<caption><p>Summary table for three models, including the characteristics of the proposed models (number of features and level of sub-sampling), the results achieved on the testing database using the floating-window method, and the time complexity expressed in hours per million signals.</p></caption>
<table frame="box" rules="all">
<thead>
<tr>
<th valign="top" align="left"><bold>Model</bold></th>
<th valign="top" align="left"><bold>&#x00023; feat</bold>.</th>
<th valign="top" align="center"><bold>Sub-samp</bold>.</th>
<th valign="top" align="center"><bold>Sensitivity (%) &#x000B1;CI95</bold></th>
<th valign="top" align="center"><bold>Precision (%) &#x000B1;CI95</bold></th>
<th valign="top" align="center"><bold>*FPR (%) &#x000B1;CI95</bold></th>
<th valign="top" align="center"><bold>Time (h) &#x000B1;CI95</bold></th>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Low</td>
<td valign="top" align="left">8</td>
<td valign="top" align="center">64 &#x000D7; </td>
<td valign="top" align="center">72.8 &#x000B1; 2.5</td>
<td valign="top" align="center">60.4 &#x000B1; 2.0</td>
<td valign="top" align="center">30.5 &#x000B1; 2.4</td>
<td valign="top" align="center"><bold>5.74</bold> <bold>&#x000B1;0.16</bold></td>
</tr>
<tr>
<td valign="top" align="left">Middle</td>
<td valign="top" align="left">64</td>
<td valign="top" align="center">64 &#x000D7; </td>
<td valign="top" align="center">92.6 &#x000B1; 1.3</td>
<td valign="top" align="center"><bold>93.1</bold> <bold>&#x000B1;1.4</bold></td>
<td valign="top" align="center"><bold>3.8</bold> <bold>&#x000B1;1.0</bold></td>
<td valign="top" align="center">6.28 &#x000B1; 0.40</td>
</tr>
<tr>
<td valign="top" align="left">High</td>
<td valign="top" align="left">128</td>
<td valign="top" align="center">16 &#x000D7; </td>
<td valign="top" align="center"><bold>94.6</bold> <bold>&#x000B1;1.2</bold></td>
<td valign="top" align="center">91.1 &#x000B1; 1.6</td>
<td valign="top" align="center">16.0 &#x000B1; 2.0</td>
<td valign="top" align="center">11.08 &#x000B1; 1.36</td>
</tr></tbody>
</table>
<table-wrap-foot>
<p>Sensitivity and accuracy values were obtained as averages for ten genes. The false positive rate (FPR) values were calculated only from signals without the gene of interest. Confidence interval (CI95) values are expressed as &#x000B1; margin of error with level 95% of confidence from 1,000-fold bootstrapping.</p>
<p><sup>&#x0002A;</sup>False positive rate for dataset of signals with no gene of interest.</p>
<p>The best achieved values among the three models are highlighted in bold.</p>
</table-wrap-foot>
</table-wrap>
<p>The CNN-based extractor comprises a series of extraction blocks, each comprising two convolutional layers with a 3 &#x000D7; 3 kernel size, followed by a ReLU activation function. The number of blocks varies for different network variants (see <xref ref-type="table" rid="T1">Table 1</xref>). The ablation study of the number of features and layers in the encoder part was simplified; thus, three model variants were designed and evaluated: Low, Middle, and High (see <xref ref-type="table" rid="T1">Table 1</xref>). These variants differ in the degree of signal downsampling and the number of extracted features. The CNN encoder produces a sub-sampled signal whose reduced length corresponds to the maximum number of tokens in the transformer block, with each token length determined by the number of extracted features.</p>
<p>An additional ablation study was conducted for the transformer part of the model, focusing on the number of heads and layers, which mainly affect the trade-off between sensitivity and precision. These parameters also had a significant impact on FPR values. The results of this ablation study are shown in <xref ref-type="supplementary-material" rid="SM1">Supplementary Figure S1</xref>. Based on the achieved evaluation metrics, a configuration with two layers and one head was chosen for the final model.</p></sec>
<sec>
<label>2.4</label>
<title>Training details</title>
<p>The network was implemented in Python 3.12 with PyTorch (v2.8). Given the multiclass nature of the classification task, the cross-entropy loss function was chosen, along with the ADAM optimization algorithm, using &#x003B2;<sub>1</sub> = 0.900 and &#x003B2;<sub>2</sub> = 0.999. Based on preliminary experiments, the number of epochs was set to 250, and the best model was saved according to validation performance to prevent both overfitting and underfitting.</p>
<p>An ablation study to determine the optimal learning hyperparameters for each model was conducted using a sophisticated Bayesian optimization method, specifically, the learning rate (LR), batch size (BS), and dropout probability (DP). The resulting parameters were consistent across all models: LR = 0.001, BS = 64, and DP = 0.0. This optimization was performed using the Bayesian Optimization package (<xref ref-type="bibr" rid="B7">Nogueira, 2014</xref>) with 20 iterations and 5 initialization points. A 5-fold cross-validation yielded an average classification accuracy of 81.74% (SD 2.53%), indicating low sensitivity to random sampling and suggesting robustness to variations in data balance and variability.</p>
<p>Basic data processing and testing were performed on a workstation equipped with an Intel Core i9 3.70 GHz processor, 64 GB of RAM, a 2 TB M.2 SSD, and an EVGA GeForce RTX 3090 graphics card with 24 GB of GDDR6 memory. For more computationally intensive tasks, such as network training and Bayesian hyperparameter optimization, resources provided by the e-INFRA CZ project (ID:90254) were used.</p></sec>
<sec>
<label>2.5</label>
<title>Training classification performance</title>
<p>The network was trained as a multi-class classifier, assigning signal segments to one of 11 predefined classes. For this classification task, a confusion matrix was computed on the validation set, and the ROC analysis for the Middle model is shown in <xref ref-type="fig" rid="F3">Figure 3</xref> (see <xref ref-type="supplementary-material" rid="SM1">Supplementary Figures S2</xref>, <xref ref-type="supplementary-material" rid="SM1">S3</xref> for the remaining models). During training, the model achieved an average validation accuracy of 87.5%.</p>
<fig position="float" id="F3">
<label>Figure 3</label>
<caption><p>Results showing the success rate of the classification of reads by the trained Middle model on the validation set as a purely classification task (without floating window access). The confusion matrix for individual classes (genes) is shown on the <bold>left</bold>, and the ROC analysis is shown on the <bold>right</bold>.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0003.tif">
<alt-text content-type="machine-generated">Confusion matrix and ROC curves for multi-class classification. The confusion matrix on the left shows true vs. predicted classes with percentages, highlighting high accuracy for several classes such as &#x0201C;fosA&#x0201D; with 85.6% accuracy. The ROC curve on the right displays the true positive rate against the false positive rate for each class, with AUC values ranging from 0.80 to 1.00, indicating high classification performance for most classes.</alt-text>
</graphic>
</fig>
<p>The ROC analysis indicates that the <italic>OqxB</italic> gene (gray curve in <xref ref-type="fig" rid="F3">Figure 3</xref>) is particularly challenging to classify (AUC = 0.80), likely due to its close genomic proximity to <italic>OqxA</italic>. Another contributing factor may be the length of the <italic>OqxB</italic> gene segments, which are the longest among all genes, as shown in <xref ref-type="fig" rid="F1">Figure 1</xref>. Furthermore, a substantial portion of these segments exceeds our window length of 40,000 samples, indicating that partial gene fragments occur more frequently in this gene than in others, which may be the primary reason for the lower accuracy.</p>
<p>Nevertheless, the overall performance improves markedly when using a floating window with a defined overlap, which enables prediction boosting for local classification and supports multiple localization tasks.</p></sec>
<sec>
<label>2.6</label>
<title>Floating window approach for continuous classification</title>
<p>To address the variability and extreme length of signals, an approach utilizing a floating window (shown in <xref ref-type="fig" rid="F2">Figure 2A</xref>) with a window size of 40,000 samples was proposed. The window size covers most gene lengths and allows for a defined extent. Each segment within the floating window is classified; for every shift, the network outputs class-assignment probabilities for the segment. Before being processed by the network, the signal is extended (padded) at both ends by half the window length to mitigate edge effects. The chosen overlap determines the density of classified positions in the signal, which are then interpolated across all signal samples (an example of such a function is shown in <xref ref-type="fig" rid="F2">Figure 2C</xref>). This approach enables the approximation of the gene location, with detection resolution influenced by both the overlap and the window size. However, precise gene positioning is beyond the scope of this study, which focuses solely on gene identification within reads. This process yields 11 probability values per signal sample, corresponding to the predefined classes. The final decision on gene presence or absence is based on selecting the class with the highest probability value for each signal sample. As part of the ablation study performed during the development of the sliding window approach, the impact of the window overlap percentage on detection performance was evaluated, as shown in <xref ref-type="fig" rid="F4">Figure 4</xref>.</p>
<fig position="float" id="F4">
<label>Figure 4</label>
<caption><p>Bar chart showing the average sensitivity (blue) and precision (orange) for all genes, including genes that are not of interest, in the Middle model predictions on the test dataset at different floating window overlap settings.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0004.tif">
<alt-text content-type="machine-generated">Bar chart displaying overall sensitivity and precision based on overlap percentages from fifty to ninety-five percent. Sensitivity and precision are measured from 0.5 to 1.0. Sensitivity values range from 0.862 at fifty percent to 0.967 at ninety-five percent, while precision values range from 0.887 to 0.958.</alt-text>
</graphic>
</fig>
</sec></sec>
<sec id="s3">
<label>3</label>
<title>Results and discussion</title>
<p>Three different models with varying capacities and subsampling rates were designed to evaluate gene detection performance in a continuous detection regime (see <xref ref-type="table" rid="T1">Table 1</xref> for their parameters and time complexity). Models were evaluated on a test dataset comprising 5% of the available data (i.e., 1,343 signals). Sensitivity and precision metrics, summarized in <xref ref-type="table" rid="T1">Table 1</xref>, were calculated to reflect detection performance. The test dataset was also expanded to include signals that did not contain any of the genes of interest in the same quantities as the gene signals. The false positive rate (in <xref ref-type="table" rid="T1">Table 1</xref>) was calculated, reflecting the number of false detections of genes that are not present. The Middle model, achieving almost 93% sensitivity, was selected for further testing as a compromise between performance and computational complexity.</p>
<p>Detailed results for each gene (<xref ref-type="fig" rid="F5">Figure 5</xref>) show a high sensitivity value (92.6% on average), confirming the model&#x00027;s ability to correctly identify genes of interest when present. Furthermore, the achieved precision value indicates that 93.1% of all detections were correctly identified. When the gene was not present in the signal, the model predicted only 3.8% false-positive detections of the gene&#x00027;s presence. The lowest value of metrics was observed for <italic>OqxB</italic> and <italic>tetD</italic>, at 65.5% and 71.7%, respectively. The lower sensitivity value for the <italic>OqxB</italic> gene may be due to its greater length compared to that of other genes. Approximately half of the instances of this gene exceed the size of our window, meaning the model often sees only part of it, potentially leading to inconsistent detection. The main cause of the low precision value for the <italic>tetD</italic> gene may be low data variability due to the limited number of instances of this gene in our dataset (764 occurrences of the gene; see <xref ref-type="supplementary-material" rid="SM1">Supplementary Table S2</xref>).</p>
<fig position="float" id="F5">
<label>Figure 5</label>
<caption><p>Bar chart showing the sensitivity (blue) and precision (orange) for individual gene identification in reads using the floating-window approach with the Middle model on the test dataset.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0005.tif">
<alt-text content-type="machine-generated">Bar chart showing sensitivity and precision for various genes, with blue representing sensitivity and orange representing precision. Genes on the x-axis include blaSHV, blaOXA, aac(3), aph(6)-Id, aph(3&#x0201C;)-Ib, QqxA, QqxB, tetA, tetD, and fosA. Metric values range from 0.6 to 1.0 on the y-axis. Notably, genes like blaSHV and tetD show high sensitivity, while genes like fosA have high precision.</alt-text>
</graphic>
</fig>
<sec>
<label>3.1</label>
<title>Analysis of success rate detection</title>
<p>Introducing a floating window with overlapping acts as a form of boosting, enabling multiple classifications of overlapping signal regions. This approach eliminates false detections caused by the possible inclusion of an incomplete gene region in the currently classified segment. The effect of boosting amplifies with increasing window overlap; however, it also increases computational complexity, as the signal is divided into multiple segments. According to the graph in <xref ref-type="fig" rid="F4">Figure 4</xref>, there is an apparent natural increase in sensitivity; however, the probability of false detection of selected genes in similar regions is also increased, thereby reducing precision. The compromise with the highest average success rate seems to be an 80% overlap.</p>
<p>The possible inclusion of only part of a gene in a floating window is a natural effect that can affect the success of identification. The graph in <xref ref-type="supplementary-material" rid="SM1">Supplementary Figure S4</xref> shows the dependence of the average identification sensitivity (calculated across all ten genes) on the proportion of the gene covered by the floating window, revealing an exponential trend. As the model may rely on different informative regions for different genes and cases, it is therefore unsurprising that the sensitivity reaches its maximum only when the entire gene is contained within the floating window. When only half of the gene is present in the window, the sensitivity decreases to 18%. Problems may thus arise when a gene lies at the end of a nanopore signal and is therefore not fully captured. However, since each strain is sequenced at an average depth of &#x0007E;100 &#x000D7; , other reads typically contain the full gene, effectively mitigating this limitation.</p></sec>
<sec>
<label>3.2</label>
<title>Multiple gene occurrences</title>
<p>ARGs may occur multiple times within a bacterial genome, and similar genes often cluster in close proximity, complicating detection. Therefore, classifying entire read alone is insufficient; the floating window approach offers a new perspective on gene detection, even for multiple occurrences within a single read (signal). For each floating window position, probabilities for all gene classes, including the no gene category, are computed, and the class with the highest probability is selected as a final decision. <xref ref-type="fig" rid="F6">Figure 6</xref> illustrates examples of four signals with multiple occurrences of ARGs. In <xref ref-type="fig" rid="F6">Figure 6C</xref>, a false negative case for the <italic>blaOXA</italic> gene (blue region) is observed, where the predicted absence probability exceeded the presence probability, despite BLAST confirming the gene&#x00027;s presence. This is despite the fact that, according to BLAST detection, the gene is present. Conversely, in the next signal (<xref ref-type="fig" rid="F6">Figure 6D</xref>), <italic>OqxA</italic> shows a high predicted probability despite local alignment failing to detect the gene, with nucleotide sequence identity at only approximately 50%. No such false detections occur in the High model, suggesting that the false detections may be caused by information loss at higher subsampling rates introduced by the encoder or by lower network capacity, making it more difficult to identify slight changes in the signal pattern.</p>
<fig position="float" id="F6">
<label>Figure 6</label>
<caption><p>Examples of four reads (signals in blue, standardised using <italic>z</italic>-score normalisation) illustrating multiple gene detections. The graph displays linearly interpolated probability curves for all 10 gene classes plus the &#x0201C;no gene&#x0201D; class (grey dotted line). Colour-coded columns indicate ground-truth gene regions identified by BLAST. <bold>(A)</bold> Correct identification of three genes; <bold>(B)</bold> correct identification of two genes; <bold>(C)</bold> false negative for the <italic>blaOXA</italic> gene (blue), where the probability assigned to the &#x0201C;no gene&#x0201D; class is higher; <bold>(D)</bold> false positive case, where the model also detects the <italic>OqxA</italic> gene (green).</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0006.tif">
<alt-text content-type="machine-generated">Four panels (A, B, C, D) show graphs of standardized signal z-scores against position in signal with shaded regions indicating detection probabilities and gene annotations. Different colored regions correspond to specific genes such as blaSHV, blaOXA, aac(3), aph(3&#x02019;)-Ib, OqxA, tetD, and others. Each graph includes a legend for gene colors, showing variations in signal detection along gene regions. The signal curves are overlayed on a shaded background, with each panel highlighting different gene configurations and signal distributions.</alt-text>
</graphic>
</fig></sec>
<sec>
<label>3.3</label>
<title>Computational time analysis</title>
<p>The time complexity of the selected model was evaluated on a test dataset under CPU and GPU configurations, with and without parallelization. <xref ref-type="fig" rid="F7">Figure 7</xref> illustrates how time complexity varies with the overlap parameter in the floating window approach. GPU batch processing offers substantial parallelization benefits, reducing computation time to approximately 6 h per million reads. Scaling to a larger number of classes (up to 1,000 gene types) is expected to minimally impact computational complexity, thanks to the network&#x00027;s architecture. Thus, the proposed model shows strong potential for detecting additional resistance-related genes, provided that the annotated dataset is expanded and the model is retrained.</p>
<fig position="float" id="F7">
<label>Figure 7</label>
<caption><p>Comparison of the time complexity of the Middle model depending on the floating-window overlap and the use of parallelization on CPU and GPU devices. The graph on the <bold>left</bold> shows results without batch parallelization, and the graph on the <bold>right</bold> shows results with batch parallelization. Times are converted to hours per million signals (test dataset) and represent the average of ten measurement repetitions.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0007.tif">
<alt-text content-type="machine-generated">Box plots comparing processing times for CPU and CUDA devices across different overlap percentages in two scenarios: non-parallelized (BatchSize=1) and parallelized (BatchSize=64). The plots display variations at 50%, 75%, and 90% overlap, highlighting differences in efficiency between CPU and CUDA processing.</alt-text>
</graphic>
</fig></sec>
<sec>
<label>3.4</label>
<title>Basecalling-free approach in practical application</title>
<p>Nanopore read processing traditionally relies on basecalling, where raw signals are converted into nucleotide sequences before downstream analysis. This conversion introduces substantial delays in the analytic workflow, as shown in <xref ref-type="fig" rid="F8">Figure 8</xref>, which depicts cumulative read processing over time. <xref ref-type="fig" rid="F8">Figure 8</xref> reflects data from the sequencing run described in Section 2.1. Sequencing and basecalling statistics were extracted from MinKNOW logs, while NanoResFormer performance metrics were derived from computational time analysis (Section 3.3).</p>
<fig position="float" id="F8">
<label>Figure 8</label>
<caption><p>Cumulative read counts from a run on the PromethION 2 Solo device (61 <italic>K. pneumoniae</italic> genomes). The green curve shows the number of reads generated during sequencing; the red curve shows the basecalling process (Dorado integrated in MinKNOW, super-accurate model); the yellow curve shows the number of reads processed by NanoResFormer, and the blue curve shows the number of reads processed by NanoGeneNet, both for gene detection and determined based on computational time analysis.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="fmicb-17-1748934-g0008.tif">
<alt-text content-type="machine-generated">Line graph showing the number of reads in millions over time in hours. Four lines represent different technologies: Nanopore sequencer (green), NanoResFormer detector (yellow), Dorado basecaller (red), and NanoGeneNet detector (blue). The Nanopore line quickly saturates, while the NanoResFormer has the steepest initial increase. Dorado shows a slower increase with occasional jumps, and the NanoGeneNet progresses linearly throughout. The y-axis ranges from zero to eighteen million, and the x-axis spans zero to two hundred sixty-four hours.</alt-text>
</graphic>
</fig>
<p>As shown in <xref ref-type="fig" rid="F8">Figure 8</xref>, after 48 h of sequencing, only 20% of reads have been basecalled. Moreover, on the basecalled data, other tools capable of ARG identification need to be applied, further extending the time required to obtain crucial results. In contrast, our basecalling-free approach enables real-time direct analysis of raw signals, including AMR gene detection during sequencing. Within the first six h of sequencing, over one million reads can be screened with &#x0003E;92% sensitivity. The full sequencing run can be processed in approximately 96 h, less than half the time required for basecalling (216 h).</p>
<p>While basecalling remains necessary for some downstream applications, rapid ARGs identification via a basecalling-free strategy offers clear clinical benefits. Using Bernoulli distribution-based calculations and considering the model&#x00027;s sensitivity, the minimum number <italic>n</italic> of reads required to ensure that at least one of the resistant genes is included in the random selection with the specified level of confidence has been estimated. Using the lowest observed gene frequency (<italic>p</italic><sub><italic>min</italic></sub> = 0.0298%, <xref ref-type="supplementary-material" rid="SM1">Supplementary Table S2</xref>) and the formula <italic>n</italic> &#x0003D; <italic>ln</italic>(1 &#x02212; 0.999)/<italic>ln</italic>(1&#x02212;<italic>p</italic><sub><italic>min</italic></sub>), it has been calculated that 24,586 reads are required to achieve 99.9% confidence in detecting at least one target gene. Given NanoResFormer&#x00027;s processing speed (Section 3.3), the first resistant gene is likely to be detected within 9.3 min. If no gene is found during this time, the absence can be inferred. If detected, processing an additional 805,545 reads (&#x0007E;5.2 hours) ensures 99.9% confidence that all resistance genes present are identified.</p></sec>
<sec>
<label>3.5</label>
<title>Comparison with NanoGeneNet</title>
<p>Due to the lack of similar published algorithms for the same task, our proposed approach is primarily compared with NanoGeneNet (<xref ref-type="bibr" rid="B8">Nykrynova et al., 2022</xref>), which, as mentioned in the Introduction, uses a combination of LSTM and CNN. This model was originally evaluated for the classification of seven MLST genes in nanopore signals, achieving a sensitivity of 92.0%. Although our model was designed to detect a different set of genes (10 resistance genes), it achieved very similar results for the same task (i.e., gene identification) on comparable nanopore signals generated using a newer sequencing chemistry (R10 instead of R9), with a sensitivity of 92.6%.</p>
<p>When comparing inference times, transformer-based models demonstrate a clear advantage thanks to their parallelization capabilities and efficient batch processing. The experiment shown in <xref ref-type="fig" rid="F8">Figure 8</xref>, where both tools were evaluated under identical conditions, i.e., on the same hardware and nanopore signal testing database, confirmed this advantage, as NanoGeneNet was up to three times slower at identifying nanopore signals. This performance gap highlights transformer models&#x00027; potential and their suitability for the real-time signal processing tasks addressed in this work.</p>
<p>As noted by the authors of NanoGeneNet (<xref ref-type="bibr" rid="B8">Nykrynova et al., 2022</xref>), training LSTM-based models is challenging and not entirely trivial, often requiring sequential training to mitigate the vanishing and exploding gradient problem. In contrast, transformers enable single-shot training, which makes it feasible to release, in future work, a user-friendly tool that enables users to retrain the model on new or custom nanopore signals.</p>
<p>The final area of comparison is the ability to detect multiple gene occurrences within a single signal. NanoGeneNet does not support this functionality because it uses global signal classification, albeit with localization. In our proposed tool, the implementation of a floating-window approach enables local classification, thereby detecting multiple gene occurrences within a single read.</p></sec>
<sec>
<label>3.6</label>
<title>Limitations</title>
<p>Although this study demonstrates the feasibility of transformer-based resistance gene detection from squiggles, several limitations must be addressed before clinical implementation. The current model was trained on a limited set of resistance genes, restricting its clinical applicability. Expanding the model to cover the comprehensive resistance gene panel required for clinical diagnostics poses significant challenges. Adding more gene classes directly to the existing architecture may be constrained by memory limitations and could reduce classification accuracy due to increased model complexity. A hierarchical modeling approach could be implemented to address this limitation through a two-tier classification system: broad-spectrum models would identify the presence of resistance gene families, followed by specialized models that resolve specific allelic variants when required. This strategy optimizes computational efficiency by avoiding simultaneous searches for all possible alleles and focusing only on those detected during the initial screening, thus making real-time implementation more feasible.</p>
<p>Another limitation may arise during the preparation of training data. Current labeling relies on BLAST-based alignment, which can introduce systematic bias. Specifically, highly variable alleles may evade detection yet remain recognizable to the transformer model, potentially causing false-positive classifications. Furthermore, these tools may not reliably identify newly emerged or significantly mutated variants of resistance genes that the model could still detect.</p>
<p>A further challenge lies in the diversity of sequencing data used to train the model. Training datasets should ideally span multiple library chemistries, flowcell types, and even different sequencing platforms to enhance robustness and generalization. However, creating such a diverse dataset is challenging in practice. Nevertheless, the dataset used in this study is based on the latest R10 chemistry, which is currently the most widely used and serves as the de facto standard in Oxford Nanopore Technologies (ONT) workflows.</p>
<p>To handle over-length reads that transformers cannot efficiently process at their original length, a floating-window approach has been proposed. This method enables the processing of variable-length signals, including extremely long ones, and improves detection success rates. Transformers complexity scales quadratically with token (window length) count; therefore, a 40,000-sample floating window was chosen, covering the lengths of all nine genes except <italic>OqxB</italic> (average length of 40,412 samples). Nevertheless, this gene was included in the study as it represents a borderline case in terms of the length of successful gene identification. Despite its borderline length, <italic>OqxB</italic> identification achieved 66% sensitivity. However, the transformer network cannot capture the entire signal context, and enlarging the window would significantly increase computational time. Overlapping floating windows partially mitigate this limitation, but it remains a practical concern.</p></sec></sec>
<sec sec-type="conclusions" id="s4">
<label>4</label>
<title>Conclusion</title>
<p>ONT sequencers, owing to their portability and growing availability, are emerging as natural candidates for deployment as comprehensive diagnostic platforms rather than simple sequencing devices in clinical microbiology. To realize this vision, diagnostic evaluation must be integrated as an inherent part of the sequencing process. Because nanopore sequencing produces data continuously over tens of hours, real-time diagnostics should ideally commence immediately after each read is measured, long before the sequencing run is complete. However, conventional workflows rely on computationally intensive basecalling, resulting in substantial delays and requiring high-performance hardware.</p>
<p>Our results demonstrate that clinically relevant information can be extracted directly from raw current signals (squiggles), eliminating the need for basecalling. The proposed hybrid convolutional&#x02013;transformer model, NanoResFormer, achieved 92.6% sensitivity with a 3.8% false-positive rate for resistance gene detection. Furthermore, it can screen one million reads in just 6.3 h, approximately half the time required for basecalling alone. Although basecalling remains essential for downstream applications such as genome assembly or variant analysis, our findings show that for targeted diagnostic tasks, a basecalling-free strategy is faster and sufficiently informative. Statistical modeling suggests that a preliminary diagnosis can be achieved within nine minutes of sequencing, as at least one resistant gene can be detected with 99.9% confidence after analyzing only 24,000 reads. Although detecting resistance genes does not, by itself, confirm phenotypic resistance, this work demonstrates the feasibility of signal-level diagnostics performed during sequencing.</p>
<p>Future work will focus on optimizing the approach for continuous real-time processing, including adaptive handling of incoming data streams and expanding the model to a broader spectrum of resistance genes. Further reductions in computational demands may be achieved through efficient transformer variants and optimized data management pipelines. As part of publishing easy-to-use software tools on GitHub, we would also like to create a simple module for user retraining on new or custom data. Ultimately, integrating models such as NanoResFormer directly into ONT sequencing devices could transform them into self-contained diagnostic systems, delivering actionable resistance information in real time and enabling rapid, on-site clinical decision-making.</p></sec>
</body>
<back>
<sec sec-type="data-availability" id="s5">
<title>Data availability statement</title>
<p>NanoResFormer is openly accessible on GitHub (<ext-link ext-link-type="uri" xlink:href="https://github.com/BioSys-BUT/NanoResFormer.git">BioSys-BUT/NanoResFormer.git</ext-link>). All POD5 sequencing data used in this study have been uploaded to the <ext-link ext-link-type="uri" xlink:href="https://data.narodni-repozitar.cz/">Czech National Repository</ext-link> and are available via the following DOI: <ext-link ext-link-type="uri" xlink:href="https://doi.org/10.48700/datst.dj8ys-a4r49">10.48700/datst.dj8ys-a4r49</ext-link>.</p>
</sec>
<sec sec-type="author-contributions" id="s6">
<title>Author contributions</title>
<p>RJ: Conceptualization, Data curation, Formal analysis, Investigation, Methodology, Software, Visualization, Writing &#x02013; original draft, Writing &#x02013; review &#x00026; editing. JV: Conceptualization, Data curation, Formal analysis, Investigation, Methodology, Software, Visualization, Writing &#x02013; original draft, Writing &#x02013; review &#x00026; editing. MJ: Conceptualization, Data curation, Investigation, Visualization, Writing &#x02013; original draft, Writing &#x02013; review &#x00026; editing. MB: Data curation, Investigation, Resources, Writing &#x02013; review &#x00026; editing. ML: Resources, Supervision, Writing &#x02013; review &#x00026; editing. HV: Conceptualization, Funding acquisition, Supervision, Writing &#x02013; original draft, Writing &#x02013; review &#x00026; editing.</p>
</sec>
<ack><title>Acknowledgments</title><p>Computational resources were provided by the e-INFRA CZ project (ID:90254), supported by the Ministry of Education, Youth and Sports of the Czech Republic.</p></ack>
<sec sec-type="COI-statement" id="conf1">
<title>Conflict of interest</title>
<p>The author(s) declared that this work was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.</p>
</sec>
<sec sec-type="ai-statement" id="s8">
<title>Generative AI statement</title>
<p>The author(s) declared that generative AI was not used in the creation of this manuscript.</p>
<p>Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.</p></sec>
<sec sec-type="disclaimer" id="s9">
<title>Publisher&#x00027;s note</title>
<p>All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.</p>
</sec>
<sec sec-type="supplementary-material" id="s10">
<title>Supplementary material</title>
<p>The Supplementary Material for this article can be found online at: <ext-link ext-link-type="uri" xlink:href="https://www.frontiersin.org/articles/10.3389/fmicb.2026.1748934/full#supplementary-material">https://www.frontiersin.org/articles/10.3389/fmicb.2026.1748934/full#supplementary-material</ext-link></p>
<supplementary-material xlink:href="Table_1.xlsx" id="SM1" mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" xmlns:xlink="http://www.w3.org/1999/xlink"/></sec>
<ref-list>
<title>References</title>
<ref id="B1">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Bao</surname> <given-names>Y.</given-names></name> <name><surname>Wadden</surname> <given-names>J.</given-names></name> <name><surname>Erb-Downward</surname> <given-names>J. R.</given-names></name> <name><surname>Ranjan</surname> <given-names>P.</given-names></name> <name><surname>Zhou</surname> <given-names>W.</given-names></name> <name><surname>McDonald</surname> <given-names>T. L.</given-names></name> <etal/></person-group>. (<year>2021</year>). <article-title>SquiggleNet: real-time, direct classification of nanopore signals</article-title>. <source>Genome Biol</source>. <volume>22</volume>:<fpage>298</fpage>. doi: <pub-id pub-id-type="doi">10.1186/s13059-021-02511-y</pub-id><pub-id pub-id-type="pmid">34706748</pub-id></mixed-citation>
</ref>
<ref id="B2">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Danecek</surname> <given-names>P.</given-names></name> <name><surname>Bonfield</surname> <given-names>J. K.</given-names></name> <name><surname>Liddle</surname> <given-names>J.</given-names></name> <name><surname>Marshall</surname> <given-names>J.</given-names></name> <name><surname>Ohan</surname> <given-names>V.</given-names></name> <name><surname>Pollard</surname> <given-names>M. O.</given-names></name> <etal/></person-group>. (<year>2021</year>). <article-title>Twelve years of samtools and bcftools</article-title>. <source>GigaScience</source> <volume>10</volume>:<fpage>giab008</fpage>. doi: <pub-id pub-id-type="doi">10.1093/gigascience/giab008</pub-id><pub-id pub-id-type="pmid">33590861</pub-id></mixed-citation>
</ref>
<ref id="B3">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Fan</surname> <given-names>K.</given-names></name> <name><surname>Li</surname> <given-names>M.</given-names></name> <name><surname>Zhang</surname> <given-names>J.</given-names></name> <name><surname>Xie</surname> <given-names>Z.</given-names></name> <name><surname>Jiang</surname> <given-names>D.</given-names></name> <name><surname>Bo</surname> <given-names>X.</given-names></name> <etal/></person-group>. (<year>2024</year>). <article-title>ReadCurrent: a VDCNN-based tool for fast and accurate nanopore selective sequencing</article-title>. <source>Brief. Bioinformatics</source> <volume>25</volume>:<fpage>bbae435</fpage>. doi: <pub-id pub-id-type="doi">10.1093/bib/bbae435</pub-id><pub-id pub-id-type="pmid">39226890</pub-id></mixed-citation>
</ref>
<ref id="B4">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Hochreiter</surname> <given-names>S.</given-names></name> <name><surname>Schmidhuber</surname> <given-names>J.</given-names></name></person-group> (<year>1997</year>). <article-title>Long short-term memory</article-title>. <source>Neural Comput</source>. <volume>9</volume>, <fpage>1735</fpage>&#x02013;<lpage>1780</lpage>. doi: <pub-id pub-id-type="doi">10.1162/neco.1997.9.8.1735</pub-id></mixed-citation>
</ref>
<ref id="B5">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Jakubickova</surname> <given-names>M.</given-names></name> <name><surname>Zbudilova</surname> <given-names>M.</given-names></name> <name><surname>Suriak</surname> <given-names>M.</given-names></name> <name><surname>Vitkova</surname> <given-names>H.</given-names></name></person-group> (<year>2025</year>). <article-title>&#x0201C;Nanoslast: nanopore signal local alignment and segmentation tool,&#x0201D;</article-title> in <source>World Congress on Electrical Engineering and Computer Systems and Science.</source> doi: <pub-id pub-id-type="doi">10.11159/icbes25.151</pub-id></mixed-citation>
</ref>
<ref id="B6">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Li</surname> <given-names>Y.</given-names></name> <name><surname>Kumar</surname> <given-names>S.</given-names></name> <name><surname>Zhang</surname> <given-names>L.</given-names></name> <name><surname>Wu</surname> <given-names>H.</given-names></name> <name><surname>Wu</surname> <given-names>H.</given-names></name></person-group> (<year>2023</year>). <article-title>Characteristics of antibiotic resistance mechanisms and genes of Klebsiella pneumoniae</article-title>. <source>Open Med</source>. <volume>18</volume>, <fpage>1735</fpage>&#x02013;<lpage>1780</lpage>. doi: <pub-id pub-id-type="doi">10.1515/med-2023-0707</pub-id><pub-id pub-id-type="pmid">37197355</pub-id></mixed-citation>
</ref>
<ref id="B7">
<mixed-citation publication-type="web"><person-group person-group-type="author"><name><surname>Nogueira</surname> <given-names>F.</given-names></name></person-group> (<year>2014</year>). <source>Bayesian Optimization: Open Source Constrained Global Optimization Tool for Python.</source> Available online at: <ext-link ext-link-type="uri" xlink:href="https://github.com/bayesian-optimization/BayesianOptimization">https://github.com/bayesian-optimization/BayesianOptimization</ext-link></mixed-citation>
</ref>
<ref id="B8">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Nykrynova</surname> <given-names>M.</given-names></name> <name><surname>Jakubicek</surname> <given-names>R.</given-names></name> <name><surname>Barton</surname> <given-names>V.</given-names></name> <name><surname>Bezdicek</surname> <given-names>M.</given-names></name> <name><surname>Lengerova</surname> <given-names>M.</given-names></name> <name><surname>Skutkova</surname> <given-names>H.</given-names></name></person-group> (<year>2022</year>). <article-title>Using deep learning for gene detection and classification in raw nanopore signals</article-title>. <source>Front. Microbiol</source>. <volume>13</volume>:<fpage>942179</fpage>. doi: <pub-id pub-id-type="doi">10.3389/fmicb.2022.942179</pub-id><pub-id pub-id-type="pmid">36187947</pub-id></mixed-citation>
</ref>
<ref id="B9">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Rang</surname> <given-names>F. J.</given-names></name> <name><surname>Kloosterman</surname> <given-names>W. P.</given-names></name> <name><surname>de Ridder</surname> <given-names>J.</given-names></name></person-group> (<year>2018</year>). <article-title>From squiggle to basepair: computational approaches for improving nanopore sequencing read accuracy</article-title>. <source>Genome Biol</source>. <volume>19</volume>:<fpage>90</fpage>. doi: <pub-id pub-id-type="doi">10.1186/s13059-018-1462-9</pub-id><pub-id pub-id-type="pmid">30005597</pub-id></mixed-citation>
</ref>
<ref id="B10">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Sadasivan</surname> <given-names>H.</given-names></name> <name><surname>Wadden</surname> <given-names>J.</given-names></name> <name><surname>Goliya</surname> <given-names>K.</given-names></name> <name><surname>Ranjan</surname> <given-names>P.</given-names></name> <name><surname>Dickson</surname> <given-names>R. P.</given-names></name> <name><surname>Blaauw</surname> <given-names>D.</given-names></name> <etal/></person-group>. (<year>2023</year>). <article-title>Rapid real-time squiggle classification for read until using RawMap</article-title>. <source>Arch. Clin. Biomed. Res</source>. <volume>07</volume>:<fpage>45</fpage>. doi: <pub-id pub-id-type="doi">10.26502/acbr.50170318</pub-id><pub-id pub-id-type="pmid">36938368</pub-id></mixed-citation>
</ref>
<ref id="B11">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Shivakumar</surname> <given-names>V. S.</given-names></name> <name><surname>Ahmed</surname> <given-names>O. Y.</given-names></name> <name><surname>Kovaka</surname> <given-names>S.</given-names></name> <name><surname>Zakeri</surname> <given-names>M.</given-names></name> <name><surname>Langmead</surname> <given-names>B.</given-names></name></person-group> (<year>2024</year>). <article-title>Sigmoni: classification of nanopore signal with a compressed pangenome index</article-title>. <source>Bioinformatics</source> <volume>40</volume>, <fpage>i287</fpage>&#x02013;<lpage>i296</lpage>. doi: <pub-id pub-id-type="doi">10.1093/bioinformatics/btae213</pub-id><pub-id pub-id-type="pmid">38940135</pub-id></mixed-citation>
</ref>
<ref id="B12">
<mixed-citation publication-type="book"><person-group person-group-type="author"><name><surname>Vaswani</surname> <given-names>A.</given-names></name> <name><surname>Shazeer</surname> <given-names>N.</given-names></name> <name><surname>Parmar</surname> <given-names>N.</given-names></name> <name><surname>Uszkoreit</surname> <given-names>J.</given-names></name> <name><surname>Jones</surname> <given-names>L.</given-names></name> <name><surname>Gomez</surname> <given-names>A. N.</given-names></name> <etal/></person-group>. (<year>2017</year>). <article-title>&#x0201C;Attention is all you need,&#x0201D;</article-title> in <source>Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS&#x00027;17</source> (<publisher-loc>Red Hook, NY, USA</publisher-loc>: <publisher-name>Curran Associates Inc.</publisher-name>), <fpage>6000</fpage>&#x02013;<lpage>6010</lpage>.</mixed-citation>
</ref>
<ref id="B13">
<mixed-citation publication-type="journal"><person-group person-group-type="author"><name><surname>Wang</surname> <given-names>Y.</given-names></name> <name><surname>Zhao</surname> <given-names>Y.</given-names></name> <name><surname>Bollas</surname> <given-names>A.</given-names></name> <name><surname>Wang</surname> <given-names>Y.</given-names></name> <name><surname>Au</surname> <given-names>K. F.</given-names></name></person-group> (<year>2021</year>). <article-title>Nanopore sequencing technology, bioinformatics and applications</article-title>. <source>Nat. Biotechnol</source>. <volume>39</volume>, <fpage>1348</fpage>&#x02013;<lpage>1365</lpage>. doi: <pub-id pub-id-type="doi">10.1038/s41587-021-01108-x</pub-id><pub-id pub-id-type="pmid">34750572</pub-id></mixed-citation>
</ref>
</ref-list>
<fn-group>
<fn fn-type="custom" custom-type="edited-by" id="fn0001">
<p>Edited by: <ext-link ext-link-type="uri" xlink:href="https://loop.frontiersin.org/people/515161/overview">Yi-Wei Tang</ext-link>, Chongqing Medical University, China</p>
</fn>
<fn fn-type="custom" custom-type="reviewed-by" id="fn0002">
<p>Reviewed by: <ext-link ext-link-type="uri" xlink:href="https://loop.frontiersin.org/people/2346841/overview">Advait Balaji</ext-link>, Occidental Petroleum Corporation, United States</p>
<p><ext-link ext-link-type="uri" xlink:href="https://loop.frontiersin.org/people/987269/overview">Qingwen Li</ext-link>, Chinese Academy of Sciences (CAS), China</p>
</fn>
</fn-group>
</back>
</article>