<s> from __future__ import print_function <EOL> import PyOpenWorm as P <EOL> from PyOpenWorm import Cell <EOL> class Neuron ( Cell ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name = False , ** kwargs ) : <EOL> super ( Neuron , self ) . __init__ ( name = name , ** kwargs ) <EOL> Neighbor ( owner = self ) <EOL> Connection ( owner = self ) <EOL> Neuron . DatatypeProperty ( "<STR_LIT:type>" , self , multiple = True ) <EOL> Neuron . DatatypeProperty ( "<STR_LIT>" , self , multiple = True ) <EOL> Neuron . DatatypeProperty ( "<STR_LIT>" , self , multiple = True ) <EOL> Neuron . DatatypeProperty ( "<STR_LIT>" , self , multiple = True ) <EOL> Neuron . DatatypeProperty ( "<STR_LIT>" , self , multiple = True ) <EOL> self . get_neighbors = self . neighbor <EOL> self . receptors = self . receptor <EOL> def GJ_degree ( self ) : <EOL> """<STR_LIT>""" <EOL> count = <NUM_LIT:0> <EOL> for c in self . connection ( ) : <EOL> if c . syntype . one ( ) == '<STR_LIT>' : <EOL> count += <NUM_LIT:1> <EOL> return count <EOL> def Syn_degree ( self ) : <EOL> """<STR_LIT>""" <EOL> count = <NUM_LIT:0> <EOL> for c in self . connection . get ( '<STR_LIT>' ) : <EOL> if c . syntype . one ( ) == '<STR_LIT>' : <EOL> count += <NUM_LIT:1> <EOL> return count <EOL> def _type_networkX ( self ) : <EOL> """<STR_LIT>""" <EOL> return self [ '<STR_LIT>' ] . node [ self . name . one ( ) ] [ '<STR_LIT>' ] <EOL> def get_incidents ( self , type = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> for item in self [ '<STR_LIT>' ] . in_edges_iter ( self . name ( ) , data = True ) : <EOL> if '<STR_LIT>' in item [ <NUM_LIT:2> ] [ '<STR_LIT>' ] : <EOL> yield item [ <NUM_LIT:0> ] <EOL> def _as_neuroml ( self ) : <EOL> """<STR_LIT>""" <EOL> class Neighbor ( P . Property ) : <EOL> multiple = True <EOL> def __init__ ( self , ** kwargs ) : <EOL> P . Property . __init__ ( self , '<STR_LIT>' , ** kwargs ) <EOL> self . _conns = [ ] <EOL> def get ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( self . _conns ) > <NUM_LIT:0> : <EOL> for c in self . _conns : <EOL> yield c . post_cell ( ) <EOL> else : <EOL> c = P . Connection ( pre_cell = self . owner , ** kwargs ) <EOL> for r in c . load ( ) : <EOL> yield r . post_cell ( ) <EOL> @ property <EOL> def values ( self ) : <EOL> return [ ] <EOL> def set ( self , other , ** kwargs ) : <EOL> c = P . Connection ( pre_cell = self . owner , post_cell = other , ** kwargs ) <EOL> self . _conns . append ( c ) <EOL> return c <EOL> def triples ( self , ** kwargs ) : <EOL> for c in self . _conns : <EOL> for x in c . triples ( ** kwargs ) : <EOL> yield x <EOL> class Connection ( P . Property ) : <EOL> """<STR_LIT>""" <EOL> multiple = True <EOL> def __init__ ( self , ** kwargs ) : <EOL> P . Property . __init__ ( self , '<STR_LIT>' , ** kwargs ) <EOL> self . _conns = [ ] <EOL> def get ( self , pre_post_or_either = '<STR_LIT>' , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> c = [ ] <EOL> if pre_post_or_either == '<STR_LIT>' : <EOL> c . append ( P . Connection ( pre_cell = self . owner , ** kwargs ) ) <EOL> elif pre_post_or_either == '<STR_LIT>' : <EOL> c . append ( P . Connection ( post_cell = self . owner , ** kwargs ) ) <EOL> elif pre_post_or_either == '<STR_LIT>' : <EOL> c . append ( P . Connection ( pre_cell = self . owner , ** kwargs ) ) <EOL> c . append ( P . Connection ( post_cell = self . owner , ** kwargs ) ) <EOL> for x in c : <EOL> for r in x . load ( ) : <EOL> yield r <EOL> @ property <EOL> def values ( self ) : <EOL> return [ ] <EOL> def count ( self , pre_post_or_either = '<STR_LIT>' , syntype = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> options = dict ( ) <EOL> options [ "<STR_LIT>" ] = """<STR_LIT>""" % self . owner . identifier ( ) <EOL> options [ "<STR_LIT>" ] = """<STR_LIT>""" % self . owner . identifier ( ) <EOL> options [ "<STR_LIT>" ] = "<STR_LIT>" % ( options [ '<STR_LIT>' ] , options [ '<STR_LIT>' ] ) <EOL> if syntype is not None : <EOL> if syntype . lower ( ) == '<STR_LIT>' : <EOL> syntype = '<STR_LIT>' <EOL> syntype_pattern = "<STR_LIT>" % syntype <EOL> else : <EOL> syntype_pattern = '<STR_LIT>' <EOL> q = """<STR_LIT>""" % ( options [ pre_post_or_either ] , syntype_pattern ) <EOL> res = <NUM_LIT:0> <EOL> for x in self . conf [ '<STR_LIT>' ] . query ( q ) : <EOL> res = x [ '<STR_LIT:count>' ] <EOL> return int ( res ) <EOL> def set ( self , conn , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> assert ( isinstance ( conn , P . Connection ) ) <EOL> self . _conns . append ( conn ) <EOL> def triples ( self , ** kwargs ) : <EOL> for c in self . _conns : <EOL> for x in c . triples ( ** kwargs ) : <EOL> yield x </s>
