Skip to content

Commit 8b0f973

Browse files
committed
Merge branch 'dev' into master
2 parents 426c57f + 84a6c3b commit 8b0f973

7 files changed

+46
-51
lines changed

owmeta-data-bundle.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
id: openworm/owmeta-data
33
name: owmeta data bundle
4-
version: 4
4+
version: 6
55
description: Bundle for OpenWorm data
66
patterns:
77
- http://data.openworm.org/sci/data_sources/DataWithEvidenceDataSource#bently_expression/context_for?*
88
- http://data.openworm.org/sci/data_sources/DataWithEvidenceDataSource#neurons/context_for?*
99
- http://data.openworm.org/sci/data_sources/DataWithEvidenceDataSource#cells/context_for?*
10-
includes:
10+
includes:
1111
- http://openworm.org/data
1212
- http://openworm.org/data-data:
1313
empty: true
@@ -63,7 +63,7 @@ includes:
6363

6464
dependencies:
6565
- id: openworm/owmeta-schema
66-
version: 2
66+
version: 3
6767
#excludes:
6868
#- http://www.w3.org/1999/02/22-rdf-syntax-ns
6969
#merges:

owmeta-schema-bundle.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
id: openworm/owmeta-schema
33
name: owmeta schema bundle
4-
version: 2
4+
version: 3
55
description: Bundle for OpenWorm schema for scientific data
6-
includes:
6+
includes:
77
- http://schema.openworm.org/2020/07/sci
88
- http://schema.openworm.org/2020/07/sci/bio
99
dependencies:

owmeta/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"""
1414

1515
from __future__ import print_function
16-
__version__ = '0.12.0'
16+
__version__ = '0.12.1'
1717
__author__ = 'OpenWorm.org authors and contributors'
1818

1919
import logging

owmeta/data_trans/connections.py

+18-29
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ..document import Document
1616
from ..evidence import Evidence
1717
from ..neuron import Neuron
18-
from ..muscle import Muscle
18+
from ..muscle import Muscle, BodyWallMuscle
1919
from ..worm import Worm
2020
from ..network import Network
2121

@@ -110,7 +110,7 @@ def translate(self, data_source, neurons_source, muscles_source):
110110
res.evidence_context(Evidence)(key="emmons2015",
111111
reference=doc,
112112
supports=docctx.rdf_object)
113-
with docctx(Neuron, Muscle, Cell, Connection) as ctx:
113+
with docctx(Neuron, Muscle, BodyWallMuscle, Cell, Connection) as ctx:
114114
res.data_context.add_import(ctx.context)
115115
with open(data_source.full_path()) as csvfile:
116116
edge_reader = csv.reader(csvfile)
@@ -125,25 +125,22 @@ def translate(self, data_source, neurons_source, muscles_source):
125125
elif syn_type == 'chemical':
126126
syn_type = 'send'
127127

128+
source_is_bwm = 'BWM' in source.upper()
129+
target_is_bwm = 'BWM' in target.upper()
130+
128131
source = normalize_cell_name(source).upper()
129132
target = normalize_cell_name(target).upper()
130133

131134
weight = int(weight)
132135

133-
# remove BMW from Body Wall Muscle cells
134-
if 'BWM' in source:
135-
source = normalize_muscle(source)
136-
if 'BWM' in target:
137-
target = normalize_muscle(target)
138-
139136
# change certain muscle names to names in wormbase
140137
if source in changed_muscles:
141138
source = changed_muscle(source)
142139
if target in changed_muscles:
143140
target = changed_muscle(target)
144141

145-
sources = convert_to_cell(ctx, source, muscles, neurons)
146-
targets = convert_to_cell(ctx, target, muscles, neurons)
142+
sources = convert_to_cell(ctx, source, muscles, neurons, source_is_bwm)
143+
targets = convert_to_cell(ctx, target, muscles, neurons, target_is_bwm)
147144

148145
for s in sources:
149146
for t in targets:
@@ -241,16 +238,21 @@ def translate(self, data_source, neurotransmitter_source):
241238
return res
242239

243240

244-
def convert_to_cell(ctx, name, muscles, neurons):
241+
def convert_to_cell(ctx, name, muscles, neurons, is_bwm):
245242
ret = []
246243
res = None
247244
res2 = None
248245
if name in neurons:
249246
res = ctx.Neuron(name)
250-
elif name in muscles:
251-
res = ctx.Muscle(name)
252247
elif name in TO_EXPAND_MUSCLES:
248+
# All of the muscle cell types we need to expand are pharyngeal, so no need to
249+
# pass through is_bwm
253250
res, res2 = expand_muscle(ctx, name)
251+
elif name in muscles:
252+
if is_bwm:
253+
res = ctx.BodyWallMuscle(name)
254+
else:
255+
res = ctx.Muscle(name)
254256
elif name in OTHER_CELLS:
255257
res = ctx.Cell(name)
256258

@@ -266,28 +268,15 @@ def add_synapse(ctx, source, target, weight, syn_type):
266268
c = ctx.Connection(pre_cell=source, post_cell=target,
267269
number=weight, syntype=syn_type)
268270

269-
if isinstance(source, ctx.Neuron) and isinstance(target, ctx.Neuron):
271+
if isinstance(source, Neuron) and isinstance(target, Neuron):
270272
c.termination('neuron')
271-
elif isinstance(source, ctx.Neuron) and isinstance(target, ctx.Muscle) or \
272-
isinstance(source, ctx.Muscle) and isinstance(target, ctx.Neuron):
273+
elif isinstance(source, Neuron) and isinstance(target, Muscle) or \
274+
isinstance(source, Muscle) and isinstance(target, Neuron):
273275
c.termination('muscle')
274276

275277
return c
276278

277279

278-
# to normalize certian body wall muscle cell names
279-
SEARCH_STRING_MUSCLE = re.compile(r'\w+[BWM]+\w+')
280-
REPLACE_STRING_MUSCLE = re.compile(r'[BWM]+')
281-
282-
283-
def normalize_muscle(name):
284-
# normalize names of Body Wall Muscles
285-
# if there is 'BWM' in the name, remove it
286-
if re.match(SEARCH_STRING_MUSCLE, name):
287-
name = REPLACE_STRING_MUSCLE.sub('', name)
288-
return name
289-
290-
291280
MUSCLES = {
292281
'ANAL': 'MU_ANAL',
293282
'INTR': 'MU_INT_R',

owmeta/data_trans/wormbase.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ..utils import normalize_cell_name
1111
from ..channel import Channel, ExpressionPattern
1212
from ..evidence import Evidence
13-
from ..muscle import Muscle
13+
from ..muscle import Muscle, BodyWallMuscle
1414
from ..network import Network
1515
from ..neuron import Neuron
1616
from ..cell import Cell
@@ -177,19 +177,25 @@ def translate(self, data_source):
177177
doc_ctx = res.data_context_for(document=doc)
178178
ctx.Evidence(reference=doc, supports=doc_ctx.rdf_object)
179179

180-
with doc_ctx(Worm=Worm, Muscle=Muscle, Network=Network, Neuron=Neuron, Cell=Cell) as ctx:
180+
with doc_ctx(Worm=Worm,
181+
BodyWallMuscle=BodyWallMuscle,
182+
Muscle=Muscle,
183+
Network=Network,
184+
Neuron=Neuron,
185+
Cell=Cell) as ctx:
181186
w = ctx.Worm()
182187
n = ctx.Network()
183188
n.worm(w)
184189

185190
for line in csvreader:
186191
cell = None
187-
if (line['Body wall muscles'] or
188-
line['Pharynx muscles'] or
189-
line['Other muscles']): # muscle's marked in these columns
192+
if line['Body wall muscles']:
193+
cell = ctx.BodyWallMuscle()
194+
w.muscle(cell)
195+
elif line['Pharynx muscles'] or line['Other muscles']:
190196
cell = ctx.Muscle()
191197
w.muscle(cell)
192-
elif line['Neurons (no male-specific cells)']: # neurons marked in this column
198+
elif line['Neurons (no male-specific cells)']:
193199
cell = ctx.Neuron()
194200
cell.wormbaseID(line['WormBase ID'])
195201
n.neuron(cell)

owmeta/muscle.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66

77
class Muscle(Cell):
8-
9-
"""A single muscle cell.
8+
"""
9+
A single muscle cell.
1010
1111
See what neurons innervate a muscle:
1212
@@ -31,3 +31,11 @@ class Muscle(Cell):
3131

3232
receptor = Alias(receptors)
3333
''' Alias to `receptors` '''
34+
35+
36+
class BodyWallMuscle(Muscle):
37+
'''
38+
A somatic muscle cell that lies close under the skin and basal lamina of C. elegans
39+
and allows the worm to move
40+
'''
41+
class_context = Cell.class_context

save_data.py

-8
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ def __init__(self):
4848
self.owm = OWM()
4949
self.ctx = self.owm.default_context.stored
5050

51-
def muscles(self):
52-
muscles = self.owm.translate(MuscleWormBaseCSVTranslator(),
53-
data_sources=[WormBaseCSVDataSource(key='wormbase_celegans_cells')],
54-
output_key='muscles')
55-
self.ctx(muscles).description(
56-
"Contains descriptions of C. elegans muscles and is the"
57-
" principle such list for OpenWorm")
58-
5951
def neurons(self):
6052
neurons = self.owm.translate(NeuronCSVDataTranslator(),
6153
data_sources=[NeuronCSVDataSource(key='neurons')],

0 commit comments

Comments
 (0)