# Pipeline Logic

### Flowchart

<figure><img src="https://1177916873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4OEB7VheHjRG5hBZXuPi%2Fuploads%2Fgit-blob-dedcba8ef263b218c8f55dd3417aa57efcbf2e4a%2Fdtma_pipeline_flowchart.png?alt=media" alt=""><figcaption><p>Control and data flow diagram for the DRAGEN Targeted Microbial analysis pipeline</p></figcaption></figure>

### Pipeline Steps

| Step                                        | Module/Script         | Run                                                                                                                                                                                                                                                        |
| ------------------------------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Reference reformatting/validation           | custom script         | If custom reference is provided                                                                                                                                                                                                                            |
| Read QC                                     | trimmomatic           | Always                                                                                                                                                                                                                                                     |
| Primer trimming (on FASTQ)                  | trimmomatic           | If primer set exists                                                                                                                                                                                                                                       |
| Read dehosting                              | human\_read\_scrubber | If checked in Input Form                                                                                                                                                                                                                                   |
| Assembly                                    | MEGAHIT               | If reference FASTA and BED files imply more than one genome as reference                                                                                                                                                                                   |
| Contig clustering                           | CD-HIT                | If assembly ran                                                                                                                                                                                                                                            |
| Reference selection                         | custom script         | If assembly ran, otherwise input reference database is used as is                                                                                                                                                                                          |
| Primer alignment / reformatting             | custom script         | If primer set is provided. Primers are aligned to selected reference sequences if coordinates are not provided. Otherwise, primers mapping to selected reference sequences (based on the provided primer coordinates) are selected as final set of primers |
| Map/Align                                   | DRAGEN                | If at least one reference sequence is generated                                                                                                                                                                                                            |
| Post-facto primer trimming (on BAM)         | custom script         | If Map/Align ran and primer set exists                                                                                                                                                                                                                     |
| Sample filtering based on amplicon coverage | custom script         | If Map/Align ran and primer set exists                                                                                                                                                                                                                     |
| Variant calling                             | DRAGEN                | If Map/Align ran and sample passed filter above                                                                                                                                                                                                            |
| Consensus sequence generation               | custom script         | If Map/Align ran and sample passed filter above                                                                                                                                                                                                            |

### Possible outcomes

| Status                                                                                              | Level    | Outcome                                                                                          | Output files (excluding log files)           |
| --------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------- |
| Pipeline completed                                                                                  | Pipeline | Pipeline exits                                                                                   | All                                          |
| Custom files are not formatted correctly                                                            | Pipeline | Pipeline exits                                                                                   | None                                         |
| None of the primers provided in custom primer definition file align to selected reference sequences | Sample   | Skip post-factor primer trimming and sample filtering based on amplicon coverage for this sample | All except for amplicon-related output files |
| No reference found after assembly                                                                   | Sample   | Do not proceed to short read map alignment for this sample                                       | Contig FASTA                                 |
| Insufficient amplicon coverage                                                                      | Sample   | Do not proceed to variant calling for this sample                                                | Contig FASTA (if assembly was run)           |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.idm.illumina.com/dragen-targeted-microbial/dragen-targeted-microbial/pipeline-logic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
