当前位置: 首页>>代码示例>>Python>>正文


Python PyOpenWorm类代码示例

本文整理汇总了Python中PyOpenWorm的典型用法代码示例。如果您正苦于以下问题:Python PyOpenWorm类的具体用法?Python PyOpenWorm怎么用?Python PyOpenWorm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PyOpenWorm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_adapt_reference

def test_adapt_reference(data_pool):
    """Test that we can map a Reference object to a PyOpenWorm
    Experiment object."""
    r = data_pool.get_reference()

    reference_adapter = Adapter.create(r)

    experiment = reference_adapter.get_pow()
    reference = reference_adapter.get_cw()

    PyOpenWorm.connect()

    pyow_dict = {
        'authors': experiment.author(),
        'doi': experiment.doi(),
        'pmid': experiment.pmid(),
        'title': experiment.title(),
        'url': experiment.uri(),
        'year': experiment.year(),
    }

    cw_dict = {
        'authors': set([reference.authors]),
        'doi': reference.doi,
        'pmid': reference.PMID,
        'title': reference.title,
        'url': set([reference.url]),
        'year': reference.year
    }

    PyOpenWorm.disconnect()

    assert pyow_dict == cw_dict
开发者ID:cheelee,项目名称:ChannelWorm,代码行数:33,代码来源:adapter_test.py

示例2: __init__

    def __init__(self, cw_obj):
        # initialize PyOpenWorm connection so we can access its API
        P.connect()

        self.channelworm_object = cw_obj
        cw_dict = model_to_dict(self.channelworm_object)

        experiment_id = cw_dict.pop('experiment')
        patch_clamp_id = cw_dict.pop('id')

        self.pyopenworm_object = P.Experiment()
        
        # get the CW model's experiment
        cw_evidence = C.Experiment.objects.get(id=experiment_id)

        # make a PyOW evidence object with it
        pow_evidence = P.Evidence(doi=cw_evidence.doi)

        # add it to the PyOW experiment model
        self.pyopenworm_object.reference(pow_evidence)

        for key, value in cw_dict.iteritems():
            self.pyopenworm_object.conditions.set(key, value)

        # we not longer need PyOW API so we can kill the connection
        P.disconnect()
开发者ID:joebowen,项目名称:model_completion_dashboard,代码行数:26,代码来源:adapters.py

示例3: __init__

    def __init__(self, cw_obj):
        self.channelworm_object = cw_obj
        self.map_properties()

        P.connect()
        # mapping evidence to Assertions
        pmids = cw_obj.expression_evidences.split(', ')
        for pmid in pmids:
            e = P.Evidence()
            e.pmid(pmid)
            e.asserts(self.pyopenworm_object.expression_pattern)
            e.save()

        pmids = cw_obj.description_evidences.split(', ')
        for pmid in pmids:
            e = P.Evidence()
            e.pmid(pmid)
            e.asserts(self.pyopenworm_object.description)
            e.save()

        # proteins in CW are ;-delimited, but should be 
        #multiple values in PyOpenWorm
        pros = cw_obj.proteins.split('; ')
        for p in pros:
            self.pyopenworm_object.proteins(p)
开发者ID:cheelee,项目名称:ChannelWorm,代码行数:25,代码来源:adapters.py

示例4: setUp

 def setUp(self):
     # Set do_logging to True if you like walls of text
     self.TestConfig = Configure.open(TEST_CONFIG)
     td = '__tempdir__'
     z = self.TestConfig['rdf.store_conf']
     if z.startswith(td):
         x = z[len(td):]
         h=tempfile.mkdtemp()
         self.TestConfig['rdf.store_conf'] = h + x
     self.delete_dir()
     PyOpenWorm.connect(conf=self.TestConfig, do_logging=False)
开发者ID:nheffelman,项目名称:pyopdata,代码行数:11,代码来源:test.py

示例5: test_adapt_GraphData

def test_adapt_GraphData(data_pool):
    """
    Test that we can map some GraphData to a PyOpenWorm 
    data object.
    """
    graph_data = data_pool.get_graph_data()
    gda = Adapter.create(graph_data)

    cw_obj = gda.get_cw()
    pow_obj = gda.get_pow()

    PyOpenWorm.connect()

    assert cw_obj.asarray() == pow_obj.data

    PyOpenWorm.disconnect()
开发者ID:cheelee,项目名称:ChannelWorm,代码行数:16,代码来源:adapter_test.py

示例6: map_properties

    def map_properties(self):
        """
        Map between the properties defined in the subclass.
        """

        # initialize PyOpenWorm connection so we can access its API
        P.connect()

        # initialize pyopenworm object
        self.pyopenworm_object = self.pyopenworm_class()

        for p, c in self.pyow_to_cw.items():
            cw_value = getattr(self.channelworm_object, c)
            pow_property = getattr(self.pyopenworm_object, p)
            map(pow_property, [cw_value])

        P.disconnect()
开发者ID:cheelee,项目名称:ChannelWorm,代码行数:17,代码来源:adapters.py

示例7: test_adapt_PatchClamp

def test_adapt_PatchClamp(data_pool):
    """
    Test that we can map a PatchClamp object to a PyOpenWorm
    PatchClamp object.
    """
    pc = data_pool.get_patch_clamp()

    pca = Adapter.create(pc)

    cw_obj = pca.get_cw()
    pow_obj = pca.get_pow()

    PyOpenWorm.connect()

    pow_dict = {
        'delta_t': pow_obj.delta_t(),
        'duration': pow_obj.duration(),
        'end_time': pow_obj.end_time(),
        'ion_channel': pow_obj.ion_channel(),
        'protocol_end': pow_obj.protocol_end(),
        'protocol_start': pow_obj.protocol_start(),
        'protocol_step': pow_obj.protocol_step(),
        'start_time': pow_obj.start_time(),
    }

    cw_dict = {
        'delta_t': cw_obj.deltat,
        'duration': cw_obj.duration,
        'end_time': cw_obj.end_time,
        'ion_channel': cw_obj.ion_channel,
        'protocol_end': cw_obj.protocol_end,
        'protocol_start': cw_obj.protocol_start,
        'protocol_step': cw_obj.protocol_step,
        'start_time': cw_obj.start_time,
    }

    PyOpenWorm.disconnect()

    assert cw_dict == pow_dict
开发者ID:cheelee,项目名称:ChannelWorm,代码行数:39,代码来源:adapter_test.py

示例8: setUp

 def setUp(self):
     # Set do_logging to True if you like walls of text
     self.TestConfig = Data.open(TEST_CONFIG)
     td = '__tempdir__'
     z = self.TestConfig['rdf.store_conf']
     if z.startswith(td):
         x = z[len(td):]
         h = tempfile.mkdtemp()
         self.TestConfig['rdf.store_conf'] = h + x
     self.delete_dir()
     self.connection = PyOpenWorm.connect(conf=self.TestConfig, do_logging=False)
     self.context = Context(ident='http://example.org/test-context',
                            conf=self.TestConfig)
     typ = type(self)
     if hasattr(typ, 'ctx_classes'):
         if isinstance(dict, typ.ctx_classes):
             self.ctx = self.context(typ.ctx_classes)
         else:
             self.ctx = self.context({x.__name__: x for x in typ.ctx_classes})
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:19,代码来源:DataTestTemplate.py

示例9: setUpClass

    def setUpClass(cls):
        import csv
        PyOpenWorm.connect(
            conf=Configure(
                **{'rdf.store_conf': 'tests/test.db', 'rdf.source': 'ZODB'}))
        PyOpenWorm.loadData(skipIfNewer=False)
        PyOpenWorm.disconnect()
        # grab the list of the names of the 302 neurons

        csvfile = open('OpenWormData/aux_data/neurons.csv', 'r')
        reader = csv.reader(csvfile, delimiter=';', quotechar='|')

        # array that holds the names of the 302 neurons at class-level scope
        cls.neurons = []
        for row in reader:
            if len(row[0]) > 0:  # Only saves valid neuron names
                cls.neurons.append(row[0])
开发者ID:clbarnes,项目名称:PyOpenWorm,代码行数:17,代码来源:DataIntegrityTest.py

示例10: setUpClass

    def setUpClass(cls):
        import csv

        cls.neurons = [] #array that holds the names of the 302 neurons at class-level scope

        if not USE_BINARY_DB:
            PyOpenWorm.connect(conf=Data()) # Connect for integrity tests that use PyOpenWorm functions
            cls.g = PyOpenWorm.config('rdf.graph') # declare class-level scope for the database
            cls.g.parse("OpenWormData/WormData.n3", format="n3") # load in the database
        else:
            conf = Configure(**{ "rdf.source" : "ZODB", "rdf.store_conf" : BINARY_DB })
            PyOpenWorm.connect(conf=conf)
            cls.g = PyOpenWorm.config('rdf.graph')

        #grab the list of the names of the 302 neurons

        csvfile = open('OpenWormData/aux_data/neurons.csv', 'r')
        reader = csv.reader(csvfile, delimiter=';', quotechar='|')

        for row in reader:
            if len(row[0]) > 0: # Only saves valid neuron names
                cls.neurons.append(row[0])
开发者ID:nheffelman,项目名称:pyopdata,代码行数:22,代码来源:DataIntegrityTest.py

示例11: Data

"""

from __future__ import absolute_import
from __future__ import print_function
import PyOpenWorm as P
from PyOpenWorm.evidence import Evidence
from PyOpenWorm.neuron import Neuron
from PyOpenWorm.document import Document
from PyOpenWorm.data import Data
from PyOpenWorm.context import Context

# Create dummy database configuration.
d = Data({'rdf.source': 'ZODB'})

# Connect to database with dummy configuration
P.connect(conf=d)

ctx = Context(ident='http://example.org/data')
evctx = Context(ident='http://example.org/meta')

# Create a new Neuron object to work with
n = ctx(Neuron)(name='AVAL')

# Create a new Evidence object with `doi` and `pmid` fields populated.
# See `PyOpenWorm/evidence.py` for other available fields.
d = evctx(Document)(key='Anonymous2011', doi='125.41.3/ploscompbiol', pmid='12345678')
e = evctx(Evidence)(key='Anonymous2011', reference=d)

# Evidence object asserts something about the enclosed dataObject.
# Here we add a receptor to the Neuron we made earlier, and "assert it".
# As the discussion (see top) reads, this might be asserting the existence of
开发者ID:gsarma,项目名称:PyOpenWorm,代码行数:31,代码来源:add_reference.py

示例12: do_insert

def do_insert(config="default.conf", logging=False):
    if config:
        if isinstance(config, P.Configure):
            pass
        elif isinstance(config, str):
            config = P.Configure.open(config)
        elif isinstance(config, dict):
            config = P.Configure().copy(config)
        else:
            raise Exception("Invalid configuration object "+ str(config))

    P.connect(conf=config, do_logging=logging)
    try:
        w = P.Worm()
        net = P.Network()
        w.neuron_network(net)
        w.save()

        upload_neurons()
        upload_muscles()
        upload_lineage_and_descriptions()
        upload_synapses()
        upload_receptors_and_innexins()
        upload_types()
        serialize_as_n3()
        #infer()
    except:
        traceback.print_exc()
    finally:
        P.disconnect()
开发者ID:nheffelman,项目名称:pyopdata,代码行数:30,代码来源:insert_worm.py

示例13: serialize_as_n3

def serialize_as_n3():
    dest = "../WormData.n3"
    # XXX: Properties aren't initialized until the first object of a class is created,
    #      so we create them here

    P.config("rdf.graph").serialize(dest, format="n3")
    print("serialized to n3 file")
开发者ID:cheelee,项目名称:PyOpenWorm,代码行数:7,代码来源:insert_worm.py

示例14: read

 def read(self):
     conns = []
     cells = []
     
     cell_names = owr.get_cells_in_model()
 
     for s in self.all_connections:
         pre = str(s.pre_cell().name())
         post = str(s.post_cell().name())
         
         if isinstance(s.post_cell(), P.Neuron) and pre in cell_names and post in cell_names:  
             syntype = str(s.syntype())
             syntype = syntype[0].upper()+syntype[1:]
             num = int(s.number())
             synclass = str(s.synclass())
             ci = ConnectionInfo(pre, post, num, syntype, synclass)
             conns.append(ci)
             if pre not in cells:
                 cells.append(pre)
             if post not in cells:
                 cells.append(post)
                 
     logger.info("Total cells read " + str(len(cells)))
     logger.info("Total connections read " + str(len(conns)))
     P.disconnect()
     return cells, conns
开发者ID:openworm,项目名称:CElegansNeuroML,代码行数:26,代码来源:OpenWormReader.py

示例15: __init__

 def __init__(self):
     logger.info("Initialising OpenWormReader")
     P.connect()
     self.net = P.Worm().get_neuron_network()
     self.all_connections = self.net.synapses()
     self.neuron_connections = set(filter(lambda x: x.termination() == u'neuron', self.all_connections))
     self.muscle_connections = set(filter(lambda x: x.termination() == u'muscle', self.all_connections))
     logger.info("Finished initialising OpenWormReader")
开发者ID:Jueast,项目名称:CElegansNeuroML,代码行数:8,代码来源:OpenWormReader.py


注:本文中的PyOpenWorm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。