Removing overzealous exception handlers
Otherwise unhandled exceptions in translators should be propagated up
so we can deal with them in OWM
Also, fixing some paths for CSV data sources
@@ -51,7 +51,6 @@ class WormbaseIonChannelCSVTranslator(DTMixin, CSVDataTranslator):
def translate(self, data_source):
res = self.make_new_output((data_source,))
- try:
with res.evidence_context(Evidence=Evidence, Website=Website) as ctx:
doc = ctx.Website(key="wormbase", url="http://Wormbase.org", title="WormBase")
doc_ctx = res.data_context_for(document=doc)
@@ -79,8 +78,6 @@ class WormbaseIonChannelCSVTranslator(DTMixin, CSVDataTranslator):
for m in matches if m is not None]
for pat in patterns:
c.expression_pattern(pat)
- except Exception:
- traceback.print_exc()
return res
@@ -97,13 +94,12 @@ class WormbaseTextMatchCSVTranslator(DTMixin, CSVDataTranslator):
ctype = self.context.resolve_class(ctype)
res = self.make_new_output((data_source,))
- try:
with res.evidence_context(Evidence=Evidence, Website=Website) as ctx:
doc = ctx.Website(key="wormbase", url="http://Wormbase.org", title="WormBase")
doc_ctx = res.data_context_for(document=doc)
ctx.Evidence(reference=doc, supports=doc_ctx.rdf_object)
- with open(data_source.csv_file_name.one(), 'r') as f:
+ with open(data_source.full_path(), 'r') as f:
reader = csv.reader(f, delimiter='\t')
header = self.skip_to_header(reader)
with doc_ctx(Channel=Channel, CType=ctype) as ctx:
@@ -115,8 +111,6 @@ class WormbaseTextMatchCSVTranslator(DTMixin, CSVDataTranslator):
for cell in cells:
m = ctx.CType(name=str(cell))
ch.appearsIn(m)
- except Exception:
- traceback.print_exc()
return res
def skip_to_header(self, reader):
@@ -212,13 +206,8 @@ class NeuronWormBaseCSVTranslator(DTMixin, CSVDataTranslator):
n = ctx.Network()
n.worm(w)
- with open(data_source.csv_file_name.one()) as csvfile:
- csvreader = csv.reader(csvfile)
-
+ with self.make_reader(data_source, skipheader=False, skiplines=3) as csvreader:
for num, line in enumerate(csvreader):
- if num < 4: # skip rows with no data
- continue
-
if line[5] == '1': # neurons marked in this column
neuron_name = normalize_cell_name(line[0]).upper()
n.neuron(ctx.Neuron(name=neuron_name))
