Skip to content

Commit

Permalink
Merge branch 'alignments' of https://github.com/PyEED/pyeed into alig…
Browse files Browse the repository at this point in the history
…nments
  • Loading branch information
alacheim committed Dec 12, 2023
2 parents 7b07601 + 4c33a42 commit 4363809
Show file tree
Hide file tree
Showing 7 changed files with 685 additions and 432 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# jupyter/scipy-notebook to build our image on top of it
FROM jupyter/scipy-notebook

LABEL Max Haeussler <[email protected]>

USER root

# Install psycopg2 dependencies
RUN apt-get update \
&& apt-get -y install libpq-dev gcc python3-dev\
&& pip install psycopg2

# Install python libraries
RUN pip install --upgrade pip \
&& pip install git+https://github.com/PyEED/pyeed.git@alignments

# Let's change to "$NB_USER" command so the image runs as a non root user by default
USER $NB_UID

#Let's define this parameter to install jupyter lab instead of the default juyter notebook command so we don't have to use it when running the container with the option -e
ENV JUPYTER_ENABLE_LAB=yes
37 changes: 37 additions & 0 deletions .github/workflows/build_push_docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image
on:
push:
branches:
- "alignments"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: haeussma/pyeed-notebook:latest
257 changes: 249 additions & 8 deletions examples/alignments/test_clustal.ipynb

Large diffs are not rendered by default.

781 changes: 367 additions & 414 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyEED/alignment/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def pairwise_alignment(
FileNotFoundError: If the substitution matrix is not valid.
Returns:
PairwiseAlignment: Pairwise alignment object with the alignment scores.
Alignment: Pairwise alignment object with the alignment scores.
"""
modes = ["global", "local"]

Expand Down
16 changes: 8 additions & 8 deletions pyEED/network/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import plotly.graph_objects as go

from pyEED.core.proteininfo import ProteinInfo
from pyEED.core.pairwisealignment import PairwiseAlignment
from pyEED.core.alignment import Alignment


def pairwise_network(
alignments: List[PairwiseAlignment],
alignments: List[Alignment],
weight: str = "identity",
cutoff: float = None,
label: str = "accession_id",
color: str = "name",
) -> None:
"""Takes a list of `PairwiseAlignment`, constructs a network graph,
"""Takes a list of `Alignment`, constructs a network graph,
whereas the edges of the graph are weighted with an attribute of the
`PairwiseAlignment` object. Visualizes the network graph.
`Alignment` object. Visualizes the network graph.
Args:
alignments (List[PairwiseAlignment]): List of pairwise alignments.
weight (str, optional): Attribute of `PairwiseAlignment` to weight the edges.
alignments (List[Alignment]): List of pairwise alignments.
weight (str, optional): Attribute of `Alignment` to weight the edges.
Defaults to "identity".
cutoff (float, optional): Sequences with a weight higher than the cutoff are connected
in the network. Defaults to None.
Expand Down Expand Up @@ -53,7 +53,7 @@ def pairwise_network(
visualize_network(graph, label=label, color=color)


def construct_network(alignments: List[PairwiseAlignment], cutoff: float) -> nx.Graph:
def construct_network(alignments: List[Alignment], cutoff: float) -> nx.Graph:
"""Maps properties of alignments to a network graph."""
graph = nx.Graph()

Expand Down Expand Up @@ -187,7 +187,7 @@ def position_nodes_and_edges(graph: nx.Graph, weight: str) -> nx.Graph:
return graph


def _get_unique_sequences(alignments: List[PairwiseAlignment]) -> List[ProteinInfo]:
def _get_unique_sequences(alignments: List[Alignment]) -> List[ProteinInfo]:
"""Gets unique sequences from a list of alignments."""

sequence_infos = []
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ readme = "README.md"
packages = [
{ include = "pyEED/core" },
{ include = "pyEED/ncbi" },
{ include = "pyEED/networks" },
{ include = "pyEED/network" },
{ include = "pyEED/alignment" },
]

[tool.poetry.dependencies]
Expand Down

0 comments on commit 4363809

Please sign in to comment.