Skip to content

Commit

Permalink
Merge pull request #57 from moshi4/develop
Browse files Browse the repository at this point in the history
Bump to v1.3.0
  • Loading branch information
moshi4 authored Aug 4, 2024
2 parents 20d4f85 + 1d62280 commit 8a5a434
Show file tree
Hide file tree
Showing 27 changed files with 741 additions and 182 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# - name: Setup Python ${{ matrix.python-version}}
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
- name: Install python dependencies
- name: Setup Python ${{matrix.python-version}} & Dependencies
run: |
rye pin ${{ matrix.python-version }}
rye sync --update-all --all-features
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
rev: v0.5.6
hooks:
- id: ruff
name: ruff lint check
Expand Down
227 changes: 182 additions & 45 deletions docs/getting_started.ipynb

Large diffs are not rendered by default.

43 changes: 23 additions & 20 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# all-features: true
# with-sources: false
# generate-hashes: false
# universal: false

-e file:.
altair==5.3.0
Expand All @@ -15,23 +16,25 @@ asttokens==2.4.1
# via stack-data
astunparse==1.6.3
# via griffe
attrs==23.2.0
attrs==24.1.0
# via jsonschema
# via referencing
babel==2.15.0
# via mkdocs-material
backcall==0.2.0
# via ipython
backports-strenum==1.3.1
# via griffe
beautifulsoup4==4.12.3
# via nbconvert
biopython==1.83
# via pygenomeviz
black==24.4.2
black==24.8.0
bleach==6.1.0
# via nbconvert
blinker==1.8.2
# via streamlit
cachetools==5.3.3
cachetools==5.4.0
# via streamlit
certifi==2024.7.4
# via requests
Expand All @@ -55,7 +58,7 @@ coverage==7.6.0
# via pytest-cov
cycler==0.12.1
# via matplotlib
debugpy==1.8.2
debugpy==1.8.3
# via ipykernel
decorator==5.1.1
# via ipython
Expand All @@ -79,13 +82,13 @@ gitdb==4.0.11
# via gitpython
gitpython==3.1.43
# via streamlit
griffe==0.47.0
griffe==0.48.0
# via mkdocstrings-python
identify==2.6.0
# via pre-commit
idna==3.7
# via requests
importlib-metadata==8.0.0
importlib-metadata==8.2.0
# via jupyter-client
# via markdown
# via mkdocs
Expand Down Expand Up @@ -127,7 +130,7 @@ jupyter-core==5.7.2
# via nbformat
jupyterlab-pygments==0.3.0
# via nbconvert
jupytext==1.16.3
jupytext==1.16.4
# via mkdocs-jupyter
kiwisolver==1.4.5
# via matplotlib
Expand Down Expand Up @@ -171,13 +174,13 @@ mkdocs-autorefs==1.0.1
mkdocs-get-deps==0.2.0
# via mkdocs
mkdocs-jupyter==0.24.8
mkdocs-material==9.5.28
mkdocs-material==9.5.31
# via mkdocs-jupyter
mkdocs-material-extensions==1.3.1
# via mkdocs-material
mkdocstrings==0.25.1
mkdocstrings==0.25.2
# via mkdocstrings-python
mkdocstrings-python==1.10.5
mkdocstrings-python==1.10.7
# via mkdocstrings
mypy-extensions==1.0.0
# via black
Expand Down Expand Up @@ -245,15 +248,15 @@ pluggy==1.5.0
pre-commit==3.5.0
prompt-toolkit==3.0.47
# via ipython
protobuf==5.27.2
protobuf==5.27.3
# via streamlit
psutil==6.0.0
# via ipykernel
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.2
pure-eval==0.2.3
# via stack-data
pyarrow==16.1.0
pyarrow==17.0.0
# via streamlit
pydeck==0.9.1
# via streamlit
Expand All @@ -263,12 +266,12 @@ pygments==2.18.0
# via mkdocs-material
# via nbconvert
# via rich
pymdown-extensions==10.8.1
pymdown-extensions==10.9
# via mkdocs-material
# via mkdocstrings
pyparsing==3.1.2
# via matplotlib
pytest==8.2.2
pytest==8.3.2
# via pytest-cov
pytest-cov==5.0.0
python-dateutil==2.9.0.post0
Expand All @@ -288,23 +291,23 @@ pyyaml==6.0.1
# via pyyaml-env-tag
pyyaml-env-tag==0.1
# via mkdocs
pyzmq==26.0.3
pyzmq==26.1.0
# via ipykernel
# via jupyter-client
referencing==0.35.1
# via jsonschema
# via jsonschema-specifications
regex==2024.5.15
regex==2024.7.24
# via mkdocs-material
requests==2.32.3
# via mkdocs-material
# via streamlit
rich==13.7.1
# via streamlit
rpds-py==0.19.0
rpds-py==0.19.1
# via jsonschema
# via referencing
ruff==0.5.1
ruff==0.5.6
six==1.16.0
# via asttokens
# via astunparse
Expand All @@ -316,7 +319,7 @@ soupsieve==2.5
# via beautifulsoup4
stack-data==0.6.3
# via ipython
streamlit==1.36.0
streamlit==1.37.0
# via pygenomeviz
tenacity==8.5.0
# via streamlit
Expand Down
13 changes: 7 additions & 6 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
# all-features: true
# with-sources: false
# generate-hashes: false
# universal: false

-e file:.
altair==5.3.0
# via streamlit
attrs==23.2.0
attrs==24.1.0
# via jsonschema
# via referencing
biopython==1.83
# via pygenomeviz
blinker==1.8.2
# via streamlit
cachetools==5.3.3
cachetools==5.4.0
# via streamlit
certifi==2024.7.4
# via requests
Expand Down Expand Up @@ -81,9 +82,9 @@ pillow==10.4.0
# via streamlit
pkgutil-resolve-name==1.3.10
# via jsonschema
protobuf==5.27.2
protobuf==5.27.3
# via streamlit
pyarrow==16.1.0
pyarrow==17.0.0
# via streamlit
pydeck==0.9.1
# via streamlit
Expand All @@ -103,14 +104,14 @@ requests==2.32.3
# via streamlit
rich==13.7.1
# via streamlit
rpds-py==0.19.0
rpds-py==0.19.1
# via jsonschema
# via referencing
six==1.16.0
# via python-dateutil
smmap==5.0.1
# via gitdb
streamlit==1.36.0
streamlit==1.37.0
# via pygenomeviz
tenacity==8.5.0
# via streamlit
Expand Down
2 changes: 1 addition & 1 deletion src/pygenomeviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pygenomeviz.genomeviz import GenomeViz

__version__ = "1.2.1"
__version__ = "1.3.0"

__all__ = [
"GenomeViz",
Expand Down
18 changes: 9 additions & 9 deletions src/pygenomeviz/align/tool/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from pygenomeviz.align import AlignCoord
from pygenomeviz.logger import get_logger
from pygenomeviz.parser import Genbank
from pygenomeviz.parser import Fasta, Genbank


class AlignToolBase(ABC):
Expand Down Expand Up @@ -156,25 +156,25 @@ def _parse_input_gbk_seqs(
return parse_seqs

def _parse_input_gbk_and_fasta_seqs(
self, seqs: Sequence[str | Path | Genbank]
) -> Sequence[Path | Genbank]:
self, seqs: Sequence[str | Path | Fasta | Genbank]
) -> Sequence[Fasta | Genbank]:
"""Parse input genbank and fasta sequences
Parameters
----------
seqs : Sequence[str | Path | Genbank]
List of `fasta file` or `genbank file` or `Genbank object`
seqs : Sequence[str | Path | Fasta | Genbank]
List of fasta or genbank
Returns
-------
parse_seqs : Sequence[Path | Genbank]
List of `fasta file` or `Genbank object`
parse_seqs : Sequence[Fasta | Genbank]
List of fasta or genbank
"""
# Check number of seqs
if len(seqs) < 2:
raise ValueError("Number of input seqs is less than 2.")
# Parse genbank or fasta files
parse_seqs: Sequence[Path | Genbank] = []
parse_seqs: Sequence[Fasta | Genbank] = []
for seq in seqs:
if isinstance(seq, str):
seq = Path(seq)
Expand All @@ -184,7 +184,7 @@ def _parse_input_gbk_and_fasta_seqs(
if seq.suffix in gbk_suffixes:
parse_seqs.append(Genbank(seq))
elif seq.suffix in fasta_suffixes:
parse_seqs.append(seq)
parse_seqs.append(Fasta(seq))
else:
valid_suffixes = gbk_suffixes + fasta_suffixes
err_msg = f"'{seq}' is invalid file suffix ({valid_suffixes=})"
Expand Down
28 changes: 11 additions & 17 deletions src/pygenomeviz/align/tool/blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import logging
import os
import shutil
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Sequence, get_args

from pygenomeviz.align import AlignCoord
from pygenomeviz.align.tool import AlignToolBase
from pygenomeviz.parser import Genbank
from pygenomeviz.parser import Fasta, Genbank
from pygenomeviz.typing import SeqType


Expand All @@ -18,7 +17,7 @@ class Blast(AlignToolBase):

def __init__(
self,
seqs: Sequence[str | Path | Genbank],
seqs: Sequence[str | Path | Fasta | Genbank],
*,
outdir: str | Path | None = None,
seqtype: SeqType = "nucleotide",
Expand All @@ -31,8 +30,8 @@ def __init__(
"""
Parameters
----------
seqs : Sequence[str | Path | Genbank]
List of `fasta file` or `genbank file` or `Genbank object`
seqs : Sequence[str | Path | Fasta | Genbank]
List of fasta or genbank
(file suffix must be `.fa`, `.fna`, `.fasta`, `.gb`, `.gbk`, `.gbff`)
outdir : str | Path | None, optional
Temporary result directory. If None, tmp directory is auto created.
Expand Down Expand Up @@ -107,7 +106,7 @@ def run(self) -> list[AlignCoord]:
return align_coords

def _write_genome_files(self, outdir: str | Path) -> list[Path]:
"""Write (or copy) genome fasta files to output directory
"""Write genome fasta files to output directory
Parameters
----------
Expand All @@ -121,15 +120,10 @@ def _write_genome_files(self, outdir: str | Path) -> list[Path]:
"""
genome_files: list[Path] = []
for seq in self._seqs:
if isinstance(seq, Genbank):
genome_file = Path(outdir) / f"{seq.name}.fna"
log_msg = f"Convert Genbank object to genome fasta file '{genome_file}'"
self._logger.info(log_msg)
seq.write_genome_fasta(genome_file)
genome_files.append(genome_file)
else:
genome_file = Path(outdir) / seq.name
self._logger.info(f"Copy genome fasta file to '{genome_file}'")
shutil.copy(seq, genome_file)
genome_files.append(genome_file)
genome_file = Path(outdir) / f"{seq.name}.fna"
cls_name = seq.__class__.__name__
log_msg = f"Convert {cls_name} object to genome fasta file '{genome_file}'"
self._logger.info(log_msg)
seq.write_genome_fasta(genome_file)
genome_files.append(genome_file)
return genome_files
Loading

0 comments on commit 8a5a434

Please sign in to comment.