Skip to content

Commit

Permalink
Add various tree utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
dpoznik committed Jan 31, 2024
1 parent 6525b21 commit 3dbe6b6
Show file tree
Hide file tree
Showing 13 changed files with 510 additions and 176 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
hooks:
- id: isort
- repo: [email protected]:psf/black.git
rev: 23.12.1
rev: 24.1.0
hooks:
- id: black
- repo: [email protected]:pre-commit/pre-commit-hooks.git
Expand All @@ -15,6 +15,7 @@ repos:
- id: check-yaml
args: [--allow-multiple-documents]
- id: pretty-format-json
exclude: .*.ipynb
- id: trailing-whitespace
exclude: tests/fixtures/output/haplogroups\..*\.txt|data/variants/isogg\.[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.txt
- repo: [email protected]:PyCQA/flake8.git
Expand Down
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,29 @@
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)


## [2.1.0] - 2024-01
## [2.1.4] - 2024-01-29

### Added
- Support for querying multiple SNPs from the command line
- Support for generating aligned-tip Newick representations of subtrees
- Support for node lookup by SNP-based haplogroup label
- `Node` methods:
- `Node.iter_depth_first`
- `Node.iter_breath_first`
- `Node.remove_children`
- `tree.get_bounded_subtree` function

### Changed
- `Tree` constructor's `Config` parameter is now optional
- `Node.is_root` and `Node.is_leaf` are now properties

### Fixed
- Output format of `--snp_query` option

[2.1.4]: https://github.com/23andMe/yhaplo/compare/2.1.0...2.1.4


## [2.1.0] - 2024-01-12

This release improves haplogroup calling by identifying and correcting various errors in
the ISOGG variant metadata and, internally, by pruning poorly performing v5 SNPs.
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Make variables
#----------------------------------------------------------------------
BOLD_CYAN = \033[1;36m
CYAN := \033[0;36m
GREEN := \033[0;32m
BOLD_CYAN := \033[1;36m
BOLD_GREEN := \033[1;32m
GREEN = \033[0;32m
NO_COLOR = \033[0m
NO_COLOR := \033[0m


## General
# ----------------------------------------------------------------------
help: ## Print this help message
@egrep -h '(\s|^)##\s' $(MAKEFILE_LIST) \
| sed -E "s/^## (.*)/\n$$(printf "${BOLD_CYAN}")\1$$(printf "${NO_COLOR}")/g" \
| awk 'BEGIN {FS = ":.*?## "}; {printf "${GREEN}%-25s${NO_COLOR} %s\n", $$1, $$2}'
| sed -E "s/^## (.*)/\n$$(printf "${BOLD_GREEN}")\1$$(printf "${NO_COLOR}")/g" \
| awk 'BEGIN {FS = ":.*?## "}; {printf "${CYAN}%-25s${NO_COLOR} %s\n", $$1, $$2}'
@echo


Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ ignore_missing_imports = true
# D107 Missing docstring in __init__
# D202 No blank lines allowed after function docstring
# Ignoring allows blank lines after one-line docstrings.
# D203 1 blank line required before class docstring
# Conflicts with black 24.
# D211 No blank lines allowed before class docstring
# Contradicts D203.
# D213 Multi-line docstring summary should start at the second line
# Contradicts D212.
# https://github.com/PyCQA/pydocstyle/issues/242#issuecomment-288166773
ignore = "D107,D202,D211,D213"
ignore = "D107,D202,D203,D211,D213"
match_dir = "(?!tests|\\.).*"

[tool.pytest.ini_options]
Expand Down
4 changes: 3 additions & 1 deletion scripts/validate_yhaplo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ echo -e "\n${BOLD_CYAN}Removed${NO_COLOR}: ${GREEN}${output_dir}\n\n${NO_COLOR}"

echo -e "${BOLD_CYAN}Text Input${NO_COLOR}\n"
yhaplo --example_text \
--hg_genos Q \
--breadth_first \
--depth_first \
--depth_first_table \
--hg_genos Q
--mrca Q J \
--snp_query L1335,S730,S530,foo
echo -e "\n"


Expand Down
9 changes: 4 additions & 5 deletions yhaplo/api/command_line_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ def get_command_line_args(set_defaults: bool = False) -> argparse.Namespace:
nargs=2,
dest="mrca_haplogroup_list",
metavar=("haplogroup1", "haplogroup2"),
help="Output mrca of two haplogroups",
help="Output MRCA of two haplogroups",
)
group.add_argument(
"-sq",
"--snp_query",
dest="query_snp_name",
metavar="snp_name",
help="List phylogenetic path for a query SNP",
dest="query_snp_names",
metavar="snp_names",
help="List phylogenetic path for each SNP in comma-separated list",
)
group.add_argument(
"-pt",
Expand Down Expand Up @@ -282,7 +282,6 @@ def get_command_line_arg_defaults() -> argparse.Namespace:


class RawTextWithDefaultsHelpFormatter(argparse.RawDescriptionHelpFormatter):

"""Help message formatter that retains formatting and adds defaults.
Combines argparse.RawTextHelpFormatter and argparse.ArgumentDefaultsHelpFormatter.
Expand Down
1 change: 0 additions & 1 deletion yhaplo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class Config:

"""Yhaplo configuration class.
This class is a container for parameters, constants, filenames, etc.
Expand Down
Loading

0 comments on commit 3dbe6b6

Please sign in to comment.