Metadata-Version: 2.4
Name: catnip-seq
Version: 0.2.0
Summary: Explore nucleotide divergence and sequence resolution across user-defined categories.
Author-email: Camila Babo <camila.babo@cibio.up.pt>
License: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/CIBIO-BU/catnip
Project-URL: Issues, https://github.com/CIBIO-BU/catnip/issues
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pysam
Requires-Dist: pandas
Requires-Dist: numpy
Dynamic: license-file

# CATnip Workflow
[![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat)](http://bioconda.github.io/recipes/catnip-seq/README.html) [![Anaconda-Server Badge](https://anaconda.org/bioconda/catnip-seq/badges/version.svg)](https://anaconda.org/bioconda/catnip-seq) [![Anaconda-Server Badge](https://anaconda.org/bioconda/catnip-seq/badges/latest_release_date.svg)](https://anaconda.org/bioconda/catnip-seq) [![Anaconda-Server Badge](https://anaconda.org/bioconda/catnip-seq/badges/downloads.svg)](https://anaconda.org/bioconda/catnip-seq) [![Anaconda-Server Badge](https://anaconda.org/bioconda/catnip-seq/badges/license.svg)](https://anaconda.org/bioconda/catnip-seq)

CATnip a tool to assess nucleotide divergence and sequence resolution between user-defined categories.

## Prerequisites

- Conda or Mamba
- Git

## Installation (Recommended)

Install CATnip directly from Bioconda:

```bash
conda create -n catnip -c conda-forge -c bioconda catnip-seq
conda activate catnip
```

Or faster with mamba:

```bash
mamba create -n catnip -c conda-forge -c bioconda catnip-seq
```

## Development Installation

1. **Clone the repository:**
   ```bash
   git clone https://github.com/CIBIO-BU/catnip
   cd catnip
   ```

2. **Create the conda environment:**
   ```bash
   conda env create -f catnip-env.yml
   ```

3. **Activate the environment:**
   ```bash
   conda activate catnip
   ```

4. **Install catnip command:**
   ```bash
   pip install -e .
   ```

5. **Check help message:**
   ```bash
   catnip -h
   ```

6. **Run the test workflow:**
   ```bash
   cd test-workflow
   catnip -i coi_micointf_mil.fasta -f coi_micointf_mil_mapping.tsv -c 0,1,2,3 -p 10
   ```

## Environment Details

The conda environment includes:
- Python 3.11
- CD-HIT 4.8.1 (sequence clustering)
- Bowtie2 2.5.4 (sequence alignment)
- SAMtools (BAM/SAM file processing)
- pysam (Python interface for SAM/BAM files)
- pandas & numpy (data analysis)

## Threads, Memory and Parallel Jobs

After clustering, CATnip aligns each heterogeneous cluster separately. These clusters are processed in parallel:

- `-t THREADS` sets the total number of threads (default: 1). CD-HIT clustering uses all of them.
- `-j PARALLEL_JOBS` sets how many clusters are aligned at the same time (default: same as `-t`). The threads are shared between these jobs, so `-t 8 -j 4` gives each Bowtie2/SAMtools job 2 threads.
- `-m AVAILABLE_MEMORY` (MB) is passed to CD-HIT, and divided between the parallel jobs for sorting the alignments.

Clusters are usually small, so many single-threaded jobs (the default) tend to be fastest. If memory is tight, lower `-j` (each job also runs a Python process that loads the mapping file). Results are the same for any `-t`/`-j` combination.

```bash
catnip -i sequences.fasta -f mapping.tsv -c 0,1,2,3 -p 10 -t 8 -m 16000
catnip -i sequences.fasta -f mapping.tsv -c 0,1,2,3 -p 10 -t 8 -j 4 -m 16000
```

## Implementation Details

- Divergence values are rounded to the NEAREST WHOLE VALUE. However, output is presented with one decimal case.
- Taxa absent from the output file were excluded from the alignment step, as they can be reliably distinguished from all other taxa in the dataset based on the input divergence thresholds.
