Пример #1
0
def make_analyses_with_single_dataset(number_to_create, user_instance):
    """Create some minimal Analyses"""

    instance = GalaxyInstanceFactory()
    workflow_engine = WorkflowEngineFactory(instance=instance)
    workflow = WorkflowFactory(uuid=str(uuid_builtin.uuid4()),
                               workflow_engine=workflow_engine)
    project = ProjectFactory(is_catch_all=True)
    dataset = create_dataset_with_necessary_models()

    while number_to_create:
        analysis_uuid = str(uuid_builtin.uuid4())
        AnalysisFactory(uuid=analysis_uuid,
                        name="Test Analysis - {}".format(analysis_uuid),
                        project=project,
                        data_set=dataset,
                        workflow=workflow)

        number_to_create -= 1

    for dataset in DataSet.objects.all():
        dataset.set_owner(user_instance)
        dataset.save()

    for analysis in Analysis.objects.all():
        analysis.set_owner(user_instance)
        analysis.save()
Пример #2
0
    def setUp(self):
        self.GALAXY_HISTORY_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_FILESIZE = 1024
        self.MISCELLANEOUS_STRING = "Coffee is tasty"

        self.galaxy_instance = GalaxyInstanceFactory(api_key=str(uuid.uuid4()))
        self.show_history_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_history").start()
        self.show_dataset_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_dataset").start()

        self.history_content_entry = {
            "name": "Test History Content Entry",
            "url": "www.example.com/history_content_entry",
            "type": "file",
            "id": self.GALAXY_DATASET_ID
        }
Пример #3
0
def make_analyses_with_single_dataset(number_to_create, user_instance):
    """Create some minimal Analyses"""

    instance = GalaxyInstanceFactory()
    workflow_engine = WorkflowEngineFactory(instance=instance)
    workflow = WorkflowFactory(uuid=str(uuid_builtin.uuid4()),
                               workflow_engine=workflow_engine)
    project = ProjectFactory(is_catch_all=True)
    dataset = create_dataset_with_necessary_models(user=user_instance)

    while number_to_create:
        create_analysis(project, dataset, workflow, user_instance)
        number_to_create -= 1

    return Analysis.objects.all(), dataset
Пример #4
0
    def setUp(self):
        self.galaxy_instance = GalaxyInstanceFactory()
        self.workflow_engine = WorkflowEngine.objects.create(
            instance=self.galaxy_instance)
        self.workflow = Workflow.objects.create(
            is_active=True, workflow_engine=self.workflow_engine)
        self.user = get_anonymous_user()
        project = Project.objects.create(name="Catch-All Project",
                                         is_catch_all=True)
        project.set_owner(self.user)
        self.user.profile.catch_all_project = project
        self.user.profile.save()

        self.dataset = create_dataset_with_necessary_models()
        self.study = self.dataset.get_latest_study()
        self.assay = Assay.objects.create(study=self.study)
Пример #5
0
    def setUp(self):
        self.GALAXY_HISTORY_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_FILESIZE = 1024
        self.MISCELLANEOUS_STRING = "Coffee is tasty"

        self.galaxy_instance = GalaxyInstanceFactory(api_key=str(uuid.uuid4()))
        self.show_history_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_history"
        ).start()
        self.show_dataset_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_dataset"
        ).start()

        self.history_content_entry = {
            "name": "Test History Content Entry",
            "url": "www.example.com/history_content_entry",
            "type": "file",
            "id": self.GALAXY_DATASET_ID
        }
    def setUp(self):
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(self.username,
                                             '*****@*****.**',
                                             self.password)
        self.project = Project.objects.create()
        self.galaxy_instance = GalaxyInstanceFactory()
        self.workflow_engine = WorkflowEngine.objects.create(
            instance=self.galaxy_instance
        )
        self.workflow = Workflow.objects.create(
            workflow_engine=self.workflow_engine
        )

        # Create Datasets
        self.data_set = DataSet.objects.create(name="coffee data_set")
        self.data_set.set_owner(self.user)

        # Create Investigation/InvestigationLinks for the DataSets
        self.investigation = Investigation.objects.create()
        InvestigationLink.objects.create(data_set=self.data_set,
                                         investigation=self.investigation,
                                         version=1)

        # Create Studys and Assays
        self.study = Study.objects.create(investigation=self.investigation)
        self.assay = Assay.objects.create(study=self.study)

        # Create Analyses
        self.analysis = Analysis.objects.create(
            name='Coffee Analysis',
            summary='coffee',
            project=self.project,
            data_set=self.data_set,
            workflow=self.workflow,
            time_start=timezone.now()
        )
        self.analysis.set_owner(self.user)
        self.serializer = AnalysisSerializer(self.analysis)
Пример #7
0
class GalaxyInstanceTests(TestCase):
    def setUp(self):
        self.GALAXY_HISTORY_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_FILESIZE = 1024
        self.MISCELLANEOUS_STRING = "Coffee is tasty"

        self.galaxy_instance = GalaxyInstanceFactory(api_key=str(uuid.uuid4()))
        self.show_history_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_history").start()
        self.show_dataset_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_dataset").start()

        self.history_content_entry = {
            "name": "Test History Content Entry",
            "url": "www.example.com/history_content_entry",
            "type": "file",
            "id": self.GALAXY_DATASET_ID
        }

    def tearDown(self):
        mock.patch.stopall()

    def test_get_history_file_list_with_populated_dataset_dict(self):
        self.show_history_mock.return_value = [self.history_content_entry]
        self.show_dataset_mock.return_value = {
            "file_ext": "bam",
            "state": "ok",
            "id": self.GALAXY_DATASET_ID,
            "file_size": self.GALAXY_DATASET_FILESIZE,
            "visible": True,
            "file_name": "Cool bam file",
            "genome_build": "hg19",
            "misc_info": self.MISCELLANEOUS_STRING,
            "misc_blurb": self.MISCELLANEOUS_STRING,
        }

        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID)

        self.assertEqual(len(history_file_list), 1)
        history_file = history_file_list[0]
        self.assertEqual(history_file["type"], "bam")
        self.assertEqual(history_file["state"], "ok")
        self.assertEqual(history_file["dataset_id"], self.GALAXY_DATASET_ID)
        self.assertEqual(history_file["file_size"],
                         self.GALAXY_DATASET_FILESIZE)
        self.assertTrue(history_file["visible"])
        self.assertEqual(history_file["file_name"], "Cool bam file")
        self.assertEqual(history_file["genome_build"], "hg19")
        self.assertEqual(history_file["misc_info"], self.MISCELLANEOUS_STRING)
        self.assertEqual(history_file["misc_blurb"], self.MISCELLANEOUS_STRING)

    def test_get_history_file_list_with_unpopulated_dataset_dict(self):
        self.show_history_mock.return_value = [self.history_content_entry]
        self.show_dataset_mock.return_value = {}
        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID)

        self.assertEqual(len(history_file_list), 1)
        history_file = history_file_list[0]
        self.assertIsNone(history_file["type"])
        self.assertIsNone(history_file["state"])
        self.assertIsNone(history_file["dataset_id"])
        self.assertIsNone(history_file["file_size"])
        self.assertIsNone(history_file["visible"])
        self.assertIsNone(history_file["file_name"])
        self.assertIsNone(history_file["genome_build"])
        self.assertIsNone(history_file["misc_info"])
        self.assertIsNone(history_file["misc_blurb"])

    def test_no_history_files_if_history_content_entry_has_no_type(self):
        del self.history_content_entry["type"]
        self.show_history_mock.return_value = [self.history_content_entry]

        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID)
        self.assertEqual(len(history_file_list), 0)

    def test_no_history_files_if_history_content_entry_isnt_a_file(self):
        self.history_content_entry["type"] = "not a file"
        self.show_history_mock.return_value = [self.history_content_entry]

        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID)
        self.assertEqual(len(history_file_list), 0)
Пример #8
0
 def test_create_workflow_engine_bad_group_name(self):
     galaxy_instance = GalaxyInstanceFactory()
     with self.assertRaises(CommandError):
         call_command("create_workflowengine", str(galaxy_instance.id),
                      "non-existent group name")
Пример #9
0
 def test_create_workflow_engine(self):
     galaxy_instance = GalaxyInstanceFactory()
     call_command("create_workflowengine", str(galaxy_instance.id),
                  ExtendedGroup.objects.public_group().name)
     self.assertIsNotNone(
         WorkflowEngine.objects.get(instance=galaxy_instance))
Пример #10
0
class GalaxyInstanceTests(TestCase):
    def setUp(self):
        self.GALAXY_HISTORY_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_ID = str(uuid.uuid4())
        self.GALAXY_DATASET_FILESIZE = 1024
        self.MISCELLANEOUS_STRING = "Coffee is tasty"

        self.galaxy_instance = GalaxyInstanceFactory(api_key=str(uuid.uuid4()))
        self.show_history_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_history"
        ).start()
        self.show_dataset_mock = mock.patch.object(
            galaxy.histories.HistoryClient, "show_dataset"
        ).start()

        self.history_content_entry = {
            "name": "Test History Content Entry",
            "url": "www.example.com/history_content_entry",
            "type": "file",
            "id": self.GALAXY_DATASET_ID
        }

    def tearDown(self):
        mock.patch.stopall()

    def test_get_history_file_list_with_populated_dataset_dict(self):
        self.show_history_mock.return_value = [self.history_content_entry]
        self.show_dataset_mock.return_value = {
            "file_ext": "bam",
            "state": "ok",
            "id": self.GALAXY_DATASET_ID,
            "file_size": self.GALAXY_DATASET_FILESIZE,
            "visible": True,
            "file_name": "Cool bam file",
            "genome_build": "hg19",
            "misc_info": self.MISCELLANEOUS_STRING,
            "misc_blurb": self.MISCELLANEOUS_STRING,
        }

        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID
        )

        self.assertEqual(len(history_file_list), 1)
        history_file = history_file_list[0]
        self.assertEqual(history_file["type"], "bam")
        self.assertEqual(history_file["state"], "ok")
        self.assertEqual(history_file["dataset_id"], self.GALAXY_DATASET_ID)
        self.assertEqual(history_file["file_size"],
                         self.GALAXY_DATASET_FILESIZE)
        self.assertTrue(history_file["visible"])
        self.assertEqual(history_file["file_name"], "Cool bam file")
        self.assertEqual(history_file["genome_build"], "hg19")
        self.assertEqual(history_file["misc_info"], self.MISCELLANEOUS_STRING)
        self.assertEqual(history_file["misc_blurb"], self.MISCELLANEOUS_STRING)

    def test_get_history_file_list_with_unpopulated_dataset_dict(self):
        self.show_history_mock.return_value = [self.history_content_entry]
        self.show_dataset_mock.return_value = {}
        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID
        )

        self.assertEqual(len(history_file_list), 1)
        history_file = history_file_list[0]
        self.assertIsNone(history_file["type"])
        self.assertIsNone(history_file["state"])
        self.assertIsNone(history_file["dataset_id"])
        self.assertIsNone(history_file["file_size"])
        self.assertIsNone(history_file["visible"])
        self.assertIsNone(history_file["file_name"])
        self.assertIsNone(history_file["genome_build"])
        self.assertIsNone(history_file["misc_info"])
        self.assertIsNone(history_file["misc_blurb"])

    def test_no_history_files_if_history_content_entry_has_no_type(self):
        del self.history_content_entry["type"]
        self.show_history_mock.return_value = [self.history_content_entry]

        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID
        )
        self.assertEqual(len(history_file_list), 0)

    def test_no_history_files_if_history_content_entry_isnt_a_file(self):
        self.history_content_entry["type"] = "not a file"
        self.show_history_mock.return_value = [self.history_content_entry]

        history_file_list = self.galaxy_instance.get_history_file_list(
            self.GALAXY_HISTORY_ID
        )
        self.assertEqual(len(history_file_list), 0)