sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:features; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_strand; 8, False; 9, block; 9, 10; 9, 17; 9, 27; 9, 70; 9, 80; 9, 98; 9, 104; 9, 112; 9, 120; 9, 213; 9, ... | def merge(self, features, ignore_strand=False):
features = list(features)
if len(features) == 0:
raise StopIteration
if ignore_strand:
strand = '.'
else:
strands = [i.strand for i in features]
if len(set(strands)) > 1:
raise... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:bed12; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 10; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, identifier:feature; 6, default_parameter; 6, 7; 6, 8; 7, identifier:block_featuretype; 8, list:['exon']; 8, 9; 9, string:'exon'; 10, default_parameter; ... | def bed12(self, feature, block_featuretype=['exon'],
thick_featuretype=['CDS'], thin_featuretype=None,
name_field='ID', color=None):
if thick_featuretype and thin_featuretype:
raise ValueError("Can only specify one of `thick_featuertype` or "
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:inspect; 3, parameters; 3, 4; 3, 5; 3, 12; 3, 15; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:look_for; 7, list:['featuretype', 'chrom', 'attribute_keys',
'feature_count']; 7, 8; 7, 9; 7, 10;... | def inspect(data, look_for=['featuretype', 'chrom', 'attribute_keys',
'feature_count'], limit=None, verbose=True):
results = {}
obj_attrs = []
for i in look_for:
if i not in ['attribute_keys', 'feature_count']:
obj_attrs.append(i)
results[i] = Counter(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:feature_from_line; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:line; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dialect; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:strict; 10, True; 11, default_parameter; 11, 12; ... | def feature_from_line(line, dialect=None, strict=True, keep_order=False):
if not strict:
lines = line.splitlines(False)
_lines = []
for i in lines:
i = i.strip()
if len(i) > 0:
_lines.append(i)
assert len(_lines) == 1, _lines
line = _li... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_reconstruct; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:keyvals; 5, identifier:dialect; 6, default_parameter; 6, 7; 6, 8; 7, identifier:keep_order; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort_attribute_values; ... | def _reconstruct(keyvals, dialect, keep_order=False,
sort_attribute_values=False):
if not dialect:
raise AttributeStringError()
if not keyvals:
return ""
parts = []
if constants.ignore_url_escape_characters or dialect['fmt'] != 'gff3':
attributes = keyvals
el... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 78; 2, function_name:create_db; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 3, 42; 3, 45; 3, 50; 3, 53; 3, 58; 3, 61; 3, 64; 3, 67; 3, 70; 3, 73; 3, 76; 4, identifier:data; 5, identifier:dbfn; 6, def... | def create_db(data, dbfn, id_spec=None, force=False, verbose=False,
checklines=10, merge_strategy='error', transform=None,
gtf_transcript_key='transcript_id', gtf_gene_key='gene_id',
gtf_subfeature='exon', force_gff=False,
force_dialect_check=False, from_string=Fa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_id_handler; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:f; 6, block; 6, 7; 6, 96; 6, 194; 7, if_statement; 7, 8; 7, 17; 7, 25; 7, 41; 7, 88; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 14; 11... | def _id_handler(self, f):
if isinstance(self.id_spec, six.string_types):
id_key = [self.id_spec]
elif hasattr(self.id_spec, '__call__'):
id_key = [self.id_spec]
elif isinstance(self.id_spec, dict):
try:
id_key = self.id_spec[f.featuretype]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:browser; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:tags; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:proxy; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:other_caps; 12, Non... | def browser(tags=None, proxy=None, other_caps=None):
browser_name = os.environ.get('SELENIUM_BROWSER', 'firefox')
def browser_check_func():
try:
if _use_remote_browser(SAUCE_ENV_VARS):
browser_class, browser_args, browser_kwargs = _remote_browser_class(
SA... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_local_browser_class; 3, parameters; 3, 4; 4, identifier:browser_name; 5, block; 5, 6; 5, 14; 5, 23; 5, 41; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:LOGGER; 10, identifier:info; 11, argument_... | def _local_browser_class(browser_name):
LOGGER.info(u"Using local browser: %s [Default is firefox]", browser_name)
browser_class = BROWSERS.get(browser_name)
headless = os.environ.get('BOKCHOY_HEADLESS', 'false').lower() == 'true'
if browser_class is None:
raise BrowserConfigError(
u... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:filter; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filter_fn; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:desc; 10, None; 11, dictionary_splat_pattern; 11, 12; 12, ... | def filter(self, filter_fn=None, desc=None, **kwargs):
if filter_fn is not None and kwargs:
raise TypeError('Must supply either a filter_fn or attribute filter parameters to filter(), but not both.')
if filter_fn is None and not kwargs:
raise TypeError('Must supply one of filter_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:order_by_on_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:objects; 5, identifier:order_field; 6, default_parameter; 6, 7; 6, 8; 7, identifier:is_desc; 8, False; 9, block; 9, 10; 9, 29; 9, 51; 10, if_statement; 10, 11; 10, 15; 11, call; 1... | def order_by_on_list(objects, order_field, is_desc=False):
if callable(order_field):
objects.sort(key=order_field, reverse=is_desc)
return
def order_key(x):
v = getattr_path(x, order_field)
if v is None:
return MIN
return v
objects.sort(key=order_key, reve... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 41; 2, function_name:render_table; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 4, identifier:request; 5, identifier:table; 6, default_parameter; 6, 7; 6, 8; 7, identifier:links; 8, None; 9, default_parameter; 9, 1... | def render_table(request,
table,
links=None,
context=None,
template='tri_table/list.html',
blank_on_empty=False,
paginate_by=40,
page=None,
paginator=None,
show_hits=F... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:create_network; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, identifier:self; 5, identifier:net_view_name; 6, identifier:cidr; 7, default_parameter; 7, 8; 7, 9; 8, identifier:nameservers; 9, None; 10, default_parameter... | def create_network(self, net_view_name, cidr, nameservers=None,
members=None, gateway_ip=None, dhcp_trel_ip=None,
network_extattrs=None):
ipv4 = ib_utils.determine_ip_version(cidr) == 4
options = []
if nameservers:
options.append(obj.Dhcp... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_run_pass; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 173; 6, while_statement; 6, 7; 6, 8; 7, True; 8, block; 8, 9; 8, 43; 8, 52; 8, 101; 8, 111; 8, 142; 8, 152; 9, try_statement; 9, 10; 9, 22; 10, block; 10, 11; 11, expression... | def _run_pass(self):
while True:
try:
data = self._file.read(4096)
except IOError, e:
if e.errno == errno.ESTALE:
self.active = False
return False
lines = self._buffer_extract(data)
if not lin... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:update_files; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 29; 5, 42; 5, 46; 5, 50; 5, 171; 5, 236; 5, 252; 6, if_statement; 6, 7; 6, 27; 7, boolean_operator:and; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, id... | def update_files(self):
if self._update_time and int(time.time()) - self._update_time < self._discover_interval:
return
self._update_time = int(time.time())
possible_files = []
files = []
if len(self._beaver_config.get('globs')) > 0:
extend_files = files.e... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:gctx_file_path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:convert_neg_666; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:rid; 10,... | def parse(gctx_file_path, convert_neg_666=True, rid=None, cid=None,
ridx=None, cidx=None, row_meta_only=False, col_meta_only=False, make_multiindex=False):
full_path = os.path.expanduser(gctx_file_path)
if not os.path.exists(full_path):
err_msg = "The given path to the gctx file cannot be foun... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:multi_index_df_to_component_dfs; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:multi_index_df; 5, default_parameter; 5, 6; 5, 7; 6, identifier:rid; 7, string:"rid"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:cid; 10, string:"cid"; 11, b... | def multi_index_df_to_component_dfs(multi_index_df, rid="rid", cid="cid"):
rids = list(multi_index_df.index.get_level_values(rid))
cids = list(multi_index_df.columns.get_level_values(cid))
if isinstance(multi_index_df.index, pd.MultiIndex):
if len(multi_index_df.index.names) > 1:
mi_df_i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:file_path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:convert_neg_666; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:rid; 10, None... | def parse(file_path, convert_neg_666=True, rid=None, cid=None, ridx=None, cidx=None,
row_meta_only=False, col_meta_only=False, make_multiindex=False):
if file_path.endswith(".gct"):
out = parse_gct.parse(file_path, convert_neg_666=convert_neg_666,
rid=rid, cid=cid, ri... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:assemble_concatenated_meta; 3, parameters; 3, 4; 3, 5; 4, identifier:concated_meta_dfs; 5, identifier:remove_all_metadata_fields; 6, block; 6, 7; 6, 29; 6, 41; 6, 49; 6, 61; 6, 76; 6, 80; 6, 98; 7, if_statement; 7, 8; 7, 9; 8, identifier:remove... | def assemble_concatenated_meta(concated_meta_dfs, remove_all_metadata_fields):
if remove_all_metadata_fields:
for df in concated_meta_dfs:
df.drop(df.columns, axis=1, inplace=True)
all_concated_meta_df = pd.concat(concated_meta_dfs, axis=0)
n_rows = all_concated_meta_df.shape[0]
logg... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:assemble_data; 3, parameters; 3, 4; 3, 5; 4, identifier:data_dfs; 5, identifier:concat_direction; 6, block; 6, 7; 6, 119; 6, 137; 7, if_statement; 7, 8; 7, 11; 7, 63; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:concat_direction; 10, s... | def assemble_data(data_dfs, concat_direction):
if concat_direction == "horiz":
all_data_df = pd.concat(data_dfs, axis=1)
n_cols = all_data_df.shape[1]
logger.debug("all_data_df.shape[1]: {}".format(n_cols))
n_cols_cumulative = sum([df.shape[1] for df in data_dfs])
assert n_co... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_rows_to_keep; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:gctoo; 5, default_parameter; 5, 6; 5, 7; 6, identifier:rid; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:row_bool; 10, None; 11, default_parameter; 11,... | def get_rows_to_keep(gctoo, rid=None, row_bool=None, ridx=None, exclude_rid=None):
if rid is not None:
assert type(rid) == list, "rid must be a list. rid: {}".format(rid)
rows_to_keep = [gctoo_row for gctoo_row in gctoo.data_df.index if gctoo_row in rid]
num_missing_rids = len(rid) - len(row... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_cols_to_keep; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:gctoo; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cid; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:col_bool; 10, None; 11, default_parameter; 11,... | def get_cols_to_keep(gctoo, cid=None, col_bool=None, cidx=None, exclude_cid=None):
if cid is not None:
assert type(cid) == list, "cid must be a list. cid: {}".format(cid)
cols_to_keep = [gctoo_col for gctoo_col in gctoo.data_df.columns if gctoo_col in cid]
num_missing_cids = len(cid) - len(c... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:finish; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:queue_name; 5, identifier:task_id; 6, identifier:owner; 7, default_parameter; 7, 8; 7, 9; 8, identifier:error; 9, False; 10, block; 10, 11; 10, 20; 10, 49; 10, 71; 10, 83; 10, 92; 10... | def finish(queue_name, task_id, owner, error=False):
task = _get_task_with_policy(queue_name, task_id, owner)
if not task.status == WorkQueue.LIVE:
logging.warning('Finishing already dead task. queue=%r, task_id=%r, '
'owner=%r, status=%r',
task.queue_name... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:send_ready_for_review; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:build_id; 5, identifier:release_name; 6, identifier:release_number; 7, block; 7, 8; 7, 21; 7, 40; 7, 49; 7, 63; 7, 86; 7, 98; 7, 117; 7, 121; 7, 152; 7, 175; 7, 185; 7, 191; ... | def send_ready_for_review(build_id, release_name, release_number):
build = models.Build.query.get(build_id)
if not build.send_email:
logging.debug(
'Not sending ready for review email because build does not have '
'email enabled. build_id=%r', build.id)
return
ops = o... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:claim_invitations; 3, parameters; 3, 4; 4, identifier:user; 5, block; 5, 6; 5, 20; 5, 33; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:invitation_user_id; 9, binary_operator:%; 9, 10; 9, 11; 10, string:'%s:%s'; 11, tu... | def claim_invitations(user):
invitation_user_id = '%s:%s' % (
models.User.EMAIL_INVITATION, user.email_address)
invitation_user = models.User.query.get(invitation_user_id)
if invitation_user:
invited_build_list = list(invitation_user.builds)
if not invited_build_list:
ret... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_check_release_done_processing; 3, parameters; 3, 4; 4, identifier:release; 5, block; 5, 6; 5, 37; 5, 54; 5, 95; 5, 113; 5, 119; 5, 125; 5, 131; 5, 150; 5, 160; 5, 169; 6, if_statement; 6, 7; 6, 16; 7, comparison_operator:!=; 7, 8; 7, 11; 8, at... | def _check_release_done_processing(release):
if release.status != models.Release.PROCESSING:
logging.info('Release not in processing state yet: build_id=%r, '
'name=%r, number=%d', release.build_id, release.name,
release.number)
return False
query = mode... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:download; 3, parameters; 4, block; 4, 5; 4, 37; 4, 51; 4, 68; 4, 81; 4, 98; 4, 112; 4, 129; 4, 146; 4, 164; 4, 187; 4, 202; 4, 229; 5, try_statement; 5, 6; 5, 16; 6, block; 6, 7; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, ide... | def download():
try:
build = auth.can_user_access_build('build_id')
except HTTPException:
logging.debug('User access to artifact failed. Trying API key.')
_, build = auth.can_api_key_access_build('build_id')
sha1sum = request.args.get('sha1sum', type=str)
if not sha1sum:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_run; 3, parameters; 3, 4; 4, identifier:run; 5, block; 5, 6; 5, 23; 6, if_statement; 6, 7; 6, 16; 7, comparison_operator:in; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:run; 10, identifier:status; 11, attribute; 11, 12; 11, 15; 1... | def sort_run(run):
if run.status in models.Run.DIFF_NEEDED_STATES:
return (0, run.name)
return (1, run.name) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:required_properties; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:additional_properties; 10, None; 11, default_param... | def parse(obj, required_properties=None, additional_properties=None,
ignore_optional_property_errors=None):
if not (required_properties is
additional_properties is
ignore_optional_property_errors is None):
with parsing(required_properties=required_properties,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:adapts; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:schemas; 6, block; 6, 7; 6, 16; 6, 143; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:validate; 10, attribute; 10, 11; 10, 15; 11, call; 11... | def adapts(**schemas):
validate = parse(schemas).validate
@decorator
def adapting(func, *args, **kwargs):
adapted = validate(inspect.getcallargs(func, *args, **kwargs), adapt=True)
argspec = inspect.getargspec(func)
if argspec.varargs is argspec.keywords is None:
return f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:download; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 17; 3, 21; 3, 24; 4, identifier:self; 5, identifier:bundle_uuid; 6, identifier:replica; 7, default_parameter; 7, 8; 7, 9; 8, identifier:version; 9, string:""; 10, default_parame... | def download(self, bundle_uuid, replica, version="", download_dir="",
metadata_files=('*',), data_files=('*',),
num_retries=10, min_delay_seconds=0.25):
errors = 0
with concurrent.futures.ThreadPoolExecutor(self.threads) as executor:
futures_to_dss_file = {e... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_do_download_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:dss_file; 6, identifier:fh; 7, identifier:num_retries; 8, identifier:min_delay_seconds; 9, block; 9, 10; 9, 18; 9, 22; 9, 26; 9, 383; 10, expressi... | def _do_download_file(self, dss_file, fh, num_retries, min_delay_seconds):
hasher = hashlib.sha256()
delay = min_delay_seconds
retries_left = num_retries
while True:
try:
response = self.get_file._request(
dict(uuid=dss_file.uuid, version=d... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:output; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:output; 6, default_parameter; 6, 7; 6, 8; 7, identifier:status; 8, None; 9, block; 9, 10; 9, 188; 10, if_statement; 10, 11; 10, 12; 11, identifier:output; 12, block; 12,... | def output(self, output, status=None):
if output:
size = self.cli.output.get_size()
margin = self.get_output_margin(status)
fits = True
buf = []
output_via_pager = self.explicit_pager and special.is_pager_enabled()
for i, line in enumerate(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:find_matches; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:text; 5, identifier:collection; 6, default_parameter; 6, 7; 6, 8; 7, identifier:start_only; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:fuzzy; 11, True;... | def find_matches(text, collection, start_only=False, fuzzy=True, casing=None):
last = last_word(text, include='most_punctuations')
text = last.lower()
completions = []
if fuzzy:
regex = '.*?'.join(map(escape, text))
pat = compile('(%s)' % regex)
for it... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:cli_bindings; 3, parameters; 4, block; 4, 5; 4, 26; 4, 71; 4, 112; 4, 169; 4, 225; 4, 281; 4, 332; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:key_binding_manager; 8, call; 8, 9; 8, 10; 9, identifier:KeyBindingManage... | def cli_bindings():
key_binding_manager = KeyBindingManager(
enable_open_in_editor=True,
enable_system_bindings=True,
enable_auto_suggest_bindings=True,
enable_search=True,
enable_abort_and_exit_bindings=True)
@key_binding_manager.registry.add_binding(Keys.F2)
def _(e... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_thumbnail_options; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:context; 6, identifier:instance; 7, block; 7, 8; 7, 16; 7, 20; 7, 30; 7, 40; 7, 54; 7, 79; 7, 90; 7, 202; 8, expression_statement; 8, 9; 9, assignment; 9... | def _get_thumbnail_options(self, context, instance):
width, height = None, None
subject_location = False
placeholder_width = context.get('width', None)
placeholder_height = context.get('height', None)
if instance.use_autoscale and placeholder_width:
width = int(placeh... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:group_and_sort_statements; 3, parameters; 3, 4; 3, 5; 4, identifier:stmt_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ev_totals; 7, None; 8, block; 8, 9; 8, 36; 8, 43; 8, 51; 8, 59; 8, 135; 8, 267; 8, 288; 9, function_definition; 9, 10... | def group_and_sort_statements(stmt_list, ev_totals=None):
def _count(stmt):
if ev_totals is None:
return len(stmt.evidence)
else:
return ev_totals[stmt.get_hash()]
stmt_rows = defaultdict(list)
stmt_counts = defaultdict(lambda: 0)
arg_counts = defaultdict(lambda: ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:make_stmt_from_sort_key; 3, parameters; 3, 4; 3, 5; 4, identifier:key; 5, identifier:verb; 6, block; 6, 7; 6, 28; 6, 35; 6, 44; 6, 144; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:make_agent; 9, parameters; 9, 10; 10, identifier... | def make_stmt_from_sort_key(key, verb):
def make_agent(name):
if name == 'None' or name is None:
return None
return Agent(name)
StmtClass = get_statement_by_name(verb)
inps = list(key[1])
if verb == 'Complex':
stmt = StmtClass([make_agent(name) for name in inps])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:print_boolean_net; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:out_file; 7, None; 8, block; 8, 9; 8, 13; 8, 41; 8, 45; 8, 259; 8, 267; 8, 291; 9, expression_statement; 9, 10; 10, assignment; 10... | def print_boolean_net(self, out_file=None):
init_str = ''
for node_key in self.graph.nodes():
node_name = self.graph.node[node_key]['name']
init_str += '%s = False\n' % node_name
rule_str = ''
for node_key in self.graph.nodes():
node_name = self.graph.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_complex_agents; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:complex_id; 6, block; 6, 7; 6, 11; 6, 20; 6, 146; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:agents; 10, list:[]; 11, expression_sta... | def _get_complex_agents(self, complex_id):
agents = []
components = self._recursively_lookup_complex(complex_id)
for c in components:
db_refs = {}
name = uniprot_client.get_gene_name(c)
if name is None:
db_refs['SIGNOR'] = c
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_args; 3, parameters; 3, 4; 4, identifier:node; 5, block; 5, 6; 5, 10; 5, 40; 5, 81; 5, 162; 5, 171; 5, 192; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:arg_roles; 9, dictionary; 10, expression_statement; 10, 11; ... | def get_args(node):
arg_roles = {}
args = node.findall('arg') + \
[node.find('arg1'), node.find('arg2'), node.find('arg3')]
for arg in args:
if arg is not None:
id = arg.attrib.get('id')
if id is not None:
arg_roles[arg.attrib['role']] = (arg.attrib['i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:map_statements; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:stmt; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:statements; 11, block; 11, 12; 12, for_statement; 12... | def map_statements(self):
for stmt in self.statements:
for agent in stmt.agent_list():
if agent is None:
continue
all_mappings = []
for db_name, db_id in agent.db_refs.items():
if isinstance(db_id, list):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:agent_texts_with_grounding; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 13; 5, 44; 5, 61; 5, 68; 5, 89; 5, 108; 5, 112; 5, 249; 5, 266; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:allag; 9, call; 9, ... | def agent_texts_with_grounding(stmts):
allag = all_agents(stmts)
for ag in allag:
pfam_def = ag.db_refs.get('PFAM-DEF')
if pfam_def is not None:
ag.db_refs['PFAM-DEF'] = tuple(pfam_def)
refs = [tuple(ag.db_refs.items()) for ag in allag]
refs_counter = Counter(refs)
refs_c... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ungrounded_texts; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 43; 5, 50; 5, 58; 5, 76; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ungrounded; 9, list_comprehension; 9, 10; 9, 15; 9, 18; 9, 25; 10, s... | def ungrounded_texts(stmts):
ungrounded = [ag.db_refs['TEXT']
for s in stmts
for ag in s.agent_list()
if ag is not None and list(ag.db_refs.keys()) == ['TEXT']]
ungroundc = Counter(ungrounded)
ungroundc = ungroundc.items()
ungroundc = sorted(unground... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:protein_map_from_twg; 3, parameters; 3, 4; 4, identifier:twg; 5, block; 5, 6; 5, 10; 5, 14; 5, 18; 5, 25; 5, 141; 5, 150; 5, 159; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:protein_map; 9, dictionary; 10, expression... | def protein_map_from_twg(twg):
protein_map = {}
unmatched = 0
matched = 0
logger.info('Building grounding map for human proteins')
for agent_text, grounding_list, _ in twg:
if 'UP' not in [entry[0] for entry in grounding_list]:
continue
uniprot_ids = [entry[1] for entry i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:save_sentences; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:twg; 5, identifier:stmts; 6, identifier:filename; 7, default_parameter; 7, 8; 7, 9; 8, identifier:agent_limit; 9, integer:300; 10, block; 10, 11; 10, 15; 10, 25; 10, 29; 10, ... | def save_sentences(twg, stmts, filename, agent_limit=300):
sentences = []
unmapped_texts = [t[0] for t in twg]
counter = 0
logger.info('Getting sentences for top %d unmapped agent texts.' %
agent_limit)
for text in unmapped_texts:
agent_sentences = get_sentences_for_agent(tex... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_text_for_grounding; 3, parameters; 3, 4; 3, 5; 4, identifier:stmt; 5, identifier:agent_text; 6, block; 6, 7; 6, 11; 6, 103; 6, 150; 6, 174; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:text; 10, None; 11, try_st... | def _get_text_for_grounding(stmt, agent_text):
text = None
try:
from indra_db.util.content_scripts \
import get_text_content_from_text_refs
from indra.literature.deft_tools import universal_extract_text
refs = stmt.evidence[0].text_refs
if stmt.evidence[0].pmid:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:map_agents_for_stmt; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:stmt; 6, default_parameter; 6, 7; 6, 8; 7, identifier:do_rename; 8, True; 9, block; 9, 10; 9, 17; 9, 25; 9, 144; 9, 151; 9, 187; 10, expression_statement; 1... | def map_agents_for_stmt(self, stmt, do_rename=True):
mapped_stmt = deepcopy(stmt)
agent_list = mapped_stmt.agent_list()
for idx, agent in enumerate(agent_list):
if agent is None:
continue
agent_txt = agent.db_refs.get('TEXT')
if agent_txt is No... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:map_agent; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:agent; 6, identifier:do_rename; 7, block; 7, 8; 7, 19; 7, 30; 7, 49; 7, 74; 7, 103; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:agent_t... | def map_agent(self, agent, do_rename):
agent_text = agent.db_refs.get('TEXT')
mapped_to_agent_json = self.agent_map.get(agent_text)
if mapped_to_agent_json:
mapped_to_agent = \
Agent._from_json(mapped_to_agent_json['agent'])
return mapped_to_agent, False
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:rename_agents; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stmts; 6, block; 6, 7; 6, 14; 6, 118; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:mapped_stmts; 10, call; 10, 11; 10, 12; 11, identifier:de... | def rename_agents(self, stmts):
mapped_stmts = deepcopy(stmts)
for _, stmt in enumerate(mapped_stmts):
for agent in stmt.agent_list():
if agent is None:
continue
if agent.db_refs.get('FPLX'):
agent.name = agent.db_refs.g... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_ptms; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:ptm_df; 6, block; 6, 7; 6, 14; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:logger; 11, identifier:info; 12, argument_list... | def get_ptms(self, ptm_df):
logger.info('Processing PTMs...')
for ix, row in ptm_df.iterrows():
ptm_class = _ptm_map[row['MOD_TYPE']]
if ptm_class is None:
continue
sub_ag = self._make_agent(row['HPRD_ID'],
refseq_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_process_interaction; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:source_id; 6, identifier:interaction; 7, identifier:text; 8, identifier:pmid; 9, identifier:extra_annotations; 10, block; 10, 11; 10, 21... | def _process_interaction(self, source_id, interaction, text, pmid,
extra_annotations):
verb = interaction[0].lower()
subj = interaction[-2]
obj = interaction[-1]
subj = self._make_agent(subj)
obj = self._make_agent(obj)
annotations = deepcopy(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_regulate_amounts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 21; 5, 33; 5, 48; 5, 52; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 1... | def get_regulate_amounts(self):
p = pb.controlsExpressionWithTemplateReac()
s = _bpp('Searcher')
res = s.searchPlain(self.model, p)
res_array = [_match_to_array(m) for m in res.toArray()]
stmts = []
for res in res_array:
'''
controller_er = res[p.i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_gef; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 21; 5, 33; 5, 48; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; ... | def get_gef(self):
p = self._gef_gap_base()
s = _bpp('Searcher')
res = s.searchPlain(self.model, p)
res_array = [_match_to_array(m) for m in res.toArray()]
for r in res_array:
controller_pe = r[p.indexOf('controller PE')]
input_pe = r[p.indexOf('input PE')... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_gap; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 21; 5, 33; 5, 48; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; ... | def get_gap(self):
p = self._gef_gap_base()
s = _bpp('Searcher')
res = s.searchPlain(self.model, p)
res_array = [_match_to_array(m) for m in res.toArray()]
for r in res_array:
controller_pe = r[p.indexOf('controller PE')]
input_pe = r[p.indexOf('input PE')... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_generic_modification; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:mod_class; 6, block; 6, 7; 6, 13; 6, 40; 6, 48; 6, 56; 6, 69; 6, 76; 6, 88; 6, 103; 6, 107; 6, 377; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 1... | def _get_generic_modification(self, mod_class):
mod_type = modclass_to_modtype[mod_class]
if issubclass(mod_class, RemoveModification):
mod_gain_const = mcct.LOSS
mod_type = modtype_to_inverse[mod_type]
else:
mod_gain_const = mcct.GAIN
mod_filter = mod... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_extract_mod_from_feature; 3, parameters; 3, 4; 4, identifier:mf; 5, block; 5, 6; 5, 14; 5, 21; 5, 33; 5, 37; 5, 76; 5, 96; 5, 102; 5, 110; 5, 207; 5, 217; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:mf_type; 9, call... | def _extract_mod_from_feature(mf):
mf_type = mf.getModificationType()
if mf_type is None:
return None
mf_type_terms = mf_type.getTerm().toArray()
known_mf_type = None
for t in mf_type_terms:
if t.startswith('MOD_RES '):
t = t[8:]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_activations; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 5, 28; 5, 39; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:act_events; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribu... | def get_activations(self):
act_events = self.tree.findall("EVENT/[type='ONT::ACTIVATE']")
inact_events = self.tree.findall("EVENT/[type='ONT::DEACTIVATE']")
inact_events += self.tree.findall("EVENT/[type='ONT::INHIBIT']")
for event in (act_events + inact_events):
event_id = e... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_activations_causal; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ccs; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11... | def get_activations_causal(self):
ccs = self.tree.findall("CC/[type='ONT::CAUSE']")
for cc in ccs:
factor = cc.find("arg/[@role=':FACTOR']")
outcome = cc.find("arg/[@role=':OUTCOME']")
if factor is None or outcome is None:
continue
factor_i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_activations_stimulate; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:stim_events; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute;... | def get_activations_stimulate(self):
stim_events = self.tree.findall("EVENT/[type='ONT::STIMULATE']")
for event in stim_events:
event_id = event.attrib.get('id')
if event_id in self._static_events:
continue
controller = event.find("arg1/[@role=':AGENT'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_degradations; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:deg_events; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 1... | def get_degradations(self):
deg_events = self.tree.findall("EVENT/[type='ONT::CONSUME']")
for event in deg_events:
if event.attrib['id'] in self._static_events:
continue
affected = event.find(".//*[@role=':AFFECTED']")
if affected is None:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_complexes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 5, 28; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:bind_events; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, ... | def get_complexes(self):
bind_events = self.tree.findall("EVENT/[type='ONT::BIND']")
bind_events += self.tree.findall("EVENT/[type='ONT::INTERACT']")
for event in bind_events:
if event.attrib['id'] in self._static_events:
continue
arg1 = event.find("arg1")... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_modifications_indirect; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 5, 22; 5, 129; 5, 236; 5, 243; 5, 250; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:mod_event_types; 9, call; 9, 10; 9, 11; 1... | def get_modifications_indirect(self):
mod_event_types = list(ont_to_mod_type.keys())
mod_event_types += ['ONT::PTM']
def get_increase_events(mod_event_types):
mod_events = []
events = self.tree.findall("EVENT/[type='ONT::INCREASE']")
for event in events:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:replace_activities; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 17; 5, 47; 5, 53; 5, 272; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logger; 10, identifier:debug; 11, arg... | def replace_activities(self):
logger.debug('Running PySB Preassembler replace activities')
new_stmts = []
def has_agent_activity(stmt):
for agent in stmt.agent_list():
if isinstance(agent, Agent) and agent.activity is not None:
return True
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:add_reverse_effects; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 14; 5, 18; 5, 22; 5, 208; 5, 212; 5, 276; 5, 303; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:pos_mod_sites; 9, dictionary; 10, ... | def add_reverse_effects(self):
pos_mod_sites = {}
neg_mod_sites = {}
syntheses = []
degradations = []
for stmt in self.statements:
if isinstance(stmt, Phosphorylation):
agent = stmt.sub.name
try:
pos_mod_sites[agent]... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:map_sites; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stmts; 6, block; 6, 7; 6, 11; 6, 15; 6, 49; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:valid_statements; 10, list:[]; 11, expression_statement... | def map_sites(self, stmts):
valid_statements = []
mapped_statements = []
for stmt in stmts:
mapped_stmt = self.map_stmt_sites(stmt)
if mapped_stmt is not None:
mapped_statements.append(mapped_stmt)
else:
valid_statements.append(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_map_agent_sites; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:agent; 6, block; 6, 7; 6, 21; 6, 28; 6, 32; 6, 105; 7, if_statement; 7, 8; 7, 16; 8, boolean_operator:or; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, i... | def _map_agent_sites(self, agent):
if agent is None or not agent.mods:
return [], agent
new_agent = deepcopy(agent)
mapped_sites = []
for idx, mod_condition in enumerate(agent.mods):
mapped_site = \
self._map_agent_mod(agent, mod_condition)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_map_agent_mod; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:agent; 6, identifier:mod_condition; 7, block; 7, 8; 7, 15; 7, 32; 7, 47; 7, 79; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:up_id;... | def _map_agent_mod(self, agent, mod_condition):
up_id = _get_uniprot_id(agent)
if not up_id:
logger.debug("No uniprot ID for %s" % agent.name)
return None
if mod_condition.position is None or mod_condition.residue is None:
return None
mapped_site = \
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_graph_reductions; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 60; 5, 64; 5, 80; 5, 92; 5, 131; 6, function_definition; 6, 7; 6, 8; 6, 11; 7, function_name:frontier; 8, parameters; 8, 9; 8, 10; 9, identifier:g; 10, identifi... | def _get_graph_reductions(graph):
def frontier(g, nd):
if g.out_degree(nd) == 0:
return set([nd])
else:
frontiers = set()
for n in g.successors(nd):
frontiers = frontiers.union(frontier(graph, n))
return frontiers
reductions = {}
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:gather_implicit_activities; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:stmt; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:statements; 11, block; 11, 12; 12, if_st... | def gather_implicit_activities(self):
for stmt in self.statements:
if isinstance(stmt, Phosphorylation) or \
isinstance(stmt, Transphosphorylation) or \
isinstance(stmt, Autophosphorylation):
if stmt.enz is not None:
enz_base = self... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:reduce_activities; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:stmt; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:statements; 11, block; 11, 12; 11, 20; 11, 70; 12... | def reduce_activities(self):
for stmt in self.statements:
agents = stmt.agent_list()
for agent in agents:
if agent is not None and agent.activity is not None:
agent_base = self._get_base(agent)
act_red = agent_base.get_activity_redu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:infer_activations; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 10; 5, 18; 5, 26; 5, 183; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:linked_stmts; 9, list:[]; 10, expression_statement; 10, 11; 11, as... | def infer_activations(stmts):
linked_stmts = []
af_stmts = _get_statements_by_type(stmts, ActiveForm)
mod_stmts = _get_statements_by_type(stmts, Modification)
for af_stmt, mod_stmt in itertools.product(*(af_stmts, mod_stmts)):
if mod_stmt.enz is None or \
(not... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:infer_active_forms; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 10; 5, 248; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:linked_stmts; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 17; 11, identi... | def infer_active_forms(stmts):
linked_stmts = []
for act_stmt in _get_statements_by_type(stmts, RegulateActivity):
if not (act_stmt.subj.activity is not None and
act_stmt.subj.activity.activity_type == 'kinase' and
act_stmt.subj.activity.is_active):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:infer_modifications; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 10; 5, 188; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:linked_stmts; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 17; 11, ident... | def infer_modifications(stmts):
linked_stmts = []
for act_stmt in _get_statements_by_type(stmts, RegulateActivity):
for af_stmt in _get_statements_by_type(stmts, ActiveForm):
if not af_stmt.agent.entity_matches(act_stmt.obj):
continue
mods ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:score_evidence_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:evidences; 6, block; 6, 7; 6, 121; 6, 139; 6, 156; 6, 163; 6, 170; 6, 179; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:_score; 9, parameters; 9, 1... | def score_evidence_list(self, evidences):
def _score(evidences):
if not evidences:
return 0
sources = [ev.source_api for ev in evidences]
uniq_sources = numpy.unique(sources)
syst_factors = {s: self.prior_probs['syst'][s]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:update_probs; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 20; 5, 78; 5, 82; 5, 153; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:syst_error; 9, float:0.05; 10, expression_statement; 10, 11; 11, ... | def update_probs(self):
syst_error = 0.05
prior_probs = {'syst': {}, 'rand': {}}
for source, (p, n) in self.prior_counts.items():
if n + p == 0:
continue
prior_probs['syst'][source] = syst_error
prior_probs['rand'][source] = \
1... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_hierarchy_probs; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:statements; 6, block; 6, 7; 6, 76; 6, 120; 6, 157; 6, 164; 6, 169; 6, 176; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:build_hierarchy_graph; 9, p... | def set_hierarchy_probs(self, statements):
def build_hierarchy_graph(stmts):
g = networkx.DiGraph()
for st1 in stmts:
g.add_node(st1.matches_key(), stmt=st1)
for st2 in st1.supported_by:
g.add_node(st2.matches_key(), stmt=st2)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_statements; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reprocess; 7, False; 8, block; 8, 9; 8, 219; 9, if_statement; 9, 10; 9, 17; 9, 208; 10, boolean_operator:or; 10, 11; 10, 16; 11, comp... | def get_statements(self, reprocess=False):
if self._statements is None or reprocess:
if self.content is None:
self._statements = []
return []
if self.reader == ReachReader.name:
if self.format == formats.JSON:
json_str =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:read; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:read_list; 6, default_parameter; 6, 7; 6, 8; 7, identifier:verbose; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:log; 11, False; 12, default_... | def read(self, read_list, verbose=False, log=False, n_per_proc=None):
"Perform the actual reading."
ret = []
self.prep_input(read_list)
L = len(self.file_list)
if L == 0:
return ret
logger.info("Beginning to run sparser.")
output_file_list = []
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:read_pmid_sentences; 3, parameters; 3, 4; 3, 5; 4, identifier:pmid_sentences; 5, dictionary_splat_pattern; 5, 6; 6, identifier:drum_args; 7, block; 7, 8; 7, 30; 7, 40; 7, 44; 7, 48; 7, 224; 7, 237; 8, function_definition; 8, 9; 8, 10; 8, 13; 9,... | def read_pmid_sentences(pmid_sentences, **drum_args):
def _set_pmid(statements, pmid):
for stmt in statements:
for evidence in stmt.evidence:
evidence.pmid = pmid
run_drum = drum_args.get('run_drum', False)
drum_process = None
all_statements = {}
for pmid, sentenc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:graph_query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:kind; 5, identifier:source; 6, default_parameter; 6, 7; 6, 8; 7, identifier:target; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:neighbor_limit; 11, intege... | def graph_query(kind, source, target=None, neighbor_limit=1,
database_filter=None):
default_databases = ['wp', 'smpdb', 'reconx', 'reactome', 'psp', 'pid',
'panther', 'netpath', 'msigdb', 'mirtarbase', 'kegg',
'intact', 'inoh', 'humancyc', 'hprd',
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_CCLE_context; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:cell_types; 6, block; 6, 7; 6, 13; 6, 26; 6, 39; 6, 49; 6, 95; 6, 279; 6, 286; 6, 296; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 1... | def set_CCLE_context(self, cell_types):
self.get_gene_names()
exp_values = \
context_client.get_protein_expression(self._gene_names, cell_types)
mut_values = \
context_client.get_mutations(self._gene_names, cell_types)
muts = {cell_line: {} for cell_line in cell_t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_node_key; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node_dict_item; 6, block; 6, 7; 6, 19; 6, 31; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:s; 10, call; 10, 11; 10, 12; 11, identifier:tuple... | def _get_node_key(self, node_dict_item):
s = tuple(sorted(node_dict_item['sources']))
t = tuple(sorted(node_dict_item['targets']))
return (s, t) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_node_groups; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 28; 5, 102; 5, 112; 5, 140; 5, 160; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:node_dict; 9, dictionary_comprehension; 9, 10; 9, 23; 10, ... | def _get_node_groups(self):
node_dict = {node['data']['id']: {'sources': [], 'targets': []}
for node in self._nodes}
for edge in self._edges:
edge_data = (edge['data']['i'], edge['data']['polarity'],
edge['data']['source'])
node_dict[... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_group_edges; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 234; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:edges_to_add; 9, list:[[], []]; 9, 10; 9, 11; 10, list:[]; 11, list:[]; 12, for_statem... | def _group_edges(self):
edges_to_add = [[], []]
for e in self._edges:
new_edge = deepcopy(e)
new_edge['data'].pop('id', None)
uuid_list = new_edge['data'].pop('uuid_list', [])
source = e['data']['source']
target = e['data']['target']
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 40; 2, function_name:get_statements; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 4, default_parameter; 4, 5; 4, 6; 5, identifier:subject; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:object; 9, None;... | def get_statements(subject=None, object=None, agents=None, stmt_type=None,
use_exact_type=False, persist=True, timeout=None,
simple_response=False, ev_limit=10, best_first=True, tries=2,
max_stmts=None):
processor = IndraDBRestProcessor(subject, object, agent... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_statements_by_hash; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:hash_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ev_limit; 7, integer:100; 8, default_parameter; 8, 9; 8, 10; 9, identifier:best_first; 10, True; 11, defau... | def get_statements_by_hash(hash_list, ev_limit=100, best_first=True, tries=2):
if not isinstance(hash_list, list):
raise ValueError("The `hash_list` input is a list, not %s."
% type(hash_list))
if not hash_list:
return []
if isinstance(hash_list[0], str):
has... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_statements_for_paper; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:ids; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ev_limit; 7, integer:10; 8, default_parameter; 8, 9; 8, 10; 9, identifier:best_first; 10, True; 11, def... | def get_statements_for_paper(ids, ev_limit=10, best_first=True, tries=2,
max_stmts=None):
id_l = [{'id': id_val, 'type': id_type} for id_type, id_val in ids]
resp = submit_statement_request('post', 'from_papers', data={'ids': id_l},
ev_limit=ev_li... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_statement_queries; 3, parameters; 3, 4; 3, 5; 4, identifier:stmts; 5, dictionary_splat_pattern; 5, 6; 6, identifier:params; 7, block; 7, 8; 7, 61; 7, 65; 7, 72; 7, 79; 7, 211; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:pic... | def get_statement_queries(stmts, **params):
def pick_ns(ag):
for ns in ['HGNC', 'FPLX', 'CHEMBL', 'CHEBI', 'GO', 'MESH']:
if ns in ag.db_refs.keys():
dbid = ag.db_refs[ns]
break
else:
ns = 'TEXT'
dbid = ag.name
return '%s@%s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:make_statement; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:action; 6, identifier:mention; 7, block; 7, 8; 7, 23; 7, 30; 7, 34; 7, 102; 7, 108; 7, 114; 7, 122; 7, 130; 7, 158; 7, 170; 7, 182; 8, expression_statement; 8, 9... | def make_statement(self, action, mention):
(statement_generator, is_direct) = \
geneways_action_to_indra_statement_type(mention.actiontype,
action.plo)
if statement_generator is None:
return None
text = None
if s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:directly_or_indirectly_related; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:ns1; 6, identifier:id1; 7, identifier:ns2; 8, identifier:id2; 9, identifier:closure_dict; 10, identifier:relation_func;... | def directly_or_indirectly_related(self, ns1, id1, ns2, id2, closure_dict,
relation_func):
if id2 is None or (id2 is None and id1 is None):
return True
elif id1 is None:
return False
if closure_dict:
term1 = self.get_uri(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:analyze_db_reading; 3, parameters; 3, 4; 3, 5; 4, identifier:job_prefix; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reading_queue; 7, string:'run_db_reading_queue'; 8, block; 8, 9; 8, 17; 8, 21; 8, 25; 8, 29; 8, 66; 8, 80; 8, 98; 8, 108; 8... | def analyze_db_reading(job_prefix, reading_queue='run_db_reading_queue'):
log_strs = get_logs_from_db_reading(job_prefix, reading_queue)
indra_log_strs = []
all_reach_logs = []
log_stats = []
for log_str in log_strs:
log_str, reach_logs = separate_reach_logs(log_str)
all_reach_logs.e... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_create_base_agent; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:agent; 6, block; 6, 7; 6, 50; 6, 216; 6, 236; 7, try_statement; 7, 8; 7, 22; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11,... | def get_create_base_agent(self, agent):
try:
base_agent = self.agents[_n(agent.name)]
except KeyError:
base_agent = BaseAgent(_n(agent.name))
self.agents[_n(agent.name)] = base_agent
if isinstance(agent, Agent):
for bc in agent.bound_conditions:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:classify_nodes; 3, parameters; 3, 4; 3, 5; 4, identifier:graph; 5, identifier:hub; 6, block; 6, 7; 6, 18; 6, 140; 6, 144; 6, 227; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:node_stats; 10, call; 10, 11; 10, 12; 11,... | def classify_nodes(graph, hub):
node_stats = defaultdict(lambda: defaultdict(list))
for u, v, data in graph.edges(data=True):
if hub == u:
h, o = u, v
if data['i'] != 'Complex':
node_stats[o]['up'].append(-1)
else:
node_stats[o]['up'].a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:doi_query; 3, parameters; 3, 4; 3, 5; 4, identifier:pmid; 5, default_parameter; 5, 6; 5, 7; 6, identifier:search_limit; 7, integer:10; 8, block; 8, 9; 8, 22; 8, 47; 8, 53; 8, 68; 8, 77; 8, 93; 8, 102; 8, 117; 8, 126; 8, 141; 8, 145; 8, 155; 8, ... | def doi_query(pmid, search_limit=10):
pubmed_meta_dict = pubmed_client.get_metadata_for_ids([pmid],
get_issns_from_nlm=True)
if pubmed_meta_dict is None or pubmed_meta_dict.get(pmid) is None:
logger.warning('No metadata found in Pubmed for PMID%s' ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_agent_rule_str; 3, parameters; 3, 4; 4, identifier:agent; 5, block; 5, 6; 5, 16; 5, 251; 5, 260; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:rule_str_list; 9, list:[_n(agent.name)]; 9, 10; 10, call; 10, 11; 10, 1... | def get_agent_rule_str(agent):
rule_str_list = [_n(agent.name)]
if isinstance(agent, ist.Agent):
for mod in agent.mods:
mstr = abbrevs[mod.mod_type]
if mod.residue is not None:
mstr += mod.residue
if mod.position is not None:
mstr += mo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:grounded_monomer_patterns; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:model; 5, identifier:agent; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_activities; 8, False; 9, block; 9, 10; 9, 43; 9, 47; 9, 126; 9, 141; 9, 145; 9, 347; 9,... | def grounded_monomer_patterns(model, agent, ignore_activities=False):
if not isinstance(agent, ist.Agent):
monomer = model.monomers.get(agent.name)
if not monomer:
return
yield monomer()
monomer = None
for ann in model.annotations:
if monomer:
break
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_site_pattern; 3, parameters; 3, 4; 4, identifier:agent; 5, block; 5, 6; 5, 18; 5, 22; 5, 57; 5, 141; 5, 196; 5, 214; 5, 252; 6, if_statement; 6, 7; 6, 15; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_l... | def get_site_pattern(agent):
if not isinstance(agent, ist.Agent):
return {}
pattern = {}
for bc in agent.bound_conditions:
if bc.is_bound:
pattern[get_binding_site_name(bc.agent)] = ANY
else:
pattern[get_binding_site_name(bc.agent)] = None
for mod in agent... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:make_model; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:policies; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:initial_conditions; 10, True; 11, default_parame... | def make_model(self, policies=None, initial_conditions=True,
reverse_effects=False, model_name='indra_model'):
ppa = PysbPreassembler(self.statements)
self.processed_policies = self.process_policies(policies)
ppa.replace_activities()
if reverse_effects:
ppa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_modifications; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 21; 5, 27; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:qstr; 9, string:"$.events.frames[(@.type is 'protein-modification')]"; 10, ... | def get_modifications(self):
qstr = "$.events.frames[(@.type is 'protein-modification')]"
res = self.tree.execute(qstr)
if res is None:
return
for r in res:
modification_type = r.get('subtype')
epistemics = self._get_epistemics(r)
if episte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.