Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bacpop-205 Fix network #53

Open
wants to merge 22 commits into
base: bacpop-186-v9-db-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e0161cf
updates for network fix
absternator Dec 2, 2024
eb5799b
Merge branch 'bacpop-186-v9-db-support' of https://github.com/bacpop/…
absternator Dec 6, 2024
41fca0f
test: small csv from nicj into microreact
absternator Dec 9, 2024
95482ce
Merge branch 'bacpop-207-csv-microreact' of https://github.com/bacpop…
absternator Dec 16, 2024
26492b7
build: update docker build command to include development image
absternator Dec 16, 2024
11bcc11
refactor: rename cluster retrieval functions for clarity
absternator Dec 16, 2024
3ff71cd
build: update docker push command to include development flag
absternator Dec 16, 2024
7b5d8fe
build: update POPPUNK_VERSION to network_relabelling
absternator Dec 16, 2024
83bcf25
refactor: rename add_query_ref_status to create_subgraphs and update …
absternator Dec 18, 2024
02eac4a
ifx merged clusters issues
absternator Dec 18, 2024
1f577f8
Revert "Merge branch 'bacpop-207-csv-microreact' of https://github.co…
absternator Dec 19, 2024
0850988
tests: unit tests code
absternator Dec 19, 2024
77c53f6
feat: tests fixing
absternator Dec 19, 2024
6fe21ef
fix: update PopPUNK installation branch in CI workflow
absternator Dec 19, 2024
331a4d4
fix: improve warning message formatting in replace_merged_component_f…
absternator Dec 19, 2024
64f9665
docs: enhance docstrings for external cluster functions in utils.py
absternator Dec 19, 2024
54bc4af
fix: tests failig
absternator Dec 19, 2024
68eef98
style: format code for better readability in setup.py and test_unit.py
absternator Dec 19, 2024
60aba3c
test: refactor test_replace_filehashes for improved clarity and funct…
absternator Dec 19, 2024
26795ef
fix: remove unnecessary --refs option from download_databases script …
absternator Dec 19, 2024
54aab40
test: clean up whitespace in test_replace_filehashes for improved rea…
absternator Dec 19, 2024
2bf8cab
fix: update download_databases script and refactor database reference…
absternator Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
# add --with-dev to below commands to build & push the dev image
- name: Build docker image
run: ./docker/build
run: ./docker/build --with-dev # TODO: remove --with-dev before merge
- name: Push docker image
run: ./docker/push
run: ./docker/push --with-dev # TODO: remove --with-dev before merge
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ jobs:
sudo apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
pip install joblib==1.1.0
conda install -c bioconda pp-sketchlib=2.0.0
pip3 install git+https://github.com/bacpop/PopPUNK@v2.7.2#egg=PopPUNK

pip3 install git+https://github.com/bacpop/PopPUNK@network_relabelling#egg=PopPUNK
# TODO revert above branch before merge
- name: Install Poetry
uses: snok/install-poetry@v1
with:
Expand Down
12 changes: 6 additions & 6 deletions beebop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,11 @@ def get_network_graphs(p_hash) -> json:
"""
fs = PoppunkFileStore(storage_location)
try:
cluster_result = get_clusters_internal(p_hash, storage_location)
cluster_result = get_cluster_assignments(p_hash, storage_location)
graphmls = {}
for cluster_info in cluster_result.values():
cluster = cluster_info["cluster"]
path = fs.network_output_component(
path = fs.pruned_network_output_component(
p_hash, get_cluster_num(cluster)
)
with open(path, "r") as graphml_file:
Expand Down Expand Up @@ -494,9 +494,9 @@ def get_results(result_type) -> json:
storage_location)


def get_clusters_internal(p_hash: str, storage_location: str) -> dict:
def get_cluster_assignments(p_hash: str, storage_location: str) -> dict:
"""
[returns cluster assignment results ]
[returns cluster assignment results]

:param p_hash: [project hash]
:param storage_location: [storage location]
Expand All @@ -516,7 +516,7 @@ def get_clusters_json(p_hash: str, storage_location: str) -> json:
:param storage_location: [storage location]
:return json: [response object with cluster results stored in 'data']
"""
cluster_result = get_clusters_internal(p_hash, storage_location)
cluster_result = get_cluster_assignments(p_hash, storage_location)
cluster_dict = {value['hash']: value for value in cluster_result.values()}
failed_samples = get_failed_samples_internal(p_hash, storage_location)

Expand Down Expand Up @@ -620,7 +620,7 @@ def get_project(p_hash) -> json:
if "error" in status:
return jsonify(error=response_failure(status)), 500
else:
clusters_result = get_clusters_internal(p_hash, storage_location)
clusters_result = get_cluster_assignments(p_hash, storage_location)
failed_samples = get_failed_samples_internal(p_hash, storage_location)

fs = PoppunkFileStore(storage_location)
Expand Down
30 changes: 14 additions & 16 deletions beebop/assignClusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def handle_external_clusters(
sketches_dict,
not_found_query_names,
output_full_tmp,
not_found_query_clusters
not_found_query_clusters,
)
)
queries_names.extend(not_found_query_names_new)
Expand Down Expand Up @@ -269,13 +269,11 @@ def handle_not_found_queries(
assign_query_clusters(
config, config.full_db_fs, not_found_query_names, output_full_tmp
)
query_names, query_clusters, _, _, _, _, _ = (
summarise_clusters(
output_full_tmp,
config.species,
config.full_db_fs.db,
not_found_query_names,
)
query_names, query_clusters, _, _, _, _, _ = summarise_clusters(
output_full_tmp,
config.species,
config.full_db_fs.db,
not_found_query_names,
)

handle_files_manipulation(
Expand Down Expand Up @@ -347,15 +345,17 @@ def update_external_clusters(
not_found_prev_querying = config.fs.external_previous_query_clustering_tmp(
config.p_hash
)
external_clusters_not_found, _ = get_external_clusters_from_file(

update_external_clusters_csv(
previous_query_clustering,
not_found_prev_querying,
not_found_query_names,
config.external_clusters_prefix,
)
update_external_clusters_csv(
previous_query_clustering,

external_clusters_not_found, _ = get_external_clusters_from_file(
not_found_prev_querying,
not_found_query_names,
external_clusters_not_found,
config.external_clusters_prefix,
)
external_clusters.update(external_clusters_not_found)

Expand Down Expand Up @@ -399,9 +399,7 @@ def copy_include_files(output_full_tmp: str, outdir: str) -> None:
merge_txt_files(dest_file, source_file)
os.remove(source_file)
else:
os.rename(
source_file, dest_file
)
os.rename(source_file, dest_file)


def filter_queries(
Expand Down
18 changes: 18 additions & 0 deletions beebop/filestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,24 @@ def network_output_component(self, p_hash, component_number) -> str:
)
)

def pruned_network_output_component(self, p_hash, component_number) -> str:
"""
[Generates the path to the pruned network component file
for the given project hash and component number.]

:param p_hash: [project hash]
:param component_number: [component number,
which is the same as cluster number]
:return str: [path to pruned network component file]
"""
return str(
PurePath(
self.output(p_hash),
"network",
f"pruned_network_component_{component_number}.graphml",
)
)

def tmp(self, p_hash) -> str:
"""
:param p_hash: [project hash]
Expand Down
6 changes: 4 additions & 2 deletions beebop/poppunkWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def create_microreact(self, cluster: str, internal_cluster: str) -> None:
),
previous_mst=None,
previous_distances=None,
network_file=self.fs.network_file(self.p_hash),
network_file=None,
gpu_graph=self.args.visualise.gpu_graph,
info_csv=self.args.visualise.info_csv,
rapidnj=shutil.which("rapidnj"),
Expand All @@ -120,6 +120,7 @@ def create_microreact(self, cluster: str, internal_cluster: str) -> None:
recalculate_distances=self.args.visualise.recalculate_distances,
use_partial_query_graph=self.fs.partial_query_graph(self.p_hash),
tmp=self.fs.tmp(self.p_hash),
extend_query_graph=True
)

def create_network(self) -> None:
Expand Down Expand Up @@ -152,7 +153,7 @@ def create_network(self) -> None:
),
previous_mst=None,
previous_distances=None,
network_file=self.fs.network_file(self.p_hash),
network_file=None,
gpu_graph=self.args.visualise.gpu_graph,
info_csv=self.args.visualise.info_csv,
rapidnj=shutil.which("rapidnj"),
Expand All @@ -164,4 +165,5 @@ def create_network(self) -> None:
recalculate_distances=self.args.visualise.recalculate_distances,
use_partial_query_graph=self.fs.partial_query_graph(self.p_hash),
tmp=self.fs.tmp(self.p_hash),
extend_query_graph=True
)
Loading
Loading