PREFIX submissionOntology: <http://jumpgate.caltech.edu/wiki/UcscSubmissionOntology#>
PREFIX ucscDaf: <http://jumpgate.caltech.edu/wiki/UcscDaf#>
-select ?submitView ?files ?md5sum ?view ?cell ?antibody ?sex ?control ?controlId ?labExpId ?labVersion ?treatment ?protocol ?readType ?insertLength ?replicate
+select ?submitView ?files ?md5sum ?view ?cell ?antibody ?sex ?control ?strain ?controlId ?labExpId ?labVersion ?treatment ?protocol ?readType ?insertLength ?replicate ?mapAlgorithm
WHERE {
?file ucscDaf:filename ?files ;
ucscDaf:md5sum ?md5sum .
OPTIONAL { ?library libraryOntology:condition ?treatment }
OPTIONAL { ?library ucscDaf:protocol ?protocol }
OPTIONAL { ?library ucscDaf:readType ?readType }
+ OPTIONAL { ?library ucscDaf:strain ?strain }
OPTIONAL { ?library libraryOntology:insert_size ?insertLength }
+ OPTIONAL { ?library ucscDaf:mapAlgorithm ?mapAlgorithm }
}
ORDER BY ?submitView"""
dag_fragments = []
outfile = os.path.join(outdir, ddf_name)
output = open(outfile,'w')
else:
+ outfile = 'stdout:'
output = sys.stdout
formatted_query = query_template % {'submission': str(submissionNode.uri)}
query = RDF.SPARQLQuery(formatted_query)
results = query.execute(view_map.model)
- variables = ['files']
# filename goes first
- variables.extend(view_map.get_daf_variables())
+ variables = view_map.get_daf_variables()
# 'controlId',
- variables += [ 'labExpId', 'md5sum']
output.write('\t'.join(variables))
output.write(os.linesep)
current = all_views.setdefault(viewname, {})
for variable_name in variables:
value = str(fromTypedNode(row[variable_name]))
+ if value is None or value == 'None':
+ logging.warn("{0}: {1} was None".format(outfile, variable_name))
if variable_name in ('files', 'md5sum'):
current.setdefault(variable_name,[]).append(value)
else:
DAF_VARIABLE_NAMES = ("variables", "extraVariables")
VARIABLES_TERM_NAME = 'variables'
+DAF_PRE_VARIABLES = ['files', 'view']
+DAF_POST_VARIABLES = [ 'labExpId', 'md5sum']
+
class ModelException(RuntimeError):
"""Assumptions about the RDF model failed"""
dafTermOntology['submission'],
submissionNode))
- # extra information
- terms = [dafTermOntology['type'],
- dafTermOntology['filename_re'],
- ]
- terms.extend((dafTermOntology[v] for v in self.get_daf_variables()))
-
# add file specific information
self.create_file_attributes(filename, submissionView, submission_uri, submission_dir)
"""Returns simple variables names that to include in the ddf
"""
variables_term = dafTermOntology[VARIABLES_TERM_NAME]
- results = ['view']
- if self.need_replicate():
+ results = []
+ results.extend([v for v in DAF_PRE_VARIABLES if v not in results])
+ results = DAF_PRE_VARIABLES[:]
+ if self.need_replicate() and 'replicate' not in results:
results.append('replicate')
for obj in self.model.get_targets(self.submissionSet, variables_term):
value = str(fromTypedNode(obj))
- results.append(value)
- results.append('labVersion')
+ if value not in results:
+ results.append(value)
+ results.extend([v for v in DAF_POST_VARIABLES if v not in results])
return results
def make_submission_name(self, submission_dir):
def test_daf_with_extra(self):
daf_mapper = load_daf_mapper('test_rep',test_daf=test_daf_extra)
variables = daf_mapper.get_daf_variables()
- self.assertEqual(len(variables), 9)
+ self.assertEqual(len(variables), 11)
self.failUnless('treatment' in variables)
self.failUnless('controlId' in variables)