output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def _fastfood_show(args):
"""Run on `fastfood show`."""
template_pack = pack.TemplatePack(args.template_pack)
if args.stencil_set:
stencil_set = template_pack.load_stencil_set(args.stencil_set)
print("Stencil Set %s:" % args.stencil_set)
print(' Stencils:')
for stencil in st... | Can you write a function in Python 3 where it
runs on fastfood show. | As a Python code analyst, you investigate and solve complex coding mysteries |
Check latest fastfood release info from PyPI. | Can you tell what is the following Python 3 function doing
def _release_info():
pypi_url = 'http://pypi.python.org/pypi/fastfood/json'
headers = {
'Accept': 'application/json',
}
request = urllib.Request(pypi_url, headers=headers)
response = urllib.urlopen(request).read().decode('utf_8')
... | As a python code expert, you are capable of creating scripts from specifications. |
Return the option from the environment in the FASTFOOD namespace. | Here you have a function in Python 3, explain what it does
def getenv(option_name, default=None):
env = "%s_%s" % (NAMESPACE.upper(), option_name.upper())
return os.environ.get(env, default) | As a python code expert, you are capable of creating scripts from specifications. |
This is the fastfood command line interface. | Given the following Python 3 function, write the documentation
def main(argv=None):
# pylint: disable=missing-docstring
import argparse
import traceback
class HelpfulParser(argparse.ArgumentParser):
def error(self, message, print_help=False):
if 'too few arguments' in message:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def get_friendly_title(err):
"""Turn class, instance, or name (str) into an eyeball-friendly title.
E.g. FastfoodStencilSetNotListed --> 'Stencil Set Not Listed'
"""
if isinstance(err, basestring):
string = err
else:
try:
string = err.__name__
except AttributeErr... | How would you implement a function in Python 3 that
turns class instance or name into an eyeball - friendly title. | As a python code expert, you are capable of creating scripts from specifications. |
Verify the manifest schema. | Here you have a function in Python 3, explain what it does
def _validate(self, key, cls=None):
if key not in self.manifest:
raise ValueError("Manifest %s requires '%s'."
% (self.manifest_path, key))
if cls:
if not isinstance(self.manifest[key], cls):
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def stencil_sets(self):
"""List of stencil sets."""
if not self._stencil_sets:
self._stencil_sets = self.manifest['stencil_sets']
return self._stencil_sets | Can you write a function in Python 3 where it
lists of stencil sets. | You are a Python code generator, capable of creating scripts from specifications. |
def load_stencil_set(self, stencilset_name):
"""Return the Stencil Set from this template pack."""
if stencilset_name not in self._stencil_sets:
if stencilset_name not in self.manifest['stencil_sets'].keys():
raise exc.FastfoodStencilSetNotListed(
"Stencil... | Can you write a function in Python 3 where it
loads a Stencil Set from this template pack. | As a Python code composer, you craft elegant and concise scripts. |
Custom quoting method for jinja. | Given the following Python 3 function, write the documentation
def qstring(option):
if (re.match(NODE_ATTR_RE, option) is None and
re.match(CHEF_CONST_RE, option) is None):
return "'%s'" % option
else:
return option | As a python code expert, you are capable of creating scripts from specifications. |
Yields the contents of the given file and returns a generator that yields the contents of the file. | Can you generate the documentation for the following Python 3 function
def render_templates_generator(*files, **template_map):
for path in files:
if not os.path.isfile(path):
raise ValueError("Template file %s not found"
% os.path.relpath(path))
else:
... | You are a Python code generator, capable of creating scripts from specifications. |
Generate code for given model. | Can you tell what is the following Python 3 function doing
def generate(self, model, outfolder):
_logger.info('Generating code to {!r}.'.format(outfolder))
for task in self.tasks:
for element in task.filtered_elements(model):
task.run(element, outfolder) | As a Python code composer, you craft elegant and concise scripts. |
Apply this task to model element. | How would you explain what the following Python 3 function does
def run(self, element, outfolder):
filepath = self.relative_path_for_element(element)
if outfolder and not os.path.isabs(filepath):
filepath = os.path.join(outfolder, filepath)
_logger.debug('{!r} --> {!r}'.format(eleme... | As a Python code composer, you craft elegant and concise scripts. |
Create a dictionary that can be used to create a template context. | Can you generate a brief explanation for the following Python 3 code
def create_template_context(self, element, **kwargs):
context = dict(element=element, **kwargs)
if self.global_context:
context.update(**self.global_context)
return context | You are a Python code analyst, evaluating scripts for potential improvements. |
Format the value or raise a : exc : ValidationException. | How would you explain what the following Python 3 function does
def _validated(self, value):
if value is None:
return None
if isinstance(value, bson.ObjectId):
return value
try:
return bson.ObjectId(value)
except (ValueError, AttributeError):
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Create a Jinja2 Environment object. | How would you explain what the following Python 3 function does
def create_environment(self, **kwargs):
return jinja2.Environment(
loader=jinja2.FileSystemLoader(self.templates_path),
**kwargs
) | As a Python code analyst, you investigate and solve complex coding mysteries |
def pairs(a):
"""Return array of pairs of adjacent elements in a.
>>> pairs([1, 2, 3, 4])
array([[1, 2],
[2, 3],
[3, 4]])
"""
a = np.asarray(a)
return as_strided(a, shape=(a.size - 1, 2), strides=a.strides * 2) | Can you create a Python 3 function that
returns array of pairs of adjacent elements in a. | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns the key used to sort transcripts in a sequence. | How would you explain what the following Python 3 function does
def transcript_sort_key(transcript):
return (
-len(transcript.protein_sequence),
-len(transcript.sequence),
transcript.name
) | As a python code expert, you are capable of creating scripts from specifications. |
Given a set of coding transcripts choose the best transcript | Make a summary of the following Python 3 code
def best_transcript(transcripts):
assert len(transcripts) > 0
sorted_list = sorted(transcripts, key=transcript_sort_key)
return sorted_list[0] | As a Python code composer, you craft elegant and concise scripts. |
Predicts epitopes from the given commandline arguments. | Explain what the following Python 3 code does
def predict_epitopes_from_args(args):
mhc_model = mhc_binding_predictor_from_args(args)
variants = variant_collection_from_args(args)
gene_expression_dict = rna_gene_expression_dict_from_args(args)
transcript_expression_dict = rna_transcript_expression_dict_... | As a python code expert, you are capable of creating scripts from specifications. |
Returns a random word from the dictionary | Explain what the following Python 3 code does
def get_random_word(dictionary, min_word_length=3, max_word_length=8):
while True:
# Choose a random word
word = choice(dictionary)
# Stop looping as soon as we have a valid candidate
if len(word) >= min_word_length and len(word) <= max_... | You are a Python code architect, reviewing and designing scalable and efficient code |
def pw(min_word_length=3, max_word_length=8, max_int_value=1000, number_of_elements=4, no_special_characters=False):
"""
Generate a password
"""
# Set the position of the integer
int_position = set_int_position(number_of_elements)
# Load dictionary
dictionary = load_dictionary()
p... | Can you create a Python 3 function that
generates a random password from the ISO. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Given a list of effects get a dictionary of subsequences and a dictionary of subsequence start offsets. | Can you tell what is the following Python 3 function doing
def protein_subsequences_around_mutations(effects, padding_around_mutation):
protein_subsequences = {}
protein_subsequence_start_offsets = {}
for effect in effects:
protein_sequence = effect.mutant_protein_sequence
# some effects wil... | As a python code expert, you are capable of creating scripts from specifications. |
Checks that the given padding is less than the minimum required padding around the mutation. | Can you tell what is the following Python 3 function doing
def check_padding_around_mutation(given_padding, epitope_lengths):
min_required_padding = max(epitope_lengths) - 1
if not given_padding:
return min_required_padding
else:
require_integer(given_padding, "Padding around mutation")
... | You are a Python code generator, capable of creating scripts from specifications. |
def peptide_mutation_interval(
peptide_start_in_protein,
peptide_length,
mutation_start_in_protein,
mutation_end_in_protein):
"""
Half-open interval of mutated residues in the peptide, determined
from the mutation interval in the original protein sequence.
Parameters
... | Write a Python 3 script for
returning the interval of the mutation in the peptide. | As a Python code composer, you craft elegant and concise scripts. |
def from_dict(cls, indicator):
"""
Create an indicator object from a dictionary.
:param indicator: The dictionary.
:return: The indicator object.
"""
tags = indicator.get('tags')
if tags is not None:
tags = [Tag.from_dict(tag) for tag in tags]
... | Implement a function in Python 3 to
create an Indicator object from a dictionary. | You are a Python code architect, reviewing and designing scalable and efficient code |
def to_dict(self, remove_nones=False):
"""
Creates a dictionary representation of the indicator.
:param remove_nones: Whether ``None`` values should be filtered out of the dictionary. Defaults to ``False``.
:return: A dictionary representation of the indicator.
"""
if ... | Create a Python 3 function to
return a dictionary representation of the object. | As a Python code translator, you convert algorithms and pseudocode into Python. |
method that takes in FireEye ( FE ) alerts and filters FE - tests and False Positives
| Can you tell what is the following Python 3 function doing
def filter_false_positive(df, process_time):
result = []
track = []
count = 0
for o in df['alerts']:
count += 1
if 'closedState' in o:
if o['closedState'] != 'False Positive':
if 'distinguishers' in o:... | You are a Python code architect, reviewing and designing scalable and efficient code |
A function that removes the alerts property from the FireEye alert and transforms the data into a JSON ready format | Here you have a function in Python 3, explain what it does
def process_alert(file_name):
processed_line = open(file_name, 'r').read()
char_pos = processed_line.find("}")
new_line = "{" + processed_line[char_pos + 2:]
return new_line | You are a Python code architect, reviewing and designing scalable and efficient code |
Apply filter to effect collection and print number of dropped elements | Here you have a function in Python 3, explain what it does
def apply_filter(
filter_fn,
collection,
result_fn=None,
filter_name="",
collection_name=""):
"""
Apply filter to effect collection and print number of dropped elements
Parameters
----------
"""
n... | As a python code expert, you are capable of creating scripts from specifications. |
Filter out non - coding variants which result in modified proteins. | Here you have a function in Python 3, explain what it does
def filter_silent_and_noncoding_effects(effects):
return apply_filter(
filter_fn=lambda effect: isinstance(effect, NonsilentCodingMutation),
collection=effects,
result_fn=effects.clone_with_new_elements,
filter_name="Silent m... | You are a Python code analyst, evaluating scripts for potential improvements. |
Filter a collection of variants by gene and transcript expression thresholds | Make a summary of the following Python 3 code
def apply_variant_expression_filters(
variants,
gene_expression_dict,
gene_expression_threshold,
transcript_expression_dict,
transcript_expression_threshold):
"""
Filter a collection of variants by gene and transcript expressi... | You are a Python code generator, capable of creating scripts from specifications. |
Filter collection of varcode effects by given gene and transcript expression thresholds. | How would you explain what the following Python 3 function does
def apply_effect_expression_filters(
effects,
gene_expression_dict,
gene_expression_threshold,
transcript_expression_dict,
transcript_expression_threshold):
"""
Filter collection of varcode effects by given g... | As a Python code composer, you craft elegant and concise scripts. |
Submit indicators to the specified enclave. | Make a summary of the following Python 3 code
def submit_indicators(self, indicators, enclave_ids=None, tags=None):
if enclave_ids is None:
enclave_ids = self.enclave_ids
if tags is not None:
tags = [tag.to_dict() for tag in tags]
body = {
"enclaveIds": enc... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns a generator that returns each successive indicator for the given time range. | Here you have a function in Python 3, explain what it does
def get_indicators(self, from_time=None, to_time=None, enclave_ids=None,
included_tag_ids=None, excluded_tag_ids=None,
start_page=0, page_size=None):
"""
Creates a generator from the |get_indicators_... | You are a Python code generator, capable of creating scripts from specifications. |
Creates a generator from the get_indicators_page method that returns each successive page. | Can you generate a brief explanation for the following Python 3 code
def _get_indicators_page_generator(self, from_time=None, to_time=None, page_number=0, page_size=None,
enclave_ids=None, included_tag_ids=None, excluded_tag_ids=None):
"""
Creates a generator from ... | As a Python code composer, you craft elegant and concise scripts. |
def get_indicators_page(self, from_time=None, to_time=None, page_number=None, page_size=None,
enclave_ids=None, included_tag_ids=None, excluded_tag_ids=None):
"""
Get a page of indicators matching the provided filters.
:param int from_time: start of time window in mi... | Can you implement a function in Python 3 that
gets a page of indicators matching the provided filters. | You are a Python code analyst, evaluating scripts for potential improvements. |
def search_indicators(self, search_term=None,
enclave_ids=None,
from_time=None,
to_time=None,
indicator_types=None,
tags=None,
excluded_tags=None):
"""
... | Write a Python 3 script for
searching for indicators in the specified enclave. | You are a Python code analyst, evaluating scripts for potential improvements. |
Creates a generator from the |search_indicators_page| method that returns each successive page. | Here you have a function in Python 3, explain what it does
def _search_indicators_page_generator(self, search_term=None,
enclave_ids=None,
from_time=None,
to_time=None,
... | You are a Python code generator, capable of creating scripts from specifications. |
Search for indicators containing a search term. | Given the following Python 3 function, write the documentation
def search_indicators_page(self, search_term=None,
enclave_ids=None,
from_time=None,
to_time=None,
indicator_types=None,
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Uses the |get_related_indicators_page| method to create a generator that returns each successive report. | How would you explain what the following Python 3 function does
def get_related_indicators(self, indicators=None, enclave_ids=None):
return Page.get_generator(page_generator=self._get_related_indicators_page_generator(indicators, enclave_ids)) | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_indicator_metadata(self, value):
"""
Provide metadata associated with a single indicators, including value, indicatorType, noteCount,
sightings, lastSeen, enclaveIds, and tags. The metadata is determined based on the enclaves the user making the
request has READ access to.
... | Create a Python 3 function for
returning the metadata associated with a single indicator. | You are a Python code analyst, evaluating scripts for potential improvements. |
This method returns the metadata associated with a list of indicators. | Make a summary of the following Python 3 code
def get_indicators_metadata(self, indicators):
data = [{
'value': i.value,
'indicatorType': i.type
} for i in indicators]
resp = self._client.post("indicators/metadata", data=json.dumps(data))
return [Indicator.from... | As a Python code analyst, you investigate and solve complex coding mysteries |
This method returns details for all indicators in the specified enclave. | Can you generate the documentation for the following Python 3 function
def get_indicator_details(self, indicators, enclave_ids=None):
# if the indicators parameter is a string, make it a singleton
if isinstance(indicators, string_types):
indicators = [indicators]
params = {
... | As a Python code composer, you craft elegant and concise scripts. |
def add_terms_to_whitelist(self, terms):
"""
Add a list of terms to the user's company's whitelist.
:param terms: The list of terms to whitelist.
:return: The list of extracted |Indicator| objects that were whitelisted.
"""
resp = self._client.post("whitelist", json=ter... | Can you create a Python 3 function that
adds a list of terms to the user s company s whitelist. | You are a Python code architect, reviewing and designing scalable and efficient code |
Delete an indicator from the user s company s whitelist. | Explain what the following Python 3 code does
def delete_indicator_from_whitelist(self, indicator):
params = indicator.to_dict()
self._client.delete("whitelist", params=params) | You are a Python code analyst, evaluating scripts for potential improvements. |
def get_community_trends(self, indicator_type=None, days_back=None):
"""
Find indicators that are trending in the community.
:param indicator_type: A type of indicator to filter by. If ``None``, will get all types of indicators except
for MALWARE and CVEs (this convention is for pa... | Write a Python 3 script to
return a list of indicators that are trending in the community. | You are a Python code architect, reviewing and designing scalable and efficient code |
Gets a paginated list of indicators that the user s company has whitelisted. | Can you generate a brief explanation for the following Python 3 code
def get_whitelist_page(self, page_number=None, page_size=None):
params = {
'pageNumber': page_number,
'pageSize': page_size
}
resp = self._client.get("whitelist", params=params)
return Page.from... | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_related_indicators_page(self, indicators=None, enclave_ids=None, page_size=None, page_number=None):
"""
Finds all reports that contain any of the given indicators and returns correlated indicators from those reports.
:param indicators: list of indicator values to search for
:par... | How would you implement a function in Python 3 that
finds all reports that contain any of the given indicators and returns correlated indicators from those reports. | You are a Python code generator, capable of creating scripts from specifications. |
Creates a generator that returns each successive page. | Here you have a function in Python 3, explain what it does
def _get_indicators_for_report_page_generator(self, report_id, start_page=0, page_size=None):
get_page = functools.partial(self.get_indicators_for_report_page, report_id=report_id)
return Page.get_page_generator(get_page, start_page, page_size) | You are a Python code analyst, evaluating scripts for potential improvements. |
Creates a generator from the |get_related_indicators_page| method that returns each
successive page. | How would you explain what the following Python 3 function does
def _get_related_indicators_page_generator(self, indicators=None, enclave_ids=None, start_page=0, page_size=None):
get_page = functools.partial(self.get_related_indicators_page, indicators, enclave_ids)
return Page.get_page_generator(get_p... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def _get_whitelist_page_generator(self, start_page=0, page_size=None):
"""
Creates a generator from the |get_whitelist_page| method that returns each successive page.
:param int start_page: The page to start on.
:param int page_size: The size of each page.
:return: The generator... | Write a Python 3 script for
creating a generator from the |get_whitelist_page| method that returns each successive page. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def points(self, size=1.0, highlight=None, colorlist=None, opacity=1.0):
"""Display the system as points.
:param float size: the size of the points.
"""
if colorlist is None:
colorlist = [get_atom_color(t) for t in self.topology['atom_types']]
if highlight is not N... | Write a Python 3 function that can
display the system as points. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Display atomic labels for the system | Given the following Python 3 function, write the documentation
def labels(self, text=None, coordinates=None, colorlist=None, sizes=None, fonts=None, opacity=1.0):
'''Display atomic labels for the system'''
if coordinates is None:
coordinates=self.coordinates
l=len(coordinates)
... | You are a Python code generator, capable of creating scripts from specifications. |
def remove_labels(self):
'''Remove all atomic labels from the system'''
for rep_id in self.representations.keys():
if self.representations[rep_id]['rep_type']=='text' and rep_id not in self._axes_reps:
self.remove_representation(rep_id) | Can you write a function in Python 3 where it
removes all atomic labels from the system | As a Python code translator, you convert algorithms and pseudocode into Python. |
Toggle the axes on and off for the current representation of the object. | Can you generate the documentation for the following Python 3 function
def toggle_axes(self, parameters = None):
'''Toggle axes [x,y,z] on and off for the current representation
Parameters: dictionary of parameters to control axes:
position/p: origin of axes
length/l: l... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Display the system bonds as lines.
| Given the following Python 3 function, write the documentation
def lines(self):
'''Display the system bonds as lines.
'''
if "bonds" not in self.topology:
return
bond_start, bond_end = zip(*self.topology['bonds'])
bond_start = np.array(bond_start)
bond_end =... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def wireframe(self, pointsize=0.2, opacity=1.0):
'''Display atoms as points of size *pointsize* and bonds as lines.'''
self.points(pointsize, opacity=opacity)
self.lines() | Create a Python 3 function to
display atoms as points and bonds as lines. | You are a Python code analyst, evaluating scripts for potential improvements. |
Display the system using a ball and stick representation. | Can you tell what is the following Python 3 function doing
def ball_and_sticks(self, ball_radius=0.05, stick_radius=0.02, colorlist=None, opacity=1.0):
# Add the spheres
if colorlist is None:
colorlist = [get_atom_color(t) for t in self.topology['atom_types']]
sizes = [ball_radius]... | As a python code expert, you are capable of creating scripts from specifications. |
Display the protein secondary structure as a white lines that passes through the
backbone chain. | Given the following Python 3 function, write the documentation
def line_ribbon(self):
'''Display the protein secondary structure as a white lines that passes through the
backbone chain.
'''
# Control points are the CA (C alphas)
backbone = np.array(self.topology['atom_names']... | You are a Python code architect, reviewing and designing scalable and efficient code |
Display the protein secondary structure as a white solid tube and the alpha - helices as yellow cylinders. | Given the following Python 3 function, write the documentation
def cylinder_and_strand(self):
'''Display the protein secondary structure as a white,
solid tube and the alpha-helices as yellow cylinders.
'''
top = self.topology
# We build a mini-state machine to find the
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def cartoon(self, cmap=None):
'''Display a protein secondary structure as a pymol-like cartoon representation.
:param cmap: is a dictionary that maps the secondary type
(H=helix, E=sheet, C=coil) to a hexadecimal color (0xffffff for white)
'''
# Parse secondary struc... | Implement a function in Python 3 to
display a protein secondary structure as a pymol - like cartoon representation. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Add an isosurface to the current scene. | Can you generate a brief explanation for the following Python 3 code
def add_isosurface(self, function, isolevel=0.3, resolution=32, style="wireframe", color=0xffffff):
'''Add an isosurface to the current scene.
:param callable function: A function that takes x, y, z coordinates as input and is broadca... | You are a Python code architect, reviewing and designing scalable and efficient code |
def add_isosurface_grid_data(self, data, origin, extent, resolution,
isolevel=0.3, scale=10,
style="wireframe", color=0xffffff):
"""
Add an isosurface to current scence using pre-computed data on a grid
"""
spacing = np.ar... | Create a Python 3 function for
adding an isosurface to the current scence using pre - computed data on a grid | You are a Python code analyst, evaluating scripts for potential improvements. |
Refreshes the token for the current user. | Make a summary of the following Python 3 code
def _refresh_token(self):
# use basic auth with API key and secret
client_auth = requests.auth.HTTPBasicAuth(self.api_key, self.api_secret)
# make request
post_data = {"grant_type": "client_credentials"}
response = requests.post(sel... | You are a Python code architect, reviewing and designing scalable and efficient code |
def _get_headers(self, is_json=False):
"""
Create headers dictionary for a request.
:param boolean is_json: Whether the request body is a json.
:return: The headers dictionary.
"""
headers = {"Authorization": "Bearer " + self._get_token()}
if self.client_type i... | How would you code a function in Python 3 to
create headers dictionary for a request. | As a Python code analyst, you investigate and solve complex coding mysteries |
def _is_expired_token_response(cls, response):
"""
Determine whether the given response indicates that the token is expired.
:param response: The response object.
:return: True if the response indicates that the token is expired.
"""
EXPIRED_MESSAGE = "Expired oauth2 ac... | Create a Python 3 function for
determining whether the given response indicates that the token is expired. | As a python code expert, you are capable of creating scripts from specifications. |
Wrapper around requests. request that handles API calls. | How would you explain what the following Python 3 function does
def request(self, method, path, headers=None, params=None, data=None, **kwargs):
retry = self.retry
attempted = False
while not attempted or retry:
# get headers and merge with headers from method parameter if it exist... | As a Python code composer, you craft elegant and concise scripts. |
This function takes a numpy array of data and returns the vertices and faces of the isosurface that is used to feed into programs
| Given the following Python 3 function, write the documentation
def isosurface_from_data(data, isolevel, origin, spacing):
spacing = np.array(extent/resolution)
if isolevel >= 0:
triangles = marching_cubes(data, isolevel)
else: # Wrong traingle unwinding roder -- god only knows why
triangles ... | You are a Python code generator, capable of creating scripts from specifications. |
def load_transcript_fpkm_dict_from_gtf(
gtf_path,
transcript_id_column_name="reference_id",
fpkm_column_name="FPKM",
feature_column_name="feature"):
"""
Load a GTF file generated by StringTie which contains transcript-level
quantification of abundance. Returns a dictionary ma... | How would you implement a function in Python 3 that
loads a GTF file generated by StringTie which contains transcript - level quantification of abundance. Returns a dictionary mapping transcript IDs of transcripts to FPKM values. | As a Python code analyst, you investigate and solve complex coding mysteries |
def predict_from_named_sequences(
self, name_to_sequence_dict):
"""
Parameters
----------
name_to_sequence_dict : (str->str) dict
Dictionary mapping sequence names to amino acid sequences
Returns pandas.DataFrame with the following columns:
- ... | How would you code a function in Python 3 to
predict the amino acid sequences in the specified named sequences. | You are a Python code generator, capable of creating scripts from specifications. |
Predict MHC ligands for sub - sequences of each input sequence. | Given the following Python 3 function, write the documentation
def predict_from_sequences(self, sequences):
# make each sequence its own unique ID
sequence_dict = {
seq: seq
for seq in sequences
}
df = self.predict_from_named_sequences(sequence_dict)
retur... | As a python code expert, you are capable of creating scripts from specifications. |
Given a Varcode. EffectCollection of predicted protein effects return predicted epitopes around each mutation. | Can you generate a brief explanation for the following Python 3 code
def predict_from_mutation_effects(
self,
effects,
transcript_expression_dict=None,
gene_expression_dict=None):
"""Given a Varcode.EffectCollection of predicted protein effects,
return pre... | You are a Python code generator, capable of creating scripts from specifications. |
Predict epitopes from a VariantCollection. | Here you have a function in Python 3, explain what it does
def predict_from_variants(
self,
variants,
transcript_expression_dict=None,
gene_expression_dict=None):
"""
Predict epitopes from a Variant collection, filtering options, and
optional gene ... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def main(args_list=None):
"""
Script entry-point to predict neo-epitopes from genomic variants using
Topiary.
"""
args = parse_args(args_list)
print("Topiary commandline arguments:")
print(args)
df = predict_epitopes_from_args(args)
write_outputs(df, args)
print("Total count: %d"... | Can you write a function in Python 3 where it
scripts entry - point to predict neo - epitopes from genomic variants using Topiary. | You are a Python code generator, capable of creating scripts from specifications. |
Render the scene with povray for publication. | Can you generate the documentation for the following Python 3 function
def render_povray(scene, filename='ipython', width=600, height=600,
antialiasing=0.01, extra_opts={}):
'''Render the scene with povray for publication.
:param dict scene: The scene to render
:param string filename: Out... | As a Python code analyst, you investigate and solve complex coding mysteries |
Create a rotation matrix from a quaternion rotation. | Can you generate a brief explanation for the following Python 3 code
def rmatrixquaternion(q):
assert np.allclose(math.sqrt(np.dot(q,q)), 1.0)
x, y, z, w = q
xx = x*x
xy = x*y
xz = x*z
xw = x*w
yy = y*y
yz = y*z
yw = y*w
zz = z*z
zw = z*w
r00 = 1.0 - 2.0 * (yy + zz)
... | You are a Python code generator, capable of creating scripts from specifications. |
def rna_transcript_expression_dict_from_args(args):
"""
Returns a dictionary mapping Ensembl transcript IDs to FPKM expression
values or None if neither Cufflinks tracking file nor StringTie GTF file
were specified.
"""
if args.rna_transcript_fpkm_tracking_file:
return load_cufflinks_fpk... | Write a Python 3 script to
return a dictionary mapping Ensembl transcript IDs to FPKM expression values or None if neither Cufflinks tracking file nor StringTie GTF file were specified. | As a Python code analyst, you investigate and solve complex coding mysteries |
Returns the total number of pages on the server. | Can you generate the documentation for the following Python 3 function
def get_total_pages(self):
if self.total_elements is None or self.page_size is None:
return None
return math.ceil(float(self.total_elements) / float(self.page_size)) | As a Python code analyst, you investigate and solve complex coding mysteries |
Returns True if there are more pages available on the server. | Make a summary of the following Python 3 code
def has_more_pages(self):
# if has_next property exists, it represents whether more pages exist
if self.has_next is not None:
return self.has_next
# otherwise, try to compute whether or not more pages exist
total_pages = self.ge... | You are a Python code generator, capable of creating scripts from specifications. |
def from_dict(page, content_type=None):
"""
Create a |Page| object from a dictionary. This method is intended for internal use, to construct a
|Page| object from the body of a response json from a paginated endpoint.
:param page: The dictionary.
:param content_type: The class t... | Can you implement a function in Python 3 that
creates a |Page| object from a dictionary. | As a Python code analyst, you investigate and solve complex coding mysteries |
def to_dict(self, remove_nones=False):
"""
Creates a dictionary representation of the page.
:param remove_nones: Whether ``None`` values should be filtered out of the dictionary. Defaults to ``False``.
:return: A dictionary representation of the page.
"""
items = []
... | Create a Python 3 function for
creating a dictionary representation of the page. | As a Python code composer, you craft elegant and concise scripts. |
def get_page_generator(func, start_page=0, page_size=None):
"""
Constructs a generator for retrieving pages from a paginated endpoint. This method is intended for internal
use.
:param func: Should take parameters ``page_number`` and ``page_size`` and return the corresponding |Page| obj... | Write a Python 3 script for
returning a generator that returns each successive page from a paginated endpoint. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def to_dict(self, remove_nones=False):
"""
Creates a dictionary representation of the object.
:param remove_nones: Whether ``None`` values should be filtered out of the dictionary. Defaults to ``False``.
:return: The dictionary representation.
"""
if remove_nones:
... | Can you implement a function in Python 3 that
returns a dictionary representation of the object. | You are a Python code generator, capable of creating scripts from specifications. |
Returns a dictionary representation of the object. | Can you generate a brief explanation for the following Python 3 code
def to_dict(self, remove_nones=False):
if remove_nones:
report_dict = super().to_dict(remove_nones=True)
else:
report_dict = {
'title': self.title,
'reportBody': self.body,
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def from_dict(cls, report):
"""
Create a report object from a dictionary. This method is intended for internal use, to construct a
:class:`Report` object from the body of a response json. It expects the keys of the dictionary to match those
of the json that would be found in a response... | Can you create a Python 3 function that
creates a report object from a dictionary. | You are a Python code architect, reviewing and designing scalable and efficient code |
def serialize_to_dict(dictionary):
'''Make a json-serializable dictionary from input dictionary by converting
non-serializable data types such as numpy arrays.'''
retval = {}
for k, v in dictionary.items():
if isinstance(v, dict):
retval[k] = serialize_to_dict(v)
else:
... | Can you implement a function in Python 3 that
makes a json - serializable dictionary from input dictionary by converting non - serializable data types such as numpy arrays. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def make_graph(pkg):
"""Returns a dictionary of information about pkg & its recursive deps.
Given a string, which can be parsed as a requirement specifier, return a
dictionary where each key is the name of pkg or one of its recursive
dependencies, and each value is a dictionary returned by research_pac... | Can you implement a function in Python 3 that
returns a dictionary of information about pkg and its recursive deps. | You are a Python code generator, capable of creating scripts from specifications. |
def get_report_details(self, report_id, id_type=None):
"""
Retrieves a report by its ID. Internal and external IDs are both allowed.
:param str report_id: The ID of the incident report.
:param str id_type: Indicates whether ID is internal or external.
:return: The retrieved |R... | Create a Python 3 function for
retrieving a report by its ID. Internal and external IDs are both allowed. | As a Python code composer, you craft elegant and concise scripts. |
This endpoint returns a page of reports from the server. | Explain what the following Python 3 code does
def get_reports_page(self, is_enclave=None, enclave_ids=None, tag=None, excluded_tags=None,
from_time=None, to_time=None):
"""
Retrieves a page of reports, filtering by time window, distribution type, enclave association, and tag.
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Submits a report to the user. | Can you tell what is the following Python 3 function doing
def submit_report(self, report):
# make distribution type default to "enclave"
if report.is_enclave is None:
report.is_enclave = True
if report.enclave_ids is None:
# use configured enclave_ids by default if dis... | You are a Python code analyst, evaluating scripts for potential improvements. |
Updates the report identified by the report. id field. | How would you explain what the following Python 3 function does
def update_report(self, report):
# default to interal ID type if ID field is present
if report.id is not None:
id_type = IdType.INTERNAL
report_id = report.id
# if no ID field is present, but external ID fie... | You are a Python code architect, reviewing and designing scalable and efficient code |
def delete_report(self, report_id, id_type=None):
"""
Deletes the report with the given ID.
:param report_id: the ID of the report to delete
:param id_type: indicates whether the ID is internal or an external ID provided by the user
:return: the response object
Example:... | How would you implement a function in Python 3 that
deletes the report with the given ID. | As a python code expert, you are capable of creating scripts from specifications. |
def get_correlated_report_ids(self, indicators):
"""
DEPRECATED!
Retrieves a list of the IDs of all TruSTAR reports that contain the searched indicators.
:param indicators: A list of indicator values to retrieve correlated reports for.
:return: The list of IDs of reports that co... | How would you implement a function in Python 3 that
gets a list of the IDs of all TruSTAR reports that contain the searched indicators. | As a Python code analyst, you investigate and solve complex coding mysteries |
Retrieves a page of all TruSTAR reports that contain the searched indicators. | Here you have a function in Python 3, explain what it does
def get_correlated_reports_page(self, indicators, enclave_ids=None, is_enclave=True,
page_size=None, page_number=None):
"""
Retrieves a page of all TruSTAR reports that contain the searched indicators.
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def search_reports_page(self, search_term=None,
enclave_ids=None,
from_time=None,
to_time=None,
tags=None,
excluded_tags=None,
page_size=None,
... | Write a Python 3 function that can
search for reports containing a search term. | As a python code expert, you are capable of creating scripts from specifications. |
def _get_reports_page_generator(self, is_enclave=None, enclave_ids=None, tag=None, excluded_tags=None,
from_time=None, to_time=None):
"""
Creates a generator from the |get_reports_page| method that returns each successive page.
:param boolean is_enclave: rest... | How would you code a function in Python 3 to
return a generator that returns each successive page. | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_reports(self, is_enclave=None, enclave_ids=None, tag=None, excluded_tags=None, from_time=None, to_time=None):
"""
Uses the |get_reports_page| method to create a generator that returns each successive report as a trustar
report object.
:param boolean is_enclave: restrict reports ... | Write a Python 3 function that can
use the |get_reports_page| method to create a generator that returns each successive report as a trustar report object. :param boolean is_enclave: restrict reports to specific distribution type (optional - by default all accessible reports are returned). :param list(str) enclave_ids: ... | You are a Python code analyst, evaluating scripts for potential improvements. |
Creates a generator from the |get_correlated_reports_page| method that returns each
successive page. | Can you generate a brief explanation for the following Python 3 code
def _get_correlated_reports_page_generator(self, indicators, enclave_ids=None, is_enclave=True,
start_page=0, page_size=None):
"""
Creates a generator from the |get_correlated_reports_page... | As a python code expert, you are capable of creating scripts from specifications. |
Uses the |get_correlated_reports_page| method to create a generator that returns each successive report. | Explain what the following Python 3 code does
def get_correlated_reports(self, indicators, enclave_ids=None, is_enclave=True):
return Page.get_generator(page_generator=self._get_correlated_reports_page_generator(indicators,
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _search_reports_page_generator(self, search_term=None,
enclave_ids=None,
from_time=None,
to_time=None,
tags=None,
exclude... | How would you implement a function in Python 3 that
creates a generator from the |search_reports_page| method that returns each successive page. | As a Python code analyst, you investigate and solve complex coding mysteries |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.