Skip to content

Commit

Permalink
Get cytoscape running with config mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Sep 29, 2023
1 parent 0e1975a commit 1313446
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ rule viz_cytoscape:
output:
session = SEP.join([out_dir, '{dataset}-cytoscape.cys'])
run:
cytoscape.run_cytoscape(input.pathways, output.session, SINGULARITY)
cytoscape.run_cytoscape(input.pathways, output.session)


# Write a single summary table for all pathways for each dataset
Expand Down
11 changes: 7 additions & 4 deletions src/analysis/cytoscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from shutil import rmtree
from typing import List, Union

from src.util import prepare_volume, run_container
import src.config as config
from src.containers import run_container
from src.util import prepare_volume


def run_cytoscape(pathways: List[Union[str, PurePath]], output_file: str, singularity: bool = False) -> None:
def run_cytoscape(pathways: List[Union[str, PurePath]], output_file: str) -> None:
"""
Create a Cytoscape session file with visualizations of each of the provided pathways
@param pathways: a list of pathways to visualize
Expand Down Expand Up @@ -49,9 +51,10 @@ def run_cytoscape(pathways: List[Union[str, PurePath]], output_file: str, singul
print('Running Cytoscape with arguments: {}'.format(' '.join(command)), flush=True)

# TODO consider making this a string in the config file instead of a Boolean
container_framework = 'singularity' if singularity else 'docker'
container_framework = config.config.container_framework
container_prefix = "py4cytoscape:v1"
out = run_container(container_framework,
'reedcompbio/py4cytoscape:v1',
container_prefix,
command,
volumes,
work_dir,
Expand Down
5 changes: 4 additions & 1 deletion test/analysis/test_cytoscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest

import src.config as config
from src.analysis.cytoscape import run_cytoscape

INPUT_DIR = 'test/analysis/input/example/'
Expand Down Expand Up @@ -33,7 +34,9 @@ def test_cytoscape(self):
# Open a GitHub issue if Cytoscape does not work on Singularity as expected for assistance debugging
@pytest.mark.xfail(reason='Requires Singularity and only works for certain Singularity configurations')
def test_cytoscape_singularity(self):
config.config.container_framework = "singularity"
out_path = Path(OUT_FILE)
out_path.unlink(missing_ok=True)
run_cytoscape(INPUT_PATHWAYS, OUT_FILE, True)
run_cytoscape(INPUT_PATHWAYS, OUT_FILE)
config.config.container_framework = "docker"
assert out_path.exists()

0 comments on commit 1313446

Please sign in to comment.