本文整理匯總了Python中timeline.Timeline.get_event方法的典型用法代碼示例。如果您正苦於以下問題:Python Timeline.get_event方法的具體用法?Python Timeline.get_event怎麽用?Python Timeline.get_event使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類timeline.Timeline
的用法示例。
在下文中一共展示了Timeline.get_event方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ExperimentSettings
# 需要導入模塊: from timeline import Timeline [as 別名]
# 或者: from timeline.Timeline import get_event [as 別名]
class ExperimentSettings(Singleton):
global_settings = {}
timeline = Timeline('TEST_STOCK')
subscribers = {}
def __init__(self):
pass
def set_field(self, tag, value, notify_subscribers=True):
self.global_settings[tag] = value
if re.match(get_matchstring_for_subtag(2, 'Well'), tag):
self.update_timeline(tag)
if notify_subscribers:
self.notify_subscribers(tag)
print 'SET FIELD: %s = %s'%(tag, value)
def get_field(self, tag, default=None):
return self.global_settings.get(tag, default)
def remove_field(self, tag, notify_subscribers=True):
'''completely removes the specified tag from the metadata (if it exists)
'''
#if self.get_field(tag) is not None:
self.global_settings.pop(tag)
if re.match(get_matchstring_for_subtag(2, 'Well'), tag):
self.update_timeline(tag)
if notify_subscribers:
self.notify_subscribers(tag)
print 'DEL FIELD: %s'%(tag)
def get_action_tags(self):
'''returns all existing TEMPORAL tags as list'''
return [tag for tag in self.global_settings
if tag.split('|')[0] in ('CellTransfer', 'Perturbation',
'Staining', 'AddProcess', 'DataAcquis', 'Notes')]
def get_field_instances(self, tag_prefix):
'''returns a list of unique instance ids for each tag beginning with
tag_prefix'''
ids = set([get_tag_instance(tag) for tag in self.global_settings
if tag.startswith(tag_prefix)])
return list(ids)
def get_attribute_list(self, tag_prefix):
'''returns a list of attributes name for each tag beginning with
tag_prefix'''
ids = set([get_tag_attribute(tag) for tag in self.global_settings
if tag.startswith(tag_prefix)])
return list(ids)
def get_attribute_list_by_instance(self, tag_prefix, instance=None):
'''returns a list of all attributes beginning with tag_prefix. If instance
is passed in, only attributes of the given instance will be returned'''
ids = set([get_tag_attribute(tag) for tag in self.global_settings
if ((tag_prefix is None or tag.startswith(tag_prefix)) and
(instance is None or get_tag_instance(tag) == instance))])
return list(ids)
#tags = []
#for tag in self.global_settings:
#if ((tag_prefix is None or tag.startswith(tag_prefix)) and
#(instance is None or get_tag_instance(tag) == instance)):
#tag += [tag]
#ids= set([get_tag_attribute(tag)])
#return list(ids)
def get_attribute_dict(self, protocol):
'''returns a dict mapping attribute names to their values for a given
protocol.
eg: get_attribute_dict('CellTransfer|Seed|1') -->
{'SeedingDensity': 12, 'MediumUsed': 'agar',
'MediumAddatives': 'None', 'Trypsinization': True}
'''
d = {}
for tag in self.get_matching_tags('|*|'.join(protocol.rsplit('|',1))):
if (get_tag_attribute(tag) not in ('Wells', 'EventTimepoint', 'Images', 'OriginWells')):
d[get_tag_attribute(tag)] = self.global_settings[tag]
return d
def get_eventtype_list(self, tag_prefix):
'''returns a list of attributes name for each tag beginning with
tag_prefix'''
ids = set([tag.split('|')[1] for tag in self.global_settings
if tag.startswith(tag_prefix)])
return list(ids)
def get_eventclass_list(self, tag_prefix):
'''returns a list of event class name for each tag beginning with
tag_prefix'''
ids = set([tag.split('|')[0] for tag in self.global_settings
if tag.startswith(tag_prefix)])
return list(ids)
def get_field_tags(self, tag_prefix=None, instance=None):
'''returns a list of all tags beginning with tag_prefix. If instance
is passed in, only tags of the given instance will be returned'''
tags = []
#.........這裏部分代碼省略.........
示例2: ExperimentSettings
# 需要導入模塊: from timeline import Timeline [as 別名]
# 或者: from timeline.Timeline import get_event [as 別名]
#.........這裏部分代碼省略.........
if tag.startswith(tag_prefix)])
return list(ids)
def get_attribute_list_by_instance(self, tag_prefix, instance=None):
'''returns a list of all attributes beginning with tag_prefix. If instance
is passed in, only attributes of the given instance will be returned'''
ids = set([get_tag_attribute(tag) for tag in self.global_settings
if ((tag_prefix is None or tag.startswith(tag_prefix)) and
(instance is None or get_tag_instance(tag) == instance))])
return list(ids)
#tags = []
#for tag in self.global_settings:
#if ((tag_prefix is None or tag.startswith(tag_prefix)) and
#(instance is None or get_tag_instance(tag) == instance)):
#tag += [tag]
#ids= set([get_tag_attribute(tag)])
#return list(ids)
def get_attribute_dict(self, protocol):
'''returns a dict mapping attribute names to their values for a given
protocol.
eg: get_attribute_dict('Transfer|Seed|1') -->
{'SeedingDensity': 12, 'MediumUsed': 'agar',
'MediumAddatives': 'None', 'Trypsinization': True}
'''
d = {}
for tag in self.get_matching_tags('|*|'.join(protocol.rsplit('|',1))):
if (get_tag_attribute(tag) not in ('Wells', 'EventTimepoint', 'Images', 'OriginWells')):
d[get_tag_attribute(tag)] = self.global_settings[tag]
return d
def get_eventtype_list(self, tag_prefix):
'''returns a list of attributes name for each tag beginning with
tag_prefix'''
ids = set([tag.split('|')[1] for tag in self.global_settings
if tag.startswith(tag_prefix)])
return list(ids)
def get_eventclass_list(self, tag_prefix):
'''returns a list of event class name for each tag beginning with
tag_prefix'''
ids = set([tag.split('|')[0] for tag in self.global_settings
if tag.startswith(tag_prefix)])
return list(ids)
def get_field_tags(self, tag_prefix=None, instance=None):
'''returns a list of all tags beginning with tag_prefix. If instance
is passed in, only tags of the given instance will be returned'''
tags = []
for tag in self.global_settings:
if ((tag_prefix is None or tag.startswith(tag_prefix)) and
(instance is None or get_tag_instance(tag) == instance)):
tags += [tag]
return tags
def get_matching_tags(self, matchstring):
'''returns a list of all tags matching matchstring
matchstring -- a string that matches the tags you want
eg: Transfer|*
'''
tags = []
for tag in self.global_settings:
match = True
for m, subtag in map(None, matchstring.split('|'), tag.split('|')):