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


Python PyOpenWorm.disconnect方法代码示例

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


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

示例1: __init__

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例2: read

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

示例3: do_insert

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例4: test_adapt_reference

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例5: __init__

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例6: test_adapt_GraphData

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例7: setUpClass

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例8: map_properties

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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: read

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [as 别名]
    def read(self):
        conns = []
        cells = []
        for s in self.all_connections:
            pre = str(s.pre_cell())
            post = str(s.post_cell())
            syntype = str(s.syntype())
            num = int(s.number())
            synclass = str(s.synclass())

            conns.append(ConnectionInfo(pre, post, num, syntype, synclass))

            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:brijeshmodi12,项目名称:CElegansNeuroML,代码行数:23,代码来源:OpenWormReader.py

示例10: do_insert

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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: test_adapt_PatchClamp

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例12: do_insert

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [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

示例13: tearDown

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [as 别名]
 def tearDown(self):
     PyOpenWorm.disconnect(self.connection)
     self.delete_dir()
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:5,代码来源:DataTestTemplate.py

示例14: Context

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [as 别名]
ctx = Context(ident='http://example.org/data', conf=conn.conf)
evctx = Context(ident='http://example.org/meta', conf=conn.conf)

# 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
# receptor UNC-8 on neuron AVAL.
n.receptor('UNC-8')

e.supports(ctx.rdf_object)

# Save the Neuron and Evidence objects to the database.
ctx.save_context()
evctx.save_context()

# What does my evidence object contain?
for e_i in evctx.stored(Evidence)().load():
    print(e_i.reference(), e_i.supports())

# Disconnect from the database.
P.disconnect(conn)
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:31,代码来源:add_reference.py

示例15: tearDown

# 需要导入模块: import PyOpenWorm [as 别名]
# 或者: from PyOpenWorm import disconnect [as 别名]
 def tearDown(self):
     PyOpenWorm.disconnect()
开发者ID:gsarma,项目名称:PyOpenWorm,代码行数:4,代码来源:EvidenceQualityTest.py


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