# abcupload

**ABCOMICS Genomic Data Upload Tool**

A command-line tool to upload sequencing and genomic data files to the
[ABCOMICS](https://abcomics.org) platform. It handles the full two-step
upload process automatically: requesting a signed URL from the API, then
streaming the file directly to secure cloud storage with a live progress bar.

---

## Installation

```bash
pip install abcupload
```

Requires Python 3.8 or later. Dependencies (`requests`, `rich`) are installed
automatically.

---

## Quick start

```bash
# Set your API key once (contact contact@abcomics.org to receive it)
export ABCOMICS_API_KEY=your_key_here

# Upload a single file
abcupload -u abc-000001 -p PRJAB00001 -d sample_R1.fastq.gz

# Upload all FASTQ files in the current directory
abcupload -u abc-000001 -p PRJAB00001 -d '*.fastq.gz'

# Upload an entire directory (scans for all accepted formats)
abcupload -u abc-000001 -p PRJAB00001 -d /data/project/

# Upload multiple specific files
abcupload -u abc-000001 -p PRJAB00001 -d file1.bam,file2.bam

# Test mode — files are deleted after 24 hours
abcupload -u abc-000001 -p PRJAB00001 -d '*.fastq.gz' -t
```

---

## Usage

```
abcupload -u USERNAME -p PROJECT_ID -d DATA [OPTIONS]

required:
  -u USERNAME     ABCOMICS username          (e.g. abc-000001)
  -p PROJECT_ID   Project ID                 (e.g. PRJAB00001)
  -d DATA         What to upload:
                    single file  :  -d sample.fastq.gz
                    comma list   :  -d file1.fastq.gz,file2.bam
                    glob pattern :  -d '*.fastq.gz'
                    directory    :  -d /path/to/data/

options:
  -k API_KEY      API key  (alternative to ABCOMICS_API_KEY env var)
  -t              Test mode — files deleted after 24 h
  -o              Overwrite existing files without asking
  -h, --help      Show this help and exit
  -V, --version   Show version and exit
```

---

## Environment variable

Set your API key as an environment variable so you do not have to pass `-k`
on every command:

```bash
# Add to ~/.bashrc or ~/.zshrc for persistence
export ABCOMICS_API_KEY=your_key_here
```

---

## Accepted file formats

| Format  | Extensions |
|---------|------------|
| FASTQ   | `.fastq`, `.fq`, `.fastq.gz`, `.fq.gz`, `.fastq.bz2`, `.fq.bz2` |
| FASTA   | `.fasta`, `.fa`, `.fna`, `.faa`, `.ffn`, `.frn`, `.fasta.gz`, `.fa.gz`, `.fna.gz`, `.faa.gz` |
| BAM / SAM / CRAM | `.bam`, `.sam`, `.cram` |
| Index files | `.bai`, `.crai`, `.csi`, `.tbi` |
| VCF / BCF | `.vcf`, `.vcf.gz`, `.bcf`, `.bcf.gz` |
| Annotation | `.gff`, `.gff3`, `.gtf`, `.bed` (and `.gz` variants) |
| Tabular | `.csv`, `.tsv` |

Maximum file size: **500 GB**.

---

## What happens under the hood

1. For each file, `abcupload` sends a POST request to the ABCOMICS API with
   your username, project ID, and filename.
2. The API validates the request and returns a time-limited signed URL pointing
   directly to the ABCOMICS cloud storage bucket.
3. `abcupload` streams the file to that URL with a live progress bar showing
   speed, percentage, and estimated time remaining.
4. If a file with the same name already exists, you are asked whether to
   overwrite it or skip it (or use `-o` to always overwrite).

---

## Development install

```bash
git clone https://github.com/african-bioinformatics-center/ABCOMICS_site.git
cd ABCOMICS_site/abcupload
pip install -e .
```

Build a distribution:

```bash
pip install build
python -m build
# output: dist/abcupload-1.0.0.tar.gz  and  dist/abcupload-1.0.0-py3-none-any.whl
```

---

## Author

**Khadim Gueye** — African Bioinformatics Center (ABCOMICS)  
Contact: [contact@abcomics.org](mailto:contact@abcomics.org)

---

## License

[MIT](LICENSE)