Skip to content

Commit

Permalink
Merge pull request #9 from moshi4/develop
Browse files Browse the repository at this point in the history
Bump to v0.4.1
  • Loading branch information
moshi4 authored Sep 7, 2023
2 parents 546869c + d3a8af1 commit 2b2232d
Show file tree
Hide file tree
Showing 8 changed files with 1,351 additions and 1,188 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.8, 3.9, "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -24,11 +24,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# Install poetry v1.4.0 to avoid _WheelFileValidationError in debugpy
# Latest poetry v1.4.1 cannot install debugpy
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Dependencies
Expand All @@ -37,8 +35,8 @@ jobs:
- name: Run black format check
run: poetry run black src tests --check --diff --verbose

- name: Run flake8 lint check
run: poetry run flake8 src tests --max-line-length=88 --ignore=E203,W503,W504
- name: Run ruff lint check
run: poetry run ruff .

- name: Run pytest
run: poetry run pytest tests --tb=line --cov=src --cov-report=xml --cov-report=term
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ pyMSAviz provides simple MSA visualization CLI.
--end End position of MSA visualization (Default: 'MSA Length')
--wrap_length Wrap length (Default: None)
--wrap_space_size Space size between wrap MSA plot area (Default: 3.0)
--label_type Label type ('id'[default]|'description')
--show_grid Show grid (Default: OFF)
--show_count Show seq char count without gap on right side (Default: OFF)
--show_consensus Show consensus sequence (Default: OFF)
Expand Down
1 change: 1 addition & 0 deletions docs/cli-docs/pymsaviz.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
--end End position of MSA visualization (Default: 'MSA Length')
--wrap_length Wrap length (Default: None)
--wrap_space_size Space size between wrap MSA plot area (Default: 3.0)
--label_type Label type ('id'[default]|'description')
--show_grid Show grid (Default: OFF)
--show_count Show seq char count without gap on right side (Default: OFF)
--show_consensus Show consensus sequence (Default: OFF)
Expand Down
2,471 changes: 1,300 additions & 1,171 deletions poetry.lock

Large diffs are not rendered by default.

34 changes: 27 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyMSAviz"
version = "0.4.0"
version = "0.4.1"
description = "MSA visualization python package for sequence analysis"
authors = ["moshi4"]
license = "MIT"
Expand All @@ -26,6 +26,27 @@ minversion = "6.0"
addopts = "--cov=src --tb=line --cov-report=xml --cov-report=term"
testpaths = ["tests"]

# Lint Rules: https://beta.ruff.rs/docs/rules
[tool.ruff]
select = ["E", "F", "W", "I", "D", "B"]
ignore = [
"D100",
"D101",
"D104",
"D105",
"D205",
"D400",
"D401",
"D403",
"D415",
"B905",
]
src = ["src", "tests"]
line-length = 88

[tool.ruff.pydocstyle]
convention = "numpy"

[tool.poetry.scripts]
pymsaviz = "pymsaviz.scripts.cli:main"

Expand All @@ -34,15 +55,14 @@ python = "^3.8"
biopython = ">=1.79"
matplotlib = ">=3.5.2"

[tool.poetry.dev-dependencies]
flake8 = ">=4.0.1"
[tool.poetry.group.dev.dependencies]
pytest = ">=7.1.2"
black = ">=22.10.0"
pydocstyle = ">=6.1.1"
pytest = ">=7.2.0"
ruff = ">=0.0.264"
pytest-cov = ">=4.0.0"
ipykernel = ">=6.16.0"
ipykernel = ">=6.13.0"
mkdocs = ">=1.2"
mkdocstrings = {version = ">=0.19.0", extras = ["python"]}
mkdocstrings = { extras = ["python"], version = ">=0.19.0" }
mkdocs-jupyter = ">=0.21.0"
mkdocs-material = ">=8.2"

Expand Down
2 changes: 1 addition & 1 deletion src/pymsaviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"get_msa_testdata",
]

__version__ = "0.4.0"
__version__ = "0.4.1"

# Setting matplotlib rc(runtime configuration) parameters
# https://matplotlib.org/stable/tutorials/introductory/customizing.html
Expand Down
9 changes: 6 additions & 3 deletions src/pymsaviz/msaviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def plotfig(self, dpi: int = 100) -> Figure:
y_size_list = [ax_type2y_size[t] for t in plot_ax_types]
figsize = (self._wrap_length * self._x_unit_size, sum(y_size_list))
fig: Figure = plt.figure(figsize=figsize, dpi=dpi) # type: ignore
fig.set_layout_engine("tight")
fig.tight_layout()
gs = GridSpec(nrows=len(plot_ax_types), ncols=1, height_ratios=y_size_list)
gs.update(left=0, right=1, bottom=0, top=1, hspace=0, wspace=0)

Expand Down Expand Up @@ -469,6 +469,9 @@ def savefig(
dpi=dpi,
pad_inches=pad_inches,
)
# Clear & close figure to suppress memory leak
fig.clear()
plt.close(fig)

############################################################
# Private Method
Expand Down Expand Up @@ -630,7 +633,7 @@ def _get_consensus_identity_list(
start = 0 if start is None else start
end = self.alignment_length if end is None else end
consensus_identity_list = []
for idx, seq_char in enumerate(self.consensus_seq[start:end], start):
for idx, _ in enumerate(self.consensus_seq[start:end], start):
column_chars = str(self.msa[:, idx])
counter = Counter(filter(lambda c: c not in ("-", "*"), column_chars))
count = counter.most_common()[0][1] if len(counter) != 0 else 0
Expand Down Expand Up @@ -741,7 +744,7 @@ def _parse_positions(self, positions: list[tuple[int, int] | int]) -> list[int]:
for pos in positions:
if isinstance(pos, (tuple, list)):
result_positions.extend(list(range(pos[0] - 1, pos[1])))
elif type(pos) == int:
elif isinstance(pos, int):
result_positions.append(pos - 1)
else:
raise ValueError(f"{positions=} is invalid.")
Expand Down
11 changes: 11 additions & 0 deletions src/pymsaviz/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def run(
end: int | None = None,
wrap_length: int | None = None,
wrap_space_size: float = 3.0,
label_type: str = "id",
show_grid: bool = False,
show_count: bool = False,
show_consensus: bool = False,
Expand All @@ -37,6 +38,7 @@ def run(
end=end,
wrap_length=wrap_length,
wrap_space_size=wrap_space_size,
label_type=label_type,
color_scheme=color_scheme,
show_grid=show_grid,
show_count=show_count,
Expand Down Expand Up @@ -129,6 +131,15 @@ def get_args() -> argparse.Namespace:
default=default_wrap_space_size,
metavar="",
)
default_label_type = "id"
parser.add_argument(
"--label_type",
type=str,
help="Label type ('id'[default]|'description')",
default=default_label_type,
choices=("id", "description"),
metavar="",
)
parser.add_argument(
"--show_grid",
help="Show grid (Default: OFF)",
Expand Down

0 comments on commit 2b2232d

Please sign in to comment.