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
+select ?submitView ?files ?md5sum ?view ?cell ?antibody ?sex ?control ?controlId ?labExpId ?labVersion ?treatment ?protocol ?readType ?insertLength ?replicate
WHERE {
?file ucscDaf:filename ?files ;
ucscDaf:md5sum ?md5sum .
OPTIONAL { ?library ucscDaf:sex ?sex }
OPTIONAL { ?library libraryOntology:library_id ?labExpId }
OPTIONAL { ?library libraryOntology:library_id ?labVersion }
+ OPTIONAL { ?library libraryOntology:replicate ?replicate }
OPTIONAL { ?library libraryOntology:condition ?treatment }
OPTIONAL { ?library ucscDaf:protocol ?protocol }
OPTIONAL { ?library ucscDaf:readType ?readType }
"""
variableTerm = dafTermOntology['variables']
results = ['view']
+ if self.need_replicate():
+ results.append('replicate')
+
for obj in self.model.get_targets(self.submissionSet, variableTerm):
value = str(fromTypedNode(obj))
results.append(value)
patterns[literal_re] = view_name
return patterns
+ def _get_library_url(self):
+ return str(self.libraryNS[''].uri)
+ def _set_library_url(self, value):
+ self.libraryNS = RDF.NS(str(value))
+ library_url = property(_get_library_url, _set_library_url)
+
def _is_paired(self, libNode):
"""Determine if a library is paired end"""
library_type = self._get_library_attribute(libNode, 'library_type')
"Unrecognized library type %s for %s" % \
(library_type, str(libNode)))
- def _get_library_url(self):
- return str(self.libraryNS[''].uri)
- def _set_library_url(self, value):
- self.libraryNS = RDF.NS(str(value))
- library_url = property(_get_library_url, _set_library_url)
+ def need_replicate(self):
+ viewTerm = dafTermOntology['views']
+ replicateTerm = dafTermOntology['hasReplicates']
+
+ views = self.model.get_targets(self.submissionSet, viewTerm)
+
+ for view in views:
+ replicate = self.model.get_target(view, replicateTerm)
+ if fromTypedNode(replicate):
+ return True
+
+ return False
required no
"""
+test_daf_no_rep = """# Lab and general info
+grant Hardison
+lab Caltech-m
+dataType ChipSeq
+variables cell, antibody,sex,age,strain,control
+compositeSuffix CaltechHistone
+assembly mm9
+dafVersion 2.0
+validationSettings validateFiles.bam:mismatches=2,bamPercent=99.9;validateFiles.fastq:quick=1000
+
+# Track/view definition
+view FastqRd1
+longLabelPrefix Caltech Fastq Read 1
+type fastq
+hasReplicates no
+required no
+"""
+
class TestDAF(unittest.TestCase):
def test_parse(self):
name = model.get_target(signal_view_node, dafTermOntology['name'])
self.failUnlessEqual(fromTypedNode(name), u'Signal')
-def load_daf_mapper(name, extra_statements=None, ns=None):
+def load_daf_mapper(name, extra_statements=None, ns=None, test_daf=test_daf):
"""Load test model in
"""
model = get_model()
str(dafTermOntology['filename_re']))
#self.failUnlessEqual(search[0].object.literal_value['string'], pattern)
+
def test_find_one_view(self):
name='testfind'
extra = '''@prefix dafTerm:<http://jumpgate.caltech.edu/wiki/UcscDaf#> .
daf_mapper.library_url = 'http://google.com'
self.failUnlessEqual(daf_mapper.library_url, 'http://google.com' )
+ def test_daf_with_replicate(self):
+ daf_mapper = load_daf_mapper('test_rep')
+ self.failUnlessEqual(daf_mapper.need_replicate(), True)
+ self.failUnless('replicate' in daf_mapper.get_daf_variables())
+
+ def test_daf_without_replicate(self):
+ daf_mapper = load_daf_mapper('test_rep',test_daf=test_daf_no_rep)
+ self.failUnlessEqual(daf_mapper.need_replicate(), False)
+ self.failUnless('replicate' not in daf_mapper.get_daf_variables())
+
@contextmanager
def mktempdir(prefix='tmp'):
d = tempfile.mkdtemp(prefix=prefix)