sequence stringlengths 1.19k 35k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_cyclic_graph_best_effort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childre... | def sort_cyclic_graph_best_effort(graph, pick_first='head'):
ordered = []
visited = set()
if pick_first == 'head':
fst_attr, snd_attr = ('head_node', 'update_node')
else:
fst_attr, snd_attr = ('update_node', 'head_node')
current = FIRST
while current is not None:
visited.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'circlescan'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def circlescan(x0, y0, r1, r2):
if r1 < 0: raise ValueError("Initial radius must be non-negative")
if r2 < 0: raise ValueError("Final radius must be non-negative")
previous = []
rstep = 1 if r2 >= r1 else -1
for distance in range(r1, r2 + rstep, rstep):
if distance == 0:
yield x0... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ringscan'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [... | def ringscan(x0, y0, r1, r2, metric=chebyshev):
if r1 < 0: raise ValueError("Initial radius must be non-negative")
if r2 < 0: raise ValueError("Final radius must be non-negative")
if not hasattr(metric, "__call__"): raise TypeError("Metric not callable")
direction = 0
steps = {0: [ 1, 0],
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def fetch(self, callback):
session = self.client.sync.start(self.device_uuid)
if session is None or 'id' not in session:
return
while True:
queue_items = self.client.sync.fetch(self.device_uuid, session['id'])
if not queue_items:
break
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'define_residues_for_plotting_traj'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'chi... | def define_residues_for_plotting_traj(self, analysis_cutoff):
self.residue_counts_fraction = {}
for traj in self.residue_counts:
self.residue_counts_fraction[traj] = {residue:float(values)/len(self.contacts_per_timeframe[traj]) for residue,values in self.residue_counts[traj].items()}
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_donors_and_acceptors_in_ligand'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'childr... | def find_donors_and_acceptors_in_ligand(self):
atom_names=[x.name for x in self.topology_data.universe.ligand]
try:
for atom in self.topology_data.mol.GetSubstructMatches(self.HDonorSmarts, uniquify=1):
self.donors.append(atom_names[atom[0]])
for atom in self.topo... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'determine_hbonds_for_drawing'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children... | def determine_hbonds_for_drawing(self, analysis_cutoff):
self.frequency = defaultdict(int)
for traj in self.hbonds_by_type:
for bond in self.hbonds_by_type[traj]:
if bond["donor_resnm"]!="LIG":
self.frequency[(bond["donor_idx"],bond["acceptor_atom"],bond["... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distance_function_match'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier'... | def distance_function_match(l1, l2, thresh, dist_fn, norm_funcs=[]):
common = []
l1 = list(enumerate(l1))
l2 = list(enumerate(l2))
for norm_fn in norm_funcs:
new_common, l1, l2 = _match_by_norm_func(
l1, l2,
lambda a: norm_fn(a[1]),
lambda a1, a2: ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_match_by_norm_func'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'ch... | def _match_by_norm_func(l1, l2, norm_fn, dist_fn, thresh):
common = []
l1_only_idx = set(range(len(l1)))
l2_only_idx = set(range(len(l2)))
buckets_l1 = _group_by_fn(enumerate(l1), lambda x: norm_fn(x[1]))
buckets_l2 = _group_by_fn(enumerate(l2), lambda x: norm_fn(x[1]))
for normed, l1_elements i... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children'... | def dump(props, fp, separator='=', comments=None, timestamp=True,
sort_keys=False):
if comments is not None:
print(to_comment(comments), file=fp)
if timestamp is not None and timestamp is not False:
print(to_comment(java_timestamp(timestamp)), file=fp)
for k,v in itemize(props, sort... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dumps'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': []... | def dumps(props, separator='=', comments=None, timestamp=True, sort_keys=False):
s = StringIO()
dump(props, s, separator=separator, comments=comments, timestamp=timestamp,
sort_keys=sort_keys)
return s.getvalue() |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'variants'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': ... | def variants(self, case_id, skip=0, count=1000, filters=None):
filters = filters or {}
logger.debug("Looking for variants in {0}".format(case_id))
limit = count + skip
gemini_query = filters.get('gemini_query') or "SELECT * from variants v"
any_filter = False
if filters.g... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_variant'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', ... | def _format_variant(self, case_id, gemini_variant, individual_objs,
index=0, add_all_info=False):
chrom = gemini_variant['chrom']
if chrom.startswith('chr') or chrom.startswith('CHR'):
chrom = chrom[3:]
variant_dict = {
'CHROM':chrom,
'... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'arg'}, {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}, {'id':... | def arg(*args, **kwargs):
def decorate(func):
func.__cmd_name__ = kwargs.pop(
'cmd_name', getattr(func, '__cmd_name__', func.__name__))
func.__cls__ = utils.check_class()
if not hasattr(func, '__arguments__'):
func.__arguments__ = utils.get_functarguments(func)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'class_args'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'},... | def class_args(cls):
ap_ = ArgParseInator(skip_init=True)
utils.collect_appendvars(ap_, cls)
cls.__cls__ = cls
cmds = {}
cls.__arguments__ = getattr(cls, '__arguments__', [])
for func in [f for f in cls.__dict__.values()
if hasattr(f, '__cmd_name__') and not inspect.isclass(f)]:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_args'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def parse_args(self):
self._compile()
self.args = None
self._self_event('before_parse', 'parse', *sys.argv[1:], **{})
cmds = [cmd for cmd in sys.argv[1:] if not cmd.startswith("-")]
if (len(cmds) > 0 and not utils.check_help() and self.default_cmd
and cmds[0] not ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_command'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def check_command(self, **new_attributes):
if not self._is_parsed:
self.parse_args()
if not self.commands:
raise exceptions.ArgParseInatorNoCommandsFound
elif self._single:
func = self._single
else:
if not self.args.command:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'i... | def merge(self):
self.merged_root = self._recursive_merge(self.root, self.head,
self.update)
if self.conflicts:
raise MergeError('Conflicts Occurred in Merge Process',
self.conflicts) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_zadd'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [],... | def _zadd(self, key, pk, ts=None, ttl=None):
return self.r.eval(self.LUA_ZADD, 1, key, ts or self._time(), pk) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def add(self, event, pk, ts=None, ttl=None):
key = self._keygen(event, ts)
try:
self._zadd(key, pk, ts, ttl)
return True
except redis.ConnectionError as e:
self.logger.error(
"redis event store failed with connection error %r" % e)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_parameter'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def add_parameter(self, **kwargs):
'''Add the parameter to ``Parameters``.
**Arguments**
The arguments are lumped into two groups:``Parameters.add_parameter``
and ``argparse.ArgumentParser.add_argument``. Parameters that are only
used by ``Parameters.add_parameter`` are removed ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mysql_pub'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def mysql_pub(mysql_dsn, tables=None, blocking=False, **kwargs):
parsed = urlparse(mysql_dsn)
mysql_settings = {
"host": parsed.hostname,
"port": parsed.port or 3306,
"user": parsed.username,
"passwd": parsed.password
}
stream = pymysqlreplication.BinLogStreamReader(
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_step'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [],... | def do_step(self, values, xy_values,coeff, width):
forces = {k:[] for k,i in enumerate(xy_values)}
for (index1, value1), (index2,value2) in combinations(enumerate(xy_values),2):
f = self.calc_2d_forces(value1[0],value1[1],value2[0],value2[1],width)
if coeff[index1] < coeff[index2... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute_get'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def execute_get(self, resource, **kwargs):
url = '%s/%s' % (self.base_url, resource)
headers = kwargs.pop('headers', dict())
headers['Accept'] = 'application/json'
headers['Content-Type'] = 'application/json'
if kwargs:
separator = '&' if '?' in url else '?'
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'variants'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': ... | def variants(self, case_id, skip=0, count=1000, filters=None):
filters = filters or {}
case_obj = self.case(case_id=case_id)
limit = count + skip
genes = set()
if filters.get('gene_ids'):
genes = set([gene_id.strip() for gene_id in filters['gene_ids']])
freque... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_filtered_variants'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'... | def _get_filtered_variants(self, vcf_file_path, filters={}):
genes = set()
consequences = set()
sv_types = set()
if filters.get('gene_ids'):
genes = set([gene_id.strip() for gene_id in filters['gene_ids']])
if filters.get('consequence'):
consequences = set... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'group'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'iterab... | def group(iterable, key):
for _, grouped in groupby(sorted(iterable, key=key), key=key):
yield list(grouped) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id'... | def run(self):
'''Run the LaTeX compilation.'''
self.old_dir = []
if self.opt.clean:
self.old_dir = os.listdir('.')
cite_counter, toc_file, gloss_files = self._read_latex_files()
self.latex_run()
self.read_glossaries()
gloss_changed = self.makeindex_ru... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'embed_ising'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children'... | def embed_ising(source_linear, source_quadratic, embedding, target_adjacency, chain_strength=1.0):
unused = {v for v in target_adjacency} - set().union(*embedding.values())
target_linear = {v: 0. for v in target_adjacency}
for v, bias in iteritems(source_linear):
try:
chain_variables = e... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fit_richness'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def fit_richness(self, atol=1.e-3, maxiter=50):
if np.isnan(self.u).any():
logger.warning("NaN signal probability found")
return 0., 0., None
if not np.any(self.u):
logger.warning("Signal probability is zero for all objects")
return 0., 0., None
if... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type': 'id... | def make_request(
url, method='GET', query=None, body=None, auth=None, timeout=10,
client=None, macaroons=None):
headers = {}
kwargs = {'timeout': timeout, 'headers': headers}
if body is not None:
if isinstance(body, collections.Mapping):
body = json.dumps(body)
k... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'time_stops'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def time_stops(self):
if not self.supports_time:
return []
if self.service.calendar == 'standard':
units = self.service.time_interval_units
interval = self.service.time_interval
steps = [self.time_start]
if units in ('years', 'decades', 'centur... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_strings'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'childr... | def sort_strings(strings, sort_order=None, reverse=False, case_sensitive=False, sort_order_first=True):
if not case_sensitive:
sort_order = tuple(s.lower() for s in sort_order)
strings = tuple(s.lower() for s in strings)
prefix_len = max(len(s) for s in sort_order)
def compare(a, b, prefix_l... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_field_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10']}; {'id': '4', 'type': 'identifier', 'children': []... | def clean_field_dict(field_dict, cleaner=str.strip, time_zone=None):
r
d = {}
if time_zone is None:
tz = DEFAULT_TZ
for k, v in viewitems(field_dict):
if k == '_state':
continue
if isinstance(v, basestring):
d[k] = cleaner(str(v))
elif isinstance(v... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hist_from_counts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'iden... | def hist_from_counts(counts, normalize=False, cumulative=False, to_str=False, sep=',', min_bin=None, max_bin=None):
counters = [dict((i, c)for i, c in enumerate(counts))]
intkeys_list = [[c for c in counts_dict if (isinstance(c, int) or (isinstance(c, float) and int(c) == c))]
for counts_dic... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '38']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_serial_number'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '16', '21', '24', '27', '30', '33']}; ... | def normalize_serial_number(sn,
max_length=None, left_fill='0', right_fill=str(), blank=str(),
valid_chars=' -0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
invalid_chars=None,
strip_whitesp... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'listify'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def listify(values, N=1, delim=None):
ans = [] if values is None else values
if hasattr(ans, '__iter__') and not isinstance(ans, basestring):
ans = list(ans)
else:
if isinstance(delim, basestring) and isinstance(ans, basestring):
try:
ans = ans.split(delim)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'best_fit'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'li'... | def best_fit(li, value):
index = min(bisect_left(li, value), len(li) - 1)
if index in (0, len(li)):
return index
if li[index] - value < value - li[index-1]:
return index
else:
return index-1 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'proj4_to_epsg'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pro... | def proj4_to_epsg(projection):
def make_definition(value):
return {x.strip().lower() for x in value.split('+') if x}
match = EPSG_RE.search(projection.srs)
if match:
return int(match.group(1))
pyproj_data_dir = os.path.join(os.path.dirname(pyproj.__file__), 'data')
pyproj_epsg_file =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'index_pix_in_pixels'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childr... | def index_pix_in_pixels(pix,pixels,sort=False,outside=-1):
if sort: pixels = np.sort(pixels)
index = np.searchsorted(pixels,pix)
if np.isscalar(index):
if not np.in1d(pix,pixels).any(): index = outside
else:
index[~np.in1d(pix,pixels)] = outside
return index |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'files'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children... | def files(self, entity_id, manifest=None, filename=None,
read_file=False, channel=None):
'''
Get the files or file contents of a file for an entity.
If all files are requested, a dictionary of filenames and urls for the
files in the archive are returned.
If filename... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '33']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27', '30']}; {'id': '4', ... | def search(self, text, includes=None, doc_type=None, limit=None,
autocomplete=False, promulgated_only=False, tags=None,
sort=None, owner=None, series=None):
'''
Search for entities in the charmstore.
@param text The text to search for.
@param includes What m... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier', 'ch... | def list(self, includes=None, doc_type=None, promulgated_only=False,
sort=None, owner=None, series=None):
'''
List entities in the charmstore.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type Filter to this type: bundle or charm.
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_common_query_parameters'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': ... | def _common_query_parameters(self, doc_type, includes, owner,
promulgated_only, series, sort):
'''
Extract common query parameters between search and list into slice.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_one'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def extract_one(self, L, P, R):
yield "*bias*"
if match(QUOTE, L):
L = QUOTE_TOKEN
elif isnumberlike(L):
L = NUMBER_TOKEN
else:
yield "len(L)={}".format(min(len(L), CLIP))
if "." in L:
yield "L:*period*"
if not s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'call'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def call(self, command, **kwargs):
for hook in self._hooks['precall']:
hook(self, command, kwargs)
op = getattr(self.client, command)
attempt = 0
while True:
try:
data = op(**kwargs)
break
except ClientError as e:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_item2'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22', '25']}; {'id': '4', ... | def delete_item2(self, tablename, key, expr_values=None, alias=None,
condition=None, returns=NONE, return_capacity=None,
return_item_collection_metrics=NONE, **kwargs):
keywords = {
'TableName': tablename,
'Key': self.dynamizer.encode_keys(key),
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_item'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14', '17']}; {'id': '4', 'type': 'ident... | def update_item(self, tablename, key, updates, returns=NONE,
return_capacity=None, expect_or=False, **kwargs):
key = self.dynamizer.encode_keys(key)
attr_updates = {}
expected = {}
keywords = {
'ReturnConsumedCapacity': self._default_capacity(return_capaci... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '38']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27', '30', '33', '36']}; {... | def query(self, tablename, attributes=None, consistent=False, count=False,
index=None, limit=None, desc=False, return_capacity=None,
filter=None, filter_or=False, exclusive_start_key=None, **kwargs):
keywords = {
'TableName': tablename,
'ReturnConsumedCapacity... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'letter_scales'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cou... | def letter_scales(counts):
try:
scale = 1.0 / sum(counts.values())
except ZeroDivisionError:
return []
freqs = [(aa, cnt*scale) for aa, cnt in counts.iteritems() if cnt]
freqs.sort(key=lambda pair: pair[1])
return freqs |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count_diffs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12']}; {'id': '4', 'type': 'identifier',... | def count_diffs(align, feats, inseq, locus, cutoff,
verbose=False, verbosity=0):
nfeats = len(feats.keys())
mm = 0
insr = 0
dels = 0
gaps = 0
match = 0
lastb = ''
l = len(align[0]) if len(align[0]) > len(align[1]) else len(align[1])
for i in range(0, l):
if al... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd_debug'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def cmd_debug(self, argv, help):
parser = argparse.ArgumentParser(
prog="%s debug" % self.progname,
description=help,
)
instances = self.instances
parser.add_argument("instance", nargs=1,
metavar="instance",
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd_ssh'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def cmd_ssh(self, argv, help):
parser = argparse.ArgumentParser(
prog="%s ssh" % self.progname,
description=help,
)
instances = self.get_instances(command='init_ssh_key')
parser.add_argument("instance", nargs=1,
metavar="instance",
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_alignment'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | def add_alignment(self, ref_seq, annotation) -> Annotation:
seq_features = get_seqs(ref_seq)
annoated_align = {}
allele = ref_seq.description.split(",")[0]
locus = allele.split("*")[0].split("-")[1]
for feat in seq_features:
if feat in annotation.annotation:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_tree'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children'... | def build_tree(self, data, tagname, attrs=None, depth=0):
r
if data is None:
data = ''
indent = ('\n%s' % (self.__options['indent'] * depth)) if self.__options['indent'] else ''
if isinstance(data, utils.DictTypes):
if self.__options['hasattr'] and self.check_stru... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_remind'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def _parse_remind(self, filename, lines=''):
files = {}
reminders = {}
if lines:
filename = '-'
files[filename] = lines
reminders[filename] = {}
cmd = ['remind', '-l', '-s%d' % self._month, '-b1', '-y', '-r',
filename, str(self._startdat... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_remind_line'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | def _parse_remind_line(self, line, text):
event = {}
line = line.split(None, 6)
dat = [int(f) for f in line[0].split('/')]
if line[4] != '*':
start = divmod(int(line[4]), 60)
event['dtstart'] = [datetime(dat[0], dat[1], dat[2], start[0], start[1], tzinfo=self._loc... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_gen_vevent'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def _gen_vevent(self, event, vevent):
vevent.add('dtstart').value = event['dtstart'][0]
vevent.add('dtstamp').value = datetime.fromtimestamp(self._mtime)
vevent.add('summary').value = event['msg']
vevent.add('uid').value = event['uid']
if 'class' in event:
vevent.add(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_remind'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24']}; {'id': '4', 'type': '... | def to_remind(self, vevent, label=None, priority=None, tags=None, tail=None,
sep=" ", postdate=None, posttime=None):
remind = ['REM']
trigdates = None
if hasattr(vevent, 'rrule'):
trigdates = Remind._parse_rruleset(vevent.rruleset)
dtstart = vevent.dtstart.v... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'module_name_from_path'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def module_name_from_path(folder_name, verbose=False):
folder_name = folder_name.split('.pyc')[0]
folder_name = folder_name.split('.py')[0]
folder_name = os.path.normpath(folder_name)
path = folder_name + '/'
package = get_python_package(path)
module = []
if verbose:
print(('folder_n... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '30', '47', '61', '75'... | def main():
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--file",
required=True,
help="input file",
type=str)
parser.add_argument("-l", "--locus",
required=True,
help="Loc... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_push_subtree'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def _push_subtree(self, leaves: List[bytes]):
size = len(leaves)
if count_bits_set(size) != 1:
raise ValueError("invalid subtree with size != 2^k: %s" % size)
subtree_h, mintree_h = lowest_bit_set(size), self.__mintree_height
if mintree_h > 0 and subtree_h > mintree_h:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'blocks'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def blocks(aln, threshold=0.5, weights=None):
assert len(aln)
if weights == False:
def pct_nongaps(col):
return 1 - (float(col.count('-')) / len(col))
else:
if weights in (None, True):
weights = sequence_weights(aln, 'avg1')
def pct_nongaps(col):
a... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sequence_weights'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [],... | def sequence_weights(aln, scaling='none', gap_chars='-.'):
expectk = [0.0, 1.0, 1.953, 2.861, 3.705, 4.524, 5.304, 6.026, 6.724, 7.397,
8.04, 8.622, 9.191, 9.739, 10.264, 10.758, 11.194, 11.635,
12.049, 12.468, 12.806, 13.185, 13.539, 13.863, 14.177, 14.466,
14.737, 15.0... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_and_append'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def load_and_append(instrument_dict, instruments=None, raise_errors=False):
if instruments is None:
instruments = {}
updated_instruments = {}
updated_instruments.update(instruments)
loaded_failed = {}
for instrument_name, instrument_class_name in instrument_dict.items... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_scan_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children... | def _scan_nodes(nodelist, context, instance_types, current_block=None, ignore_blocks=None):
results = []
for node in nodelist:
if isinstance(node, instance_types):
results.append(node)
elif isinstance(node, IncludeNode):
if node.template:
if not callable(g... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_command'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'comma... | def run_command(commands):
use_shell = False
subprocess_flags = 0
startupinfo = None
if sysstr == 'Windows':
if isinstance(commands, list):
commands = ' '.join(str(c) for c in commands)
import ctypes
SEM_NOGPFAULTERRORBOX = 0x0002
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'intersect_keys'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': ... | def intersect_keys(keys, reffile, cache=False, clean_accs=False):
index = None
if cache:
refcache = reffile + '.sqlite'
if os.path.exists(refcache):
if os.stat(refcache).st_mtime < os.stat(reffile).st_mtime:
logging.warn("Outdated cache; rebuilding index")
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'family_check'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | def family_check(self):
self.logger.info("Checking family relations for {0}".format(
self.family_id)
)
for individual_id in self.individuals:
self.logger.debug("Checking individual {0}".format(individual_id))
individual = self.individuals[individual_id]
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_ped'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | def to_ped(self, outfile=None):
ped_header = [
'
'IndividualID',
'PaternalID',
'MaternalID',
'Sex',
'Phenotype',
]
extra_headers = [
'InheritanceModel',
'Proband',
'Consultand',
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refresh_instruments'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def refresh_instruments(self):
def list_access_nested_dict(dict, somelist):
return reduce(operator.getitem, somelist, dict)
def update(item):
if item.isExpanded():
for index in range(item.childCount()):
child = item.child(index)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def post(self, endpoint, data, parallelism=5):
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"x-standardize-only": "true" if self.standardize else "false",
"x-include-invalid": "true" if self.invalid else "false",
"x-acc... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_contents_static'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [... | def get_contents_static(self, block_alias, context):
if 'request' not in context:
return ''
current_url = context['request'].path
try:
resolver_match = resolve(current_url)
namespace = ''
if resolver_match.namespaces:
namespace = re... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'files_to_pif'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [... | def files_to_pif(files, verbose=0, quality_report=True, inline=True):
'''Given a directory that contains output from
a DFT calculation, parse the data and return
a pif object
Input:
files - [str] list of files from which the parser is allowed to read.
verbose - int, How much status messa... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_cards'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def _sort_cards(self, cards: Generator) -> list:
'''sort cards by blocknum and blockseq'''
return sorted([card.__dict__ for card in cards],
key=itemgetter('blocknum', 'blockseq', 'cardseq')) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_label'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def _get_label(self):
'''Find the label for the output files
for this calculation
'''
if self._label is None:
foundfiles = False
for f in self._files:
if ".files" in f:
foundfiles = True
self._label = f.sp... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_estimate_progress'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def _estimate_progress(self):
estimate = True
current_subscript = self._current_subscript_stage['current_subscript']
num_subscripts = len(self.scripts)
if self.iterator_type == 'loop':
num_iterations = self.settings['num_loops']
elif self.iterator_type == 'sweep':
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_default_settings'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childr... | def get_default_settings(sub_scripts, script_order, script_execution_freq, iterator_type):
def populate_sweep_param(scripts, parameter_list, trace=''):
'''
Args:
scripts: a dict of {'class name': <class object>} pairs
Returns: A list of all parameters of the i... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'consensus'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children'... | def consensus(aln, weights=None, gap_threshold=0.5, simple=False, trim_ends=True):
if simple:
col_consensus = make_simple_col_consensus(alnutils.aa_frequencies(aln))
def is_majority_gap(col):
return (float(col.count('-')) / len(col) >= gap_threshold)
else:
if weights is None:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_simple_col_consensus'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def make_simple_col_consensus(bg_freqs):
def col_consensus(col, prev_col=[], prev_char=[]):
aa_counts = sequtils.aa_frequencies(col)
assert aa_counts, "Column is all gaps! That's not allowed."
best_char, best_score = max(aa_counts.iteritems(),
key=lambda k... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'supported'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'aln'}, ... | def supported(aln):
def col_consensus(columns):
for col in columns:
if (
(col.count('-') >= len(col)/2) or
all(c.islower() for c in col if c not in '.-')
):
yield '-'
continue
if any(c.islower() for c in ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_aliases'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def sort_aliases(self, aliases):
self._cache_init()
if not aliases:
return aliases
parent_aliases = self._cache_get_entry(self.CACHE_NAME_PARENTS).keys()
return [parent_alias for parent_alias in parent_aliases if parent_alias in aliases] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_and_append'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def load_and_append(probe_dict, probes, instruments={}):
loaded_failed = {}
updated_probes = {}
updated_probes.update(probes)
updated_instruments = {}
updated_instruments.update(instruments)
new_instruments = list(set(probe_dict.keys())-set(probes.keys()))
if new_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_line'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children':... | def _get_line(self, search_string, search_file, return_string=True, case_sens=True):
'''Return the first line containing a set of strings in a file.
If return_string is False, we just return whether such a line
was found. If case_sens is False, the search is case
insensitive.
'''... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'action_remove'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def action_remove(cls, request, category_list):
if not category_list.editor.allow_remove:
raise SitecatsSecurityException(
'`action_remove()` is not supported by parent `%s`category.' % category_list.alias)
category_id = int(request.POST.get('category_id', 0))
if not ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'action_add'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def action_add(cls, request, category_list):
if not category_list.editor.allow_add:
raise SitecatsSecurityException('`action_add()` is not supported by `%s` category.' % category_list.alias)
titles = request.POST.get('category_title', '').strip()
if not titles:
raise Site... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | async def verify(self, headers: Mapping, method=None, path=None):
if not 'authorization' in headers:
return False
auth_type, auth_params = parse_authorization_header(headers['authorization'])
if auth_type.lower() != 'signature':
return False
for param in ('algorit... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_config'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def set_config(self, **config):
reinit = False
if 'stdopt' in config:
stdopt = config.pop('stdopt')
reinit = (stdopt != self.stdopt)
self.stdopt = stdopt
if 'attachopt' in config:
attachopt = config.pop('attachopt')
reinit = reinit or (... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'preview'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def preview(self, stream=sys.stdout):
write = stream.write
write(('[Quick preview of Docpie %s]' % self._version).center(80, '='))
write('\n')
write(' sections '.center(80, '-'))
write('\n')
write(self.usage_text)
write('\n')
option_sections = self.option_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parts'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'i... | def parts(self):
parts = []
upserts = dict()
deletes = []
max_upload_size = 700000
base_part_size = 118
if not self.replace_all:
base_part_size += 1
part_size = base_part_size
for value in self.upserts:
if (part_size + self.upserts_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compare_versions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def compare_versions(version_a, version_b):
logger.debug('compare_versions(%s, %s)', version_a, version_b)
if version_a == version_b:
return a_eq_b
try:
chars_a, chars_b = list(version_a), list(version_b)
except TypeError:
raise RpmError('Could not compare {0} to '
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_compare_blocks'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def _compare_blocks(block_a, block_b):
logger.debug('_compare_blocks(%s, %s)', block_a, block_b)
if block_a[0].isdigit():
_trim_zeros(block_a, block_b)
if len(block_a) != len(block_b):
logger.debug('block lengths are not equal')
return a_newer if len(block_a) > len(block_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Find'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def Find(self, node_type, item_type):
'''
method for finding specific types of notation from nodes.
will currently return the first one it encounters because this method's only really intended
for some types of notation for which the exact value doesn't really
matter.
:pa... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'SplitString'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value... | def SplitString(value):
string_length = len(value)
chunks = int(string_length / 10)
string_list = list(value)
lstring = ""
if chunks > 1:
lstring = "\\markup { \n\r \column { "
for i in range(int(chunks)):
lstring += "\n\r\r \\line { \""
index = i * 10
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'NumbersToWords'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'nu... | def NumbersToWords(number):
units = [
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine']
tens = [
'ten',
'twenty',
'thirty',
'forty',
'fifty',
'sixty',
'seventy',
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_image'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': 'id... | def _generate_image(self, matrix, width, height, padding, foreground, background, image_format):
image = Image.new("RGBA", (width + padding[2] + padding[3], height + padding[0] + padding[1]), background)
draw = ImageDraw.Draw(image)
block_width = width // self.columns
block_height = heig... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'alignment_to_reads'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'c... | def alignment_to_reads(
sam_merged,
output_dir,
parameters=DEFAULT_PARAMETERS,
save_memory=True,
*bin_fasta
):
def get_file_string(file_thing):
try:
file_string = file_thing.name
except AttributeError:
file_string = str(file_thing)
return file_stri... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_config'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def _validate_config(config):
if not isinstance(config, list):
raise TypeError('Config must be a list')
for config_dict in config:
if not isinstance(config_dict, dict):
raise TypeError('Config must be a list of dictionaries')
label = config_dict.keys()... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'taskinfo'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ... | def taskinfo(self):
task_input = {'taskName': 'QueryTask',
'inputParameters': {"Task_Name": self._name}}
info = taskengine.execute(task_input, self._engine, cwd=self._cwd)
task_def = info['outputParameters']['DEFINITION']
task_def['name'] = str(task_def.pop('NAME'))... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distance_diagonal_law'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def distance_diagonal_law(matrix, positions=None):
n = min(matrix.shape)
if positions is None:
return np.array([np.average(np.diagonal(matrix, j)) for j in range(n)])
else:
contigs = positions_to_contigs(positions)
def is_intra(i, j):
return contigs[i] == contigs[j]
max_intra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.