# bamfiles cannot be detected as bam datatype

**URL:** <https://help.galaxyproject.org/t/bamfiles-cannot-be-detected-as-bam-datatype/8067>\
**Category:** usegalaxy.org support\
**Tags:** mapping, samtools\
**Created:** [May 19, 2022, 11:06am UTC](https://help.galaxyproject.org/t/bamfiles-cannot-be-detected-as-bam-datatype/8067 "2022-05-19T11:06:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielleBianchi](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/daniellebianchi/32/3380_2.png) [@DanielleBianchi](https://help.galaxyproject.org/u/DanielleBianchi)\
**Post date:** [May 19, 2022, 11:06am UTC](https://help.galaxyproject.org/t/bamfiles-cannot-be-detected-as-bam-datatype/8067/1 "2022-05-19T11:06:28Z")

</div>

I have tried uploading several .bam datafiles, but for some reason they cannot be detected as the bam datatype (and therefore not used in my workflow). I’ve tried manually setting the datatype to bam both before and after uploading the files. But it gives me the error ‘An error occurred setting the metadata for this dataset. Set it manually or retry auto-detection’. Both of these options gave a similar error. The datasets look like the image. I have uploaded .bam files before and it was never an issue. The only difference is that these bamfiles were generated from .cram files. I’m quite novel to working with these datatypes, so hope I’ve given all the information needed to help me with this issue. How can I make sure they are detected as proper bamfiles?

Thanks a lot for the help!

 ![image](https://us1.discourse-cdn.com/flex020/uploads/galaxy/original/2X/0/00cf2bc319781fce0ad718acafbf5db41925c97e.png)

---

<div class="post-metadata">

**Author:** ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)\
**Post date:** [May 19, 2022, 11:01pm UTC](https://help.galaxyproject.org/t/bamfiles-cannot-be-detected-as-bam-datatype/8067/2 "2022-05-19T23:01:11Z")

</div>

Hi @DanielleBianchi

> [@DanielleBianchi](#):
>
> I have uploaded .bam files before and it was never an issue. The only difference is that these bamfiles were generated from .cram files.

**Try this:** check the file content before Upload to Galaxy. Try converting `bam` to `sam` format with `Samtools`. You could also try sorting the `bam`. If it fails for you locally, then it would fail in Galaxy.

**Or, try this:** directly Upload the `cram` data to Galaxy. Most tools do not directly use `cram` format, but you can convert `cram` to `bam` in Galaxy with the tool `Samtools view`.

For either, try letting the `Upload` tool auto detect the format first. If that doesn’t work, you can assign the datatype instead (during Upload – not sure if you tried that already for the `bam` or not).

I’m also not exactly sure how good we are at auto detecting `cram` format right now… but I’ll test that later today or tomorrow since am now curious. If any usage deviates from the above – I’ll post back.

It would be best to do this at the [UseGalaxy.org](http://UseGalaxy.org) or [UseGalaxy.org.au](http://UseGalaxy.org.au) server right now. The [UseGalaxy.eu](http://UseGalaxy.eu) server is [undergoing some admin changes](https://help.galaxyproject.org/t/usegalaxy-eu-unexpected-server-behavior-may-2022/8062) this week, and some odd behavior is expected until the banner clears. It is easier to troubleshoot without complicating factors.

Thanks!
