# How to realign a CRAM file to a new reference with DRAGEN

CRAM is a reference-based compression format that offers better compression than BAM and SAM. The **reference** used for compression is crucial to decompress the CRAM file.

In software versions **prior to DRAGEN v4.0.3**, in order to re-align a CRAM file to a different reference, a **two-step process** must be followed.

1. CRAM to BAM: use the **original reference** to convert the **CRAM file to BAM file**; Relevant flags:

* '--cram-input --enable-map-align true --enable-map-align-output true --output-format BAM --enable-bam-indexing true --ref-dir \<Path to original reference's hash table>....'

2. BAM to CRAM with new reference: relevant flags:

* '-b --enable-map-align true --enable-map-align-output true --output-format CRAM --ref-dir \<Path to new reference's hash table>....'

With **DRAGEN v4.0.3**, a **single step** is used by including the flag:

* **--cram-reference** flag -
* Relevant flags:
  * -r \<Path to new reference's hash table> --cram-input --output-directory \<out\_dir> --output-file-prefix \<out\_prefix> --cram-reference \<Path to original reference's hash table or original reference FASTA file (and FAI file)>

See the [DRAGEN v4.0.3 user guide](https://support-docs.illumina.com/SW/DRAGEN_v40/Content/SW/DRAGEN/Inputfiles_fDG.htm) for more information.

\
\
\ <br>

|                                                                                                                                                                                                                                                                                                                                                                 |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| *For any feedback or questions regarding this article (Illumina Knowledge Article #7021), contact Illumina Technical Support* [*techsupport@illumina.com*](mailto:techsupport@illumina.com?subject=Question%2FFeedback%20Regarding%20Illumina%20Knowledge%20Article%20#000007021%20-%20Software%20\&body=Dear%20Illumina%20Technical%20Support,%0D%0A%0D%0A)*.* |


---

# 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://knowledge.illumina.com/software/general/software-general-reference_material-list/000007021.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.
