# Database creation

![Workflow db creation](/files/-LJYLWJ6rt8FQSu-7MYc)

## Workflow for database creation

1\) Download plasmid sequences available in [NCBI refseq](ftp://ftp.ncbi.nlm.nih.gov/refseq/release/plasmid/).

2\) Extract fasta from tar.gz.

3\) Download and extract [NCBI taxonomy](ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz), which will be fed to pATLAS.

4\) Clone this repository:

```
git clone https://github.com/tiagofilipe12/pATLAS
```

5\) Install its [dependencies](https://github.com/tiagofilipe12/pATLAS#dependencies)

6\) Configure the database:

```
createdb <database_name>
pATLAS/patlas/db_manager/db_create.py <database_name>
```

7\) run [MASHix.py](https://github.com/tiagofilipe12/pATLAS#mashixpy) - the output will include a filtered. fasta file (`master_fasta_*.fas`).

8\) run [ABRicate](https://github.com/tseemann/abricate), with CARD, ResFinder, PlasmidFinder, VFDB databases.

```
# e.g.
abricate --db card <master_fasta*.fas> > abr_card.tsv
abricate --db resfinder <master_fasta*.fas> > abr_resfinder.tsv
abricate --db vfdb <master_fasta*.fas> > abr_vfdb.tsv
abricate --db plasmidfinder <master_fasta*.fas> > abr_plasmidfinder.tsv
```

9\) Download the [card index](https://card.mcmaster.ca/download/0/broadstreet-v2.0.2.tar.gz) necessary for the abricate2db.py script (aro\_index.csv).

10\) Update the git submodules (`git submodule update --init --recursive`) and run [abricate2db.py](https://github.com/tiagofilipe12/pATLAS#abricate2dbpy) - using all the previous tsv as input.

```
# e.g.
abricate2db.py -i abr_plasmidfinder.tsv -db plasmidfinder \
    -id 80 -cov 90 -csv aro_index.csv -db_psql <database_name>
```

11\) [dump database to a sql file](/docs/api/database_creation.md#database-export).

### Automation of this steps

This steps are fully automated in the nextflow pipeline [pATLAS-db-creation](https://github.com/tiagofilipe12/pATLAS-db-creation).

### Creating a custom version of pATLAS

If you require to add your own plasmids to pATLAS database without asking to add them to [pATLAS website](https://github.com/tiagofilipe12/pATLAS/tree/70001e32d809856e7f793ffcebd527d812e7824e/docs/www.patlas.site), you can provide custom fasta files when building the database using the `-i` option of [MASHix.py](https://github.com/tiagofilipe12/pATLAS#mashixpy). Then follow the steps [described above](/docs/api/database_creation.md#workflow-for-database-creation).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://patlas.gitbook.io/docs/api/database_creation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
