Metadata-Version: 2.4
Name: genoarmory
Version: 0.1.0
Summary: A DNA sequence Adversial attack and defense benchmark
Home-page: https://github.com/MAGICS-LAB/DNAAttack
Author: Robin Luo & Jerry Qiu
Author-email: robinluo2027@u.northwestern.edu
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.1.0
Requires-Dist: transformers>=4.0.0
Requires-Dist: numpy>=1.19.0
Requires-Dist: matplotlib>=3.3.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary


<div align="center">
  <img src="asserts/logo.jpg" alt="Image" />
</div>

<div align="center">
<p align="center">
    <p align="center">A comprehensive toolkit for DNA sequence Adversarial Attack and Defense Benchmark.
    <br>
</p>


[![arXiv](https://img.shields.io/badge/arXiv-GenoArmory-ff0000.svg?style=for-the-badge)](https://github.com/MAGICS-LAB/GenoArmory)  [![Github](https://img.shields.io/badge/GenoArmory-000000?style=for-the-badge&logo=github&logoColor=white)](https://github.com/MAGICS-LAB/GenoArmory)  [![Hugging Face Pretrained](https://huggingface.co/datasets/huggingface/badges/resolve/main/model-on-hf-md-dark.svg)](https://huggingface.co/collections/magicslabnu/gfm-67f4d4a9327ee4acdcb3806b) [![Hugging Face Dataset](https://huggingface.co/datasets/huggingface/badges/resolve/main/dataset-on-hf-md.svg)](https://huggingface.co/datasets/magicslabnu/GenoAdv) 
</div>

## Installation

You can install GenoArmory using pip:

```bash
pip install genoarmory
```

## Quick Start

```python
# Initialize model
from GenoArmory import GenoArmory
import json
# You need to initialize GenoArmory with a model and tokenizer.
# For visualization, you don't need a real model/tokenizer, so you can use None if the method doesn't use them.
gen = GenoArmory(model=None, tokenizer=None)
params_file = '/projects/p32013/DNABERT-meta/scripts/PGD/pgd_dnabert.json'

# Visulization
gen.visualization(
    folder_path='/projects/p32013/DNABERT-meta/BERT-Attack/results/meta/test',
    output_pdf_path='/projects/p32013/DNABERT-meta/BERT-Attack/results/meta/test'
)

# Attack
if params_file:
  try:
      with open(params_file, "r") as f:
          kwargs = json.load(f)
  except json.JSONDecodeError as e:
      raise ValueError(f"Invalid JSON in params file '{params_file}': {e}")
  except FileNotFoundError:
      raise FileNotFoundError(f"Params file '{params_file}' not found.")

gen.attack(
    attack_method='pgd',
    model_path='magicslabnu/GERM',
    **kwargs
)
```

## Command Line Usage

GenoArmory can also be used from the command line:

```bash
# Attack
python GenoArmory.py --model_path magicslabnu/GERM attack --method pgd --params_file /projects/p32013/DNABERT-meta/scripts/PGD/pgd_dnabert.json

# Defense
python GenoArmory.py --model_path magicslabnu/GERM defense --method at --params_file /projects/p32013/DNABERT-meta/scripts/AT/at_pgd_dnabert.json

# Visualization
python GenoArmory.py --model_path magicslabnu/GERM visualize --folder_path /projects/p32013/DNABERT-meta/BERT-Attack/results/meta/test --save_path /projects/p32013/DNABERT-meta/BERT-Attack/results/meta/test/frequency.pdf


# Read MetaData
python GenoArmory.py --model_path magicslabnu/GERM read --type attack --method TextFooler --model_name dnabert

```

## Features

- Multiple attack methods:

  - BERT-Attack
  - TextFooler
  - PGD
  - FIMBA

- Defense methods:

  - ADFAR
  - FreeLB
  - Traditional Adversarial Training

- Visualization tools
- Artifact management
- Batch processing
- Command-line interface

## Documentation

For detailed documentation, visit [docs](We will release soon).

## License

This project is licensed under the MIT License.

## Citation

If you have any question regarding our paper or codes, please feel free to start an issue.

If you use GenoArmory in your work, please kindly cite our paper:

```

```
