Commit e44eede4 authored by aknecht2's avatar aknecht2
Browse files

Added function to check if result exists.

parent 25ce6edf
......@@ -38,6 +38,32 @@ class MongoDB(object):
print "result_id %s doesn't exist." % (result_id,)
return
def check_result(self, control_sample_ids, experiment_sample_ids, ref_genome, result_type, params):
try:
query = {
"control_sample_ids": {
"$all": control_sample_ids
},
"experiment_sample_ids": {
"$all": experiment_sample_ids
},
"result_type": result_type,
"ref_genome": ref_genome
}
for job_name in params:
param_keys = params[job_name].keys()
if len(param_keys) == 0:
query[job_name] = {"$exists": True}
else:
for param_name in param_keys:
query[job_name + "." + param_name] = params[job_name][param_name]
cursor = self.db.results.find(query)
if cursor.count() == 1:
return True
except pymongo.errors.OperationFailure as e:
print "Error with experiment_id %s: %s" % (experiment_id, e)
return False
def create_result(self, output_file, control_sample_ids, experiment_sample_ids, result_type, additional_data = {}, gfs_attributes = {}):
# Make sure output_file exists
if os.path.isfile(output_file):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment