Skip to main content
`Ctrl`+`K`

# Sample an alignment to a fixed length

Let’s load in an alignment of rodents to use in the examples.

## How to sample the first `n` positions of an alignment

We can use the `fixed_length` app to sample an alignment to a fixed length. By default, it will sample from the beginning of an alignment, the argument `length=20` specifies how many positions to sample.

## How to sample `n` positions from within an alignment

Creating the `fixed_length` app with the argument `start=x` specifies that the sampled sequence should begin `x` positions into the alignment.

## How to sample `n` positions randomly from within an alignment

The start position can be selected at random with `random=True`. An optional `seed` can be provided to ensure the same start position is used when the app is called.