# Using existing alignment

**URL:** https://nextstrain.discourse.group/t/using-existing-alignment/947
**Category:** Help and Getting Started
**Created:** [January 18, 2022, 7:45pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment/947 "2022-01-18T19:45:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sanna](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Sanna](https://nextstrain.discourse.group/u/Sanna)
#### Post date: [January 18, 2022, 7:45pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment/947/1 "2022-01-18T19:45:27Z")

</div>

Hi,

Is it possible to feed nextstrain my own alignment file? Meaning, how is it possible to give it my own alignment and only do the next steps on it, rather than using nextstrain’s alignment rule?  
Both my context and focal datasets are aligned and have the same length.

Thanks!

---

<div class="post-metadata">

### Author: ![james](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/james/32/11_2.png) [@james](https://nextstrain.discourse.group/u/james)
#### Post date: [January 19, 2022, 9:45pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment/947/2 "2022-01-19T21:45:24Z")

</div>

Hi @Sanna – there are two alignment steps in the [nCoV workflow](https://github.com/nextstrain/ncov), which is what I think you’re using?

The first alignment happens per-input, and aligns everything before we move onto the subsampling step(s). This can be skipped by defining an input like so:

```auto
inputs:
  - name: your-input-name
    metadata: "path-to-metadata-tsv"
    aligned: "path-to-alignment"

```

The second alignment happens after subsampling, before we build the phylogeny. There is no way to skip this currently, although it should be quick as it only happens on the subsampled sequences.

---

<div class="post-metadata">

### Author: ![Sanna](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Sanna](https://nextstrain.discourse.group/u/Sanna)
#### Post date: [January 20, 2022, 1:19am UTC](https://nextstrain.discourse.group/t/using-existing-alignment/947/3 "2022-01-20T01:19:37Z")

</div>

Hi @james  
Thank you for your response!  
Is there a way to skip the subsampling step? I have my own focal and context sequences and I would like to create a phylogeny of those only. How would I do that?  
Thanks again!!

---

<div class="post-metadata">

### Author: ![james](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/james/32/11_2.png) [@james](https://nextstrain.discourse.group/u/james)
#### Post date: [January 20, 2022, 1:37am UTC](https://nextstrain.discourse.group/t/using-existing-alignment/947/4 "2022-01-20T01:37:34Z")

</div>

Absolutely – if you don’t explicitly supply a subsampling scheme, or specify “all”, then no subsampling will be used. E.g. the first 2 of the following builds won’t subsample, but the third will use the subsampling scheme “my-scheme” (which itself must be defined):

```auto
builds:
  buildA:
    region: global # this key won't be used, but I think you need at least one key per build?
  buildB:
    subsampling_scheme: all
  buildC:
    subsampling_scheme: my-scheme

```

---

<div class="post-metadata">

### Author: ![Sanna](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Sanna](https://nextstrain.discourse.group/u/Sanna)
#### Post date: [January 29, 2022, 5:28am UTC](https://nextstrain.discourse.group/t/using-existing-alignment/947/5 "2022-01-29T05:28:06Z")

</div>

Hi James. thank you for your response.  
I tried the subsampling\_scheme: all and got an error, saying that my builds file it not valid.  
I looked at the defaults and it looks like the default is no subsampling:

---

<div class="post-metadata">

### Author: ![Sanna](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Sanna](https://nextstrain.discourse.group/u/Sanna)
#### Post date: [January 29, 2022, 5:33am UTC](https://nextstrain.discourse.group/t/using-existing-alignment/947/6 "2022-01-29T05:33:43Z")

</div>

I looked at the defaults and it looks like the default is no subsampling:

```auto
subsampling:
  # Default subsampling logic to select all strains from all inputs (i.e., no subsampling).
  all:
    all:
      no_subsampling: true

```

So I tried this and my builds.yaml file looks like this:

```auto
#Define inputs
inputs:
  - name: test_run
    metadata: data/metadata_delim.tsv
    aligned: data/msa.fasta

#Define builds

refine:
  root: "hCoV-19/Wuhan/WIV04/2019"

```

With this too, I get the following error:

 ![Screen Shot 2022-01-29 at 12.30.05 AM](https://canada1.discourse-cdn.com/flex031/uploads/nextstrain/original/1X/88096619c6340da496307e887d87cf3bf392d1dd.jpeg)  
Could you please help me with this?
