Skip to content

Commit

Permalink
Feature clean path (#44)
Browse files Browse the repository at this point in the history
* fix history check in blastn function

* rename main directory variable

* path job cleaned up

* path refactoring in blaster

* refactor blaster module file name

* clean config dict blaster assets

* test cases quality assessment

* path fix and type output for asset

* refactor status file names

* refactor file names viewer asset

* remove all use of pyspark

* update readme to remove openjdk dependency

* fix paths and typo

* attempt to test temp dir

* change flake flag for complexity

* ran flake and black
  • Loading branch information
vestalisvirginis authored Jan 4, 2024
1 parent 723373b commit 2f03727
Show file tree
Hide file tree
Showing 39 changed files with 196,848 additions and 537 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
coverage run -m pytest test/unit
coverage xml -o coverage.xml
env:
PHAGY_DIRECTORY: ${{ env.PHAGY_DIRECTORY }}
DATA_DIR: ${{ env.DATA_DIR }}
FILE_SYSTEM: ${{ env.FILE_SYSTEM }}
EMAIL: ${{ secrets.EMAIL }}
API_KEY: ${{ secrets.API_KEY }}
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ clean: # Remove workspace files
@rm -rf ./dist
@rm -rf test/fixtures/assets_testing_folder/ncbi_download/fetch
@rm -rf test/fixtures/assets_testing_folder/sequence_quality/genbank
@rm -rf test/fixtures/assets_testing_folder/sequence_quality_with_history/genbank
@rm -rf test/fixtures/assets_testing_folder/blasting/gene_identity
@rm -rf test/fixtures/assets_testing_folder/blasting_with_history/gene_identity
@rm -rf test/fixtures/assets_testing_folder/synteny/synteny
Expand All @@ -25,7 +26,7 @@ black: # Format code
@black test

flake: # Lint code
@flake8 --ignore=E501,W503,E731,E722 --max-cognitive-complexity=30 synphage
@flake8 --ignore=E501,W503,E731,E722 --max-complexity=30 synphage
@python -c "print('Linting: 👌')"

radon:
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ docker pull vestalisvirginis/synphage:latest

### Additional dependencies

Synphage relies on two non-python dependencies that need to be manually installed when Synphage is installed with pip:
Synphage relies on one non-python dependency that need to be manually installed when Synphage is installed with pip:
- [Blast+](https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/) >= 2.12.0
- [OpenJDK](https://openjdk.org/projects/jdk/17/) == 17
```bash
apt update
apt install -y ncbi-blast+
```


## Usage
Expand All @@ -61,7 +64,7 @@ Synphage requires:
#### Path setup

```bash
export PHAGY_DIRECTORY=<path_to_data_folder>
export DATA_DIR=<path_to_data_folder>
```

**Note:** For docker users, this path is defaulted to `/data`.
Expand Down
50 changes: 17 additions & 33 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,59 @@
# import os
# import warnings
import pytest
# from pyspark.sql import SparkSession
#import logging

#logger = logging.getLogger(__name__)


@pytest.fixture
def mock_env_ncbi_connect(monkeypatch):
monkeypatch.setenv("EMAIL", "[email protected]")
monkeypatch.setenv("API_KEY", "jhd6hdz778ahjeahj8889")


@pytest.fixture
def mock_env_ncbi_download_pos(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/ncbi_download/positive")

monkeypatch.setenv("DATA_DIR", "test/fixtures/ncbi_download/positive")

@pytest.fixture
def mock_env_ncbi_download_neg(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/ncbi_download/negative")

monkeypatch.setenv("DATA_DIR", "test/fixtures/ncbi_download/negative")

@pytest.fixture
def mock_env_ncbi_count(monkeypatch):
monkeypatch.setenv("DATABASE", "nuccore")
monkeypatch.setenv("KEYWORD", "Bacillus subtilis strain P9_B1")


@pytest.fixture
def mock_env_ncbi_fetch(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/ncbi_download/fetch")

monkeypatch.setenv("DATA_DIR", "test/fixtures/ncbi_download/fetch")

@pytest.fixture
def mock_env_sequence_check(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/assets_testing_folder/sequence_quality")
monkeypatch.setenv("DATA_DIR", "test/fixtures/assets_testing_folder/sequence_quality")

@pytest.fixture
def mock_env_sequence_check_with_history(monkeypatch):
monkeypatch.setenv("DATA_DIR", "test/fixtures/assets_testing_folder/sequence_quality_with_history")

@pytest.fixture
def mock_env_phagy_dir_blasting(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/assets_testing_folder/blasting")
monkeypatch.setenv("DATA_DIR", "test/fixtures/assets_testing_folder/blasting")

@pytest.fixture
def mock_env_phagy_dir_blasting_with_history(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/assets_testing_folder/blasting_with_history")
monkeypatch.setenv("DATA_DIR", "test/fixtures/assets_testing_folder/blasting_with_history")

@pytest.fixture
def mock_env_phagy_dir_transform(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/assets_testing_folder/transform")
monkeypatch.setenv("DATA_DIR", "test/fixtures/assets_testing_folder/transform")
monkeypatch.setenv("FILE_SYSTEM", "fs")

@pytest.fixture
def mock_env_phagy_dir_transform_step3(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/assets_testing_folder/transform_3")
monkeypatch.setenv("DATA_DIR", "test/fixtures/assets_testing_folder/transform_3")

@pytest.fixture
def mock_env_phagy_dir_synteny(monkeypatch):
monkeypatch.setenv("PHAGY_DIRECTORY", "test/fixtures/assets_testing_folder/synteny")
monkeypatch.setenv("DATA_DIR", "test/fixtures/assets_testing_folder/synteny")
monkeypatch.setenv("SEQUENCE_FILE", "sequences.csv")
# @pytest.fixture(scope="session")
# def spark():
# try:
# #logger = logging.getLogger("py4j")
# #ogger.setLevel(logging.ERROR)
# spark_session = SparkSession.builder.config(
# "spark.driver.memory", "2g"
# ).getOrCreate()
# yield spark_session
# except:
# pass
# finally:
# spark_session.stop()

@pytest.fixture
def mock_env_phagy_dir_none(monkeypatch):
monkeypatch.delenv("DATA_DIR", raising=False)

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies = [
"biopython >= 1.81",
"reportlab >= 3.6.12",
"rlPyCairo >= 0.3.0",
"pyspark >= 2.15.1",
"cuallee >= 0.6.0",
"duckdb >= 0.9.1",
"polars >= 0.19.11",
Expand Down
Loading

0 comments on commit 2f03727

Please sign in to comment.