Exemplo n.º 1
0
    def test_get_task(self):
        from xssp_api.tasks import get_task

        task = get_task('pdb_id', 'dssp')
        eq_(task.__name__, 'get_dssp')
        task = get_task('pdb_id', 'hssp_hssp')
        eq_(task.__name__, 'get_hssp')
        task = get_task('pdb_id', 'hssp_stockholm')
        eq_(task.__name__, 'get_hssp')

        task = get_task('pdb_redo_id', 'dssp')
        eq_(task.__name__, 'get_dssp_redo')

        task = get_task('pdb_file', 'dssp')
        eq_(task.__name__, 'mkdssp_from_pdb')
        task = get_task('pdb_file', 'hssp_hssp')
        eq_(task.__name__, 'mkhssp_from_pdb')
        task = get_task('pdb_file', 'hssp_stockholm')
        eq_(task.__name__, 'mkhssp_from_pdb')

        task = get_task('sequence', 'hssp_hssp')
        eq_(task.__name__, 'mkhssp_from_sequence')
        task = get_task('sequence', 'hssp_stockholm')
        eq_(task.__name__, 'mkhssp_from_sequence')
        task = get_task('sequence', 'hg_hssp')
        eq_(task.__name__, 'get_hg_hssp')
Exemplo n.º 2
0
    def test_get_task(self):
        from xssp_api.tasks import get_task

        task = get_task('pdb_id', 'dssp')
        eq_(task.__name__, 'get_dssp')
        task = get_task('pdb_id', 'hssp_hssp')
        eq_(task.__name__, 'get_hssp')
        task = get_task('pdb_id', 'hssp_stockholm')
        eq_(task.__name__, 'get_hssp')

        task = get_task('pdb_redo_id', 'dssp')
        eq_(task.__name__, 'get_dssp_redo')

        task = get_task('pdb_file', 'dssp')
        eq_(task.__name__, 'mkdssp_from_pdb')
        task = get_task('pdb_file', 'hssp_hssp')
        eq_(task.__name__, 'mkhssp_from_pdb')
        task = get_task('pdb_file', 'hssp_stockholm')
        eq_(task.__name__, 'mkhssp_from_pdb')

        task = get_task('sequence', 'hssp_hssp')
        eq_(task.__name__, 'mkhssp_from_sequence')
        task = get_task('sequence', 'hssp_stockholm')
        eq_(task.__name__, 'mkhssp_from_sequence')
        task = get_task('sequence', 'hg_hssp')
        eq_(task.__name__, 'get_hg_hssp')
Exemplo n.º 3
0
def get_xssp_result(input_type, output_type, id):
    """
    Get the result of a previous job submission.

    :param input_type:
        Either 'pdb_id', 'pdb_redo_id', 'pdb_file' or 'sequence'.
    :param output_type: Either 'hssp_hssp', 'hssp_stockholm', or 'dssp'.
    :param id: The id returned by a call to the create method.
    :return: The output of the job. If the job status is not SUCCESS, this
             method returns an error.
    """
    from xssp_api.tasks import get_task
    task = get_task(input_type, output_type)
    _log.debug("task is {}".format(task.__name__))

    async_result = task.AsyncResult(id)
    if async_result.status != 'SUCCESS':
        return jsonify({'error': 'job status is {}'.format(async_result.status)}), 500

    result = async_result.get()
    if len(result) <= 0:
        return jsonify({'error': 'empty result'}), 500

    response = {'result': result}
    return jsonify(response)
Exemplo n.º 4
0
    def __call__(self):
        from xssp_api.tasks import get_task
        task = get_task('pdb_redo_id', self.output_format)
        _log.debug("Calling task '{}'".format(task.__name__))

        if self.output_format == 'dssp':
            result = task.delay(self.pdb_redo_id)
        return result.id
Exemplo n.º 5
0
    def __call__(self):
        from xssp_api.tasks import get_task
        task = get_task('sequence', self.output_format)
        _log.debug("Calling task '{}'".format(task.__name__))

        if 'hg_hssp' in self.output_format:
            result = task.delay(self.sequence)
        elif 'hssp' in self.output_format:
            result = task.delay(self.sequence, self.output_format)
        return result.id
Exemplo n.º 6
0
    def __call__(self):
        from xssp_api.tasks import get_task
        task = get_task('pdb_file', self.output_format)
        _log.debug("Calling task '{}'".format(task.__name__))

        if 'hssp' in self.output_format:
            result = task.delay(self.pdb_file_path, self.output_format)
        else:
            result = task.delay(self.pdb_file_path)
        return result.id
Exemplo n.º 7
0
def get_queued():
    res = storage.find('tasks', {})

    from xssp_api.tasks import get_task

    tasks = []
    for t in res:
        task = get_task(t['input_type'], t['output_type'])
        async_result = task.AsyncResult(t['task_id'])

        tasks.append({'task_id': t['task_id'],
                      'input_type': t['input_type'],
                      'output_type': t['output_type'],
                      'status': async_result.status})

    return jsonify({ 'tasks': tasks })
Exemplo n.º 8
0
def get_queued():
    res = storage.find('tasks', {})

    from xssp_api.tasks import get_task

    tasks = []
    for t in res:
        task = get_task(t['input_type'], t['output_type'])
        async_result = task.AsyncResult(t['task_id'])

        tasks.append({'task_id': t['task_id'],
                      'input_type': t['input_type'],
                      'output_type': t['output_type'],
                      'status': async_result.status})

    return jsonify({ 'tasks': tasks })
Exemplo n.º 9
0
def get_xssp_result(input_type, output_type, id):
    """
    Get the result of a previous job submission.

    :param input_type:
        Either 'pdb_id', 'pdb_redo_id', 'pdb_file' or 'sequence'.
    :param output_type: Either 'hssp_hssp', 'hssp_stockholm', or 'dssp'.
    :param id: The id returned by a call to the create method.
    :return: The output of the job. If the job status is not SUCCESS, this
             method returns an error.
    """
    from xssp_api.tasks import get_task
    task = get_task(input_type, output_type)
    _log.debug("task is {}".format(task.__name__))
    response = {'result': task.AsyncResult(id).get()}

    return jsonify(response)
Exemplo n.º 10
0
def get_xssp_status(input_type, output_type, id):
    """
    Get the status of a previous job submission.

    :param input_type:
        Either 'pdb_id', 'pdb_redo_id', 'pdb_file' or 'sequence'.
    :param output_type: Either 'hssp_hssp', 'hssp_stockholm', or 'dssp'.
    :param id: The id returned by a call to the create method.
    :return: Either PENDING, STARTED, SUCCESS, FAILURE, RETRY, or REVOKED.
    """
    from xssp_api.tasks import get_task
    task = get_task(input_type, output_type)
    async_result = task.AsyncResult(id)

    response = {'status': async_result.status}
    if async_result.failed():
        response.update({'message': async_result.traceback})
    return jsonify(response)
Exemplo n.º 11
0
def get_xssp_status(input_type, output_type, id):
    """
    Get the status of a previous job submission.

    :param input_type:
        Either 'pdb_id', 'pdb_redo_id', 'pdb_file' or 'sequence'.
    :param output_type: Either 'hssp_hssp', 'hssp_stockholm', or 'dssp'.
    :param id: The id returned by a call to the create method.
    :return: Either PENDING, STARTED, SUCCESS, FAILURE, RETRY, or REVOKED.
    """
    from xssp_api.tasks import get_task
    task = get_task(input_type, output_type)
    async_result = task.AsyncResult(id)

    response = {'status': async_result.status}
    if async_result.failed():
        response.update({'message': async_result.traceback})
    return jsonify(response)
Exemplo n.º 12
0
 def test_get_task_invalid_combination_sequence_dssp(self):
     from xssp_api.tasks import get_task
     get_task('pdb_redo_id', 'hssp_stockholm')
Exemplo n.º 13
0
 def test_get_task_unexpected_input_type(self):
     from xssp_api.tasks import get_task
     get_task('unexpected', 'hssp_stockholm')
Exemplo n.º 14
0
 def test_get_task_invalid_combination_sequence_dssp(self):
     from xssp_api.tasks import get_task
     get_task('pdb_redo_id', 'hssp_stockholm')
Exemplo n.º 15
0
 def test_get_task_invalid_combination_pdb_redo_id_hssp_stockholm(self):
     from xssp_api.tasks import get_task
     get_task('sequence', 'dssp')
Exemplo n.º 16
0
 def test_get_task_invalid_combination_pdb_redo_id_hssp(self):
     from xssp_api.tasks import get_task
     get_task('pdb_redo_id', 'hssp')
Exemplo n.º 17
0
 def test_get_task_unexpected_input_type(self):
     from xssp_api.tasks import get_task
     get_task('unexpected', 'hssp_stockholm')
Exemplo n.º 18
0
 def test_get_task_invalid_combination_pdb_redo_id_hssp_stockholm(self):
     from xssp_api.tasks import get_task
     get_task('sequence', 'dssp')
Exemplo n.º 19
0
 def test_get_task_invalid_combination_pdb_redo_id_hssp(self):
     from xssp_api.tasks import get_task
     get_task('pdb_redo_id', 'hssp')