Skip to content

Commit

Permalink
Add missing arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
cachitas committed Apr 5, 2024
1 parent 70dcdd2 commit 541e22b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
44 changes: 38 additions & 6 deletions src/stringx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,60 @@
identity = ""


def map(identifiers: list[str], species: int):
def map(
identifiers: list[str],
species: int,
*,
limit: int = 1,
echo_query: bool = True,
):
with Client(identity=identity) as client:
return (
client.map(identifiers=identifiers, species=species)
client.map(
identifiers=identifiers,
species=species,
limit=limit,
echo_query=echo_query,
)
.raise_for_status()
.json()
)


def network(identifiers: list[str], species: int):
def network(
identifiers: list[str],
species: int,
*,
required_score: float | None = None,
network_type: str = "functional",
add_nodes: int | None = None,
show_query_node_labels: bool = False,
):
with Client(identity=identity) as client:
return (
client.network(identifiers=identifiers, species=species)
client.network(
identifiers=identifiers,
species=species,
required_score=required_score,
network_type=network_type,
add_nodes=add_nodes,
show_query_node_labels=show_query_node_labels,
)
.raise_for_status()
.json()
)


def interaction_partners(identifiers: list[str], species: int):
def interaction_partners(
identifiers: list[str], species: int, limit: int | None = None
):
with Client(identity=identity) as client:
return (
client.interaction_partners(identifiers=identifiers, species=species)
client.interaction_partners(
identifiers=identifiers,
species=species,
limit=limit,
)
.raise_for_status()
.json()
)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_stringx.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,23 @@ def test_valid_identity(httpx_mock):
def test_map(httpx_mock):
httpx_mock.add_response(json=True)
stringx.map(["id1"], 1234)
stringx.map(["id1"], 1234, limit=2)
stringx.map(["id1"], 1234, echo_query=False)


def test_network(httpx_mock):
httpx_mock.add_response(json=True)
stringx.network(["id1"], 1234)
stringx.network(["id1"], 1234, required_score=1)
stringx.network(["id1"], 1234, network_type="other")
stringx.network(["id1"], 1234, add_nodes=50)
stringx.network(["id1"], 1234, show_query_node_labels=True)


def test_interaction_partners(httpx_mock):
httpx_mock.add_response(json=True)
stringx.interaction_partners(["id1"], 1234)
stringx.interaction_partners(["id1"], 1234, limit=10)


def test_homology(httpx_mock):
Expand Down

0 comments on commit 541e22b

Please sign in to comment.