Skip to content

Commit

Permalink
Merge branch 'cogent3:develop' into feature/issue-1682
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcar17 committed May 1, 2024
2 parents 0e5477b + 5a95c67 commit baf9b1e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 38 deletions.
8 changes: 0 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,8 @@ new_fragment_template="file: changelog.d/templates/new.md.j2"
entry_title_template="file: changelog.d/templates/title.md.j2"

[project.entry-points."cogent3.app"]
compress = "cogent3.app.io:compress"
concat = "cogent3.app.sample:concat"
decompress = "cogent3.app.io:decompress"
fixed_length = "cogent3.app.sample:fixed_length"
from_json = "cogent3.app.io:from_json"
from_primitive = "cogent3.app.io:from_primitive"
load_aligned = "cogent3.app.io:load_aligned"
load_db = "cogent3.app.io:load_db"
load_json = "cogent3.app.io:load_json"
Expand All @@ -192,16 +188,12 @@ omit_bad_seqs = "cogent3.app.sample:omit_bad_seqs"
omit_degenerates = "cogent3.app.sample:omit_degenerates"
omit_duplicated = "cogent3.app.sample:omit_duplicated"
omit_gap_pos = "cogent3.app.sample:omit_gap_pos"
pickle_it = "cogent3.app.io:pickle_it"
select_translatable = "cogent3.app.translate:select_translatable"
take_codon_positions = "cogent3.app.sample:take_codon_positions"
take_n_seqs = "cogent3.app.sample:take_n_seqs"
take_named_seqs = "cogent3.app.sample:take_named_seqs"
to_json = "cogent3.app.io:to_json"
to_primitive = "cogent3.app.io:to_primitive"
translate_seqs = "cogent3.app.translate:translate_seqs"
trim_stop_codons = "cogent3.app.sample:trim_stop_codons"
unpickle_it = "cogent3.app.io:unpickle_it"
write_db = "cogent3.app.io:write_db"
write_json = "cogent3.app.io:write_json"
write_seqs = "cogent3.app.io:write_seqs"
Expand Down
43 changes: 22 additions & 21 deletions src/cogent3/core/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,41 +1608,42 @@ def strand_symmetry(self, motif_length=1):

def dotplot(
self,
name1=None,
name2=None,
window=20,
threshold=None,
k=None,
min_gap=0,
width=500,
title=None,
rc=False,
show_progress=False,
name1: Optional[str] = None,
name2: Optional[str] = None,
window: int = 20,
threshold: Optional[int] = None,
k: Optional[int] = None,
min_gap: int = 0,
width: int = 500,
title: Optional[str] = None,
rc: bool = False,
show_progress: bool = False,
):
"""make a dotplot between specified sequences. Random sequences
chosen if names not provided.
Parameters
----------
name1, name2 : str or None
names of sequences. If one is not provided, a random choice is made
window : int
k-mer size for comparison between sequences
threshold : int
name1, name2
names of sequences. If not provided, a random choice is made
window
segment size for comparison between sequences
threshold
windows where the sequences are identical >= threshold are a match
k : int
k
size of k-mer to break sequences into. Larger values increase
speed but reduce resolution. If not specified, is computed as the
maximum of (window-threshold), (window % k) * k <= threshold.
min_gap : int
speed but reduce resolution. If not specified, and
window == threshold, then k is set to window. Otherwise, it is
computed as the maximum of {threshold // (window - threshold), 5}.
min_gap
permitted gap for joining adjacent line segments, default is no gap
joining
width : int
width
figure width. Figure height is computed based on the ratio of
len(seq1) / len(seq2)
title
title for the plot
rc : bool or None
rc
include dotplot of reverse compliment also. Only applies to Nucleic
acids moltypes
Expand Down
5 changes: 3 additions & 2 deletions src/cogent3/draw/dotplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ def __init__(
windows where the sequences are identical >= threshold are a match
k : int
size of k-mer to break sequences into. Larger values increase
speed but reduce resolution. If not specified, is computed as the
maximum of (window-threshold), (window % k) * k <= threshold.
speed but reduce resolution. If not specified, and
window == threshold, then k is set to window. Otherwise, it is
computed as the maximum of {threshold // (window - threshold), 5}.
min_gap : int
permitted gap for joining adjacent line segments, default is no gap
joining
Expand Down
4 changes: 2 additions & 2 deletions tests/test_app/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ def test_get_app_kwargs():


def test_app_help(capsys):
app_help("compress")
app_help("concat")
got = capsys.readouterr().out
assert "Options" in got
assert got.count("bytes") >= 2 # both input and output types are bytes
assert got.count("SerialisableType") == 1 # output type


@pytest.mark.parametrize(
Expand Down
10 changes: 5 additions & 5 deletions tests/test_app/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,27 +608,27 @@ def test_default_serialiser_deserialiser(data):


def test_to_json():
to_j = get_app("to_json")
to_j = io_app.to_json()
data = {"a": [0, 1]}
assert to_j(data) == json.dumps(data)


def test_from_json():
from_j = get_app("from_json")
from_j = io_app.from_json()
assert from_j('{"a": [0, 1]}') == {"a": [0, 1]}


def test_to_from_json():
to_j = get_app("to_json")
from_j = get_app("from_json")
to_j = io_app.to_json()
from_j = io_app.from_json()
app = to_j + from_j
data = {"a": [0, 1]}
assert app(data) == data
assert app(data) is not data


def test_to_json_combines():
app = get_app("to_primitive") + get_app("to_json")
app = io_app.to_primitive() + io_app.to_json()
assert app(DNA) == DNA.to_json()


Expand Down

0 comments on commit baf9b1e

Please sign in to comment.