Example #1
0
    def add_galaxy(self, url, key):
        """Connect a galaxy account to Askomics

        add triples for the url of galaxy, and the user api key

        :param self; url: the galaxy url
        :type self; url: string
        :param key: the galaxy user api key
        :type key: string
        """

        # try to connect to the galaxy server
        galaxy = GalaxyConnector(self.settings, self.session, url, key)
        try:
            galaxy.check_galaxy_instance()
        except Exception as e:
            raise e

        database = DatabaseConnector(self.settings, self.session)
        query = '''
        INSERT INTO galaxy_accounts VALUES(
            NULL,
            ?,
            ?,
            ?
        )
        '''

        database.execute_sql_query(query, (self.get_user_id_by_username(), url, key))
Example #2
0
    def test_check_galaxy_instance(self):
        """Test the check_galaxy_instance method"""

        galaxy_connector = GalaxyConnector(self.settings, self.request.session,
                                           self.galaxy['url'],
                                           self.galaxy['key'])

        assert galaxy_connector.check_galaxy_instance() is True
Example #3
0
    def test_send_json_to_history(self):
        """Test the send_json_to_history method"""

        galaxy_connector = GalaxyConnector(self.settings, self.request.session,
                                           self.galaxy['url'],
                                           self.galaxy['key'])

        galaxy_connector.send_json_to_history('hello world')

        assert self.interface_galaxy.check_dataset_presence(
            'askomics_query_', start_with=True) is True
Example #4
0
    def test_upload_files(self):
        """Test upload_files method"""

        galaxy_connector = GalaxyConnector(self.settings, self.request.session,
                                           self.galaxy['url'],
                                           self.galaxy['key'])

        galaxy_connector.upload_files([self.datasets['hello']['dataset_id']])

        assert self.interface_galaxy.check_uploaded_files(
            self.temp_directory) is True
Example #5
0
    def test_upload_files(self):
        """Test upload_files method"""

        galaxy_connector = GalaxyConnector(self.settings, self.request.session,
                                           self.galaxy['url'],
                                           self.galaxy['key'])

        galaxy_connector.upload_files([self.datasets['hello']['dataset_id']])

        assert self.interface_galaxy.check_uploaded_files(
            self.settings['askomics.files_dir'] + '/' +
            self.request.session['username'] + '/upload/') is True
Example #6
0
    def test_get_file_content(self):
        """Test get_file_content method"""

        galaxy_connector = GalaxyConnector(self.settings, self.request.session,
                                           self.galaxy['url'],
                                           self.galaxy['key'])

        content = galaxy_connector.get_file_content(
            self.datasets['hello']['dataset_id'])

        expected_content = 'hello world\n'

        assert content == expected_content
Example #7
0
    def test_send_to_history(self):
        """Test the send_to_history method"""

        galaxy_connector = GalaxyConnector(self.settings, self.request.session,
                                           self.galaxy['url'],
                                           self.galaxy['key'])

        param_manager = ParamManager(self.settings, self.request.session)
        src_file = param_manager.get_upload_directory()
        filepath = src_file + 'play_instrument.tsv'

        galaxy_connector.send_to_history(filepath, 'play_instrument.tsv',
                                         'tabular')

        assert self.interface_galaxy.check_dataset_presence(
            'play_instrument.tsv') is True
Example #8
0
    def add_galaxy(self, url, key):
        """Connect a galaxy account to Askomics

        add triples for the url of galaxy, and the user api key

        :param self; url: the galaxy url
        :type self; url: string
        :param key: the galaxy user api key
        :type key: string
        """

        # try to connect to the galaxy server
        galaxy = GalaxyConnector(self.settings, self.session, url, key)
        try:
            galaxy.check_galaxy_instance()
        except Exception as e:
            raise e

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        query_laucher.execute_query(
            sqa.add_galaxy(self.username, url, key).query)
Example #9
0
    def test_get_datasets_and_histories(self):
        """Test the get_datasets_and_histories method"""
        galaxy_connector = GalaxyConnector(self.settings, self.request.session,
                                           self.galaxy['url'],
                                           self.galaxy['key'])

        # Test with history id
        result = galaxy_connector.get_datasets_and_histories(
            ['tabular'], history_id=self.history_id)

        created_history = {
            'name': 'askomics_test',
            'id': self.history_id,
            'selected': True
        }

        assert isinstance(result, dict)
        assert len(result) == 2
        assert 'datasets' in result
        assert 'histories' in result
        assert created_history in result['histories']

        # Test without history id
        result = galaxy_connector.get_datasets_and_histories(['tabular'])

        created_history = {
            'name': 'askomics_test',
            'id': self.history_id,
            'selected': True
        }

        assert isinstance(result, dict)
        assert len(result) == 2
        assert 'datasets' in result
        assert 'histories' in result
        assert created_history in result['histories']