# Contig 'MT' is not in the reference genome

**URL:** <https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691>\
**Category:** Hail Query & hailctl\
**Created:** [June 2, 2022, 7:22pm UTC](https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691 "2022-06-02T19:22:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rna](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rna](https://discuss.hail.is/u/rna)\
**Post date:** [June 2, 2022, 7:22pm UTC](https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691/1 "2022-06-02T19:22:28Z")

</div>

Hi all, I am trying to import the ClinVar VCF file from ncbi into Hail, but I am getting this error:

```auto
Invalid locus 'MT:235' found. Contig 'MT' is not in the reference genome 'GRCh38'

```

I downloaded the GRCh38 version of the VCF file and used the corresponding ref genome, can I know how to resolve this? Appreciate any input.

---

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [June 2, 2022, 8:25pm UTC](https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691/2 "2022-06-02T20:25:09Z")

</div>

GRCh38 uses chrM for the mitochondrial config (see [reference](https://github.com/broadinstitute/gatk/blob/master/src/test/resources/large/Homo_sapiens_assembly38.dict)).

You can fix this on import with `hl.import_vcf(...,contig_recoding={'MT': 'chrM'})`.

---

<div class="post-metadata">

**Author:** ![rna](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rna](https://discuss.hail.is/u/rna)\
**Post date:** [June 2, 2022, 10:48pm UTC](https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691/3 "2022-06-02T22:48:30Z")

</div>

> [@danking](#):
>
> {‘MT’: ‘chrM’}

Thank you very much. Is there a way to include it with this line?

```python
recode = {f"{i}":f"chr{i}" for i in (list(range(1, 23)) + ['X', 'Y', 'M'])} 

```

This did not seem to work for me.

---

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [June 3, 2022, 1:09am UTC](https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691/4 "2022-06-03T01:09:28Z")

</div>

Sorry. Above it should have said “contig\_recoding” but the autocorrect changed it to “config\_recoding”. Your list comprehension wont work because it maps M to chrM. You need to remap MT.

---

<div class="post-metadata">

**Author:** ![rna](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rna](https://discuss.hail.is/u/rna)\
**Post date:** [June 3, 2022, 1:04pm UTC](https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691/5 "2022-06-03T13:04:49Z")

</div>

Oh that make sense! However, the VCF file also has the issue where “chr1” is “1”, hence I cannot just do `{'MT': 'chrM'}`. I am not too familiar with this data type, can I know if there is a way to combine with the above recode?

---

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [June 3, 2022, 1:43pm UTC](https://discuss.hail.is/t/contig-mt-is-not-in-the-reference-genome/2691/6 "2022-06-03T13:43:49Z")

</div>

You can combine dictionaries like this:

```auto
contig_recoding={
    “MT”:”chrM”,
    **{f"{i}":f"chr{i}" for i in (list(range(1, 23)) + ['X', 'Y']}
}
```
