Skip to content

Commit

Permalink
Rename phenotype inventory to just "inventory"
Browse files Browse the repository at this point in the history
Since we now have a genotype inventory, it better fits the use case.
  • Loading branch information
amstilp committed Jul 29, 2024
1 parent 7f60a52 commit 8126df7
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Temporary script to create some test data.
# Run with: python manage.py shell < add_phenotype_inventory_input_example_data.py
# Run with: python manage.py shell < add_inventory_input_example_data.py

from anvil_consortium_manager.tests.factories import (
ManagedGroupFactory,
Expand Down
4 changes: 2 additions & 2 deletions primed/primed_anvil/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def get_summary_table_data():
return data


def get_workspaces_for_phenotype_inventory():
def get_workspaces_for_inventory():
"""Get input to the primed-phenotype-inventory workflow.
This function generates the input for the "workspaces" field of the primed-phenotype-inventory workflow. Only
workspaces that have been shared with the consortium are included.
See dockstore link: https://dockstore.org/workflows/github.com/UW-GAC/primed-inventory-workflows/primed_phenotype_inventory:main?tab=info
See dockstore link: https://dockstore.org/workflows/github.com/UW-GAC/primed-inventory-workflows/primed_inventory:main?tab=info
The "workspaces" field has the format:
{
Expand Down
66 changes: 33 additions & 33 deletions primed/primed_anvil/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def test_one_cdsa_workspace_one_open_access_workspace_different_available_data(


class GetWorkspacesForPhenotypeInventoryTest(TestCase):
"""Tests for the helpers.get_workspaces_for_phenotype_inventory method."""
"""Tests for the helpers.get_workspaces_for_inventory method."""

def setUp(self):
"""Set up the test case."""
Expand All @@ -550,32 +550,32 @@ def setUp(self):
self.primed_all_group = ManagedGroupFactory.create(name="PRIMED_ALL")

def test_no_workspaces(self):
"""get_workspaces_for_phenotype_inventory with no workspaces."""
res = helpers.get_workspaces_for_phenotype_inventory()
"""get_workspaces_for_inventory with no workspaces."""
res = helpers.get_workspaces_for_inventory()
self.assertEqual(res, {})

def test_one_dbgap_workspace_not_shared(self):
"""get_workspaces_for_phenotype_inventory with one dbGaP workspace."""
"""get_workspaces_for_inventory with one dbGaP workspace."""
dbGaPWorkspaceFactory.create()
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(res, {})

def test_one_dbgap_workspace_shared_one_study(self):
"""get_workspaces_for_phenotype_inventory with one dbGaP workspace."""
"""get_workspaces_for_inventory with one dbGaP workspace."""
study = StudyFactory.create(short_name="TEST")
workspace = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-bp",
workspace__name="test-ws",
dbgap_study_accession__studies=[study],
)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 1)
self.assertIn("test-bp/test-ws", res)
self.assertEqual(res["test-bp/test-ws"], "TEST")

def test_one_dbgap_workspace_shared_two_studies(self):
"""get_workspaces_for_phenotype_inventory with one dbGaP workspace."""
"""get_workspaces_for_inventory with one dbGaP workspace."""
study_1 = StudyFactory.create(short_name="TEST_2")
study_2 = StudyFactory.create(short_name="TEST_1")
study_accession = dbGaPStudyAccessionFactory.create(studies=[study_1, study_2])
Expand All @@ -585,13 +585,13 @@ def test_one_dbgap_workspace_shared_two_studies(self):
dbgap_study_accession=study_accession,
)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 1)
self.assertIn("test-bp/test-ws", res)
self.assertEqual(res["test-bp/test-ws"], "TEST_1, TEST_2")

def test_two_dbgap_workspaces(self):
"""get_workspaces_for_phenotype_inventory with two dbGaP workspaces."""
"""get_workspaces_for_inventory with two dbGaP workspaces."""
study_1 = StudyFactory.create(short_name="TEST 1")
workspace_1 = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-bp-1",
Expand All @@ -606,35 +606,35 @@ def test_two_dbgap_workspaces(self):
dbgap_study_accession__studies=[study_2],
)
WorkspaceGroupSharingFactory.create(workspace=workspace_2.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 2)
self.assertIn("test-bp-1/test-ws-1", res)
self.assertEqual(res["test-bp-1/test-ws-1"], "TEST 1")
self.assertIn("test-bp-2/test-ws-2", res)
self.assertEqual(res["test-bp-2/test-ws-2"], "TEST 2")

def test_one_cdsa_workspace_not_shared(self):
"""get_workspaces_for_phenotype_inventory with one CDSA workspace."""
"""get_workspaces_for_inventory with one CDSA workspace."""
CDSAWorkspaceFactory.create()
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(res, {})

def test_one_cdsa_workspace_shared_one_study(self):
"""get_workspaces_for_phenotype_inventory with one CDSA workspace."""
"""get_workspaces_for_inventory with one CDSA workspace."""
study = StudyFactory.create(short_name="TEST")
workspace = CDSAWorkspaceFactory.create(
workspace__billing_project__name="test-bp",
workspace__name="test-ws",
study=study,
)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 1)
self.assertIn("test-bp/test-ws", res)
self.assertEqual(res["test-bp/test-ws"], "TEST")

def test_two_cdsa_workspaces(self):
"""get_workspaces_for_phenotype_inventory with two CDSA workspaces."""
"""get_workspaces_for_inventory with two CDSA workspaces."""
study_1 = StudyFactory.create(short_name="TEST 1")
workspace_1 = CDSAWorkspaceFactory.create(
workspace__billing_project__name="test-bp-1",
Expand All @@ -649,47 +649,47 @@ def test_two_cdsa_workspaces(self):
study=study_2,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_2.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 2)
self.assertIn("test-bp-1/test-ws-1", res)
self.assertEqual(res["test-bp-1/test-ws-1"], "TEST 1")
self.assertIn("test-bp-2/test-ws-2", res)
self.assertEqual(res["test-bp-2/test-ws-2"], "TEST 2")

def test_one_open_access_workspace_not_shared(self):
"""get_workspaces_for_phenotype_inventory with one dbGaP workspace."""
"""get_workspaces_for_inventory with one dbGaP workspace."""
OpenAccessWorkspaceFactory.create()
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(res, {})

def test_one_open_access_workspace_shared_no_study(self):
"""get_workspaces_for_phenotype_inventory with one Open access workspace."""
"""get_workspaces_for_inventory with one Open access workspace."""
workspace = OpenAccessWorkspaceFactory.create(
workspace__billing_project__name="test-bp",
workspace__name="test-ws",
)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 1)
self.assertIn("test-bp/test-ws", res)
self.assertEqual(res["test-bp/test-ws"], "")

def test_one_open_access_workspace_shared_one_study(self):
"""get_workspaces_for_phenotype_inventory with one Open access workspace."""
"""get_workspaces_for_inventory with one Open access workspace."""
study = StudyFactory.create(short_name="TEST")
workspace = OpenAccessWorkspaceFactory.create(
workspace__billing_project__name="test-bp",
workspace__name="test-ws",
)
workspace.studies.add(study)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 1)
self.assertIn("test-bp/test-ws", res)
self.assertEqual(res["test-bp/test-ws"], "TEST")

def test_one_open_access_workspace_shared_two_studies(self):
"""get_workspaces_for_phenotype_inventory with one Open access workspace."""
"""get_workspaces_for_inventory with one Open access workspace."""
study_1 = StudyFactory.create(short_name="TEST_2")
study_2 = StudyFactory.create(short_name="TEST_1")
workspace = OpenAccessWorkspaceFactory.create(
Expand All @@ -698,13 +698,13 @@ def test_one_open_access_workspace_shared_two_studies(self):
)
workspace.studies.add(study_1, study_2)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 1)
self.assertIn("test-bp/test-ws", res)
self.assertEqual(res["test-bp/test-ws"], "TEST_1, TEST_2")

def test_two_open_access_workspaces(self):
"""get_workspaces_for_phenotype_inventory with two Open access workspace."""
"""get_workspaces_for_inventory with two Open access workspace."""
workspace_1 = OpenAccessWorkspaceFactory.create(
workspace__billing_project__name="test-bp-1",
workspace__name="test-ws-1",
Expand All @@ -717,7 +717,7 @@ def test_two_open_access_workspaces(self):
)
workspace_2.studies.add(study_2)
WorkspaceGroupSharingFactory.create(workspace=workspace_2.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 2)
self.assertIn("test-bp-1/test-ws-1", res)
self.assertEqual(res["test-bp-1/test-ws-1"], "")
Expand Down Expand Up @@ -747,7 +747,7 @@ def test_multiple_workspace_types_same_study(self):
)
workspace.studies.add(study)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 3)
self.assertIn("test-bp-dbgap/test-ws-dbgap", res)
self.assertEqual(res["test-bp-dbgap/test-ws-dbgap"], "TEST")
Expand Down Expand Up @@ -781,7 +781,7 @@ def test_multiple_workspace_types_separate_studies(self):
)
workspace.studies.add(study_3)
WorkspaceGroupSharingFactory.create(workspace=workspace.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 3)
self.assertIn("test-bp-dbgap/test-ws-dbgap", res)
self.assertEqual(res["test-bp-dbgap/test-ws-dbgap"], "TEST 1")
Expand Down Expand Up @@ -850,7 +850,7 @@ def test_non_consecutive_grouping(self):
dbgap_study_accession=study_accession_1,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_1_d.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 8)
self.assertEqual(res["test-b/test-a-b_c1"], "TEST_1, TEST_2")
self.assertEqual(res["test-b/test-a-b_c2"], "TEST_1, TEST_2")
Expand Down Expand Up @@ -878,7 +878,7 @@ def test_order_dbgap(self):
workspace__name="test-ws-2",
)
WorkspaceGroupSharingFactory.create(workspace=workspace_3.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 3)
self.assertEqual(list(res)[0], "test-bp-1/test-ws-2")
self.assertEqual(list(res)[1], "test-bp-2/test-ws-1")
Expand All @@ -901,7 +901,7 @@ def test_order_cdsa(self):
workspace__name="test-ws-2",
)
WorkspaceGroupSharingFactory.create(workspace=workspace_3.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 3)
self.assertEqual(list(res)[0], "test-bp-1/test-ws-2")
self.assertEqual(list(res)[1], "test-bp-2/test-ws-1")
Expand All @@ -924,7 +924,7 @@ def test_order_open_access(self):
workspace__name="test-ws-2",
)
WorkspaceGroupSharingFactory.create(workspace=workspace_3.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
res = helpers.get_workspaces_for_inventory()
self.assertEqual(len(res), 3)
self.assertEqual(list(res)[0], "test-bp-1/test-ws-2")
self.assertEqual(list(res)[1], "test-bp-2/test-ws-1")
Expand Down
8 changes: 4 additions & 4 deletions primed/primed_anvil/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,8 +1247,8 @@ def test_includes_cdsa_workspaces(self):
self.assertEqual(len(response.context_data["summary_table"].rows), 1)


class PhenotypeInventoryInputsViewTest(TestCase):
"""Tests for the PhenotypeInventoryInputsView view."""
class InventoryInputsViewTest(TestCase):
"""Tests for the InventoryInputsView view."""

def setUp(self):
"""Set up test class."""
Expand All @@ -1262,11 +1262,11 @@ def setUp(self):

def get_url(self, *args):
"""Get the url for the view being tested."""
return reverse("primed_anvil:utilities:phenotype_inventory_inputs", args=args)
return reverse("primed_anvil:utilities:inventory_inputs", args=args)

def get_view(self):
"""Return the view being tested."""
return views.PhenotypeInventoryInputsView.as_view()
return views.InventoryInputsView.as_view()

def test_view_redirect_not_logged_in(self):
"View redirects to login view when user is not logged in."
Expand Down
6 changes: 3 additions & 3 deletions primed/primed_anvil/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
utilities_patterns = (
[
path(
"phenotype_inventory_inputs/",
views.PhenotypeInventoryInputsView.as_view(),
name="phenotype_inventory_inputs",
"inventory_inputs/",
views.InventoryInputsView.as_view(),
name="inventory_inputs",
),
],
"utilities",
Expand Down
6 changes: 3 additions & 3 deletions primed/primed_anvil/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ def get_context_data(self, **kwargs):
return context


class PhenotypeInventoryInputsView(AnVILConsortiumManagerStaffViewRequired, TemplateView):
template_name = "primed_anvil/phenotype_inventory_inputs.html"
class InventoryInputsView(AnVILConsortiumManagerStaffViewRequired, TemplateView):
template_name = "primed_anvil/inventory_inputs.html"

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["workspaces_input"] = json.dumps(helpers.get_workspaces_for_phenotype_inventory(), indent=2)
context["workspaces_input"] = json.dumps(helpers.get_workspaces_for_inventory(), indent=2)
return context
2 changes: 1 addition & 1 deletion primed/templates/anvil_consortium_manager/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<li><hr class="dropdown-divider"></li>
<li>
<a class="dropdown-item" href="{% url 'primed_anvil:utilities:phenotype_inventory_inputs' %}">Phenotype inventory</a>
<a class="dropdown-item" href="{% url 'primed_anvil:utilities:inventory_inputs' %}">Inventory inputs</a>
</li>

<li><hr class="dropdown-divider"></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h2>Phenotype inventory workflow</h2>

<p>
This page creates the input for the "workspaces" field in the
<a href="https://dockstore.org/workflows/github.com/UW-GAC/primed-inventory-workflows/primed_phenotype_inventory:main?tab=info">PRIMED phenotype inventory workflow</a>.
<a href="https://dockstore.org/workflows/github.com/UW-GAC/primed-inventory-workflows/primed_inventory:main?tab=info">PRIMED phenotype inventory workflow</a>.
Copy the text in the box below and paste it into the "workspaces" field when running the workflow on AnVIL.
</p>

Expand Down

0 comments on commit 8126df7

Please sign in to comment.