# EnteroTyper

This is a set of scripts to type assemblies according to schemes retrieved from Enterobase.

Enterobase databases can be manually retrieved with [EnterobasePull](https://github.com/bfssi-forest-dussault/EnterobasePull). Database files retrieved from Enterobase can be automatically formatted via makeblastdb by the typer script.

## Requirements
- Python >= 3.6
- [ncbi-blast+](https://blast.ncbi.nlm.nih.gov/Blast.cgi?PAGE_TYPE=BlastDocs&DOC_TYPE=Download) (makeblastdb and blastn must be in your $PATH)
- [MUSCLE](https://www.drive5.com/muscle/) (muscle must be in your $PATH)

### Installation
```
pip install EnteroTyper
```

## Usage
### Calling EnteroTyper (*enterotyper.py*)
```
Usage: enterotyper [OPTIONS] COMMAND [ARGS]...

  EnteroTyper is a suite of tools to type and evaluate assemblies with
  Enterobase typing schemes.

Options:
  --help  Show this message and exit.

Commands:
  bulk         Runs typer on many samples simultaneously
  compare      Compares sequence types across samples processed by typer
  concatenate  Concatenate sequences from report files generated by typer
  typer        Types an assembly based on a given Enterobase scheme
```


### Single-sample Usage
```
Usage: enterotyper typer [OPTIONS]

  Types an assembly based on an Enterobase scheme

Options:
  -i, --input_assembly PATH  Path to input assembly in FASTA format
                             [required]
  -db, --database PATH       Path to your MLST database  [required]
  -o, --outdir PATH         Root directory to store all output files
                             [required]
  --create_db                Set this flag to create the blastDB files using
                             makeblastdb in the specified database
                             directory.Will re-create the database files if
                             they are already present.
  -v, --verbose              Set this flag to enable more verbose logging.
  --version                  Specify this flag to print the version and exit.
  --help                     Show this message and exit.
  ```

### Multi-sample Usage
```
Usage: enterotyper bulk [OPTIONS]

  Runs typer on many samples simultaneously

Options:
  -i, --input_dir PATH  Path to directory containing FASTA assemblies
                        [required]
  -db, --database PATH  Path to your MLST database  [required]
  -o, --outdir PATH    Root directory to store all output files  [required]
  --create_db           Set this flag to create the blastDB files using
                        makeblastdb in the specified database directory.Will
                        re-create the database files if they are already
                        present.
  -v, --verbose         Set this flag to enable more verbose logging.
  --version             Specify this flag to print the version and exit.
  --help                Show this message and exit.
```

### Sequence Concatenation
```
Usage: enterotyper concatenate [OPTIONS] [TARGETS]...

  Takes a list of target *.BLASTn_Detailed_Report.tsv files, followed by
  several options. Extracts sequences from the BLASTn report files as FASTA
  files, aligns them all with MUSCLE, and then concatenates all sequences
  into a single FASTA.

Options:
  -o, --outdir PATH     Root directory to store all output files  [required]
  -db, --database PATH  Path to your MLST database  [required]
  -v, --verbose         Set this flag to enable more verbose logging.
  --help                Show this message and exit.
```

### Sequence Comparison
```
Usage: enterotyper compare [OPTIONS] [TARGETS]...

  Takes a list of target *.cgMLST_Allele_Report.tsv files as input.
  Number of mismatches will be indicated in output files -
  a zero means no mismatches between types.

Options:
  -o, --outdir PATH  Root directory to store all output files  [required]
  -v, --verbose       Set this flag to enable more verbose logging.
  --help              Show this message and exit.
```