Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented changes described in comments in the previous PR #13

Merged
merged 50 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c29337a
Update analyze schema with Comments in previous PR. Added liting work…
luissian Jan 8, 2024
92f379b
fixiing some liting
luissian Jan 8, 2024
e1ed738
fixiing more liting errors
luissian Jan 8, 2024
1d86220
changed file extension for old python files
luissian Jan 8, 2024
c18365d
fixing latest liting
luissian Jan 8, 2024
54533b1
fixing latest liting 2
luissian Jan 8, 2024
1da9102
fixing latest liting 3
luissian Jan 8, 2024
cfcc652
checking liting in functions which are defined the type of variable
luissian Jan 16, 2024
eb00782
Checking testing file
luissian Jan 17, 2024
d732fa0
first draft to run test
luissian Jan 17, 2024
dccedc1
first draft to run test
luissian Jan 17, 2024
b19266d
added deps to github action test
luissian Jan 17, 2024
5f4e2ef
Updated test and environment for conda installation
luissian Jan 17, 2024
8b70dbe
Removed python packages from conda and move to pip
luissian Jan 17, 2024
e8eecd0
remove Self from annotation
luissian Jan 17, 2024
f2ef7ad
liting
luissian Jan 17, 2024
84a52d3
Updated with comments in PR#13. Adding testing analyze schema with te…
luissian Jan 22, 2024
917df0a
fixing liting and error testing
luissian Jan 22, 2024
e599433
Again trying to fix liting and testing
luissian Jan 22, 2024
174da64
modified schema input parameter
luissian Jan 22, 2024
12cfabc
correcting wrong path of schema
luissian Jan 22, 2024
dc9b272
including echo ls to know which is the working path
luissian Jan 22, 2024
8678110
including ls to know which is the working path
luissian Jan 22, 2024
a6254bc
removing variable
luissian Jan 22, 2024
88f4de8
activate conda environment
luissian Jan 22, 2024
b022f43
added conda init before activate conda base
luissian Jan 22, 2024
db76c5b
activte conda env with the source command and the activate
luissian Jan 22, 2024
e372796
testing how to run prokka
luissian Jan 22, 2024
002ca49
testing how to run prokka_2
luissian Jan 22, 2024
397da09
testing 1
luissian Jan 22, 2024
58d7bad
test2
luissian Jan 22, 2024
d3f53c4
test3
luissian Jan 22, 2024
ba3276e
test4
luissian Jan 22, 2024
983a7d5
test5
luissian Jan 22, 2024
00f8692
test5
luissian Jan 22, 2024
0003585
test6
luissian Jan 22, 2024
55dbd45
added kaleido package
luissian Jan 22, 2024
573a253
Udpated code with latest comment in PR
luissian Jan 23, 2024
a740b91
replace deprecate setup.py for pyproject.toml
luissian Jan 24, 2024
c8dcc7f
reduce the 2 loop for checking the duplicated and sub allele
luissian Jan 25, 2024
33130e2
remove unnecesary comments
luissian Jan 25, 2024
98a1f63
testing new pyproject.toml file
luissian Jan 25, 2024
6cabd24
fixing liting and update test
luissian Jan 25, 2024
ef0f2b7
update installation taranis for testing
luissian Jan 25, 2024
a8ae894
include all command in the same run
luissian Jan 25, 2024
9b34397
Split the number of cpus used for prokka and app
luissian Jan 25, 2024
22096fa
commit to start with reference allele feature
luissian Jan 28, 2024
86fbcdc
Including poetry.lock in gitignore
luissian Jan 28, 2024
4a0a754
Fixing liting
luissian Jan 28, 2024
0572e69
Fixing liting
luissian Jan 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/workflows/dockerhub_push_release.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/python_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: python_lint

on:
push:
paths:
- '**.py'
pull_request:
paths:
- '**.py'

jobs:
flake8_py3:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.9.x
architecture: x64
- name: Checkout PyTorch
uses: actions/checkout@master
- name: Install flake8
run: pip install flake8
- name: Run flake8
run: flake8 --ignore E501,W503,E203,W605

black_lint:
runs-on: ubuntu-latest
steps:
- name: Setup
uses: actions/checkout@v2
- name: Install black in jupyter
run: pip install black[jupyter]
- name: Check code lints with Black
uses: psf/black@stable
49 changes: 21 additions & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
name: tests ci
# This workflow runs the pipeline with the minimal test dataset to check that it completes any errors
# This workflow runs the pipeline with the minimal test dataset to check
# is completed without any errors
on:
push:
branches: [develop]
pull_request_target:
branches: [develop]
release:
types: [published]
pull_request:
push:

jobs:
push_dockerhub:
name: Push new Docker image to Docker Hub (dev)
create-conda-env:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
create-conda-env:
tests:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test file updated to use the pyroject.toml file instead of setup.py

- name: Activate env and install taranis
        run: |
          source $CONDA/etc/profile.d/conda.sh
          conda activate taranis_env
          poetry install
          taranis analyze-schema -i  test/MLST_listeria -o analyze_schema_test  --cpus 1 --output-allele-annot --remove-no-cds --remove-duplicated --remove-subset

runs-on: ubuntu-latest
# Only run for the official repo, for releases and merged PRs
if: ${{ github.repository == 'BU-ISCIII/taranis' }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASSWORD }}

steps:
- name: Check out pipeline code
- name: Checkout repository
uses: actions/checkout@v2

- name: Build new docker image
run: docker build --no-cache . -t buisciii/taranis:dev
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: myenv
environment-file: environment.yml

- name: Push Docker image to DockerHub (develop)
run: |
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push buisciii/taranis:dev
run-tests:
name: Run tests
needs: push_dockerhub
runs-on: ubuntu-latest
steps:
- name: Run pipeline with test data
- name: Verify Conda environment
run: conda env list

- name: Run your script
run: |
docker run buisciii/taranis:dev bash -c /opt/taranis/test/test.sh
source $CONDA/etc/profile.d/conda.sh
conda activate myenv
pip install .
taranis analyze-schema -i test/MLST_listeria -o analyze_schema_test --cpus 1

14 changes: 5 additions & 9 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
name: taranis
name: taranis_env
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- conda-forge::python>=3.6
- conda-forge::biopython==1.72
- conda-forge::pandas==1.2.4
- conda-forge::openpyxl==3.0.7
- conda-forge::plotly==5.0.0
- conda-forge::numpy==1.20.3
- conda-forge::rich==13.7.0
- conda-forge::python-kaleido
- python=3.10
- bioconda::prokka>=1.14
- bioconda::blast>=2.9
- bioconda::mash>=2
- bioconda::prodigal=2.6.3
- pip
- pip :
- -r requirements.txt
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
biopython
rich
click
questionary
bio
scikit-learn
plotly
plotly
kaleido
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

version = "2.2.0"
version = "3.0.0"

with open("README.md") as f:
readme = f.read()
Expand All @@ -28,9 +28,7 @@
author_email="[email protected]",
url="https://github.com/BU-ISCIII/taranis",
license="GNU GENERAL PUBLIC LICENSE v.3",
entry_points={
"console_scripts": ["taranis=taranis.__main__:run_taranis"]
},
entry_points={"console_scripts": ["taranis=taranis.__main__:run_taranis"]},
install_requires=required,
packages=find_packages(exclude=("docs")),
include_package_data=True,
Expand Down
2 changes: 1 addition & 1 deletion taranis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import pkg_resources

__version__ = pkg_resources.get_distribution("taranis").version
__version__ = pkg_resources.get_distribution("taranis").version
63 changes: 41 additions & 22 deletions taranis/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import sys
import time

import taranis.prediction
import taranis.utils
import taranis.analyze_schema
import taranis.reference_alleles
Expand Down Expand Up @@ -52,7 +51,7 @@ def run_taranis():
)

# stderr.print("[green] `._,._,'\n", highlight=False)
__version__ = "2.1.0"
__version__ = "3.0.0"
stderr.print(
"\n" "[grey39] Taranis version {}".format(__version__), highlight=False
)
Expand Down Expand Up @@ -166,6 +165,12 @@ def taranis_cli(verbose, log_file):
default=False,
help="Remove no CDS alleles from the schema.",
)
@click.option(
"--output-allele-annot/--no-output-allele-annot",
required=False,
default=True,
help="output prokka/allele annotation for all alleles in locus",
)
@click.option(
"--genus",
required=False,
Expand All @@ -184,29 +189,41 @@ def taranis_cli(verbose, log_file):
default="Genus",
help="Use genus-specific BLAST databases for Prokka schema genes annotation (needs --genus). Default is False.",
)
@click.option(
"--cpus",
required=False,
multiple=False,
type=int,
default=1,
help="Number of cpus used for execution",
saramonzon marked this conversation as resolved.
Show resolved Hide resolved
)
def analyze_schema(
inputdir,
output,
remove_subset,
remove_duplicated,
remove_no_cds,
genus,
species,
usegenus,
inputdir: str,
output: str,
remove_subset: bool,
remove_duplicated: bool,
remove_no_cds: bool,
output_allele_annot: bool,
genus: str,
species: str,
usegenus: str,
cpus: int,
):
schema_files = taranis.utils.get_files_in_folder(inputdir, "fasta")

"""
schema_analyze = {}
""" TODO.DELETE CODE
schema_analyze = []
saramonzon marked this conversation as resolved.
Show resolved Hide resolved
for schema_file in schema_files:
schema_obj = taranis.analyze_schema.AnalyzeSchema(schema_file, output, remove_subset, remove_duplicated, remove_no_cds, genus, species, usegenus)
schema_analyze.update(schema_obj.analyze_allele_in_schema())

"""
schema_analyze.append(schema_obj.analyze_allele_in_schema())
import pdb; pdb.set_trace()
_ = taranis.analyze_schema.collect_statistics(schema_analyze, output, output_allele_annot)
sys.exit(0)
# for schema_file in schema_files:
"""
results = []
start = time.perf_counter()
with concurrent.futures.ProcessPoolExecutor() as executor:
with concurrent.futures.ProcessPoolExecutor(max_workers=cpus) as executor:
futures = [
executor.submit(
taranis.analyze_schema.parallel_execution,
Expand All @@ -224,10 +241,11 @@ def analyze_schema(
# Collect results as they complete
for future in concurrent.futures.as_completed(futures):
results.append(future.result())
_ = taranis.analyze_schema.collect_statistics(results, output)
_ = taranis.analyze_schema.collect_statistics(results, output, output_allele_annot)
finish = time.perf_counter()
print(f"Schema analyze finish in {round((finish-start)/60, 2)} minutes")


# Reference alleles
@taranis_cli.command(help_priority=2)
@click.option(
Expand All @@ -247,12 +265,13 @@ def analyze_schema(
help="Output folder to save reference alleles",
)
def reference_alleles(
schema,
output,
schema: str,
output: str,
):
# taranis reference-alleles -s ../../documentos_antiguos/datos_prueba/schema_1_locus/ -o ../../new_taranis_result_code
# taranis reference-alleles -s ../../documentos_antiguos/datos_prueba/schema_test/ -o ../../new_taranis_result_code
# taranis reference-alleles -s /media/lchapado/Reference_data/proyectos_isciii/taranis/taranis_testing_data/listeria_testing_schema/ -o /media/lchapado/Reference_data/proyectos_isciii/taranis/test/reference_alleles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, testing code? this is clearer but indicate it anyhow

schema_files = taranis.utils.get_files_in_folder(schema, "fasta")

# Check if output folder exists
if taranis.utils.folder_exists(output):
q_question = (
Expand All @@ -268,7 +287,7 @@ def reference_alleles(
try:
os.makedirs(output)
except OSError as e:
log.info("Unable to create folder at %s", output)
log.info("Unable to create folder at %s with error %s", output, e)
stderr.print("[red] ERROR. Unable to create folder " + output)
sys.exit(1)
"""Create the reference alleles from the schema """
Expand Down Expand Up @@ -362,7 +381,7 @@ def allele_calling(
try:
os.makedirs(output)
except OSError as e:
log.info("Unable to create folder at %s", output)
log.info("Unable to create folder at %s because %s", output, e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.info("Unable to create folder at %s because %s", output, e)
log.info("Unable to create folder at %s with error %s", output, e)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

stderr.print("[red] ERROR. Unable to create folder " + output)
sys.exit(1)
# Filter fasta files from reference folder
Expand Down
Loading
Loading