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


Python PyOpenWorm.connect方法代码示例

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


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

示例1: test_adapt_reference

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
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,代码行数:35,代码来源:adapter_test.py

示例2: __init__

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
    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,代码行数:28,代码来源:adapters.py

示例3: __init__

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
    def __init__(self, cw_obj):
        self.channelworm_object = cw_obj
        self.map_properties()

        P.connect()
        self.pyopenworm_object.set_data(cw_obj.asarray())
        P.disconnect()
开发者ID:cheelee,项目名称:ChannelWorm,代码行数:9,代码来源:adapters.py

示例4: do_insert

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
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,代码行数:32,代码来源:insert_worm.py

示例5: __init__

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
 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,代码行数:10,代码来源:OpenWormReader.py

示例6: setUp

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
 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,代码行数:13,代码来源:test.py

示例7: test_adapt_GraphData

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
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,代码行数:18,代码来源:adapter_test.py

示例8: map_properties

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
    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,代码行数:19,代码来源:adapters.py

示例9: setUpClass

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
    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,代码行数:19,代码来源:DataIntegrityTest.py

示例10: do_insert

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
def do_insert(config="default.conf", logging=False):
    global SQLITE_EVIDENCE
    global WORM
    global NETWORK

    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)
    SQLITE_EVIDENCE = P.Evidence(key="C_elegans_SQLite_DB", title="C. elegans sqlite database")
    try:
        WORM = P.Worm()
        NETWORK = P.Network()
        WORM.neuron_network(NETWORK)
        NETWORK.worm(WORM)

        upload_neurons()
        upload_muscles()
        upload_lineage_and_descriptions()
        upload_connections()
        upload_receptors_types_neurotransmitters_neuropeptides_innexins()

        print("Saving...")
        WORM.save()

        infer()
        print("Serializing...")
        serialize_as_n3()

    except:
        traceback.print_exc()
    finally:
        P.disconnect()
开发者ID:cheelee,项目名称:PyOpenWorm,代码行数:42,代码来源:insert_worm.py

示例11: setUpClass

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
    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,代码行数:24,代码来源:DataIntegrityTest.py

示例12: test_adapt_PatchClamp

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
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,代码行数:41,代码来源:adapter_test.py

示例13: do_insert

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
def do_insert():
    import sys
    logging = False
    if len(sys.argv) > 1 and sys.argv[1] == '-l':
        logging = True
    P.connect(configFile='default.conf', do_logging=logging)
    try:
        upload_muscles()
        print ("uploaded muscles")
        upload_lineage_and_descriptions()
        print ("uploaded lineage and descriptions")
        upload_synapses()
        print ("uploaded synapses")
        upload_receptors_and_innexins()
        print ("uploaded receptors and innexins")
        update_neurons_and_muscles_with_lineage_and_descriptions()
        print ("updated muscles and neurons with cell data")
        infer()
        print ("filled in with inferred data")
    except:
        traceback.print_exc()
    finally:
        P.disconnect()
开发者ID:travs,项目名称:OpenWormData,代码行数:25,代码来源:insert_worm.py

示例14: setUp

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
 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,代码行数:21,代码来源:DataTestTemplate.py

示例15: print

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import connect [as 别名]
Try running this script and see what it prints out. It takes a while to run
because there are so many connections, so feel free to comment out some of the
neuron names in the arbitrary list declared further below.
"""
from __future__ import absolute_import
from __future__ import print_function
import PyOpenWorm as P
from PyOpenWorm.worm import Worm
from PyOpenWorm.neuron import Neuron
from PyOpenWorm.context import Context
from OpenWormData import BIO_ENT_NS


print("Connecting to the database...")
conn = P.connect('default.conf')

ctx = Context(ident=BIO_ENT_NS['worm0'], conf=conn.conf).stored

#Get the worm object.
worm = ctx(Worm)()

#Extract the network object from the worm object.
net = worm.neuron_network()

#Make a list of some arbitrary neuron names.
some_neuron_names = ["ADAL", "AIBL", "I1R", "PVCR", "DD5"]

#Go through our list and get the neuron object associated with each name.
#Store these in another list.
some_neurons = [ctx(Neuron)(name) for name in some_neuron_names]
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:32,代码来源:NetworkInfo.py


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