# BamAdapter

Auto-generated from the config schema in the source. See the [config guide](https://jbrowse.org/jb2/docs/config_guide) for concepts. Provided by the `alignments` plugin. [View source](https://github.com/GMOD/jbrowse-components/blob/main/plugins/alignments/src/BamAdapter/configSchema.ts).

Reads BAM alignment files, with a BAI or CSI index.

Note: `sequenceAdapter` does **not** need to be specified manually — JBrowse
automatically supplies it from the enclosing assembly's sequence track.

## Example usage

The `uri` shorthand auto-resolves the `.bai` index (pass `csi: true` for a
`.csi` index). For a differently-named index, set `index` explicitly with
the full slot form:

```js
{
  type: 'AlignmentsTrack',
  trackId: 'my_track',
  name: 'My track',
  assemblyNames: ['hg38'],
  adapter: {
    type: 'BamAdapter',
    uri: 'https://example.com/sample.bam',
  },
}
```

JBrowse infers `BamAdapter` and `AlignmentsTrack` from `sample.bam`, and `name` defaults to the file name. In a config declaring one assembly, `assemblyNames` comes from there too — see [the shortest track](https://jbrowse.org/jb2/docs/config_guides/tracks#the-shortest-track).

```js
{
  trackId: 'my_track',
  uri: 'https://example.com/sample.bam',
  assemblyNames: ['hg38'],
}
```

## Related links

- **Track:** [AlignmentsTrack](../alignmentstrack)
- **Display:** [LinearAlignmentsDisplay](../linearalignmentsdisplay)
- **Display:** [LinearMarkDisplay](../linearmarkdisplay)

## Config slots

Adapter slots go inside the track's `adapter`: `"adapter": { "type": "BamAdapter", ... }`. It also accepts the [shorthand](https://jbrowse.org/jb2/docs/config_guides/file_types#the-uri-shorthand) keys `uri`, `baseUri`, `csi` in place of writing a location slot out. Slot types (`fileLocation`, `frozen`, ...) are explained in the [config slot types reference](https://jbrowse.org/jb2/docs/config_guides/slot_types). Slots a base configuration contributes are listed here too, so this table is the whole surface.

| Slot | Description |
| --- | --- |
| **bamLocation**<br>[`fileLocation`](https://jbrowse.org/jb2/docs/config_guides/slot_types#filelocation) = <code>{ uri: '/path/to/my.bam', locationType: 'UriLocation' }</code> | location of the BAM file. Per-base mismatches come from the record's MD tag when it has one, and are otherwise computed against the assembly's reference sequence. |
| **index**<br>[BamIndex](../bamindex) | The BAM index location and its kind. The `uri` shorthand derives both, so a config using it states neither. |
| **fetchSizeLimit**<br>[`number`](https://jbrowse.org/jb2/docs/config_guides/slot_types#number) = <code>5000000</code> | size to fetch in bytes over which to display a warning to the user that too much data will be fetched<br>_advanced_ |

## Retired keys

An older config may still write these. Each loads without an error, and `jbrowse validate` reports it as stale.

| Key | On load |
| --- | --- |
| `sequenceAdapter` | ignored |
| `chunkSizeLimit` | ignored |

