def get_sample_details(request_id, sample_id, analysis_id): """ swag_from_file: sbs/swagger/sbs_get_individual_sample.yml """ params = {} if not request_id: return create_json_response(ERROR, REQUIRED_FIELD_REQUEST_ID) if not sample_id: return create_json_response(ERROR, REQUIRED_FIELD_SAMPLE_ID) if not analysis_id: return create_json_response(ERROR, REQUIRED_FIELD_ANALYSIS_ID) filter_type = request.args.get('filter_type') role = user_svc.get_current_user_role_by_access_token() params['request_id'] = request_id params['sample_id'] = sample_id params['analysis_id'] = analysis_id params['filter_type'] = filter_type params['role'] = role try: result = sample_svc.get_sample_details(params) except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, result)
def add_observed_maps(): """ swag_from_file: sbs/swagger/sbs_post_observed_map_multiple.yml """ params = request.get_json(force=True) request_maps = params['request_maps'] status_list = [] if request_maps: for request_map_dict in request_maps: if request_map_dict: sample_id = request_map_dict['sample_id'] analysis_id = request_map_dict['analysis_id'] map_id = request_map_dict['map_id'] if not sample_id: return create_json_response(ERROR, REQUIRED_FIELD_SAMPLE_ID) if not analysis_id: return create_json_response(ERROR, REQUIRED_FIELD_ANALYSIS_ID) if not map_id: return create_json_response(ERROR, REQUIRED_FIELD_MAP_ID) obs_params = {} obs_params['sample_id'] = sample_id obs_params['analysis_id'] = analysis_id obs_params['map_id'] = map_id try: status = observed_map_svc.add_observed_map( obs_params).as_dict() status_list.append(status) except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, status_list)
def get_observed_maps(analysis_id): """ swag_from_file: sbs/swagger/sbs_get_observed_maps.yml """ if not analysis_id: return create_json_response(ERROR, REQUIRED_FIELD_ANALYSIS_ID) try: result = observed_map_svc.get_observed_maps(analysis_id) except Exception as e: logger.error('An error occurred: {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, result)
def delete_sample(sample_id): """ swag_from_file: sbs/swagger/sbs_delete_samples.yml """ if not sample_id: return create_json_response(ERROR, REQUIRED_FIELD_SAMPLE_ID) try: response = sample_svc.delete_sample(sample_id) except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, response)
def update_sample(sample_id): """ swag_from_file: sbs/swagger/sbs_put_samples.yml """ params = request.get_json(force=True) params['sample_id'] = sample_id try: response = sample_svc.update_sample(params).as_dict() except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, response)
def delete_observed_map(observed_map_id): """ swag_from_file: sbs/swagger/sbs_delete_observed_map.yml """ if not observed_map_id: return create_json_response(ERROR, "Observed Map Id is a required filed") try: observed_map_svc.delete_observed_map(observed_map_id) except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, None)
def add_sample(): """ swag_from_file: sbs/swagger/sbs_post_samples.yml """ params = request.get_json(force=True) if 'request_id' not in params or not params['request_id']: return create_json_response(ERROR, REQUIRED_FIELD_REQUEST_ID) if 'sample_id' not in params or not params['sample_id']: return create_json_response(ERROR, REQUIRED_FIELD_SAMPLE_ID) try: response = sample_svc.add_sample(params).as_dict() except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, response)
def get_observed_map_comment(observed_map_id): """ swag_from_file: sbs/swagger/sbs_get_observed_map_comments.yml """ if not observed_map_id: return create_json_response(ERROR, REQUIRED_FIELD_OBSERVED_MAP_ID) try: result = observed_map_svc.get_observed_map_comment(observed_map_id) except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) result_list = [] for observed_map_comment in result: result_list.append(observed_map_comment.as_dict()) return create_json_response(SUCCESS, result_list)
def add_observed_map_comment(observed_map_id): """ swag_from_file: sbs/swagger/sbs_post_observed_map_comments.yml """ if not observed_map_id: return create_json_response(ERROR, REQUIRED_FIELD_OBSERVED_MAP_ID) params = request.get_json(force=True) params['username'] = get_username() if 'comment' not in params or not params['comment']: return create_json_response(ERROR, REQUIRED_FIELD_COMMENT) try: result = observed_map_svc.add_observed_map_comments( observed_map_id, params) except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, result)
def add_observed_map(sample_id, analysis_id, map_id): """ swag_from_file: sbs/swagger/sbs_post_observed_map.yml """ params = request.get_json(force=True) if not sample_id: return create_json_response(ERROR, REQUIRED_FIELD_SAMPLE_ID) if not analysis_id: return create_json_response(ERROR, REQUIRED_FIELD_ANALYSIS_ID) if not map_id: return create_json_response(ERROR, REQUIRED_FIELD_MAP_ID) params['sample_id'] = sample_id params['analysis_id'] = analysis_id params['map_id'] = map_id try: result = observed_map_svc.add_observed_map(params).as_dict() except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) return create_json_response(SUCCESS, result)
def change_tier(): """ swag_from_file: sbs/swagger/sbs_put_change_tier.yml """ result = "" params = request.get_json(force=True) if 'variation_list' not in params or not params['variation_list']: create_json_response(ERROR, REQUIRED_FIELD_VARIATION_LIST) try: result = variation_svc.batch_update_tier(params['variation_list']) except Exception as e: logger.error('An error occurred : {}'.format(str(e))) return create_json_response(ERROR, e) if result: for variation in result: variation['is_tier_label_updated'] = "true" if \ variation['is_tier_label_updated'] else "false" return create_json_response(SUCCESS, result)