<commit_before># -*- coding: utf-8 -*-
"""
.. class:: Network

   This module contains the class that defines the neuronal network

"""

import PyOpenWorm

class Network(PyOpenWorm.Configure):

    def __init__(self,conf=False):
        PyOpenWorm.Configure.__init__(self,conf)

    def aneuron_nocheck(self, name):
        """
        Get a neuron by name

        :param name: Name of a c. elegans neuron
        :returns: Corresponding neuron to the name given
        :rtype: PyOpenWorm.Neuron
        """
        return PyOpenWorm.Neuron(name,self)

    def aneuron(self, name):
        """
        Get a neuron by name

        :param name: Name of a c. elegans neuron
        :returns: Corresponding neuron to the name given
        :rtype: PyOpenWorm.Neuron
        """
        n = PyOpenWorm.Neuron(name,self)
        assert(n.check_exists())
        return n

    def neurons(self):
        """
        Get all neurons by name

        :returns: A list of all neuron names
        :rtype: list
        """

        qres = self['semantic_net'].query(
          """SELECT ?subLabel     #we want to get out the labels associated with the objects
           WHERE {
              ?subject <http://openworm.org/entities/1515> <http://openworm.org/entities/1> .# match all subjects that have the 'is a' (1515) property pointing to 'neuron' (1)
              ?subject rdfs:label ?subLabel  #for the subject, look up their plain text label.
            }""")

        neurons = []
        for r in qres.result:
            neurons.append(str(r[0]))

        return neurons

    def as_networkx(self):
        return self['nx']

    #def sensory(self):

    #def inter(self):

    #def neuroml(self):

    #def rdf(self):

    #def networkx(self):

<commit_msg>Adedd a function for printing synapses<commit_after># -*- coding: utf-8 -*-
"""
.. class:: Network

   This module contains the class that defines the neuronal network

"""

import PyOpenWorm

class Network(PyOpenWorm.Configure):

    def __init__(self,conf=False):
        PyOpenWorm.Configure.__init__(self,conf)

    def aneuron_nocheck(self, name):
        """
        Get a neuron by name

        :param name: Name of a c. elegans neuron
        :returns: Corresponding neuron to the name given
        :rtype: PyOpenWorm.Neuron
        """
        return PyOpenWorm.Neuron(name,self)

    def aneuron(self, name):
        """
        Get a neuron by name

        :param name: Name of a c. elegans neuron
        :returns: Corresponding neuron to the name given
        :rtype: PyOpenWorm.Neuron
        """
        n = PyOpenWorm.Neuron(name,self)
        assert(n.check_exists())
        return n

    def neurons(self):
        """
        Get all neurons by name

        :returns: A list of all neuron names
        :rtype: list
        """

        qres = self['semantic_net'].query(
          """SELECT ?subLabel     #we want to get out the labels associated with the objects
           WHERE {
              ?subject <http://openworm.org/entities/1515> <http://openworm.org/entities/1> .# match all subjects that have the 'is a' (1515) property pointing to 'neuron' (1)
              ?subject rdfs:label ?subLabel  #for the subject, look up their plain text label.
            }""")

        neurons = []
        for r in qres.result:
            neurons.append(str(r[0]))

        return neurons

    def synapses(self):
        """
        Get all synapses by

        :returns: A generator of (neuron1,neuron2,(synapse_type,neurotransmitter))
        :rtype: generator
        """
        for n,nbrs in self['nx'].adjacency_iter():
            for nbr,eattr in nbrs.items():
                yield (n,nbr,(eattr['synapse'],eattr['neurotransmitter']))
    def as_networkx(self):
        return self['nx']

    #def sensory(self):

    #def inter(self):

    #def neuroml(self):

    #def rdf(self):

    #def networkx(self):


{'fraction_non_alphanumeric': 0.109375, 'fraction_numerical': 0.00665983606557377, 'mean_word_length': 2.1140350877192984, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3997827', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1143, 'n_words': 352}