_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q39000 | SeqPrep._get_result_paths | train | def _get_result_paths(self, data):
"""Captures SeqPrep output.
"""
result = {}
# Always output:
result['UnassembledReads1'] = ResultPath(Path=
self._unassembled_reads1_out_file_name(
... | python | {
"resource": ""
} |
q39001 | get_files_for_document | train | def get_files_for_document(document):
"""
Returns the available files for all languages.
In case the file is already present in another language, it does not re-add
it again.
"""
files = []
for doc_trans in document.translations.all():
if doc_trans.filer_file is not None and \
... | python | {
"resource": ""
} |
q39002 | get_frontpage_documents | train | def get_frontpage_documents(context):
"""Returns the library favs that should be shown on the front page."""
req = context.get('request')
qs = Document.objects.published(req).filter(is_on_front_page=True)
return qs | python | {
"resource": ""
} |
q39003 | authenticate_connection | train | def authenticate_connection(username, password, db=None):
"""
Authenticates the current database connection with the passed username
and password. If the database connection uses all default parameters,
this can be called without connect_to_database. Otherwise, it should
be preceded by a connect_t... | python | {
"resource": ""
} |
q39004 | add_user | train | def add_user(name, password=None, read_only=None, db=None, **kwargs):
"""
Adds a user that can be used for authentication.
@param name: the name of the user to create
@param passowrd: the password of the user to create. Can not be used with
the userSource argument.
@param read_only: if ... | python | {
"resource": ""
} |
q39005 | add_superuser | train | def add_superuser(name, password, **kwargs):
"""
Adds a user with userAdminAnyDatabase role to mongo.
@param name: the name of the user to create
@param passowrd: the password of the user to create. Can not be used with
the userSource argument.
@param **kwargs: forwarded to pymongo.data... | python | {
"resource": ""
} |
q39006 | list_database | train | def list_database(db=None):
"""
Lists the names of either the databases on the machine or the collections
of a particular database
@param db: the database for which to list the collection names;
if db is None, then it lists all databases instead
the contents of the database with the... | python | {
"resource": ""
} |
q39007 | MongoConnection.authenticate | train | def authenticate(self, username, password, db=None):
""" Authenticates the MongoClient with the passed username and password """
if db is None:
return self.get_connection().admin.authenticate(username, password)
return self.get_connection()[db].authenticate(username, password) | python | {
"resource": ""
} |
q39008 | MongoConnection.add_user | train | def add_user(self, name, password=None, read_only=None, db=None, **kwargs):
""" Adds a user that can be used for authentication """
if db is None:
return self.get_connection().admin.add_user(
name, password=password, read_only=read_only, **kwargs)
return self.get_... | python | {
"resource": ""
} |
q39009 | MetriqueContainer._add_variants | train | def _add_variants(self, key, value, schema):
''' also possible to define some function that takes
current value and creates a new value from it
'''
variants = schema.get('variants')
obj = {}
if variants:
for _key, func in variants.iteritems():
... | python | {
"resource": ""
} |
q39010 | MetriqueContainer._type_container | train | def _type_container(self, value, _type):
' apply type to all values in the list '
if value is None:
# normalize null containers to empty list
return []
elif not isinstance(value, list):
raise ValueError("expected list type, got: %s" % type(value))
else... | python | {
"resource": ""
} |
q39011 | MetriqueContainer._type_single | train | def _type_single(self, value, _type):
' apply type to the single value '
if value is None or _type in (None, NoneType):
# don't convert null values
# default type is the original type if none set
pass
elif isinstance(value, _type): # or values already of corr... | python | {
"resource": ""
} |
q39012 | MetriqueContainer.flush | train | def flush(self, objects=None, batch_size=None, **kwargs):
''' flush objects stored in self.container or those passed in'''
batch_size = batch_size or self.config.get('batch_size')
# if we're flushing these from self.store, we'll want to
# pop them later.
if objects:
f... | python | {
"resource": ""
} |
q39013 | build_database_sortmerna | train | def build_database_sortmerna(fasta_path,
max_pos=None,
output_dir=None,
temp_dir=tempfile.gettempdir(),
HALT_EXEC=False):
""" Build sortmerna db from fasta_path; return db name
and list of fil... | python | {
"resource": ""
} |
q39014 | sortmerna_ref_cluster | train | def sortmerna_ref_cluster(seq_path=None,
sortmerna_db=None,
refseqs_fp=None,
result_path=None,
tabular=False,
max_e_value=1,
similarity=0.97,
... | python | {
"resource": ""
} |
q39015 | sortmerna_map | train | def sortmerna_map(seq_path,
output_dir,
refseqs_fp,
sortmerna_db,
e_value=1,
threads=1,
best=None,
num_alignments=None,
HALT_EXEC=False,
output_sam=False,
... | python | {
"resource": ""
} |
q39016 | Plotter.get_color | train | def get_color(self, color):
'''
Returns a color to use.
:param integer/string color:
Color for the plot. Can be an index for the color from COLORS
or a key(string) from CNAMES.
'''
if color is None:
color = self.counter
if isinstance(c... | python | {
"resource": ""
} |
q39017 | Plotter.plot | train | def plot(self, series, label='', color=None, style=None):
'''
Wrapper around plot.
:param pandas.Series series:
The series to be plotted, all values must be positive if stacked
is True.
:param string label:
The label for the series.
:param int... | python | {
"resource": ""
} |
q39018 | Plotter.plots | train | def plots(self, series_list, label_list, colors=None):
'''
Plots all the series from the list.
The assumption is that all of the series share the same index.
:param list series_list:
A list of series which should be plotted
:param list label_list:
A list ... | python | {
"resource": ""
} |
q39019 | Plotter.lines | train | def lines(self, lines_dict, y='bottom', color='grey', **kwargs):
'''
Creates vertical lines in the plot.
:param lines_dict:
A dictionary of label, x-coordinate pairs.
:param y:
May be 'top', 'bottom' or int.
The y coordinate of the text-labels.
... | python | {
"resource": ""
} |
q39020 | DocumentManager.published | train | def published(self, request=None):
"""
Returns the published documents in the current language.
:param request: A Request instance.
"""
language = getattr(request, 'LANGUAGE_CODE', get_language())
if not language:
return self.model.objects.none()
qs... | python | {
"resource": ""
} |
q39021 | Module._format | train | def _format(self):
"""Format search queries to perform in bulk.
Build up the URLs to call for the search engine. These will be ran
through a bulk processor and returned to a detailer.
"""
self.log.debug("Formatting URLs to request")
items = list()
for i in range(... | python | {
"resource": ""
} |
q39022 | Module._process | train | def _process(self, responses):
"""Process search engine results for detailed analysis.
Search engine result pages (SERPs) come back with each request and will
need to be extracted in order to crawl the actual hits.
"""
self.log.debug("Processing search results")
items = ... | python | {
"resource": ""
} |
q39023 | Module._fetch | train | def _fetch(self, urls):
"""Perform bulk collection of data and return the content.
Gathering responses is handled by the base class and uses futures to
speed up the processing. Response data is saved inside a local variable
to be used later in extraction.
"""
responses =... | python | {
"resource": ""
} |
q39024 | Module._extract | train | def _extract(self):
"""Extract email addresses from results.
Text content from all crawled pages are ran through a simple email
extractor. Data is cleaned prior to running pattern expressions.
"""
self.log.debug("Extracting emails from text content")
for item in self.dat... | python | {
"resource": ""
} |
q39025 | Module.search | train | def search(self):
"""Run the full search process.
Simple public method to abstract the steps needed to produce a full
search using the engine.
"""
requests = self._format()
serps = self._fetch(requests)
urls = self._process(serps)
details = self._fetch(ur... | python | {
"resource": ""
} |
q39026 | cmdline_generator | train | def cmdline_generator(param_iter, PathToBin=None, PathToCmd=None,
PathsToInputs=None, PathToOutput=None,
PathToStderr='/dev/null', PathToStdout='/dev/null',
UniqueOutputs=False, InputParam=None,
OutputParam=None):
"""Generates c... | python | {
"resource": ""
} |
q39027 | get_tmp_filename | train | def get_tmp_filename(tmp_dir=gettempdir(), prefix="tmp", suffix=".txt",
result_constructor=FilePath):
""" Generate a temporary filename and return as a FilePath object
tmp_dir: the directory to house the tmp_filename
prefix: string to append to beginning of filename
... | python | {
"resource": ""
} |
q39028 | guess_input_handler | train | def guess_input_handler(seqs, add_seq_names=False):
"""Returns the name of the input handler for seqs."""
if isinstance(seqs, str):
if '\n' in seqs: # can't be a filename...
return '_input_as_multiline_string'
else: # assume it was a filename
return '_input_as_string'
... | python | {
"resource": ""
} |
q39029 | CommandLineAppResult.cleanUp | train | def cleanUp(self):
""" Delete files that are written by CommandLineApplication from disk
WARNING: after cleanUp() you may still have access to part of
your result data, but you should be aware that if the file
size exceeds the size of the buffer you will only have pa... | python | {
"resource": ""
} |
q39030 | CommandLineApplication._input_as_lines | train | def _input_as_lines(self, data):
""" Write a seq of lines to a temp file and return the filename string
data: a sequence to be written to a file, each element of the
sequence will compose a line in the file
* Note: the result will be the filename as a FilePath object
... | python | {
"resource": ""
} |
q39031 | CommandLineApplication._input_as_paths | train | def _input_as_paths(self, data):
""" Return data as a space delimited string with each path quoted
data: paths or filenames, most likely as a list of
strings
"""
return self._command_delimiter.join(
map(str, map(self._input_as_path, data))) | python | {
"resource": ""
} |
q39032 | CommandLineApplication._absolute | train | def _absolute(self, path):
""" Convert a filename to an absolute path """
path = FilePath(path)
if isabs(path):
return path
else:
# these are both Path objects, so joining with + is acceptable
return self.WorkingDir + path | python | {
"resource": ""
} |
q39033 | CommandLineApplication.getTmpFilename | train | def getTmpFilename(self, tmp_dir=None, prefix='tmp', suffix='.txt',
include_class_id=False, result_constructor=FilePath):
""" Return a temp filename
tmp_dir: directory where temporary files will be stored
prefix: text to append to start of file name
su... | python | {
"resource": ""
} |
q39034 | get_accent_char | train | def get_accent_char(char):
"""
Get the accent of an single char, if any.
"""
index = utils.VOWELS.find(char.lower())
if (index != -1):
return 5 - index % 6
else:
return Accent.NONE | python | {
"resource": ""
} |
q39035 | get_accent_string | train | def get_accent_string(string):
"""
Get the first accent from the right of a string.
"""
accents = list(filter(lambda accent: accent != Accent.NONE,
map(get_accent_char, string)))
return accents[-1] if accents else Accent.NONE | python | {
"resource": ""
} |
q39036 | add_accent_char | train | def add_accent_char(char, accent):
"""
Add accent to a single char. Parameter accent is member of class
Accent
"""
if char == "":
return ""
case = char.isupper()
char = char.lower()
index = utils.VOWELS.find(char)
if (index != -1):
index = index - index % 6 + 5
... | python | {
"resource": ""
} |
q39037 | remove_accent_string | train | def remove_accent_string(string):
"""
Remove all accent from a whole string.
"""
return utils.join([add_accent_char(c, Accent.NONE) for c in string]) | python | {
"resource": ""
} |
q39038 | assign_taxonomy | train | def assign_taxonomy(
data, min_confidence=0.80, output_fp=None, training_data_fp=None,
fixrank=True, max_memory=None, tmp_dir=tempfile.gettempdir()):
"""Assign taxonomy to each sequence in data with the RDP classifier
data: open fasta file object or list of fasta lines
confidence: m... | python | {
"resource": ""
} |
q39039 | train_rdp_classifier | train | def train_rdp_classifier(
training_seqs_file, taxonomy_file, model_output_dir, max_memory=None,
tmp_dir=tempfile.gettempdir()):
""" Train RDP Classifier, saving to model_output_dir
training_seqs_file, taxonomy_file: file-like objects used to
train the RDP Classifier (see RdpTrai... | python | {
"resource": ""
} |
q39040 | train_rdp_classifier_and_assign_taxonomy | train | def train_rdp_classifier_and_assign_taxonomy(
training_seqs_file, taxonomy_file, seqs_to_classify, min_confidence=0.80,
model_output_dir=None, classification_output_fp=None, max_memory=None,
tmp_dir=tempfile.gettempdir()):
""" Train RDP Classifier and assign taxonomy in one fell swoop
T... | python | {
"resource": ""
} |
q39041 | parse_rdp_assignment | train | def parse_rdp_assignment(line):
"""Returns a list of assigned taxa from an RDP classification line
"""
toks = line.strip().split('\t')
seq_id = toks.pop(0)
direction = toks.pop(0)
if ((len(toks) % 3) != 0):
raise ValueError(
"Expected assignments in a repeating series of (ran... | python | {
"resource": ""
} |
q39042 | RdpClassifier._get_jar_fp | train | def _get_jar_fp(self):
"""Returns the full path to the JAR file.
If the JAR file cannot be found in the current directory and
the environment variable RDP_JAR_PATH is not set, returns
None.
"""
# handles case where the jar file is in the current working directory
... | python | {
"resource": ""
} |
q39043 | RdpClassifier._commandline_join | train | def _commandline_join(self, tokens):
"""Formats a list of tokens as a shell command
This seems to be a repeated pattern; may be useful in
superclass.
"""
commands = filter(None, map(str, tokens))
return self._command_delimiter.join(commands).strip() | python | {
"resource": ""
} |
q39044 | RdpClassifier._get_result_paths | train | def _get_result_paths(self, data):
""" Return a dict of ResultPath objects representing all possible output
"""
assignment_fp = str(self.Parameters['-o'].Value).strip('"')
if not os.path.isabs(assignment_fp):
assignment_fp = os.path.relpath(assignment_fp, self.WorkingDir)
... | python | {
"resource": ""
} |
q39045 | RdpTrainer.ModelDir | train | def ModelDir(self):
"""Absolute FilePath to the training output directory.
"""
model_dir = self.Parameters['model_output_dir'].Value
absolute_model_dir = os.path.abspath(model_dir)
return FilePath(absolute_model_dir) | python | {
"resource": ""
} |
q39046 | RdpTrainer._input_handler_decorator | train | def _input_handler_decorator(self, data):
"""Adds positional parameters to selected input_handler's results.
"""
input_handler = getattr(self, self.__InputHandler)
input_parts = [
self.Parameters['taxonomy_file'],
input_handler(data),
self.Parameters['... | python | {
"resource": ""
} |
q39047 | RdpTrainer._get_result_paths | train | def _get_result_paths(self, output_dir):
"""Return a dict of output files.
"""
# Only include the properties file here. Add the other result
# paths in the __call__ method, so we can catch errors if an
# output file is not written.
self._write_properties_file()
pr... | python | {
"resource": ""
} |
q39048 | RdpTrainer._write_properties_file | train | def _write_properties_file(self):
"""Write an RDP training properties file manually.
"""
# The properties file specifies the names of the files in the
# training directory. We use the example properties file
# directly from the rdp_classifier distribution, which lists
# ... | python | {
"resource": ""
} |
q39049 | InfobloxHost.delete_old_host | train | def delete_old_host(self, hostname):
"""Remove all records for the host.
:param str hostname: Hostname to remove
:rtype: bool
"""
host = Host(self.session, name=hostname)
return host.delete() | python | {
"resource": ""
} |
q39050 | InfobloxHost.add_new_host | train | def add_new_host(self, hostname, ipv4addr, comment=None):
"""Add or update a host in the infoblox, overwriting any IP address
entries.
:param str hostname: Hostname to add/set
:param str ipv4addr: IP Address to add/set
:param str comment: The comment for the record
"""
... | python | {
"resource": ""
} |
q39051 | Mafft._input_as_seqs | train | def _input_as_seqs(self, data):
"""Format a list of seq as input.
Parameters
----------
data: list of strings
Each string is a sequence to be aligned.
Returns
-------
A temp file name that contains the sequences.
See Also
--------
... | python | {
"resource": ""
} |
q39052 | Segmenter.from_config | train | def from_config(cls, config, name, section_key="segmenters"):
"""
Constructs a segmenter from a configuration doc.
"""
section = config[section_key][name]
segmenter_class_path = section['class']
Segmenter = yamlconf.import_module(segmenter_class_path)
return Segme... | python | {
"resource": ""
} |
q39053 | random_hex | train | def random_hex(length):
"""Generates a random hex string"""
return escape.to_unicode(binascii.hexlify(os.urandom(length))[length:]) | python | {
"resource": ""
} |
q39054 | password_hash | train | def password_hash(password, password_salt=None):
"""Hashes a specified password"""
password_salt = password_salt or oz.settings["session_salt"]
salted_password = password_salt + password
return "sha256!%s" % hashlib.sha256(salted_password.encode("utf-8")).hexdigest() | python | {
"resource": ""
} |
q39055 | bisect | train | def bisect(func, a, b, xtol=1e-12, maxiter=100):
"""
Finds the root of `func` using the bisection method.
Requirements
------------
- func must be continuous function that accepts a single number input
and returns a single number
- `func(a)` and `func(b)` must have opposite sign
Para... | python | {
"resource": ""
} |
q39056 | ResourceURL.parse_string | train | def parse_string(s):
'''
Parses a foreign resource URL into the URL string itself and any
relevant args and kwargs
'''
matched_obj = SPLIT_URL_RE.match(s)
if not matched_obj:
raise URLParseException('Invalid Resource URL: "%s"' % s)
url_string, argume... | python | {
"resource": ""
} |
q39057 | add_experiment_choice | train | def add_experiment_choice(experiment, choice):
"""Adds an experiment choice"""
redis = oz.redis.create_connection()
oz.bandit.Experiment(redis, experiment).add_choice(choice) | python | {
"resource": ""
} |
q39058 | remove_experiment_choice | train | def remove_experiment_choice(experiment, choice):
"""Removes an experiment choice"""
redis = oz.redis.create_connection()
oz.bandit.Experiment(redis, experiment).remove_choice(choice) | python | {
"resource": ""
} |
q39059 | get_experiment_results | train | def get_experiment_results():
"""
Computes the results of all experiments, stores it in redis, and prints it
out
"""
redis = oz.redis.create_connection()
for experiment in oz.bandit.get_experiments(redis):
experiment.compute_default_choice()
csq, confident = experiment.confiden... | python | {
"resource": ""
} |
q39060 | sync_experiments_from_spec | train | def sync_experiments_from_spec(filename):
"""
Takes the path to a JSON file declaring experiment specifications, and
modifies the experiments stored in redis to match the spec.
A spec looks like this:
{
"experiment 1": ["choice 1", "choice 2", "choice 3"],
"experiment 2": ["choice 1",... | python | {
"resource": ""
} |
q39061 | Report.add_chapter | train | def add_chapter(self, title):
'''
Adds a new chapter to the report.
:param str title: Title of the chapter.
'''
chap_id = 'chap%s' % self.chap_counter
self.chap_counter += 1
self.sidebar += '<a href="#%s" class="list-group-item">%s</a>\n' % (
chap_id,... | python | {
"resource": ""
} |
q39062 | Report.write_report | train | def write_report(self, force=False):
'''
Writes the report to a file.
'''
path = self.title + '.html'
value = self._template.format(
title=self.title, body=self.body, sidebar=self.sidebar)
write_file(path, value, force=force)
plt.ion() | python | {
"resource": ""
} |
q39063 | diff | train | def diff(a, b):
"""
Performs a longest common substring diff.
:Parameters:
a : sequence of `comparable`
Initial sequence
b : sequence of `comparable`
Changed sequence
:Returns:
An `iterable` of operations.
"""
a, b = list(a), list(b)
opcodes ... | python | {
"resource": ""
} |
q39064 | convert_endpoint | train | async def convert_endpoint(url_string, ts, is_just_checking):
'''
Main logic for HTTP endpoint.
'''
response = singletons.server.response
# Prep ForeignResource and ensure does not validate security settings
singletons.settings
foreign_res = ForeignResource(url_string)
target_ts = Type... | python | {
"resource": ""
} |
q39065 | apply_command_list_template | train | def apply_command_list_template(command_list, in_path, out_path, args):
'''
Perform necessary substitutions on a command list to create a CLI-ready
list to launch a conversion or download process via system binary.
'''
replacements = {
'$IN': in_path,
'$OUT': out_path,
}
# A... | python | {
"resource": ""
} |
q39066 | convert_local | train | async def convert_local(path, to_type):
'''
Given an absolute path to a local file, convert to a given to_type
'''
# Now find path between types
typed_foreign_res = TypedLocalResource(path)
original_ts = typed_foreign_res.typestring
conversion_path = singletons.converter_graph.find_path(
... | python | {
"resource": ""
} |
q39067 | enqueue_conversion_path | train | def enqueue_conversion_path(url_string, to_type, enqueue_convert):
'''
Given a URL string that has already been downloaded, enqueue
necessary conversion to get to target type
'''
target_ts = TypeString(to_type)
foreign_res = ForeignResource(url_string)
# Determine the file type of the forei... | python | {
"resource": ""
} |
q39068 | check_path | train | def check_path(path, otherwise):
"""
Checks if a path exists. If it does, print a warning message; if not,
execute the `otherwise` callback argument.
"""
if os.path.exists(path):
print("WARNING: Path '%s' already exists; skipping" % path)
else:
otherwise(path) | python | {
"resource": ""
} |
q39069 | config_maker | train | def config_maker(project_name, path):
"""Creates a config file based on the project name"""
with open(skeleton_path("config.py"), "r") as config_source:
config_content = config_source.read()
config_content = config_content.replace("__PROJECT_NAME__", project_name)
with open(path, "w") as conf... | python | {
"resource": ""
} |
q39070 | skeleton_path | train | def skeleton_path(parts):
"""Gets the path to a skeleton asset"""
return os.path.join(os.path.dirname(oz.__file__), "skeleton", parts) | python | {
"resource": ""
} |
q39071 | server | train | def server():
"""Runs the server"""
tornado.log.enable_pretty_logging()
# Get and validate the server_type
server_type = oz.settings["server_type"]
if server_type not in [None, "wsgi", "asyncio", "twisted"]:
raise Exception("Unknown server type: %s" % server_type)
# Install the correc... | python | {
"resource": ""
} |
q39072 | repl | train | def repl():
"""Runs an IPython repl with some context"""
try:
import IPython
except:
print("ERROR: IPython is not installed. Please install it to use the repl.", file=sys.stderr)
raise
IPython.embed(user_ns=dict(
settings=oz.settings,
actions=oz._actions,
... | python | {
"resource": ""
} |
q39073 | ResolverGraph.find_resource_url_basename | train | def find_resource_url_basename(self, resource_url):
'''
Figure out path basename for given resource_url
'''
scheme = resource_url.parsed.scheme
if scheme in ('http', 'https', 'file'):
return _get_basename_based_on_url(resource_url)
elif scheme in ('git', 'git... | python | {
"resource": ""
} |
q39074 | ResolverGraph.find_destination_type | train | def find_destination_type(self, resource_url):
'''
Given a resource_url, figure out what it would resolve into
'''
resolvers = self.converters.values()
for resolver in resolvers:
# Not all resolvers are opinionated about destination types
if not hasattr(re... | python | {
"resource": ""
} |
q39075 | ResolverGraph.download | train | async def download(self, resource_url):
'''
Download given Resource URL by finding path through graph and applying
each step
'''
resolver_path = self.find_path_from_url(resource_url)
await self.apply_resolver_path(resource_url, resolver_path) | python | {
"resource": ""
} |
q39076 | insert_sequences_into_tree | train | def insert_sequences_into_tree(aln, moltype, params={}):
"""Returns a tree from placement of sequences
"""
# convert aln to phy since seq_names need fixed to run through parsinsert
new_aln=get_align_for_phylip(StringIO(aln))
# convert aln to fasta in case it is not already a fasta file
aln2 = A... | python | {
"resource": ""
} |
q39077 | ParsInsert._get_result_paths | train | def _get_result_paths(self,data):
""" Get the resulting tree"""
result = {}
result['Tree'] = ResultPath(Path=splitext(self._input_filename)[0] + \
'.tree')
return result | python | {
"resource": ""
} |
q39078 | download | train | async def download(resource_url):
'''
Download given resource_url
'''
scheme = resource_url.parsed.scheme
if scheme in ('http', 'https'):
await download_http(resource_url)
elif scheme in ('git', 'git+https', 'git+http'):
await download_git(resource_url)
else:
raise Va... | python | {
"resource": ""
} |
q39079 | IIIVZincBlendeAlloy.F | train | def F(self, **kwargs):
'''
Returns the Kane remote-band parameter, `F`, calculated from
`Eg_Gamma_0`, `Delta_SO`, `Ep`, and `meff_e_Gamma_0`.
'''
Eg = self.Eg_Gamma_0(**kwargs)
Delta_SO = self.Delta_SO(**kwargs)
Ep = self.Ep(**kwargs)
meff = self.meff_e_Ga... | python | {
"resource": ""
} |
q39080 | IIIVZincBlendeAlloy.nonparabolicity | train | def nonparabolicity(self, **kwargs):
'''
Returns the Kane band nonparabolicity parameter for the Gamma-valley.
'''
Eg = self.Eg_Gamma(**kwargs)
meff = self.meff_e_Gamma(**kwargs)
T = kwargs.get('T', 300.)
return k*T/Eg * (1 - meff)**2 | python | {
"resource": ""
} |
q39081 | ConverterGraph._setup_converter_graph | train | def _setup_converter_graph(self, converter_list, prune_converters):
'''
Set up directed conversion graph, pruning unavailable converters as
necessary
'''
for converter in converter_list:
if prune_converters:
try:
converter.configure... | python | {
"resource": ""
} |
q39082 | ConverterGraph._setup_preferred_paths | train | def _setup_preferred_paths(self, preferred_conversion_paths):
'''
Add given valid preferred conversion paths
'''
for path in preferred_conversion_paths:
for pair in pair_looper(path):
if pair not in self.converters:
log.warning('Invalid con... | python | {
"resource": ""
} |
q39083 | ConverterGraph._setup_profiles | train | def _setup_profiles(self, conversion_profiles):
'''
Add given conversion profiles checking for invalid profiles
'''
# Check for invalid profiles
for key, path in conversion_profiles.items():
if isinstance(path, str):
path = (path, )
for lef... | python | {
"resource": ""
} |
q39084 | ConverterGraph._setup_direct_converter | train | def _setup_direct_converter(self, converter):
'''
Given a converter, set up the direct_output routes for conversions,
which is used for transcoding between similar datatypes.
'''
inputs = (
converter.direct_inputs
if hasattr(converter, 'direct_inputs')
... | python | {
"resource": ""
} |
q39085 | ConverterGraph.find_path | train | def find_path(self, in_, out):
'''
Given an input and output TypeString, produce a graph traversal,
keeping in mind special options like Conversion Profiles, Preferred
Paths, and Direct Conversions.
'''
if in_.arguments:
raise ValueError('Cannot originate path... | python | {
"resource": ""
} |
q39086 | ConverterGraph.find_path_with_profiles | train | def find_path_with_profiles(self, conversion_profiles, in_, out):
'''
Like find_path, except forces the conversion profiles to be the given
conversion profile setting. Useful for "temporarily overriding" the
global conversion profiles with your own.
'''
original_profiles ... | python | {
"resource": ""
} |
q39087 | get_frames | train | def get_frames(tback, is_breakpoint):
"""Builds a list of ErrorFrame objects from a traceback"""
frames = []
while tback is not None:
if tback.tb_next is None and is_breakpoint:
break
filename = tback.tb_frame.f_code.co_filename
function = tback.tb_frame.f_code.co_name... | python | {
"resource": ""
} |
q39088 | prettify_object | train | def prettify_object(obj):
"""Makes a pretty string for an object for nice output"""
try:
return pprint.pformat(str(obj))
except UnicodeDecodeError as e:
raise
except Exception as e:
return "[could not display: <%s: %s>]" % (e.__class__.__name__, str(e)) | python | {
"resource": ""
} |
q39089 | render_from_repo | train | def render_from_repo(repo_path, to_path, template_params, settings_dir):
"""
rendering all files into the target directory
"""
TEMPLATE_PROJECT_FOLDER_PLACEHOLDER_NAME = 'deployer_project'
repo_path = repo_path.rstrip('/')
to_path = to_path.rstrip('/')
files_to_render = get_template_filelis... | python | {
"resource": ""
} |
q39090 | gen_headers | train | def gen_headers() -> Dict[str, str]:
"""Generate a header pairing."""
ua_list: List[str] = ['Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36']
headers: Dict[str, str] = {'User-Agent': ua_list[random.randint(0, len(ua_list) - 1)]}
return heade... | python | {
"resource": ""
} |
q39091 | extract_emails | train | def extract_emails(results: str, domain: str, fuzzy: bool) -> List[str]:
"""Grab email addresses from raw text data."""
pattern: Pattern = re.compile(r'([\w.-]+@[\w.-]+)')
hits: List[str] = pattern.findall(results)
if fuzzy:
seed = domain.split('.')[0]
emails: List[str] = [x.lower() for ... | python | {
"resource": ""
} |
q39092 | seqs_to_stream | train | def seqs_to_stream(seqs, ih):
"""Converts seqs into stream of FASTA records, depending on input handler.
Each FASTA record will be a list of lines.
"""
if ih == '_input_as_multiline_string':
recs = FastaFinder(seqs.split('\n'))
elif ih == '_input_as_string':
recs = FastaFinder(open(... | python | {
"resource": ""
} |
q39093 | blast_seqs | train | def blast_seqs(seqs,
blast_constructor,
blast_db=None,
blast_mat_root=None,
params={},
add_seq_names=True,
out_filename=None,
WorkingDir=None,
SuppressStderr=None,
Sup... | python | {
"resource": ""
} |
q39094 | fasta_cmd_get_seqs | train | def fasta_cmd_get_seqs(acc_list,
blast_db=None,
is_protein=None,
out_filename=None,
params={},
WorkingDir=tempfile.gettempdir(),
SuppressStderr=None,
SuppressStdout=None):
"""Retrieve sequences for... | python | {
"resource": ""
} |
q39095 | psiblast_n_neighbors | train | def psiblast_n_neighbors(seqs,
n=100,
blast_db=None,
core_threshold=1e-50,
extra_threshold=1e-10,
lower_threshold=1e-6,
step=100,
method="two-step",
blast_mat_root=None,
... | python | {
"resource": ""
} |
q39096 | ids_from_seq_two_step | train | def ids_from_seq_two_step(seq, n, max_iterations, app, core_threshold, \
extra_threshold, lower_threshold, second_db=None):
"""Returns ids that match a seq, using a 2-tiered strategy.
Optionally uses a second database for the second search.
"""
#first time through: reset 'h' and 'e' to core
#-h... | python | {
"resource": ""
} |
q39097 | ids_from_seq_lower_threshold | train | def ids_from_seq_lower_threshold(seq, n, max_iterations, app, core_threshold, \
lower_threshold, step=100):
"""Returns ids that match a seq, decreasing the sensitivity."""
last_num_ids = None
checkpoints = []
cp_name_base = make_unique_str()
# cache ides for each iteration
# store { iterati... | python | {
"resource": ""
} |
q39098 | make_unique_str | train | def make_unique_str(num_chars=20):
"""make a random string of characters for a temp filename"""
chars = 'abcdefghigklmnopqrstuvwxyz'
all_chars = chars + chars.upper() + '01234567890'
picks = list(all_chars)
return ''.join([choice(picks) for i in range(num_chars)]) | python | {
"resource": ""
} |
q39099 | keep_everything_scorer | train | def keep_everything_scorer(checked_ids):
"""Returns every query and every match in checked_ids, with best score."""
result = checked_ids.keys()
for i in checked_ids.values():
result.extend(i.keys())
return dict.fromkeys(result).keys() | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.