Ejemplo n.º 1
0
def post_jobs():
    """
    Create a job to create preferences/predictions for a custom sequence using the specified model(model_name).
    request['sequence_id'] str: uuid of the custom sequence to process
    request['job_type'] str: see config.DataType properties for values
    request['model_name'] str: name of the model to use
    :return: json response with id of the job
    """
    required_prop_names = ["sequence_id", "job_type", "model_name"]
    (sequence_id, job_type,
     model_name) = get_required_json_props(request, required_prop_names)
    try:
        seq = SequenceList(sequence_id)
        seq.load(get_db())
    except KeyError as ex:
        raise ClientException("Unable to find sequence. It may have purged.",
                              ErrorType.SEQUENCE_NOT_FOUND,
                              error_data=sequence_id)
    job = CustomJob.find_existing_job(get_db(), job_type, sequence_id,
                                      model_name)
    status_code = None
    if not job:
        status_code = None
        job = CustomJob.create_job(get_db(), job_type, sequence_id, model_name)
    return make_ok_json_response({'id': job.uuid}, status_code)
Ejemplo n.º 2
0
 def test_sequence_too_big(self):
     with self.assertRaises(ClientException) as cm:
         seq_list = SequenceList('1234')
         seq_list.content = make_too_big()
         seq_list.title = 'Too big list'
         seq_list.insert(db=FakeDB())
     self.assertEqual(ErrorType.UPLOADED_DATA_TOO_BIG,
                      cm.exception.error_type)
     self.assertEqual(400, cm.exception.status_code)
Ejemplo n.º 3
0
def get_custom_sequences_data(sequence_id):
    """
    Get base64 encoded contents and other properties of a custom sequence(DNA).
    :param sequence_id: str: uuid associated with a particular sequence
    :return: json response
    """
    seq = SequenceList(sequence_id)
    seq.load(get_db())
    return make_json_response({
        "id": seq.seq_uuid,
        "data": base64.b64encode(seq.content),
        "created": seq.created
    })
Ejemplo n.º 4
0
 def test_sequence_good_size(self):
     seq_list = SequenceList('1234')
     seq_list.content = "myseq>\nAACCGGTTAACCGTTTTTAACCTTGGG"
     seq_list.title = 'Good list'
     seq_list.insert(db=FakeDB())