repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
broadinstitute/fiss
firecloud/fiss.py
attr_set
def attr_set(args): ''' Set key=value attributes: if entity name & type are specified then attributes will be set upon that entity, otherwise the attribute will be set at the workspace level''' if args.entity_type and args.entity: prompt = "Set {0}={1} for {2}:{3} in {4}/{5}?\n[Y\\n]: ".format(...
python
def attr_set(args): ''' Set key=value attributes: if entity name & type are specified then attributes will be set upon that entity, otherwise the attribute will be set at the workspace level''' if args.entity_type and args.entity: prompt = "Set {0}={1} for {2}:{3} in {4}/{5}?\n[Y\\n]: ".format(...
[ "def", "attr_set", "(", "args", ")", ":", "if", "args", ".", "entity_type", "and", "args", ".", "entity", ":", "prompt", "=", "\"Set {0}={1} for {2}:{3} in {4}/{5}?\\n[Y\\\\n]: \"", ".", "format", "(", "args", ".", "attribute", ",", "args", ".", "value", ",", ...
Set key=value attributes: if entity name & type are specified then attributes will be set upon that entity, otherwise the attribute will be set at the workspace level
[ "Set", "key", "=", "value", "attributes", ":", "if", "entity", "name", "&", "type", "are", "specified", "then", "attributes", "will", "be", "set", "upon", "that", "entity", "otherwise", "the", "attribute", "will", "be", "set", "at", "the", "workspace", "le...
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L883-L912
broadinstitute/fiss
firecloud/fiss.py
attr_delete
def attr_delete(args): ''' Delete key=value attributes: if entity name & type are specified then attributes will be deleted from that entity, otherwise the attribute will be removed from the workspace''' if args.entity_type and args.entities: # Since there is no attribute deletion endpoint, we ...
python
def attr_delete(args): ''' Delete key=value attributes: if entity name & type are specified then attributes will be deleted from that entity, otherwise the attribute will be removed from the workspace''' if args.entity_type and args.entities: # Since there is no attribute deletion endpoint, we ...
[ "def", "attr_delete", "(", "args", ")", ":", "if", "args", ".", "entity_type", "and", "args", ".", "entities", ":", "# Since there is no attribute deletion endpoint, we must perform 2 steps", "# here: first we retrieve the entity_ids, and any foreign keys (e.g.", "# participant_id ...
Delete key=value attributes: if entity name & type are specified then attributes will be deleted from that entity, otherwise the attribute will be removed from the workspace
[ "Delete", "key", "=", "value", "attributes", ":", "if", "entity", "name", "&", "type", "are", "specified", "then", "attributes", "will", "be", "deleted", "from", "that", "entity", "otherwise", "the", "attribute", "will", "be", "removed", "from", "the", "work...
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L915-L1000
broadinstitute/fiss
firecloud/fiss.py
attr_copy
def attr_copy(args): """ Copy workspace attributes between workspaces. """ if not args.to_workspace: args.to_workspace = args.workspace if not args.to_project: args.to_project = args.project if (args.project == args.to_project and args.workspace == args.to_workspace): epr...
python
def attr_copy(args): """ Copy workspace attributes between workspaces. """ if not args.to_workspace: args.to_workspace = args.workspace if not args.to_project: args.to_project = args.project if (args.project == args.to_project and args.workspace == args.to_workspace): epr...
[ "def", "attr_copy", "(", "args", ")", ":", "if", "not", "args", ".", "to_workspace", ":", "args", ".", "to_workspace", "=", "args", ".", "workspace", "if", "not", "args", ".", "to_project", ":", "args", ".", "to_project", "=", "args", ".", "project", "...
Copy workspace attributes between workspaces.
[ "Copy", "workspace", "attributes", "between", "workspaces", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1003-L1045
broadinstitute/fiss
firecloud/fiss.py
attr_fill_null
def attr_fill_null(args): """ Assign the null sentinel value for all entities which do not have a value for the given attributes. see gs://broad-institute-gdac/GDAC_FC_NULL for more details """ NULL_SENTINEL = "gs://broad-institute-gdac/GDAC_FC_NULL" attrs = args.attributes if not attr...
python
def attr_fill_null(args): """ Assign the null sentinel value for all entities which do not have a value for the given attributes. see gs://broad-institute-gdac/GDAC_FC_NULL for more details """ NULL_SENTINEL = "gs://broad-institute-gdac/GDAC_FC_NULL" attrs = args.attributes if not attr...
[ "def", "attr_fill_null", "(", "args", ")", ":", "NULL_SENTINEL", "=", "\"gs://broad-institute-gdac/GDAC_FC_NULL\"", "attrs", "=", "args", ".", "attributes", "if", "not", "attrs", ":", "print", "(", "\"Error: provide at least one attribute to set\"", ")", "return", "1", ...
Assign the null sentinel value for all entities which do not have a value for the given attributes. see gs://broad-institute-gdac/GDAC_FC_NULL for more details
[ "Assign", "the", "null", "sentinel", "value", "for", "all", "entities", "which", "do", "not", "have", "a", "value", "for", "the", "given", "attributes", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1048-L1160
broadinstitute/fiss
firecloud/fiss.py
health
def health(args): """ Health FireCloud Server """ r = fapi.health() fapi._check_response_code(r, 200) return r.content
python
def health(args): """ Health FireCloud Server """ r = fapi.health() fapi._check_response_code(r, 200) return r.content
[ "def", "health", "(", "args", ")", ":", "r", "=", "fapi", ".", "health", "(", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return", "r", ".", "content" ]
Health FireCloud Server
[ "Health", "FireCloud", "Server" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1163-L1167
broadinstitute/fiss
firecloud/fiss.py
mop
def mop(args): ''' Clean up unreferenced data in a workspace''' # First retrieve the workspace to get bucket information if args.verbose: print("Retrieving workspace information...") r = fapi.get_workspace(args.project, args.workspace) fapi._check_response_code(r, 200) workspace = r.json...
python
def mop(args): ''' Clean up unreferenced data in a workspace''' # First retrieve the workspace to get bucket information if args.verbose: print("Retrieving workspace information...") r = fapi.get_workspace(args.project, args.workspace) fapi._check_response_code(r, 200) workspace = r.json...
[ "def", "mop", "(", "args", ")", ":", "# First retrieve the workspace to get bucket information", "if", "args", ".", "verbose", ":", "print", "(", "\"Retrieving workspace information...\"", ")", "r", "=", "fapi", ".", "get_workspace", "(", "args", ".", "project", ","...
Clean up unreferenced data in a workspace
[ "Clean", "up", "unreferenced", "data", "in", "a", "workspace" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1170-L1283
broadinstitute/fiss
firecloud/fiss.py
sset_loop
def sset_loop(args): ''' Loop over all sample sets in a workspace, performing a func ''' # Ensure that the requested action is a valid fiss_cmd fiss_func = __cmd_to_func(args.action) if not fiss_func: eprint("invalid FISS cmd '" + args.action + "'") return 1 # First get the sample s...
python
def sset_loop(args): ''' Loop over all sample sets in a workspace, performing a func ''' # Ensure that the requested action is a valid fiss_cmd fiss_func = __cmd_to_func(args.action) if not fiss_func: eprint("invalid FISS cmd '" + args.action + "'") return 1 # First get the sample s...
[ "def", "sset_loop", "(", "args", ")", ":", "# Ensure that the requested action is a valid fiss_cmd", "fiss_func", "=", "__cmd_to_func", "(", "args", ".", "action", ")", "if", "not", "fiss_func", ":", "eprint", "(", "\"invalid FISS cmd '\"", "+", "args", ".", "action...
Loop over all sample sets in a workspace, performing a func
[ "Loop", "over", "all", "sample", "sets", "in", "a", "workspace", "performing", "a", "func" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1304-L1333
broadinstitute/fiss
firecloud/fiss.py
monitor
def monitor(args): ''' Retrieve status of jobs submitted from a given workspace, as a list of TSV lines sorted by descending order of job submission date''' r = fapi.list_submissions(args.project, args.workspace) fapi._check_response_code(r, 200) statuses = sorted(r.json(), key=lambda k: k['subm...
python
def monitor(args): ''' Retrieve status of jobs submitted from a given workspace, as a list of TSV lines sorted by descending order of job submission date''' r = fapi.list_submissions(args.project, args.workspace) fapi._check_response_code(r, 200) statuses = sorted(r.json(), key=lambda k: k['subm...
[ "def", "monitor", "(", "args", ")", ":", "r", "=", "fapi", ".", "list_submissions", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "statuses", "=", "sorted", "(", "r", ...
Retrieve status of jobs submitted from a given workspace, as a list of TSV lines sorted by descending order of job submission date
[ "Retrieve", "status", "of", "jobs", "submitted", "from", "a", "given", "workspace", "as", "a", "list", "of", "TSV", "lines", "sorted", "by", "descending", "order", "of", "job", "submission", "date" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1336-L1353
broadinstitute/fiss
firecloud/fiss.py
supervise
def supervise(args): ''' Run legacy, Firehose-style workflow of workflows''' project = args.project workspace = args.workspace namespace = args.namespace workflow = args.workflow sample_sets = args.sample_sets recovery_file = args.json_checkpoint # If no sample sets are provided, run on...
python
def supervise(args): ''' Run legacy, Firehose-style workflow of workflows''' project = args.project workspace = args.workspace namespace = args.namespace workflow = args.workflow sample_sets = args.sample_sets recovery_file = args.json_checkpoint # If no sample sets are provided, run on...
[ "def", "supervise", "(", "args", ")", ":", "project", "=", "args", ".", "project", "workspace", "=", "args", ".", "workspace", "namespace", "=", "args", ".", "namespace", "workflow", "=", "args", ".", "workflow", "sample_sets", "=", "args", ".", "sample_se...
Run legacy, Firehose-style workflow of workflows
[ "Run", "legacy", "Firehose", "-", "style", "workflow", "of", "workflows" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1356-L1381
broadinstitute/fiss
firecloud/fiss.py
entity_copy
def entity_copy(args): """ Copy entities from one workspace to another. """ if not args.to_workspace: args.to_workspace = args.workspace if not args.to_project: args.to_project = args.project if (args.project == args.to_project and args.workspace == args.to_workspace): ep...
python
def entity_copy(args): """ Copy entities from one workspace to another. """ if not args.to_workspace: args.to_workspace = args.workspace if not args.to_project: args.to_project = args.project if (args.project == args.to_project and args.workspace == args.to_workspace): ep...
[ "def", "entity_copy", "(", "args", ")", ":", "if", "not", "args", ".", "to_workspace", ":", "args", ".", "to_workspace", "=", "args", ".", "workspace", "if", "not", "args", ".", "to_project", ":", "args", ".", "to_project", "=", "args", ".", "project", ...
Copy entities from one workspace to another.
[ "Copy", "entities", "from", "one", "workspace", "to", "another", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1389-L1419
broadinstitute/fiss
firecloud/fiss.py
proj_list
def proj_list(args): '''Retrieve the list of billing projects accessible to the caller/user, and show the level of access granted for each (e.g. Owner, User, ...)''' projects = fapi.list_billing_projects() fapi._check_response_code(projects, 200) projects = sorted(projects.json(), key=lambda d: d...
python
def proj_list(args): '''Retrieve the list of billing projects accessible to the caller/user, and show the level of access granted for each (e.g. Owner, User, ...)''' projects = fapi.list_billing_projects() fapi._check_response_code(projects, 200) projects = sorted(projects.json(), key=lambda d: d...
[ "def", "proj_list", "(", "args", ")", ":", "projects", "=", "fapi", ".", "list_billing_projects", "(", ")", "fapi", ".", "_check_response_code", "(", "projects", ",", "200", ")", "projects", "=", "sorted", "(", "projects", ".", "json", "(", ")", ",", "ke...
Retrieve the list of billing projects accessible to the caller/user, and show the level of access granted for each (e.g. Owner, User, ...)
[ "Retrieve", "the", "list", "of", "billing", "projects", "accessible", "to", "the", "caller", "/", "user", "and", "show", "the", "level", "of", "access", "granted", "for", "each", "(", "e", ".", "g", ".", "Owner", "User", "...", ")" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1422-L1430
broadinstitute/fiss
firecloud/fiss.py
config_validate
def config_validate(args): ''' Validate a workspace configuration: if an entity was specified (i.e. upon which the configuration should operate), then also validate that the entity has the necessary attributes''' r = fapi.validate_config(args.project, args.workspace, args.namespace, ...
python
def config_validate(args): ''' Validate a workspace configuration: if an entity was specified (i.e. upon which the configuration should operate), then also validate that the entity has the necessary attributes''' r = fapi.validate_config(args.project, args.workspace, args.namespace, ...
[ "def", "config_validate", "(", "args", ")", ":", "r", "=", "fapi", ".", "validate_config", "(", "args", ".", "project", ",", "args", ".", "workspace", ",", "args", ".", "namespace", ",", "args", ".", "config", ")", "fapi", ".", "_check_response_code", "(...
Validate a workspace configuration: if an entity was specified (i.e. upon which the configuration should operate), then also validate that the entity has the necessary attributes
[ "Validate", "a", "workspace", "configuration", ":", "if", "an", "entity", "was", "specified", "(", "i", ".", "e", ".", "upon", "which", "the", "configuration", "should", "operate", ")", "then", "also", "validate", "that", "the", "entity", "has", "the", "ne...
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1433-L1472
broadinstitute/fiss
firecloud/fiss.py
_validate_helper
def _validate_helper(args, config_d, workspace_d, entity_d=None): """ Return FISSFC validation information on config for a certain entity """ # 4 ways to have invalid config: invalid_inputs = sorted(config_d["invalidInputs"]) invalid_outputs = sorted(config_d["invalidOutputs"]) # Also insert va...
python
def _validate_helper(args, config_d, workspace_d, entity_d=None): """ Return FISSFC validation information on config for a certain entity """ # 4 ways to have invalid config: invalid_inputs = sorted(config_d["invalidInputs"]) invalid_outputs = sorted(config_d["invalidOutputs"]) # Also insert va...
[ "def", "_validate_helper", "(", "args", ",", "config_d", ",", "workspace_d", ",", "entity_d", "=", "None", ")", ":", "# 4 ways to have invalid config:", "invalid_inputs", "=", "sorted", "(", "config_d", "[", "\"invalidInputs\"", "]", ")", "invalid_outputs", "=", "...
Return FISSFC validation information on config for a certain entity
[ "Return", "FISSFC", "validation", "information", "on", "config", "for", "a", "certain", "entity" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1474-L1521
broadinstitute/fiss
firecloud/fiss.py
runnable
def runnable(args): """ Show me what can be run in a given workspace """ w = fapi.get_workspace(args.project, args.workspace) fapi._check_response_code(w, 200) workspace_d = w.json() if args.config and args.namespace and not args.entity: # See what entities I can run on with this config ...
python
def runnable(args): """ Show me what can be run in a given workspace """ w = fapi.get_workspace(args.project, args.workspace) fapi._check_response_code(w, 200) workspace_d = w.json() if args.config and args.namespace and not args.entity: # See what entities I can run on with this config ...
[ "def", "runnable", "(", "args", ")", ":", "w", "=", "fapi", ".", "get_workspace", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "w", ",", "200", ")", "workspace_d", "=", "w", ".", "json", "...
Show me what can be run in a given workspace
[ "Show", "me", "what", "can", "be", "run", "in", "a", "given", "workspace" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1524-L1649
broadinstitute/fiss
firecloud/fiss.py
_confirm_prompt
def _confirm_prompt(message, prompt="\nAre you sure? [y/yes (default: no)]: ", affirmations=("Y", "Yes", "yes", "y")): """ Display a message, then confirmation prompt, and return true if the user responds with one of the affirmations. """ answer = input(message + prompt) retu...
python
def _confirm_prompt(message, prompt="\nAre you sure? [y/yes (default: no)]: ", affirmations=("Y", "Yes", "yes", "y")): """ Display a message, then confirmation prompt, and return true if the user responds with one of the affirmations. """ answer = input(message + prompt) retu...
[ "def", "_confirm_prompt", "(", "message", ",", "prompt", "=", "\"\\nAre you sure? [y/yes (default: no)]: \"", ",", "affirmations", "=", "(", "\"Y\"", ",", "\"Yes\"", ",", "\"yes\"", ",", "\"y\"", ")", ")", ":", "answer", "=", "input", "(", "message", "+", "pro...
Display a message, then confirmation prompt, and return true if the user responds with one of the affirmations.
[ "Display", "a", "message", "then", "confirmation", "prompt", "and", "return", "true", "if", "the", "user", "responds", "with", "one", "of", "the", "affirmations", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1663-L1670
broadinstitute/fiss
firecloud/fiss.py
_nonempty_project
def _nonempty_project(string): """ Argparse validator for ensuring a workspace is provided """ value = str(string) if len(value) == 0: msg = "No project provided and no default project configured" raise argparse.ArgumentTypeError(msg) return value
python
def _nonempty_project(string): """ Argparse validator for ensuring a workspace is provided """ value = str(string) if len(value) == 0: msg = "No project provided and no default project configured" raise argparse.ArgumentTypeError(msg) return value
[ "def", "_nonempty_project", "(", "string", ")", ":", "value", "=", "str", "(", "string", ")", "if", "len", "(", "value", ")", "==", "0", ":", "msg", "=", "\"No project provided and no default project configured\"", "raise", "argparse", ".", "ArgumentTypeError", ...
Argparse validator for ensuring a workspace is provided
[ "Argparse", "validator", "for", "ensuring", "a", "workspace", "is", "provided" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1672-L1680
broadinstitute/fiss
firecloud/fiss.py
_entity_paginator
def _entity_paginator(namespace, workspace, etype, page_size=500, filter_terms=None, sort_direction="asc"): """Pages through the get_entities_query endpoint to get all entities in the workspace without crashing. """ page = 1 all_entities = [] # Make initial reques...
python
def _entity_paginator(namespace, workspace, etype, page_size=500, filter_terms=None, sort_direction="asc"): """Pages through the get_entities_query endpoint to get all entities in the workspace without crashing. """ page = 1 all_entities = [] # Make initial reques...
[ "def", "_entity_paginator", "(", "namespace", ",", "workspace", ",", "etype", ",", "page_size", "=", "500", ",", "filter_terms", "=", "None", ",", "sort_direction", "=", "\"asc\"", ")", ":", "page", "=", "1", "all_entities", "=", "[", "]", "# Make initial re...
Pages through the get_entities_query endpoint to get all entities in the workspace without crashing.
[ "Pages", "through", "the", "get_entities_query", "endpoint", "to", "get", "all", "entities", "in", "the", "workspace", "without", "crashing", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1682-L1714
broadinstitute/fiss
firecloud/fiss.py
__cmd_to_func
def __cmd_to_func(cmd): """ Returns the function object in this module matching cmd. """ fiss_module = sys.modules[__name__] # Returns None if string is not a recognized FISS command func = getattr(fiss_module, cmd, None) if func and not hasattr(func, 'fiss_cmd'): func = None return func
python
def __cmd_to_func(cmd): """ Returns the function object in this module matching cmd. """ fiss_module = sys.modules[__name__] # Returns None if string is not a recognized FISS command func = getattr(fiss_module, cmd, None) if func and not hasattr(func, 'fiss_cmd'): func = None return func
[ "def", "__cmd_to_func", "(", "cmd", ")", ":", "fiss_module", "=", "sys", ".", "modules", "[", "__name__", "]", "# Returns None if string is not a recognized FISS command", "func", "=", "getattr", "(", "fiss_module", ",", "cmd", ",", "None", ")", "if", "func", "a...
Returns the function object in this module matching cmd.
[ "Returns", "the", "function", "object", "in", "this", "module", "matching", "cmd", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1720-L1727
broadinstitute/fiss
firecloud/fiss.py
_valid_headerline
def _valid_headerline(l): """return true if the given string is a valid loadfile header""" if not l: return False headers = l.split('\t') first_col = headers[0] tsplit = first_col.split(':') if len(tsplit) != 2: return False if tsplit[0] in ('entity', 'update'): re...
python
def _valid_headerline(l): """return true if the given string is a valid loadfile header""" if not l: return False headers = l.split('\t') first_col = headers[0] tsplit = first_col.split(':') if len(tsplit) != 2: return False if tsplit[0] in ('entity', 'update'): re...
[ "def", "_valid_headerline", "(", "l", ")", ":", "if", "not", "l", ":", "return", "False", "headers", "=", "l", ".", "split", "(", "'\\t'", ")", "first_col", "=", "headers", "[", "0", "]", "tsplit", "=", "first_col", ".", "split", "(", "':'", ")", "...
return true if the given string is a valid loadfile header
[ "return", "true", "if", "the", "given", "string", "is", "a", "valid", "loadfile", "header" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1729-L1751
broadinstitute/fiss
firecloud/fiss.py
_batch_load
def _batch_load(project, workspace, headerline, entity_data, chunk_size=500): """ Submit a large number of entity updates in batches of chunk_size """ if fcconfig.verbosity: print("Batching " + str(len(entity_data)) + " updates to Firecloud...") # Parse the entity type from the first cell, e.g. "...
python
def _batch_load(project, workspace, headerline, entity_data, chunk_size=500): """ Submit a large number of entity updates in batches of chunk_size """ if fcconfig.verbosity: print("Batching " + str(len(entity_data)) + " updates to Firecloud...") # Parse the entity type from the first cell, e.g. "...
[ "def", "_batch_load", "(", "project", ",", "workspace", ",", "headerline", ",", "entity_data", ",", "chunk_size", "=", "500", ")", ":", "if", "fcconfig", ".", "verbosity", ":", "print", "(", "\"Batching \"", "+", "str", "(", "len", "(", "entity_data", ")",...
Submit a large number of entity updates in batches of chunk_size
[ "Submit", "a", "large", "number", "of", "entity", "updates", "in", "batches", "of", "chunk_size" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1753-L1784
broadinstitute/fiss
firecloud/fiss.py
main_as_cli
def main_as_cli(argv=None): '''Use this entry point to call HL fiss funcs as though from the UNIX CLI. (see firecloud/tests/highlevel_tests.py:call_cli for usage examples)''' try: result = main(argv) except Exception as e: result = __pretty_print_fc_exception(e) # FIXME: we should...
python
def main_as_cli(argv=None): '''Use this entry point to call HL fiss funcs as though from the UNIX CLI. (see firecloud/tests/highlevel_tests.py:call_cli for usage examples)''' try: result = main(argv) except Exception as e: result = __pretty_print_fc_exception(e) # FIXME: we should...
[ "def", "main_as_cli", "(", "argv", "=", "None", ")", ":", "try", ":", "result", "=", "main", "(", "argv", ")", "except", "Exception", "as", "e", ":", "result", "=", "__pretty_print_fc_exception", "(", "e", ")", "# FIXME: we should invert True/False return values...
Use this entry point to call HL fiss funcs as though from the UNIX CLI. (see firecloud/tests/highlevel_tests.py:call_cli for usage examples)
[ "Use", "this", "entry", "point", "to", "call", "HL", "fiss", "funcs", "as", "though", "from", "the", "UNIX", "CLI", ".", "(", "see", "firecloud", "/", "tests", "/", "highlevel_tests", ".", "py", ":", "call_cli", "for", "usage", "examples", ")" ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L2547-L2556
broadinstitute/fiss
firecloud/entity.py
Entity.create_payload
def create_payload(entities): """Create a tsv payload describing entities. A TSV payload consists of 1 header row describing entity type and attribute names. Each subsequent line is an entity_id followed by attribute values separated by the tab "\\t" character. This payload can ...
python
def create_payload(entities): """Create a tsv payload describing entities. A TSV payload consists of 1 header row describing entity type and attribute names. Each subsequent line is an entity_id followed by attribute values separated by the tab "\\t" character. This payload can ...
[ "def", "create_payload", "(", "entities", ")", ":", "#First check that all entities are of the same type", "types", "=", "{", "e", ".", "etype", "for", "e", "in", "entities", "}", "if", "len", "(", "types", ")", "!=", "1", ":", "raise", "ValueError", "(", "\...
Create a tsv payload describing entities. A TSV payload consists of 1 header row describing entity type and attribute names. Each subsequent line is an entity_id followed by attribute values separated by the tab "\\t" character. This payload can be uploaded to the workspace via ...
[ "Create", "a", "tsv", "payload", "describing", "entities", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/entity.py#L40-L70
broadinstitute/fiss
firecloud/entity.py
Entity.create_loadfile
def create_loadfile(entities, f): """Create payload and save to file.""" with open(f, 'w') as out: out.write(Entity.create_payload(entities))
python
def create_loadfile(entities, f): """Create payload and save to file.""" with open(f, 'w') as out: out.write(Entity.create_payload(entities))
[ "def", "create_loadfile", "(", "entities", ",", "f", ")", ":", "with", "open", "(", "f", ",", "'w'", ")", "as", "out", ":", "out", ".", "write", "(", "Entity", ".", "create_payload", "(", "entities", ")", ")" ]
Create payload and save to file.
[ "Create", "payload", "and", "save", "to", "file", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/entity.py#L73-L76
broadinstitute/fiss
setup.py
InstallCommand.needs_gcloud
def needs_gcloud(self): """Returns true if gcloud is unavailable and needed for authentication.""" gcloud_default_path = ['google-cloud-sdk', 'bin'] if platform.system() != "Windows": gcloud_default_path = os.path.join(os.path.expanduser('~'), ...
python
def needs_gcloud(self): """Returns true if gcloud is unavailable and needed for authentication.""" gcloud_default_path = ['google-cloud-sdk', 'bin'] if platform.system() != "Windows": gcloud_default_path = os.path.join(os.path.expanduser('~'), ...
[ "def", "needs_gcloud", "(", "self", ")", ":", "gcloud_default_path", "=", "[", "'google-cloud-sdk'", ",", "'bin'", "]", "if", "platform", ".", "system", "(", ")", "!=", "\"Windows\"", ":", "gcloud_default_path", "=", "os", ".", "path", ".", "join", "(", "o...
Returns true if gcloud is unavailable and needed for authentication.
[ "Returns", "true", "if", "gcloud", "is", "unavailable", "and", "needed", "for", "authentication", "." ]
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/setup.py#L16-L30
fhcrc/seqmagick
seqmagick/subcommands/mogrify.py
action
def action(arguments): """ Run mogrify. Most of the action is in convert, this just creates a temp file for the output. """ for input_file in arguments.input_files: logging.info(input_file) # Generate a temporary file with common.atomic_write( input_file.name...
python
def action(arguments): """ Run mogrify. Most of the action is in convert, this just creates a temp file for the output. """ for input_file in arguments.input_files: logging.info(input_file) # Generate a temporary file with common.atomic_write( input_file.name...
[ "def", "action", "(", "arguments", ")", ":", "for", "input_file", "in", "arguments", ".", "input_files", ":", "logging", ".", "info", "(", "input_file", ")", "# Generate a temporary file", "with", "common", ".", "atomic_write", "(", "input_file", ".", "name", ...
Run mogrify. Most of the action is in convert, this just creates a temp file for the output.
[ "Run", "mogrify", ".", "Most", "of", "the", "action", "is", "in", "convert", "this", "just", "creates", "a", "temp", "file", "for", "the", "output", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/mogrify.py#L22-L34
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
all_unambiguous
def all_unambiguous(sequence_str): """ All unambiguous versions of sequence_str """ result = [[]] for c in sequence_str: result = [i + [a] for i in result for a in _AMBIGUOUS_MAP.get(c, c)] return [''.join(i) for i in result]
python
def all_unambiguous(sequence_str): """ All unambiguous versions of sequence_str """ result = [[]] for c in sequence_str: result = [i + [a] for i in result for a in _AMBIGUOUS_MAP.get(c, c)] return [''.join(i) for i in result]
[ "def", "all_unambiguous", "(", "sequence_str", ")", ":", "result", "=", "[", "[", "]", "]", "for", "c", "in", "sequence_str", ":", "result", "=", "[", "i", "+", "[", "a", "]", "for", "i", "in", "result", "for", "a", "in", "_AMBIGUOUS_MAP", ".", "ge...
All unambiguous versions of sequence_str
[ "All", "unambiguous", "versions", "of", "sequence_str" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L44-L51
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
build_parser
def build_parser(parser): """ Generate a subparser """ parser.add_argument( 'sequence_file', type=FileType('r'), help="""Input fastq file. A fasta-format file may also be provided if --input-qual is also specified.""") parser.add_argument( '--input-qual', ...
python
def build_parser(parser): """ Generate a subparser """ parser.add_argument( 'sequence_file', type=FileType('r'), help="""Input fastq file. A fasta-format file may also be provided if --input-qual is also specified.""") parser.add_argument( '--input-qual', ...
[ "def", "build_parser", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "'sequence_file'", ",", "type", "=", "FileType", "(", "'r'", ")", ",", "help", "=", "\"\"\"Input fastq file. A fasta-format file may also be provided\n if --input-qual is also spe...
Generate a subparser
[ "Generate", "a", "subparser" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L54-L194
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
moving_average
def moving_average(iterable, n): """ From Python collections module documentation moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0 """ it = iter(iterable) d = collections.deque(itertools.islice(it, n - 1)) d.appendleft(0) s = sum(d) for elem in it: s += elem ...
python
def moving_average(iterable, n): """ From Python collections module documentation moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0 """ it = iter(iterable) d = collections.deque(itertools.islice(it, n - 1)) d.appendleft(0) s = sum(d) for elem in it: s += elem ...
[ "def", "moving_average", "(", "iterable", ",", "n", ")", ":", "it", "=", "iter", "(", "iterable", ")", "d", "=", "collections", ".", "deque", "(", "itertools", ".", "islice", "(", "it", ",", "n", "-", "1", ")", ")", "d", ".", "appendleft", "(", "...
From Python collections module documentation moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0
[ "From", "Python", "collections", "module", "documentation" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L204-L217
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
parse_barcode_file
def parse_barcode_file(fp, primer=None, header=False): """ Load label, barcode, primer records from a CSV file. Returns a map from barcode -> label Any additional columns are ignored """ tr = trie.trie() reader = csv.reader(fp) if header: # Skip header next(reader) ...
python
def parse_barcode_file(fp, primer=None, header=False): """ Load label, barcode, primer records from a CSV file. Returns a map from barcode -> label Any additional columns are ignored """ tr = trie.trie() reader = csv.reader(fp) if header: # Skip header next(reader) ...
[ "def", "parse_barcode_file", "(", "fp", ",", "primer", "=", "None", ",", "header", "=", "False", ")", ":", "tr", "=", "trie", ".", "trie", "(", ")", "reader", "=", "csv", ".", "reader", "(", "fp", ")", "if", "header", ":", "# Skip header", "next", ...
Load label, barcode, primer records from a CSV file. Returns a map from barcode -> label Any additional columns are ignored
[ "Load", "label", "barcode", "primer", "records", "from", "a", "CSV", "file", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L641-L672
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
action
def action(arguments): """ Given parsed arguments, filter input files. """ if arguments.quality_window_mean_qual and not arguments.quality_window: raise ValueError("--quality-window-mean-qual specified without " "--quality-window") if trie is None or triefind is Non...
python
def action(arguments): """ Given parsed arguments, filter input files. """ if arguments.quality_window_mean_qual and not arguments.quality_window: raise ValueError("--quality-window-mean-qual specified without " "--quality-window") if trie is None or triefind is Non...
[ "def", "action", "(", "arguments", ")", ":", "if", "arguments", ".", "quality_window_mean_qual", "and", "not", "arguments", ".", "quality_window", ":", "raise", "ValueError", "(", "\"--quality-window-mean-qual specified without \"", "\"--quality-window\"", ")", "if", "t...
Given parsed arguments, filter input files.
[ "Given", "parsed", "arguments", "filter", "input", "files", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L675-L767
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
RecordEventListener.iterable_hook
def iterable_hook(self, name, iterable): """ Fire an event named ``name`` with each item in iterable """ for record in iterable: self(name, record) yield record
python
def iterable_hook(self, name, iterable): """ Fire an event named ``name`` with each item in iterable """ for record in iterable: self(name, record) yield record
[ "def", "iterable_hook", "(", "self", ",", "name", ",", "iterable", ")", ":", "for", "record", "in", "iterable", ":", "self", "(", "name", ",", "record", ")", "yield", "record" ]
Fire an event named ``name`` with each item in iterable
[ "Fire", "an", "event", "named", "name", "with", "each", "item", "in", "iterable" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L258-L264
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
RecordReportHandler._found_barcode
def _found_barcode(self, record, sample, barcode=None): """Hook called when barcode is found""" assert record.id == self.current_record['sequence_name'] self.current_record['sample'] = sample
python
def _found_barcode(self, record, sample, barcode=None): """Hook called when barcode is found""" assert record.id == self.current_record['sequence_name'] self.current_record['sample'] = sample
[ "def", "_found_barcode", "(", "self", ",", "record", ",", "sample", ",", "barcode", "=", "None", ")", ":", "assert", "record", ".", "id", "==", "self", ".", "current_record", "[", "'sequence_name'", "]", "self", ".", "current_record", "[", "'sample'", "]",...
Hook called when barcode is found
[ "Hook", "called", "when", "barcode", "is", "found" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L327-L330
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
BaseFilter.filter_records
def filter_records(self, records): """ Apply the filter to records """ for record in records: try: filtered = self.filter_record(record) assert (filtered) # Quick tracking whether the sequence was modified if fil...
python
def filter_records(self, records): """ Apply the filter to records """ for record in records: try: filtered = self.filter_record(record) assert (filtered) # Quick tracking whether the sequence was modified if fil...
[ "def", "filter_records", "(", "self", ",", "records", ")", ":", "for", "record", "in", "records", ":", "try", ":", "filtered", "=", "self", ".", "filter_record", "(", "record", ")", "assert", "(", "filtered", ")", "# Quick tracking whether the sequence was modif...
Apply the filter to records
[ "Apply", "the", "filter", "to", "records" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L374-L396
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
QualityScoreFilter.filter_record
def filter_record(self, record): """ Filter a single record """ quality_scores = record.letter_annotations['phred_quality'] mean_score = mean(quality_scores) if mean_score >= self.min_mean_score: return record else: raise FailedFilter(mean...
python
def filter_record(self, record): """ Filter a single record """ quality_scores = record.letter_annotations['phred_quality'] mean_score = mean(quality_scores) if mean_score >= self.min_mean_score: return record else: raise FailedFilter(mean...
[ "def", "filter_record", "(", "self", ",", "record", ")", ":", "quality_scores", "=", "record", ".", "letter_annotations", "[", "'phred_quality'", "]", "mean_score", "=", "mean", "(", "quality_scores", ")", "if", "mean_score", ">=", "self", ".", "min_mean_score",...
Filter a single record
[ "Filter", "a", "single", "record" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L427-L437
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
WindowQualityScoreFilter.filter_record
def filter_record(self, record): """ Filter a single record """ quality_scores = record.letter_annotations['phred_quality'] # Simple case - window covers whole sequence if len(record) <= self.window_size: mean_score = mean(quality_scores) if mean_...
python
def filter_record(self, record): """ Filter a single record """ quality_scores = record.letter_annotations['phred_quality'] # Simple case - window covers whole sequence if len(record) <= self.window_size: mean_score = mean(quality_scores) if mean_...
[ "def", "filter_record", "(", "self", ",", "record", ")", ":", "quality_scores", "=", "record", ".", "letter_annotations", "[", "'phred_quality'", "]", "# Simple case - window covers whole sequence", "if", "len", "(", "record", ")", "<=", "self", ".", "window_size", ...
Filter a single record
[ "Filter", "a", "single", "record" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L455-L485
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
AmbiguousBaseFilter.filter_record
def filter_record(self, record): """ Filter a record, truncating or dropping at an 'N' """ nloc = record.seq.find('N') if nloc == -1: return record elif self.action == 'truncate': return record[:nloc] elif self.action == 'drop': ...
python
def filter_record(self, record): """ Filter a record, truncating or dropping at an 'N' """ nloc = record.seq.find('N') if nloc == -1: return record elif self.action == 'truncate': return record[:nloc] elif self.action == 'drop': ...
[ "def", "filter_record", "(", "self", ",", "record", ")", ":", "nloc", "=", "record", ".", "seq", ".", "find", "(", "'N'", ")", "if", "nloc", "==", "-", "1", ":", "return", "record", "elif", "self", ".", "action", "==", "'truncate'", ":", "return", ...
Filter a record, truncating or dropping at an 'N'
[ "Filter", "a", "record", "truncating", "or", "dropping", "at", "an", "N" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L504-L516
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
MinLengthFilter.filter_record
def filter_record(self, record): """ Filter record, dropping any that don't meet minimum length """ if len(record) >= self.min_length: return record else: raise FailedFilter(len(record))
python
def filter_record(self, record): """ Filter record, dropping any that don't meet minimum length """ if len(record) >= self.min_length: return record else: raise FailedFilter(len(record))
[ "def", "filter_record", "(", "self", ",", "record", ")", ":", "if", "len", "(", "record", ")", ">=", "self", ".", "min_length", ":", "return", "record", "else", ":", "raise", "FailedFilter", "(", "len", "(", "record", ")", ")" ]
Filter record, dropping any that don't meet minimum length
[ "Filter", "record", "dropping", "any", "that", "don", "t", "meet", "minimum", "length" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L575-L583
fhcrc/seqmagick
seqmagick/subcommands/quality_filter.py
MaxLengthFilter.filter_record
def filter_record(self, record): """ Filter record, truncating any over some maximum length """ if len(record) >= self.max_length: return record[:self.max_length] else: return record
python
def filter_record(self, record): """ Filter record, truncating any over some maximum length """ if len(record) >= self.max_length: return record[:self.max_length] else: return record
[ "def", "filter_record", "(", "self", ",", "record", ")", ":", "if", "len", "(", "record", ")", ">=", "self", ".", "max_length", ":", "return", "record", "[", ":", "self", ".", "max_length", "]", "else", ":", "return", "record" ]
Filter record, truncating any over some maximum length
[ "Filter", "record", "truncating", "any", "over", "some", "maximum", "length" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L597-L604
fhcrc/seqmagick
seqmagick/subcommands/info.py
summarize_sequence_file
def summarize_sequence_file(source_file, file_type=None): """ Summarizes a sequence file, returning a tuple containing the name, whether the file is an alignment, minimum sequence length, maximum sequence length, average length, number of sequences. """ is_alignment = True avg_length = None ...
python
def summarize_sequence_file(source_file, file_type=None): """ Summarizes a sequence file, returning a tuple containing the name, whether the file is an alignment, minimum sequence length, maximum sequence length, average length, number of sequences. """ is_alignment = True avg_length = None ...
[ "def", "summarize_sequence_file", "(", "source_file", ",", "file_type", "=", "None", ")", ":", "is_alignment", "=", "True", "avg_length", "=", "None", "min_length", "=", "sys", ".", "maxsize", "max_length", "=", "0", "sequence_count", "=", "0", "# Get an iterato...
Summarizes a sequence file, returning a tuple containing the name, whether the file is an alignment, minimum sequence length, maximum sequence length, average length, number of sequences.
[ "Summarizes", "a", "sequence", "file", "returning", "a", "tuple", "containing", "the", "name", "whether", "the", "file", "is", "an", "alignment", "minimum", "sequence", "length", "maximum", "sequence", "length", "average", "length", "number", "of", "sequences", ...
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/info.py#L98-L143
fhcrc/seqmagick
seqmagick/subcommands/info.py
action
def action(arguments): """ Given one more more sequence files, determine if the file is an alignment, the maximum sequence length and the total number of sequences. Provides different output formats including tab (tab-delimited), csv and align (aligned as if part of a borderless table). """ ...
python
def action(arguments): """ Given one more more sequence files, determine if the file is an alignment, the maximum sequence length and the total number of sequences. Provides different output formats including tab (tab-delimited), csv and align (aligned as if part of a borderless table). """ ...
[ "def", "action", "(", "arguments", ")", ":", "# Ignore SIGPIPE, for head support", "common", ".", "exit_on_sigpipe", "(", ")", "common", ".", "exit_on_sigint", "(", ")", "handle", "=", "arguments", ".", "destination_file", "output_format", "=", "arguments", ".", "...
Given one more more sequence files, determine if the file is an alignment, the maximum sequence length and the total number of sequences. Provides different output formats including tab (tab-delimited), csv and align (aligned as if part of a borderless table).
[ "Given", "one", "more", "more", "sequence", "files", "determine", "if", "the", "file", "is", "an", "alignment", "the", "maximum", "sequence", "length", "and", "the", "total", "number", "of", "sequences", ".", "Provides", "different", "output", "formats", "incl...
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/info.py#L145-L178
fhcrc/seqmagick
seqmagick/transform.py
_record_buffer
def _record_buffer(records, buffer_size=DEFAULT_BUFFER_SIZE): """ Buffer for transform functions which require multiple passes through data. Value returned by context manager is a function which returns an iterator through records. """ with tempfile.SpooledTemporaryFile(buffer_size, mode='wb+')...
python
def _record_buffer(records, buffer_size=DEFAULT_BUFFER_SIZE): """ Buffer for transform functions which require multiple passes through data. Value returned by context manager is a function which returns an iterator through records. """ with tempfile.SpooledTemporaryFile(buffer_size, mode='wb+')...
[ "def", "_record_buffer", "(", "records", ",", "buffer_size", "=", "DEFAULT_BUFFER_SIZE", ")", ":", "with", "tempfile", ".", "SpooledTemporaryFile", "(", "buffer_size", ",", "mode", "=", "'wb+'", ")", "as", "tf", ":", "pickler", "=", "pickle", ".", "Pickler", ...
Buffer for transform functions which require multiple passes through data. Value returned by context manager is a function which returns an iterator through records.
[ "Buffer", "for", "transform", "functions", "which", "require", "multiple", "passes", "through", "data", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L32-L53
fhcrc/seqmagick
seqmagick/transform.py
dashes_cleanup
def dashes_cleanup(records, prune_chars='.:?~'): """ Take an alignment and convert any undesirable characters such as ? or ~ to -. """ logging.info( "Applying _dashes_cleanup: converting any of '{}' to '-'.".format(prune_chars)) translation_table = {ord(c): '-' for c in prune_chars} ...
python
def dashes_cleanup(records, prune_chars='.:?~'): """ Take an alignment and convert any undesirable characters such as ? or ~ to -. """ logging.info( "Applying _dashes_cleanup: converting any of '{}' to '-'.".format(prune_chars)) translation_table = {ord(c): '-' for c in prune_chars} ...
[ "def", "dashes_cleanup", "(", "records", ",", "prune_chars", "=", "'.:?~'", ")", ":", "logging", ".", "info", "(", "\"Applying _dashes_cleanup: converting any of '{}' to '-'.\"", ".", "format", "(", "prune_chars", ")", ")", "translation_table", "=", "{", "ord", "(",...
Take an alignment and convert any undesirable characters such as ? or ~ to -.
[ "Take", "an", "alignment", "and", "convert", "any", "undesirable", "characters", "such", "as", "?", "or", "~", "to", "-", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L56-L67
fhcrc/seqmagick
seqmagick/transform.py
deduplicate_sequences
def deduplicate_sequences(records, out_file): """ Remove any duplicate records with identical sequences, keep the first instance seen and discard additional occurences. """ logging.info('Applying _deduplicate_sequences generator: ' 'removing any duplicate records with identical seq...
python
def deduplicate_sequences(records, out_file): """ Remove any duplicate records with identical sequences, keep the first instance seen and discard additional occurences. """ logging.info('Applying _deduplicate_sequences generator: ' 'removing any duplicate records with identical seq...
[ "def", "deduplicate_sequences", "(", "records", ",", "out_file", ")", ":", "logging", ".", "info", "(", "'Applying _deduplicate_sequences generator: '", "'removing any duplicate records with identical sequences.'", ")", "checksum_sequences", "=", "collections", ".", "defaultdic...
Remove any duplicate records with identical sequences, keep the first instance seen and discard additional occurences.
[ "Remove", "any", "duplicate", "records", "with", "identical", "sequences", "keep", "the", "first", "instance", "seen", "and", "discard", "additional", "occurences", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L70-L89
fhcrc/seqmagick
seqmagick/transform.py
deduplicate_taxa
def deduplicate_taxa(records): """ Remove any duplicate records with identical IDs, keep the first instance seen and discard additional occurences. """ logging.info('Applying _deduplicate_taxa generator: ' + \ 'removing any duplicate records with identical IDs.') taxa = set() ...
python
def deduplicate_taxa(records): """ Remove any duplicate records with identical IDs, keep the first instance seen and discard additional occurences. """ logging.info('Applying _deduplicate_taxa generator: ' + \ 'removing any duplicate records with identical IDs.') taxa = set() ...
[ "def", "deduplicate_taxa", "(", "records", ")", ":", "logging", ".", "info", "(", "'Applying _deduplicate_taxa generator: '", "+", "'removing any duplicate records with identical IDs.'", ")", "taxa", "=", "set", "(", ")", "for", "record", "in", "records", ":", "# Defa...
Remove any duplicate records with identical IDs, keep the first instance seen and discard additional occurences.
[ "Remove", "any", "duplicate", "records", "with", "identical", "IDs", "keep", "the", "first", "instance", "seen", "and", "discard", "additional", "occurences", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L92-L114
fhcrc/seqmagick
seqmagick/transform.py
first_name_capture
def first_name_capture(records): """ Take only the first whitespace-delimited word as the name of the sequence. Essentially removes any extra text from the sequence's description. """ logging.info('Applying _first_name_capture generator: ' 'making sure ID only contains the first whi...
python
def first_name_capture(records): """ Take only the first whitespace-delimited word as the name of the sequence. Essentially removes any extra text from the sequence's description. """ logging.info('Applying _first_name_capture generator: ' 'making sure ID only contains the first whi...
[ "def", "first_name_capture", "(", "records", ")", ":", "logging", ".", "info", "(", "'Applying _first_name_capture generator: '", "'making sure ID only contains the first whitespace-delimited '", "'word.'", ")", "whitespace", "=", "re", ".", "compile", "(", "r'\\s+'", ")", ...
Take only the first whitespace-delimited word as the name of the sequence. Essentially removes any extra text from the sequence's description.
[ "Take", "only", "the", "first", "whitespace", "-", "delimited", "word", "as", "the", "name", "of", "the", "sequence", ".", "Essentially", "removes", "any", "extra", "text", "from", "the", "sequence", "s", "description", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L117-L131
fhcrc/seqmagick
seqmagick/transform.py
include_from_file
def include_from_file(records, handle): """ Filter the records, keeping only sequences whose ID is contained in the handle. """ ids = set(i.strip() for i in handle) for record in records: if record.id.strip() in ids: yield record
python
def include_from_file(records, handle): """ Filter the records, keeping only sequences whose ID is contained in the handle. """ ids = set(i.strip() for i in handle) for record in records: if record.id.strip() in ids: yield record
[ "def", "include_from_file", "(", "records", ",", "handle", ")", ":", "ids", "=", "set", "(", "i", ".", "strip", "(", ")", "for", "i", "in", "handle", ")", "for", "record", "in", "records", ":", "if", "record", ".", "id", ".", "strip", "(", ")", "...
Filter the records, keeping only sequences whose ID is contained in the handle.
[ "Filter", "the", "records", "keeping", "only", "sequences", "whose", "ID", "is", "contained", "in", "the", "handle", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L134-L143
fhcrc/seqmagick
seqmagick/transform.py
isolate_region
def isolate_region(sequences, start, end, gap_char='-'): """ Replace regions before and after start:end with gap chars """ # Check arguments if end <= start: raise ValueError("start of slice must precede end ({0} !> {1})".format( end, start)) for sequence in sequences: ...
python
def isolate_region(sequences, start, end, gap_char='-'): """ Replace regions before and after start:end with gap chars """ # Check arguments if end <= start: raise ValueError("start of slice must precede end ({0} !> {1})".format( end, start)) for sequence in sequences: ...
[ "def", "isolate_region", "(", "sequences", ",", "start", ",", "end", ",", "gap_char", "=", "'-'", ")", ":", "# Check arguments", "if", "end", "<=", "start", ":", "raise", "ValueError", "(", "\"start of slice must precede end ({0} !> {1})\"", ".", "format", "(", ...
Replace regions before and after start:end with gap chars
[ "Replace", "regions", "before", "and", "after", "start", ":", "end", "with", "gap", "chars" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L158-L174
fhcrc/seqmagick
seqmagick/transform.py
drop_columns
def drop_columns(records, slices): """ Drop all columns present in ``slices`` from records """ for record in records: # Generate a set of indices to remove drop = set(i for slice in slices for i in range(*slice.indices(len(record)))) keep = [i not in drop for i...
python
def drop_columns(records, slices): """ Drop all columns present in ``slices`` from records """ for record in records: # Generate a set of indices to remove drop = set(i for slice in slices for i in range(*slice.indices(len(record)))) keep = [i not in drop for i...
[ "def", "drop_columns", "(", "records", ",", "slices", ")", ":", "for", "record", "in", "records", ":", "# Generate a set of indices to remove", "drop", "=", "set", "(", "i", "for", "slice", "in", "slices", "for", "i", "in", "range", "(", "*", "slice", ".",...
Drop all columns present in ``slices`` from records
[ "Drop", "all", "columns", "present", "in", "slices", "from", "records" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L184-L194
fhcrc/seqmagick
seqmagick/transform.py
cut_sequences_relative
def cut_sequences_relative(records, slices, record_id): """ Cuts records to slices, indexed by non-gap positions in record_id """ with _record_buffer(records) as r: try: record = next(i for i in r() if i.id == record_id) except StopIteration: raise ValueError("Rec...
python
def cut_sequences_relative(records, slices, record_id): """ Cuts records to slices, indexed by non-gap positions in record_id """ with _record_buffer(records) as r: try: record = next(i for i in r() if i.id == record_id) except StopIteration: raise ValueError("Rec...
[ "def", "cut_sequences_relative", "(", "records", ",", "slices", ",", "record_id", ")", ":", "with", "_record_buffer", "(", "records", ")", "as", "r", ":", "try", ":", "record", "=", "next", "(", "i", "for", "i", "in", "r", "(", ")", "if", "i", ".", ...
Cuts records to slices, indexed by non-gap positions in record_id
[ "Cuts", "records", "to", "slices", "indexed", "by", "non", "-", "gap", "positions", "in", "record_id" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L242-L254
fhcrc/seqmagick
seqmagick/transform.py
multi_mask_sequences
def multi_mask_sequences(records, slices): """ Replace characters sliced by slices with gap characters. """ for record in records: record_indices = list(range(len(record))) keep_indices = reduce(lambda i, s: i - frozenset(record_indices[s]), slices, frozense...
python
def multi_mask_sequences(records, slices): """ Replace characters sliced by slices with gap characters. """ for record in records: record_indices = list(range(len(record))) keep_indices = reduce(lambda i, s: i - frozenset(record_indices[s]), slices, frozense...
[ "def", "multi_mask_sequences", "(", "records", ",", "slices", ")", ":", "for", "record", "in", "records", ":", "record_indices", "=", "list", "(", "range", "(", "len", "(", "record", ")", ")", ")", "keep_indices", "=", "reduce", "(", "lambda", "i", ",", ...
Replace characters sliced by slices with gap characters.
[ "Replace", "characters", "sliced", "by", "slices", "with", "gap", "characters", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L256-L267
fhcrc/seqmagick
seqmagick/transform.py
prune_empty
def prune_empty(records): """ Remove any sequences which are entirely gaps ('-') """ for record in records: if not all(c == '-' for c in str(record.seq)): yield record
python
def prune_empty(records): """ Remove any sequences which are entirely gaps ('-') """ for record in records: if not all(c == '-' for c in str(record.seq)): yield record
[ "def", "prune_empty", "(", "records", ")", ":", "for", "record", "in", "records", ":", "if", "not", "all", "(", "c", "==", "'-'", "for", "c", "in", "str", "(", "record", ".", "seq", ")", ")", ":", "yield", "record" ]
Remove any sequences which are entirely gaps ('-')
[ "Remove", "any", "sequences", "which", "are", "entirely", "gaps", "(", "-", ")" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L301-L307
fhcrc/seqmagick
seqmagick/transform.py
_reverse_annotations
def _reverse_annotations(old_record, new_record): """ Copy annotations form old_record to new_record, reversing any lists / tuples / strings. """ # Copy the annotations over for k, v in list(old_record.annotations.items()): # Trim if appropriate if isinstance(v, (tuple, list)) an...
python
def _reverse_annotations(old_record, new_record): """ Copy annotations form old_record to new_record, reversing any lists / tuples / strings. """ # Copy the annotations over for k, v in list(old_record.annotations.items()): # Trim if appropriate if isinstance(v, (tuple, list)) an...
[ "def", "_reverse_annotations", "(", "old_record", ",", "new_record", ")", ":", "# Copy the annotations over", "for", "k", ",", "v", "in", "list", "(", "old_record", ".", "annotations", ".", "items", "(", ")", ")", ":", "# Trim if appropriate", "if", "isinstance"...
Copy annotations form old_record to new_record, reversing any lists / tuples / strings.
[ "Copy", "annotations", "form", "old_record", "to", "new_record", "reversing", "any", "lists", "/", "tuples", "/", "strings", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L310-L327
fhcrc/seqmagick
seqmagick/transform.py
reverse_sequences
def reverse_sequences(records): """ Reverse the order of sites in sequences. """ logging.info('Applying _reverse_sequences generator: ' 'reversing the order of sites in sequences.') for record in records: rev_record = SeqRecord(record.seq[::-1], id=record.id, ...
python
def reverse_sequences(records): """ Reverse the order of sites in sequences. """ logging.info('Applying _reverse_sequences generator: ' 'reversing the order of sites in sequences.') for record in records: rev_record = SeqRecord(record.seq[::-1], id=record.id, ...
[ "def", "reverse_sequences", "(", "records", ")", ":", "logging", ".", "info", "(", "'Applying _reverse_sequences generator: '", "'reversing the order of sites in sequences.'", ")", "for", "record", "in", "records", ":", "rev_record", "=", "SeqRecord", "(", "record", "."...
Reverse the order of sites in sequences.
[ "Reverse", "the", "order", "of", "sites", "in", "sequences", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L330-L343
fhcrc/seqmagick
seqmagick/transform.py
reverse_complement_sequences
def reverse_complement_sequences(records): """ Transform sequences into reverse complements. """ logging.info('Applying _reverse_complement_sequences generator: ' 'transforming sequences into reverse complements.') for record in records: rev_record = SeqRecord(record.seq.rev...
python
def reverse_complement_sequences(records): """ Transform sequences into reverse complements. """ logging.info('Applying _reverse_complement_sequences generator: ' 'transforming sequences into reverse complements.') for record in records: rev_record = SeqRecord(record.seq.rev...
[ "def", "reverse_complement_sequences", "(", "records", ")", ":", "logging", ".", "info", "(", "'Applying _reverse_complement_sequences generator: '", "'transforming sequences into reverse complements.'", ")", "for", "record", "in", "records", ":", "rev_record", "=", "SeqRecor...
Transform sequences into reverse complements.
[ "Transform", "sequences", "into", "reverse", "complements", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L346-L359
fhcrc/seqmagick
seqmagick/transform.py
ungap_sequences
def ungap_sequences(records, gap_chars=GAP_TABLE): """ Remove gaps from sequences, given an alignment. """ logging.info('Applying _ungap_sequences generator: removing all gap characters') for record in records: yield ungap_all(record, gap_chars)
python
def ungap_sequences(records, gap_chars=GAP_TABLE): """ Remove gaps from sequences, given an alignment. """ logging.info('Applying _ungap_sequences generator: removing all gap characters') for record in records: yield ungap_all(record, gap_chars)
[ "def", "ungap_sequences", "(", "records", ",", "gap_chars", "=", "GAP_TABLE", ")", ":", "logging", ".", "info", "(", "'Applying _ungap_sequences generator: removing all gap characters'", ")", "for", "record", "in", "records", ":", "yield", "ungap_all", "(", "record", ...
Remove gaps from sequences, given an alignment.
[ "Remove", "gaps", "from", "sequences", "given", "an", "alignment", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L362-L368
fhcrc/seqmagick
seqmagick/transform.py
_update_id
def _update_id(record, new_id): """ Update a record id to new_id, also modifying the ID in record.description """ old_id = record.id record.id = new_id # At least for FASTA, record ID starts the description record.description = re.sub('^' + re.escape(old_id), new_id, record.description) ...
python
def _update_id(record, new_id): """ Update a record id to new_id, also modifying the ID in record.description """ old_id = record.id record.id = new_id # At least for FASTA, record ID starts the description record.description = re.sub('^' + re.escape(old_id), new_id, record.description) ...
[ "def", "_update_id", "(", "record", ",", "new_id", ")", ":", "old_id", "=", "record", ".", "id", "record", ".", "id", "=", "new_id", "# At least for FASTA, record ID starts the description", "record", ".", "description", "=", "re", ".", "sub", "(", "'^'", "+",...
Update a record id to new_id, also modifying the ID in record.description
[ "Update", "a", "record", "id", "to", "new_id", "also", "modifying", "the", "ID", "in", "record", ".", "description" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L380-L389
fhcrc/seqmagick
seqmagick/transform.py
name_append_suffix
def name_append_suffix(records, suffix): """ Given a set of sequences, append a suffix for each sequence's name. """ logging.info('Applying _name_append_suffix generator: ' 'Appending suffix ' + suffix + ' to all ' 'sequence IDs.') for record in records: new...
python
def name_append_suffix(records, suffix): """ Given a set of sequences, append a suffix for each sequence's name. """ logging.info('Applying _name_append_suffix generator: ' 'Appending suffix ' + suffix + ' to all ' 'sequence IDs.') for record in records: new...
[ "def", "name_append_suffix", "(", "records", ",", "suffix", ")", ":", "logging", ".", "info", "(", "'Applying _name_append_suffix generator: '", "'Appending suffix '", "+", "suffix", "+", "' to all '", "'sequence IDs.'", ")", "for", "record", "in", "records", ":", "...
Given a set of sequences, append a suffix for each sequence's name.
[ "Given", "a", "set", "of", "sequences", "append", "a", "suffix", "for", "each", "sequence", "s", "name", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L392-L402
fhcrc/seqmagick
seqmagick/transform.py
name_insert_prefix
def name_insert_prefix(records, prefix): """ Given a set of sequences, insert a prefix for each sequence's name. """ logging.info('Applying _name_insert_prefix generator: ' 'Inserting prefix ' + prefix + ' for all ' 'sequence IDs.') for record in records: ne...
python
def name_insert_prefix(records, prefix): """ Given a set of sequences, insert a prefix for each sequence's name. """ logging.info('Applying _name_insert_prefix generator: ' 'Inserting prefix ' + prefix + ' for all ' 'sequence IDs.') for record in records: ne...
[ "def", "name_insert_prefix", "(", "records", ",", "prefix", ")", ":", "logging", ".", "info", "(", "'Applying _name_insert_prefix generator: '", "'Inserting prefix '", "+", "prefix", "+", "' for all '", "'sequence IDs.'", ")", "for", "record", "in", "records", ":", ...
Given a set of sequences, insert a prefix for each sequence's name.
[ "Given", "a", "set", "of", "sequences", "insert", "a", "prefix", "for", "each", "sequence", "s", "name", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L405-L415
fhcrc/seqmagick
seqmagick/transform.py
name_include
def name_include(records, filter_regex): """ Given a set of sequences, filter out any sequences with names that do not match the specified regular expression. Ignore case. """ logging.info('Applying _name_include generator: ' 'including only IDs matching ' + filter_regex + ...
python
def name_include(records, filter_regex): """ Given a set of sequences, filter out any sequences with names that do not match the specified regular expression. Ignore case. """ logging.info('Applying _name_include generator: ' 'including only IDs matching ' + filter_regex + ...
[ "def", "name_include", "(", "records", ",", "filter_regex", ")", ":", "logging", ".", "info", "(", "'Applying _name_include generator: '", "'including only IDs matching '", "+", "filter_regex", "+", "' in results.'", ")", "regex", "=", "re", ".", "compile", "(", "fi...
Given a set of sequences, filter out any sequences with names that do not match the specified regular expression. Ignore case.
[ "Given", "a", "set", "of", "sequences", "filter", "out", "any", "sequences", "with", "names", "that", "do", "not", "match", "the", "specified", "regular", "expression", ".", "Ignore", "case", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L419-L430
fhcrc/seqmagick
seqmagick/transform.py
name_replace
def name_replace(records, search_regex, replace_pattern): """ Given a set of sequences, replace all occurrences of search_regex with replace_pattern. Ignore case. If the ID and the first word of the description match, assume the description is FASTA-like and apply the transform to the entire de...
python
def name_replace(records, search_regex, replace_pattern): """ Given a set of sequences, replace all occurrences of search_regex with replace_pattern. Ignore case. If the ID and the first word of the description match, assume the description is FASTA-like and apply the transform to the entire de...
[ "def", "name_replace", "(", "records", ",", "search_regex", ",", "replace_pattern", ")", ":", "regex", "=", "re", ".", "compile", "(", "search_regex", ")", "for", "record", "in", "records", ":", "maybe_id", "=", "record", ".", "description", ".", "split", ...
Given a set of sequences, replace all occurrences of search_regex with replace_pattern. Ignore case. If the ID and the first word of the description match, assume the description is FASTA-like and apply the transform to the entire description, then set the ID from the first word. If the ID and the ...
[ "Given", "a", "set", "of", "sequences", "replace", "all", "occurrences", "of", "search_regex", "with", "replace_pattern", ".", "Ignore", "case", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L446-L466
fhcrc/seqmagick
seqmagick/transform.py
seq_include
def seq_include(records, filter_regex): """ Filter any sequences who's seq does not match the filter. Ignore case. """ regex = re.compile(filter_regex) for record in records: if regex.search(str(record.seq)): yield record
python
def seq_include(records, filter_regex): """ Filter any sequences who's seq does not match the filter. Ignore case. """ regex = re.compile(filter_regex) for record in records: if regex.search(str(record.seq)): yield record
[ "def", "seq_include", "(", "records", ",", "filter_regex", ")", ":", "regex", "=", "re", ".", "compile", "(", "filter_regex", ")", "for", "record", "in", "records", ":", "if", "regex", ".", "search", "(", "str", "(", "record", ".", "seq", ")", ")", "...
Filter any sequences who's seq does not match the filter. Ignore case.
[ "Filter", "any", "sequences", "who", "s", "seq", "does", "not", "match", "the", "filter", ".", "Ignore", "case", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L469-L476
fhcrc/seqmagick
seqmagick/transform.py
sample
def sample(records, k, random_seed=None): """Choose a length-``k`` subset of ``records``, retaining the input order. If k > len(records), all are returned. If an integer ``random_seed`` is provided, sets ``random.seed()`` """ if random_seed is not None: random.seed(random_seed) resul...
python
def sample(records, k, random_seed=None): """Choose a length-``k`` subset of ``records``, retaining the input order. If k > len(records), all are returned. If an integer ``random_seed`` is provided, sets ``random.seed()`` """ if random_seed is not None: random.seed(random_seed) resul...
[ "def", "sample", "(", "records", ",", "k", ",", "random_seed", "=", "None", ")", ":", "if", "random_seed", "is", "not", "None", ":", "random", ".", "seed", "(", "random_seed", ")", "result", "=", "[", "]", "for", "i", ",", "record", "in", "enumerate"...
Choose a length-``k`` subset of ``records``, retaining the input order. If k > len(records), all are returned. If an integer ``random_seed`` is provided, sets ``random.seed()``
[ "Choose", "a", "length", "-", "k", "subset", "of", "records", "retaining", "the", "input", "order", ".", "If", "k", ">", "len", "(", "records", ")", "all", "are", "returned", ".", "If", "an", "integer", "random_seed", "is", "provided", "sets", "random", ...
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L489-L507
fhcrc/seqmagick
seqmagick/transform.py
head
def head(records, head): """ Limit results to the top N records. With the leading `-', print all but the last N records. """ logging.info('Applying _head generator: ' 'limiting results to top ' + head + ' records.') if head == '-0': for record in records: yi...
python
def head(records, head): """ Limit results to the top N records. With the leading `-', print all but the last N records. """ logging.info('Applying _head generator: ' 'limiting results to top ' + head + ' records.') if head == '-0': for record in records: yi...
[ "def", "head", "(", "records", ",", "head", ")", ":", "logging", ".", "info", "(", "'Applying _head generator: '", "'limiting results to top '", "+", "head", "+", "' records.'", ")", "if", "head", "==", "'-0'", ":", "for", "record", "in", "records", ":", "yi...
Limit results to the top N records. With the leading `-', print all but the last N records.
[ "Limit", "results", "to", "the", "top", "N", "records", ".", "With", "the", "leading", "-", "print", "all", "but", "the", "last", "N", "records", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L510-L529
fhcrc/seqmagick
seqmagick/transform.py
tail
def tail(records, tail): """ Limit results to the bottom N records. Use +N to output records starting with the Nth. """ logging.info('Applying _tail generator: ' 'limiting results to top ' + tail + ' records.') if tail == '+0': for record in records: yield r...
python
def tail(records, tail): """ Limit results to the bottom N records. Use +N to output records starting with the Nth. """ logging.info('Applying _tail generator: ' 'limiting results to top ' + tail + ' records.') if tail == '+0': for record in records: yield r...
[ "def", "tail", "(", "records", ",", "tail", ")", ":", "logging", ".", "info", "(", "'Applying _tail generator: '", "'limiting results to top '", "+", "tail", "+", "' records.'", ")", "if", "tail", "==", "'+0'", ":", "for", "record", "in", "records", ":", "yi...
Limit results to the bottom N records. Use +N to output records starting with the Nth.
[ "Limit", "results", "to", "the", "bottom", "N", "records", ".", "Use", "+", "N", "to", "output", "records", "starting", "with", "the", "Nth", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L531-L551
fhcrc/seqmagick
seqmagick/transform.py
gap_proportion
def gap_proportion(sequences, gap_chars='-'): """ Generates a list with the proportion of gaps by index in a set of sequences. """ aln_len = None gaps = [] for i, sequence in enumerate(sequences): if aln_len is None: aln_len = len(sequence) gaps = [0] * aln_le...
python
def gap_proportion(sequences, gap_chars='-'): """ Generates a list with the proportion of gaps by index in a set of sequences. """ aln_len = None gaps = [] for i, sequence in enumerate(sequences): if aln_len is None: aln_len = len(sequence) gaps = [0] * aln_le...
[ "def", "gap_proportion", "(", "sequences", ",", "gap_chars", "=", "'-'", ")", ":", "aln_len", "=", "None", "gaps", "=", "[", "]", "for", "i", ",", "sequence", "in", "enumerate", "(", "sequences", ")", ":", "if", "aln_len", "is", "None", ":", "aln_len",...
Generates a list with the proportion of gaps by index in a set of sequences.
[ "Generates", "a", "list", "with", "the", "proportion", "of", "gaps", "by", "index", "in", "a", "set", "of", "sequences", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L554-L577
fhcrc/seqmagick
seqmagick/transform.py
squeeze
def squeeze(records, gap_threshold=1.0): """ Remove any gaps that are present in the same position across all sequences in an alignment. Takes a second sequence iterator for determining gap positions. """ with _record_buffer(records) as r: gap_proportions = gap_proportion(r()) ...
python
def squeeze(records, gap_threshold=1.0): """ Remove any gaps that are present in the same position across all sequences in an alignment. Takes a second sequence iterator for determining gap positions. """ with _record_buffer(records) as r: gap_proportions = gap_proportion(r()) ...
[ "def", "squeeze", "(", "records", ",", "gap_threshold", "=", "1.0", ")", ":", "with", "_record_buffer", "(", "records", ")", "as", "r", ":", "gap_proportions", "=", "gap_proportion", "(", "r", "(", ")", ")", "keep_columns", "=", "[", "g", "<", "gap_thres...
Remove any gaps that are present in the same position across all sequences in an alignment. Takes a second sequence iterator for determining gap positions.
[ "Remove", "any", "gaps", "that", "are", "present", "in", "the", "same", "position", "across", "all", "sequences", "in", "an", "alignment", ".", "Takes", "a", "second", "sequence", "iterator", "for", "determining", "gap", "positions", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L580-L596
fhcrc/seqmagick
seqmagick/transform.py
strip_range
def strip_range(records): """ Cut off trailing /<start>-<stop> ranges from IDs. Ranges must be 1-indexed and the stop integer must not be less than the start integer. """ logging.info('Applying _strip_range generator: ' 'removing /<start>-<stop> ranges from IDs') # Split up and...
python
def strip_range(records): """ Cut off trailing /<start>-<stop> ranges from IDs. Ranges must be 1-indexed and the stop integer must not be less than the start integer. """ logging.info('Applying _strip_range generator: ' 'removing /<start>-<stop> ranges from IDs') # Split up and...
[ "def", "strip_range", "(", "records", ")", ":", "logging", ".", "info", "(", "'Applying _strip_range generator: '", "'removing /<start>-<stop> ranges from IDs'", ")", "# Split up and be greedy.", "cut_regex", "=", "re", ".", "compile", "(", "r\"(?P<id>.*)\\/(?P<start>\\d+)\\-...
Cut off trailing /<start>-<stop> ranges from IDs. Ranges must be 1-indexed and the stop integer must not be less than the start integer.
[ "Cut", "off", "trailing", "/", "<start", ">", "-", "<stop", ">", "ranges", "from", "IDs", ".", "Ranges", "must", "be", "1", "-", "indexed", "and", "the", "stop", "integer", "must", "not", "be", "less", "than", "the", "start", "integer", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L598-L617
fhcrc/seqmagick
seqmagick/transform.py
transcribe
def transcribe(records, transcribe): """ Perform transcription or back-transcription. transcribe must be one of the following: dna2rna rna2dna """ logging.info('Applying _transcribe generator: ' 'operation to perform is ' + transcribe + '.') for record in records...
python
def transcribe(records, transcribe): """ Perform transcription or back-transcription. transcribe must be one of the following: dna2rna rna2dna """ logging.info('Applying _transcribe generator: ' 'operation to perform is ' + transcribe + '.') for record in records...
[ "def", "transcribe", "(", "records", ",", "transcribe", ")", ":", "logging", ".", "info", "(", "'Applying _transcribe generator: '", "'operation to perform is '", "+", "transcribe", "+", "'.'", ")", "for", "record", "in", "records", ":", "sequence", "=", "str", ...
Perform transcription or back-transcription. transcribe must be one of the following: dna2rna rna2dna
[ "Perform", "transcription", "or", "back", "-", "transcription", ".", "transcribe", "must", "be", "one", "of", "the", "following", ":", "dna2rna", "rna2dna" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L620-L640
fhcrc/seqmagick
seqmagick/transform.py
translate
def translate(records, translate): """ Perform translation from generic DNA/RNA to proteins. Bio.Seq does not perform back-translation because the codons would more-or-less be arbitrary. Option to translate only up until reaching a stop codon. translate must be one of the following: dna2p...
python
def translate(records, translate): """ Perform translation from generic DNA/RNA to proteins. Bio.Seq does not perform back-translation because the codons would more-or-less be arbitrary. Option to translate only up until reaching a stop codon. translate must be one of the following: dna2p...
[ "def", "translate", "(", "records", ",", "translate", ")", ":", "logging", ".", "info", "(", "'Applying translation generator: '", "'operation to perform is '", "+", "translate", "+", "'.'", ")", "to_stop", "=", "translate", ".", "endswith", "(", "'stop'", ")", ...
Perform translation from generic DNA/RNA to proteins. Bio.Seq does not perform back-translation because the codons would more-or-less be arbitrary. Option to translate only up until reaching a stop codon. translate must be one of the following: dna2protein dna2proteinstop rna2prot...
[ "Perform", "translation", "from", "generic", "DNA", "/", "RNA", "to", "proteins", ".", "Bio", ".", "Seq", "does", "not", "perform", "back", "-", "translation", "because", "the", "codons", "would", "more", "-", "or", "-", "less", "be", "arbitrary", ".", "...
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L675-L708
fhcrc/seqmagick
seqmagick/transform.py
max_length_discard
def max_length_discard(records, max_length): """ Discard any records that are longer than max_length. """ logging.info('Applying _max_length_discard generator: ' 'discarding records longer than ' '.') for record in records: if len(record) > max_length: ...
python
def max_length_discard(records, max_length): """ Discard any records that are longer than max_length. """ logging.info('Applying _max_length_discard generator: ' 'discarding records longer than ' '.') for record in records: if len(record) > max_length: ...
[ "def", "max_length_discard", "(", "records", ",", "max_length", ")", ":", "logging", ".", "info", "(", "'Applying _max_length_discard generator: '", "'discarding records longer than '", "'.'", ")", "for", "record", "in", "records", ":", "if", "len", "(", "record", "...
Discard any records that are longer than max_length.
[ "Discard", "any", "records", "that", "are", "longer", "than", "max_length", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L711-L724
fhcrc/seqmagick
seqmagick/transform.py
min_length_discard
def min_length_discard(records, min_length): """ Discard any records that are shorter than min_length. """ logging.info('Applying _min_length_discard generator: ' 'discarding records shorter than %d.', min_length) for record in records: if len(record) < min_length: ...
python
def min_length_discard(records, min_length): """ Discard any records that are shorter than min_length. """ logging.info('Applying _min_length_discard generator: ' 'discarding records shorter than %d.', min_length) for record in records: if len(record) < min_length: ...
[ "def", "min_length_discard", "(", "records", ",", "min_length", ")", ":", "logging", ".", "info", "(", "'Applying _min_length_discard generator: '", "'discarding records shorter than %d.'", ",", "min_length", ")", "for", "record", "in", "records", ":", "if", "len", "(...
Discard any records that are shorter than min_length.
[ "Discard", "any", "records", "that", "are", "shorter", "than", "min_length", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L727-L738
fhcrc/seqmagick
seqmagick/transform.py
min_ungap_length_discard
def min_ungap_length_discard(records, min_length): """ Discard any records that are shorter than min_length after removing gaps. """ for record in records: if len(ungap_all(record)) >= min_length: yield record
python
def min_ungap_length_discard(records, min_length): """ Discard any records that are shorter than min_length after removing gaps. """ for record in records: if len(ungap_all(record)) >= min_length: yield record
[ "def", "min_ungap_length_discard", "(", "records", ",", "min_length", ")", ":", "for", "record", "in", "records", ":", "if", "len", "(", "ungap_all", "(", "record", ")", ")", ">=", "min_length", ":", "yield", "record" ]
Discard any records that are shorter than min_length after removing gaps.
[ "Discard", "any", "records", "that", "are", "shorter", "than", "min_length", "after", "removing", "gaps", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L741-L747
fhcrc/seqmagick
seqmagick/transform.py
sort_length
def sort_length(source_file, source_file_type, direction=1): """ Sort sequences by length. 1 is ascending (default) and 0 is descending. """ direction_text = 'ascending' if direction == 1 else 'descending' logging.info('Indexing sequences by length: %s', direction_text) # Adapted from the Biop...
python
def sort_length(source_file, source_file_type, direction=1): """ Sort sequences by length. 1 is ascending (default) and 0 is descending. """ direction_text = 'ascending' if direction == 1 else 'descending' logging.info('Indexing sequences by length: %s', direction_text) # Adapted from the Biop...
[ "def", "sort_length", "(", "source_file", ",", "source_file_type", ",", "direction", "=", "1", ")", ":", "direction_text", "=", "'ascending'", "if", "direction", "==", "1", "else", "'descending'", "logging", ".", "info", "(", "'Indexing sequences by length: %s'", ...
Sort sequences by length. 1 is ascending (default) and 0 is descending.
[ "Sort", "sequences", "by", "length", ".", "1", "is", "ascending", "(", "default", ")", "and", "0", "is", "descending", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L750-L781
fhcrc/seqmagick
seqmagick/subcommands/backtrans_align.py
batch
def batch(iterable, chunk_size): """ Return items from iterable in chunk_size bits. If len(iterable) % chunk_size > 0, the last item returned will be shorter. """ i = iter(iterable) while True: r = list(itertools.islice(i, chunk_size)) if not r: break yield r
python
def batch(iterable, chunk_size): """ Return items from iterable in chunk_size bits. If len(iterable) % chunk_size > 0, the last item returned will be shorter. """ i = iter(iterable) while True: r = list(itertools.islice(i, chunk_size)) if not r: break yield r
[ "def", "batch", "(", "iterable", ",", "chunk_size", ")", ":", "i", "=", "iter", "(", "iterable", ")", "while", "True", ":", "r", "=", "list", "(", "itertools", ".", "islice", "(", "i", ",", "chunk_size", ")", ")", "if", "not", "r", ":", "break", ...
Return items from iterable in chunk_size bits. If len(iterable) % chunk_size > 0, the last item returned will be shorter.
[ "Return", "items", "from", "iterable", "in", "chunk_size", "bits", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L51-L62
fhcrc/seqmagick
seqmagick/subcommands/backtrans_align.py
action
def action(arguments): """ Run """ # Ignore SIGPIPE, for head support common.exit_on_sigpipe() logging.basicConfig() prot_sequences = SeqIO.parse(arguments.protein_align, fileformat.from_handle(arguments.protein_align)) nucl_sequences = SeqIO.parse(argum...
python
def action(arguments): """ Run """ # Ignore SIGPIPE, for head support common.exit_on_sigpipe() logging.basicConfig() prot_sequences = SeqIO.parse(arguments.protein_align, fileformat.from_handle(arguments.protein_align)) nucl_sequences = SeqIO.parse(argum...
[ "def", "action", "(", "arguments", ")", ":", "# Ignore SIGPIPE, for head support", "common", ".", "exit_on_sigpipe", "(", ")", "logging", ".", "basicConfig", "(", ")", "prot_sequences", "=", "SeqIO", ".", "parse", "(", "arguments", ".", "protein_align", ",", "fi...
Run
[ "Run" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L150-L167
fhcrc/seqmagick
seqmagick/subcommands/backtrans_align.py
AlignmentMapper._validate_translation
def _validate_translation(self, aligned_prot, aligned_nucl): """ Given a seq for protein and nucleotide, ensure that the translation holds """ codons = [''.join(i) for i in batch(str(aligned_nucl), 3)] for codon, aa in zip(codons, str(aligned_prot)): # Check gaps ...
python
def _validate_translation(self, aligned_prot, aligned_nucl): """ Given a seq for protein and nucleotide, ensure that the translation holds """ codons = [''.join(i) for i in batch(str(aligned_nucl), 3)] for codon, aa in zip(codons, str(aligned_prot)): # Check gaps ...
[ "def", "_validate_translation", "(", "self", ",", "aligned_prot", ",", "aligned_nucl", ")", ":", "codons", "=", "[", "''", ".", "join", "(", "i", ")", "for", "i", "in", "batch", "(", "str", "(", "aligned_nucl", ")", ",", "3", ")", "]", "for", "codon"...
Given a seq for protein and nucleotide, ensure that the translation holds
[ "Given", "a", "seq", "for", "protein", "and", "nucleotide", "ensure", "that", "the", "translation", "holds" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L70-L93
fhcrc/seqmagick
seqmagick/subcommands/backtrans_align.py
AlignmentMapper.map_alignment
def map_alignment(self, prot_seq, nucl_seq): """ Use aligned prot_seq to align nucl_seq """ if prot_seq.id != nucl_seq.id: logging.warning( 'ID mismatch: %s != %s. Are the sequences in the same order?', prot_seq.id, nucl_seq.id) # Unga...
python
def map_alignment(self, prot_seq, nucl_seq): """ Use aligned prot_seq to align nucl_seq """ if prot_seq.id != nucl_seq.id: logging.warning( 'ID mismatch: %s != %s. Are the sequences in the same order?', prot_seq.id, nucl_seq.id) # Unga...
[ "def", "map_alignment", "(", "self", ",", "prot_seq", ",", "nucl_seq", ")", ":", "if", "prot_seq", ".", "id", "!=", "nucl_seq", ".", "id", ":", "logging", ".", "warning", "(", "'ID mismatch: %s != %s. Are the sequences in the same order?'", ",", "prot_seq", ".", ...
Use aligned prot_seq to align nucl_seq
[ "Use", "aligned", "prot_seq", "to", "align", "nucl_seq" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L95-L136
fhcrc/seqmagick
seqmagick/subcommands/backtrans_align.py
AlignmentMapper.map_all
def map_all(self, prot_alignment, nucl_sequences): """ Convert protein sequences to nucleotide alignment """ zipped = itertools.zip_longest(prot_alignment, nucl_sequences) for p, n in zipped: if p is None: raise ValueError("Exhausted protein sequences"...
python
def map_all(self, prot_alignment, nucl_sequences): """ Convert protein sequences to nucleotide alignment """ zipped = itertools.zip_longest(prot_alignment, nucl_sequences) for p, n in zipped: if p is None: raise ValueError("Exhausted protein sequences"...
[ "def", "map_all", "(", "self", ",", "prot_alignment", ",", "nucl_sequences", ")", ":", "zipped", "=", "itertools", ".", "zip_longest", "(", "prot_alignment", ",", "nucl_sequences", ")", "for", "p", ",", "n", "in", "zipped", ":", "if", "p", "is", "None", ...
Convert protein sequences to nucleotide alignment
[ "Convert", "protein", "sequences", "to", "nucleotide", "alignment" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L138-L148
fhcrc/seqmagick
seqmagick/fileformat.py
from_extension
def from_extension(extension): """ Look up the BioPython file type corresponding with input extension. Look up is case insensitive. """ if not extension.startswith('.'): raise ValueError("Extensions must begin with a period.") try: return EXTENSION_TO_TYPE[extension.lower()] ...
python
def from_extension(extension): """ Look up the BioPython file type corresponding with input extension. Look up is case insensitive. """ if not extension.startswith('.'): raise ValueError("Extensions must begin with a period.") try: return EXTENSION_TO_TYPE[extension.lower()] ...
[ "def", "from_extension", "(", "extension", ")", ":", "if", "not", "extension", ".", "startswith", "(", "'.'", ")", ":", "raise", "ValueError", "(", "\"Extensions must begin with a period.\"", ")", "try", ":", "return", "EXTENSION_TO_TYPE", "[", "extension", ".", ...
Look up the BioPython file type corresponding with input extension. Look up is case insensitive.
[ "Look", "up", "the", "BioPython", "file", "type", "corresponding", "with", "input", "extension", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/fileformat.py#L45-L58
fhcrc/seqmagick
seqmagick/fileformat.py
from_filename
def from_filename(file_name): """ Look up the BioPython file type corresponding to an input file name. """ base, extension = os.path.splitext(file_name) if extension in COMPRESS_EXT: # Compressed file extension = os.path.splitext(base)[1] return from_extension(extension)
python
def from_filename(file_name): """ Look up the BioPython file type corresponding to an input file name. """ base, extension = os.path.splitext(file_name) if extension in COMPRESS_EXT: # Compressed file extension = os.path.splitext(base)[1] return from_extension(extension)
[ "def", "from_filename", "(", "file_name", ")", ":", "base", ",", "extension", "=", "os", ".", "path", ".", "splitext", "(", "file_name", ")", "if", "extension", "in", "COMPRESS_EXT", ":", "# Compressed file", "extension", "=", "os", ".", "path", ".", "spli...
Look up the BioPython file type corresponding to an input file name.
[ "Look", "up", "the", "BioPython", "file", "type", "corresponding", "to", "an", "input", "file", "name", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/fileformat.py#L61-L69
fhcrc/seqmagick
seqmagick/fileformat.py
from_handle
def from_handle(fh, stream_default='fasta'): """ Look up the BioPython file type corresponding to a file-like object. For stdin, stdout, and stderr, ``stream_default`` is used. """ if fh in (sys.stdin, sys.stdout, sys.stderr): return stream_default return from_filename(fh.name)
python
def from_handle(fh, stream_default='fasta'): """ Look up the BioPython file type corresponding to a file-like object. For stdin, stdout, and stderr, ``stream_default`` is used. """ if fh in (sys.stdin, sys.stdout, sys.stderr): return stream_default return from_filename(fh.name)
[ "def", "from_handle", "(", "fh", ",", "stream_default", "=", "'fasta'", ")", ":", "if", "fh", "in", "(", "sys", ".", "stdin", ",", "sys", ".", "stdout", ",", "sys", ".", "stderr", ")", ":", "return", "stream_default", "return", "from_filename", "(", "f...
Look up the BioPython file type corresponding to a file-like object. For stdin, stdout, and stderr, ``stream_default`` is used.
[ "Look", "up", "the", "BioPython", "file", "type", "corresponding", "to", "a", "file", "-", "like", "object", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/fileformat.py#L72-L80
fhcrc/seqmagick
seqmagick/scripts/cli.py
parse_arguments
def parse_arguments(argv): """ Extract command-line arguments for different actions. """ parser = argparse.ArgumentParser(description='seqmagick - Manipulate ' + \ ' sequence files.', prog='seqmagick') parser.add_argument('-V', '--version', action='version', version='seqmagick v'...
python
def parse_arguments(argv): """ Extract command-line arguments for different actions. """ parser = argparse.ArgumentParser(description='seqmagick - Manipulate ' + \ ' sequence files.', prog='seqmagick') parser.add_argument('-V', '--version', action='version', version='seqmagick v'...
[ "def", "parse_arguments", "(", "argv", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'seqmagick - Manipulate '", "+", "' sequence files.'", ",", "prog", "=", "'seqmagick'", ")", "parser", ".", "add_argument", "(", "'-V'", ...
Extract command-line arguments for different actions.
[ "Extract", "command", "-", "line", "arguments", "for", "different", "actions", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/scripts/cli.py#L32-L71
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
ungap_index_map
def ungap_index_map(sequence, gap_chars='-'): """ Returns a dict mapping from an index in the ungapped sequence to an index in the gapped sequence. >>> ungap_index_map('AC-TG-') {0: 0, 1: 1, 2: 3, 3: 4} """ counter = itertools.count(0).__next__ ungap_indexes = [ counter() if c n...
python
def ungap_index_map(sequence, gap_chars='-'): """ Returns a dict mapping from an index in the ungapped sequence to an index in the gapped sequence. >>> ungap_index_map('AC-TG-') {0: 0, 1: 1, 2: 3, 3: 4} """ counter = itertools.count(0).__next__ ungap_indexes = [ counter() if c n...
[ "def", "ungap_index_map", "(", "sequence", ",", "gap_chars", "=", "'-'", ")", ":", "counter", "=", "itertools", ".", "count", "(", "0", ")", ".", "__next__", "ungap_indexes", "=", "[", "counter", "(", ")", "if", "c", "not", "in", "gap_chars", "else", "...
Returns a dict mapping from an index in the ungapped sequence to an index in the gapped sequence. >>> ungap_index_map('AC-TG-') {0: 0, 1: 1, 2: 3, 3: 4}
[ "Returns", "a", "dict", "mapping", "from", "an", "index", "in", "the", "ungapped", "sequence", "to", "an", "index", "in", "the", "gapped", "sequence", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L63-L78
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
gap_index_map
def gap_index_map(sequence, gap_chars='-'): """ Opposite of ungap_index_map: returns mapping from gapped index to ungapped index. >>> gap_index_map('AC-TG-') {0: 0, 1: 1, 3: 2, 4: 3} """ return dict( (v, k) for k, v in list(ungap_index_map(sequence, gap_chars).items()))
python
def gap_index_map(sequence, gap_chars='-'): """ Opposite of ungap_index_map: returns mapping from gapped index to ungapped index. >>> gap_index_map('AC-TG-') {0: 0, 1: 1, 3: 2, 4: 3} """ return dict( (v, k) for k, v in list(ungap_index_map(sequence, gap_chars).items()))
[ "def", "gap_index_map", "(", "sequence", ",", "gap_chars", "=", "'-'", ")", ":", "return", "dict", "(", "(", "v", ",", "k", ")", "for", "k", ",", "v", "in", "list", "(", "ungap_index_map", "(", "sequence", ",", "gap_chars", ")", ".", "items", "(", ...
Opposite of ungap_index_map: returns mapping from gapped index to ungapped index. >>> gap_index_map('AC-TG-') {0: 0, 1: 1, 3: 2, 4: 3}
[ "Opposite", "of", "ungap_index_map", ":", "returns", "mapping", "from", "gapped", "index", "to", "ungapped", "index", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L81-L90
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
_iupac_ambiguous_equal
def _iupac_ambiguous_equal(ambig_base, unambig_base): """ Tests two bases for equality, accounting for IUPAC ambiguous DNA ambiguous base may be IUPAC ambiguous, unambiguous must be one of ACGT """ iupac_translation = { 'A': 'A', 'C': 'C', 'G': 'G', 'T': 'T', ...
python
def _iupac_ambiguous_equal(ambig_base, unambig_base): """ Tests two bases for equality, accounting for IUPAC ambiguous DNA ambiguous base may be IUPAC ambiguous, unambiguous must be one of ACGT """ iupac_translation = { 'A': 'A', 'C': 'C', 'G': 'G', 'T': 'T', ...
[ "def", "_iupac_ambiguous_equal", "(", "ambig_base", ",", "unambig_base", ")", ":", "iupac_translation", "=", "{", "'A'", ":", "'A'", ",", "'C'", ":", "'C'", ",", "'G'", ":", "'G'", ",", "'T'", ":", "'T'", ",", "'U'", ":", "'U'", ",", "'R'", ":", "'AG...
Tests two bases for equality, accounting for IUPAC ambiguous DNA ambiguous base may be IUPAC ambiguous, unambiguous must be one of ACGT
[ "Tests", "two", "bases", "for", "equality", "accounting", "for", "IUPAC", "ambiguous", "DNA" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L93-L122
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
hamming_distance
def hamming_distance(s1, s2, equality_function=operator.eq): """ Returns the hamming distance between two strings. """ if not len(s1) == len(s2): raise ValueError("String lengths are not equal") # Number of non-matching characters: return sum(not equality_function(c1, c2) for c1, c2 in ...
python
def hamming_distance(s1, s2, equality_function=operator.eq): """ Returns the hamming distance between two strings. """ if not len(s1) == len(s2): raise ValueError("String lengths are not equal") # Number of non-matching characters: return sum(not equality_function(c1, c2) for c1, c2 in ...
[ "def", "hamming_distance", "(", "s1", ",", "s2", ",", "equality_function", "=", "operator", ".", "eq", ")", ":", "if", "not", "len", "(", "s1", ")", "==", "len", "(", "s2", ")", ":", "raise", "ValueError", "(", "\"String lengths are not equal\"", ")", "#...
Returns the hamming distance between two strings.
[ "Returns", "the", "hamming", "distance", "between", "two", "strings", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L125-L133
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
locate_primers
def locate_primers(sequences, forward_primer, reverse_primer, reverse_complement, max_hamming_distance): """ Find forward and reverse primers in a set of sequences, return two tuples: (forward_start, forward_end), (reverse_start, reverse_end) """ forward_loc = None reverse_loc...
python
def locate_primers(sequences, forward_primer, reverse_primer, reverse_complement, max_hamming_distance): """ Find forward and reverse primers in a set of sequences, return two tuples: (forward_start, forward_end), (reverse_start, reverse_end) """ forward_loc = None reverse_loc...
[ "def", "locate_primers", "(", "sequences", ",", "forward_primer", ",", "reverse_primer", ",", "reverse_complement", ",", "max_hamming_distance", ")", ":", "forward_loc", "=", "None", "reverse_loc", "=", "None", "seq_length", "=", "None", "# Reverse complement the revers...
Find forward and reverse primers in a set of sequences, return two tuples: (forward_start, forward_end), (reverse_start, reverse_end)
[ "Find", "forward", "and", "reverse", "primers", "in", "a", "set", "of", "sequences", "return", "two", "tuples", ":", "(", "forward_start", "forward_end", ")", "(", "reverse_start", "reverse_end", ")" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L220-L272
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
trim
def trim(sequences, start, end): """ Slice the input sequences from start to end """ logging.info("Trimming from %d to %d", start, end) return (sequence[start:end] for sequence in sequences)
python
def trim(sequences, start, end): """ Slice the input sequences from start to end """ logging.info("Trimming from %d to %d", start, end) return (sequence[start:end] for sequence in sequences)
[ "def", "trim", "(", "sequences", ",", "start", ",", "end", ")", ":", "logging", ".", "info", "(", "\"Trimming from %d to %d\"", ",", "start", ",", "end", ")", "return", "(", "sequence", "[", "start", ":", "end", "]", "for", "sequence", "in", "sequences",...
Slice the input sequences from start to end
[ "Slice", "the", "input", "sequences", "from", "start", "to", "end" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L275-L280
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
action
def action(arguments): """ Trim the alignment as specified """ # Determine file format for input and output source_format = (arguments.source_format or fileformat.from_handle(arguments.source_file)) output_format = (arguments.output_format or fileformat....
python
def action(arguments): """ Trim the alignment as specified """ # Determine file format for input and output source_format = (arguments.source_format or fileformat.from_handle(arguments.source_file)) output_format = (arguments.output_format or fileformat....
[ "def", "action", "(", "arguments", ")", ":", "# Determine file format for input and output", "source_format", "=", "(", "arguments", ".", "source_format", "or", "fileformat", ".", "from_handle", "(", "arguments", ".", "source_file", ")", ")", "output_format", "=", "...
Trim the alignment as specified
[ "Trim", "the", "alignment", "as", "specified" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L287-L331
fhcrc/seqmagick
seqmagick/subcommands/primer_trim.py
PrimerAligner.align
def align(self, sequence): """ Aligns the primer to the given query sequence, returning a tuple of: hamming_distance, start, end Where hamming distance is the distance between the primer and aligned sequence, and start and end give the start and end index of the primer ...
python
def align(self, sequence): """ Aligns the primer to the given query sequence, returning a tuple of: hamming_distance, start, end Where hamming distance is the distance between the primer and aligned sequence, and start and end give the start and end index of the primer ...
[ "def", "align", "(", "self", ",", "sequence", ")", ":", "seq_aln", ",", "primer_aln", ",", "score", ",", "start", ",", "end", "=", "pairwise2", ".", "align", ".", "globalms", "(", "str", "(", "sequence", ")", ".", "upper", "(", ")", ",", "str", "("...
Aligns the primer to the given query sequence, returning a tuple of: hamming_distance, start, end Where hamming distance is the distance between the primer and aligned sequence, and start and end give the start and end index of the primer relative to the input sequence.
[ "Aligns", "the", "primer", "to", "the", "given", "query", "sequence", "returning", "a", "tuple", "of", ":" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L161-L205
fhcrc/seqmagick
examples/apply-function/myfunctions.py
hash_starts_numeric
def hash_starts_numeric(records): """ Very useful function that only accepts records with a numeric start to their sha-1 hash. """ for record in records: seq_hash = hashlib.sha1(str(record.seq)).hexdigest() if seq_hash[0].isdigit(): yield record
python
def hash_starts_numeric(records): """ Very useful function that only accepts records with a numeric start to their sha-1 hash. """ for record in records: seq_hash = hashlib.sha1(str(record.seq)).hexdigest() if seq_hash[0].isdigit(): yield record
[ "def", "hash_starts_numeric", "(", "records", ")", ":", "for", "record", "in", "records", ":", "seq_hash", "=", "hashlib", ".", "sha1", "(", "str", "(", "record", ".", "seq", ")", ")", ".", "hexdigest", "(", ")", "if", "seq_hash", "[", "0", "]", ".",...
Very useful function that only accepts records with a numeric start to their sha-1 hash.
[ "Very", "useful", "function", "that", "only", "accepts", "records", "with", "a", "numeric", "start", "to", "their", "sha", "-", "1", "hash", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/examples/apply-function/myfunctions.py#L11-L19
fhcrc/seqmagick
seqmagick/subcommands/common.py
atomic_write
def atomic_write(path, mode='wt', permissions=None, file_factory=None, **kwargs): """ Open a file for atomic writing. Generates a temp file, renames to value of ``path``. Arguments: ``permissions``: Permissions to set (default: umask) ``file_factory``: If given, the handle yielded will be the ...
python
def atomic_write(path, mode='wt', permissions=None, file_factory=None, **kwargs): """ Open a file for atomic writing. Generates a temp file, renames to value of ``path``. Arguments: ``permissions``: Permissions to set (default: umask) ``file_factory``: If given, the handle yielded will be the ...
[ "def", "atomic_write", "(", "path", ",", "mode", "=", "'wt'", ",", "permissions", "=", "None", ",", "file_factory", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "permissions", "is", "None", ":", "permissions", "=", "apply_umask", "(", ")", "# ...
Open a file for atomic writing. Generates a temp file, renames to value of ``path``. Arguments: ``permissions``: Permissions to set (default: umask) ``file_factory``: If given, the handle yielded will be the result of calling file_factory(path) Additional arguments are passed to tempfile....
[ "Open", "a", "file", "for", "atomic", "writing", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L35-L72
fhcrc/seqmagick
seqmagick/subcommands/common.py
cut_range
def cut_range(string): """ A custom argparse 'type' to deal with sequences ranges such as 5:500. Returns a 0-based slice corresponding to the selection defined by the slice """ value_range = string.split(':') if len(value_range) == 1: start = int(value_range[0]) stop = start ...
python
def cut_range(string): """ A custom argparse 'type' to deal with sequences ranges such as 5:500. Returns a 0-based slice corresponding to the selection defined by the slice """ value_range = string.split(':') if len(value_range) == 1: start = int(value_range[0]) stop = start ...
[ "def", "cut_range", "(", "string", ")", ":", "value_range", "=", "string", ".", "split", "(", "':'", ")", "if", "len", "(", "value_range", ")", "==", "1", ":", "start", "=", "int", "(", "value_range", "[", "0", "]", ")", "stop", "=", "start", "elif...
A custom argparse 'type' to deal with sequences ranges such as 5:500. Returns a 0-based slice corresponding to the selection defined by the slice
[ "A", "custom", "argparse", "type", "to", "deal", "with", "sequences", "ranges", "such", "as", "5", ":", "500", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L83-L107
fhcrc/seqmagick
seqmagick/subcommands/common.py
typed_range
def typed_range(type_func, minimum, maximum): """ Require variables to be of the specified type, between minimum and maximum """ @functools.wraps(type_func) def inner(string): result = type_func(string) if not result >= minimum and result <= maximum: raise argparse.Argume...
python
def typed_range(type_func, minimum, maximum): """ Require variables to be of the specified type, between minimum and maximum """ @functools.wraps(type_func) def inner(string): result = type_func(string) if not result >= minimum and result <= maximum: raise argparse.Argume...
[ "def", "typed_range", "(", "type_func", ",", "minimum", ",", "maximum", ")", ":", "@", "functools", ".", "wraps", "(", "type_func", ")", "def", "inner", "(", "string", ")", ":", "result", "=", "type_func", "(", "string", ")", "if", "not", "result", ">=...
Require variables to be of the specified type, between minimum and maximum
[ "Require", "variables", "to", "be", "of", "the", "specified", "type", "between", "minimum", "and", "maximum" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L110-L122
fhcrc/seqmagick
seqmagick/subcommands/common.py
partial_append_action
def partial_append_action(fn, argument_keys=None): """ Creates a new class extending argparse.Action, which appends a partially-applied function to dest. The optional argument_keys argument should either be None (no additional arguments to fn) or an iterable of function keys to partially apply. ...
python
def partial_append_action(fn, argument_keys=None): """ Creates a new class extending argparse.Action, which appends a partially-applied function to dest. The optional argument_keys argument should either be None (no additional arguments to fn) or an iterable of function keys to partially apply. ...
[ "def", "partial_append_action", "(", "fn", ",", "argument_keys", "=", "None", ")", ":", "if", "isinstance", "(", "argument_keys", ",", "str", ")", ":", "argument_keys", "=", "[", "argument_keys", "]", "argument_keys", "=", "argument_keys", "or", "[", "]", "c...
Creates a new class extending argparse.Action, which appends a partially-applied function to dest. The optional argument_keys argument should either be None (no additional arguments to fn) or an iterable of function keys to partially apply.
[ "Creates", "a", "new", "class", "extending", "argparse", ".", "Action", "which", "appends", "a", "partially", "-", "applied", "function", "to", "dest", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L125-L178
fhcrc/seqmagick
seqmagick/subcommands/common.py
positive_value
def positive_value(target_type): """ Wraps target_type in a function that requires the parsed argument be >= 0 """ def inner(string): value = target_type(string) if not value >= 0: raise argparse.ArgumentTypeError("Invalid positive number: " + string) ...
python
def positive_value(target_type): """ Wraps target_type in a function that requires the parsed argument be >= 0 """ def inner(string): value = target_type(string) if not value >= 0: raise argparse.ArgumentTypeError("Invalid positive number: " + string) ...
[ "def", "positive_value", "(", "target_type", ")", ":", "def", "inner", "(", "string", ")", ":", "value", "=", "target_type", "(", "string", ")", "if", "not", "value", ">=", "0", ":", "raise", "argparse", ".", "ArgumentTypeError", "(", "\"Invalid positive num...
Wraps target_type in a function that requires the parsed argument be >= 0
[ "Wraps", "target_type", "in", "a", "function", "that", "requires", "the", "parsed", "argument", "be", ">", "=", "0" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L181-L193
fhcrc/seqmagick
seqmagick/subcommands/convert.py
add_options
def add_options(parser): """ Add optional arguments to the parser """ partial_action = common.partial_append_action file_mods = parser.add_argument_group("Sequence File Modification") file_mods.add_argument('--line-wrap', dest='line_wrap', metavar='N', type=int, help='Adjust line wrap fo...
python
def add_options(parser): """ Add optional arguments to the parser """ partial_action = common.partial_append_action file_mods = parser.add_argument_group("Sequence File Modification") file_mods.add_argument('--line-wrap', dest='line_wrap', metavar='N', type=int, help='Adjust line wrap fo...
[ "def", "add_options", "(", "parser", ")", ":", "partial_action", "=", "common", ".", "partial_append_action", "file_mods", "=", "parser", ".", "add_argument_group", "(", "\"Sequence File Modification\"", ")", "file_mods", ".", "add_argument", "(", "'--line-wrap'", ","...
Add optional arguments to the parser
[ "Add", "optional", "arguments", "to", "the", "parser" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/convert.py#L25-L219
fhcrc/seqmagick
seqmagick/subcommands/convert.py
build_parser
def build_parser(parser): """ Add shared arguments to the convert or mogrify parser. """ add_options(parser) parser.add_argument('source_file', type=common.FileType('rt'), help="Input sequence file") parser.add_argument('dest_file', help="Output file") return parser
python
def build_parser(parser): """ Add shared arguments to the convert or mogrify parser. """ add_options(parser) parser.add_argument('source_file', type=common.FileType('rt'), help="Input sequence file") parser.add_argument('dest_file', help="Output file") return parser
[ "def", "build_parser", "(", "parser", ")", ":", "add_options", "(", "parser", ")", "parser", ".", "add_argument", "(", "'source_file'", ",", "type", "=", "common", ".", "FileType", "(", "'rt'", ")", ",", "help", "=", "\"Input sequence file\"", ")", "parser",...
Add shared arguments to the convert or mogrify parser.
[ "Add", "shared", "arguments", "to", "the", "convert", "or", "mogrify", "parser", "." ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/convert.py#L222-L231
fhcrc/seqmagick
seqmagick/subcommands/convert.py
module_function
def module_function(string): """ Load a function from a python module using a file name, function name specification of format: /path/to/x.py:function_name[:parameter] """ parts = string.split(':', 2) if len(parts) < 2: raise ValueError( "Illegal specification. Should...
python
def module_function(string): """ Load a function from a python module using a file name, function name specification of format: /path/to/x.py:function_name[:parameter] """ parts = string.split(':', 2) if len(parts) < 2: raise ValueError( "Illegal specification. Should...
[ "def", "module_function", "(", "string", ")", ":", "parts", "=", "string", ".", "split", "(", "':'", ",", "2", ")", "if", "len", "(", "parts", ")", "<", "2", ":", "raise", "ValueError", "(", "\"Illegal specification. Should be module:function[:parameter]\"", "...
Load a function from a python module using a file name, function name specification of format: /path/to/x.py:function_name[:parameter]
[ "Load", "a", "function", "from", "a", "python", "module", "using", "a", "file", "name", "function", "name", "specification", "of", "format", ":", "/", "path", "/", "to", "/", "x", ".", "py", ":", "function_name", "[", ":", "parameter", "]" ]
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/convert.py#L321-L347
phac-nml/sistr_cmd
sistr/misc/reduce_to_centroid_alleles.py
parse_cgmlst_alleles
def parse_cgmlst_alleles(cgmlst_fasta): """Parse cgMLST alleles from fasta file cgMLST FASTA file must have a header format of ">{marker name}|{allele name}" Args: cgmlst_fasta (str): cgMLST fasta file path Returns: dict of list: Marker name to list of allele sequences """ out ...
python
def parse_cgmlst_alleles(cgmlst_fasta): """Parse cgMLST alleles from fasta file cgMLST FASTA file must have a header format of ">{marker name}|{allele name}" Args: cgmlst_fasta (str): cgMLST fasta file path Returns: dict of list: Marker name to list of allele sequences """ out ...
[ "def", "parse_cgmlst_alleles", "(", "cgmlst_fasta", ")", ":", "out", "=", "defaultdict", "(", "list", ")", "for", "header", ",", "seq", "in", "parse_fasta", "(", "cgmlst_fasta", ")", ":", "if", "not", "'|'", "in", "header", ":", "raise", "Exception", "(", ...
Parse cgMLST alleles from fasta file cgMLST FASTA file must have a header format of ">{marker name}|{allele name}" Args: cgmlst_fasta (str): cgMLST fasta file path Returns: dict of list: Marker name to list of allele sequences
[ "Parse", "cgMLST", "alleles", "from", "fasta", "file", "cgMLST", "FASTA", "file", "must", "have", "a", "header", "format", "of", ">", "{", "marker", "name", "}", "|", "{", "allele", "name", "}" ]
train
https://github.com/phac-nml/sistr_cmd/blob/4630fae72439723b354a94b94fbe76ad2f9f6295/sistr/misc/reduce_to_centroid_alleles.py#L44-L60