repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
broadinstitute/fiss
firecloud/fiss.py
space_lock
def space_lock(args): """ Lock a workspace """ r = fapi.lock_workspace(args.project, args.workspace) fapi._check_response_code(r, 204) if fcconfig.verbosity: eprint('Locked workspace {0}/{1}'.format(args.project, args.workspace)) return 0
python
def space_lock(args): """ Lock a workspace """ r = fapi.lock_workspace(args.project, args.workspace) fapi._check_response_code(r, 204) if fcconfig.verbosity: eprint('Locked workspace {0}/{1}'.format(args.project, args.workspace)) return 0
[ "def", "space_lock", "(", "args", ")", ":", "r", "=", "fapi", ".", "lock_workspace", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "204", ")", "if", "fcconfig", ".", "verbosity", ":...
Lock a workspace
[ "Lock", "a", "workspace" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L85-L91
train
broadinstitute/fiss
firecloud/fiss.py
space_unlock
def space_unlock(args): """ Unlock a workspace """ r = fapi.unlock_workspace(args.project, args.workspace) fapi._check_response_code(r, 204) if fcconfig.verbosity: eprint('Unlocked workspace {0}/{1}'.format(args.project,args.workspace)) return 0
python
def space_unlock(args): """ Unlock a workspace """ r = fapi.unlock_workspace(args.project, args.workspace) fapi._check_response_code(r, 204) if fcconfig.verbosity: eprint('Unlocked workspace {0}/{1}'.format(args.project,args.workspace)) return 0
[ "def", "space_unlock", "(", "args", ")", ":", "r", "=", "fapi", ".", "unlock_workspace", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "204", ")", "if", "fcconfig", ".", "verbosity", ...
Unlock a workspace
[ "Unlock", "a", "workspace" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L94-L100
train
broadinstitute/fiss
firecloud/fiss.py
space_new
def space_new(args): """ Create a new workspace. """ r = fapi.create_workspace(args.project, args.workspace, args.authdomain, dict()) fapi._check_response_code(r, 201) if fcconfig.verbosity: eprint(r.content) return 0
python
def space_new(args): """ Create a new workspace. """ r = fapi.create_workspace(args.project, args.workspace, args.authdomain, dict()) fapi._check_response_code(r, 201) if fcconfig.verbosity: eprint(r.content) return 0
[ "def", "space_new", "(", "args", ")", ":", "r", "=", "fapi", ".", "create_workspace", "(", "args", ".", "project", ",", "args", ".", "workspace", ",", "args", ".", "authdomain", ",", "dict", "(", ")", ")", "fapi", ".", "_check_response_code", "(", "r",...
Create a new workspace.
[ "Create", "a", "new", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L103-L110
train
broadinstitute/fiss
firecloud/fiss.py
space_info
def space_info(args): """ Get metadata for a workspace. """ r = fapi.get_workspace(args.project, args.workspace) fapi._check_response_code(r, 200) return r.text
python
def space_info(args): """ Get metadata for a workspace. """ r = fapi.get_workspace(args.project, args.workspace) fapi._check_response_code(r, 200) return r.text
[ "def", "space_info", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_workspace", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return", "r", ".", "text" ]
Get metadata for a workspace.
[ "Get", "metadata", "for", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L113-L117
train
broadinstitute/fiss
firecloud/fiss.py
space_delete
def space_delete(args): """ Delete a workspace. """ message = "WARNING: this will delete workspace: \n\t{0}/{1}".format( args.project, args.workspace) if not args.yes and not _confirm_prompt(message): return 0 r = fapi.delete_workspace(args.project, args.workspace) fapi._check_respo...
python
def space_delete(args): """ Delete a workspace. """ message = "WARNING: this will delete workspace: \n\t{0}/{1}".format( args.project, args.workspace) if not args.yes and not _confirm_prompt(message): return 0 r = fapi.delete_workspace(args.project, args.workspace) fapi._check_respo...
[ "def", "space_delete", "(", "args", ")", ":", "message", "=", "\"WARNING: this will delete workspace: \\n\\t{0}/{1}\"", ".", "format", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "if", "not", "args", ".", "yes", "and", "not", "_confirm_promp...
Delete a workspace.
[ "Delete", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L120-L131
train
broadinstitute/fiss
firecloud/fiss.py
space_clone
def space_clone(args): """ Replicate a workspace """ # FIXME: add --deep copy option (shallow by default) # add aliasing capability, then make space_copy alias if not args.to_workspace: args.to_workspace = args.workspace if not args.to_project: args.to_project = args.project ...
python
def space_clone(args): """ Replicate a workspace """ # FIXME: add --deep copy option (shallow by default) # add aliasing capability, then make space_copy alias if not args.to_workspace: args.to_workspace = args.workspace if not args.to_project: args.to_project = args.project ...
[ "def", "space_clone", "(", "args", ")", ":", "if", "not", "args", ".", "to_workspace", ":", "args", ".", "to_workspace", "=", "args", ".", "workspace", "if", "not", "args", ".", "to_project", ":", "args", ".", "to_project", "=", "args", ".", "project", ...
Replicate a workspace
[ "Replicate", "a", "workspace" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L134-L158
train
broadinstitute/fiss
firecloud/fiss.py
space_acl
def space_acl(args): ''' Retrieve access control list for a workspace''' r = fapi.get_workspace_acl(args.project, args.workspace) fapi._check_response_code(r, 200) result = dict() for user, info in sorted(r.json()['acl'].items()): result[user] = info['accessLevel'] return result
python
def space_acl(args): ''' Retrieve access control list for a workspace''' r = fapi.get_workspace_acl(args.project, args.workspace) fapi._check_response_code(r, 200) result = dict() for user, info in sorted(r.json()['acl'].items()): result[user] = info['accessLevel'] return result
[ "def", "space_acl", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_workspace_acl", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "result", "=", "dict", "(", ")", "...
Retrieve access control list for a workspace
[ "Retrieve", "access", "control", "list", "for", "a", "workspace" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L161-L168
train
broadinstitute/fiss
firecloud/fiss.py
space_set_acl
def space_set_acl(args): """ Assign an ACL role to list of users for a workspace """ acl_updates = [{"email": user, "accessLevel": args.role} for user in args.users] r = fapi.update_workspace_acl(args.project, args.workspace, acl_updates) fapi._check_response_code(r, 200) errors =...
python
def space_set_acl(args): """ Assign an ACL role to list of users for a workspace """ acl_updates = [{"email": user, "accessLevel": args.role} for user in args.users] r = fapi.update_workspace_acl(args.project, args.workspace, acl_updates) fapi._check_response_code(r, 200) errors =...
[ "def", "space_set_acl", "(", "args", ")", ":", "acl_updates", "=", "[", "{", "\"email\"", ":", "user", ",", "\"accessLevel\"", ":", "args", ".", "role", "}", "for", "user", "in", "args", ".", "users", "]", "r", "=", "fapi", ".", "update_workspace_acl", ...
Assign an ACL role to list of users for a workspace
[ "Assign", "an", "ACL", "role", "to", "list", "of", "users", "for", "a", "workspace" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L171-L188
train
broadinstitute/fiss
firecloud/fiss.py
space_search
def space_search(args): """ Search for workspaces matching certain criteria """ r = fapi.list_workspaces() fapi._check_response_code(r, 200) # Parse the JSON for workspace + namespace; then filter by # search terms: each term is treated as a regular expression workspaces = r.json() extra_te...
python
def space_search(args): """ Search for workspaces matching certain criteria """ r = fapi.list_workspaces() fapi._check_response_code(r, 200) # Parse the JSON for workspace + namespace; then filter by # search terms: each term is treated as a regular expression workspaces = r.json() extra_te...
[ "def", "space_search", "(", "args", ")", ":", "r", "=", "fapi", ".", "list_workspaces", "(", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "workspaces", "=", "r", ".", "json", "(", ")", "extra_terms", "=", "[", "]", "if", "args...
Search for workspaces matching certain criteria
[ "Search", "for", "workspaces", "matching", "certain", "criteria" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L191-L216
train
broadinstitute/fiss
firecloud/fiss.py
entity_import
def entity_import(args): """ Upload an entity loadfile. """ project = args.project workspace = args.workspace chunk_size = args.chunk_size with open(args.tsvfile) as tsvf: headerline = tsvf.readline().strip() entity_data = [l.rstrip('\n') for l in tsvf] return _batch_load(proje...
python
def entity_import(args): """ Upload an entity loadfile. """ project = args.project workspace = args.workspace chunk_size = args.chunk_size with open(args.tsvfile) as tsvf: headerline = tsvf.readline().strip() entity_data = [l.rstrip('\n') for l in tsvf] return _batch_load(proje...
[ "def", "entity_import", "(", "args", ")", ":", "project", "=", "args", ".", "project", "workspace", "=", "args", ".", "workspace", "chunk_size", "=", "args", ".", "chunk_size", "with", "open", "(", "args", ".", "tsvfile", ")", "as", "tsvf", ":", "headerl...
Upload an entity loadfile.
[ "Upload", "an", "entity", "loadfile", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L219-L229
train
broadinstitute/fiss
firecloud/fiss.py
entity_types
def entity_types(args): """ List entity types in a workspace """ r = fapi.list_entity_types(args.project, args.workspace) fapi._check_response_code(r, 200) return r.json().keys()
python
def entity_types(args): """ List entity types in a workspace """ r = fapi.list_entity_types(args.project, args.workspace) fapi._check_response_code(r, 200) return r.json().keys()
[ "def", "entity_types", "(", "args", ")", ":", "r", "=", "fapi", ".", "list_entity_types", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return", "r", ".", "json", "(", ...
List entity types in a workspace
[ "List", "entity", "types", "in", "a", "workspace" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L250-L254
train
broadinstitute/fiss
firecloud/fiss.py
entity_list
def entity_list(args): """ List entities in a workspace. """ r = fapi.get_entities_with_type(args.project, args.workspace) fapi._check_response_code(r, 200) return [ '{0}\t{1}'.format(e['entityType'], e['name']) for e in r.json() ]
python
def entity_list(args): """ List entities in a workspace. """ r = fapi.get_entities_with_type(args.project, args.workspace) fapi._check_response_code(r, 200) return [ '{0}\t{1}'.format(e['entityType'], e['name']) for e in r.json() ]
[ "def", "entity_list", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_entities_with_type", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return", "[", "'{0}\\t{1}'", "...
List entities in a workspace.
[ "List", "entities", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L257-L261
train
broadinstitute/fiss
firecloud/fiss.py
participant_list
def participant_list(args): ''' List participants within a container''' # Case 1: retrieve participants within a named data entity if args.entity_type and args.entity: # Edge case: caller asked for participant within participant (itself) if args.entity_type == 'participant': ret...
python
def participant_list(args): ''' List participants within a container''' # Case 1: retrieve participants within a named data entity if args.entity_type and args.entity: # Edge case: caller asked for participant within participant (itself) if args.entity_type == 'participant': ret...
[ "def", "participant_list", "(", "args", ")", ":", "if", "args", ".", "entity_type", "and", "args", ".", "entity", ":", "if", "args", ".", "entity_type", "==", "'participant'", ":", "return", "[", "args", ".", "entity", ".", "strip", "(", ")", "]", "r",...
List participants within a container
[ "List", "participants", "within", "a", "container" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L283-L298
train
broadinstitute/fiss
firecloud/fiss.py
pair_list
def pair_list(args): ''' List pairs within a container. ''' # Case 1: retrieve pairs within a named data entity if args.entity_type and args.entity: # Edge case: caller asked for pair within a pair (itself) if args.entity_type == 'pair': return [ args.entity.strip() ] # ...
python
def pair_list(args): ''' List pairs within a container. ''' # Case 1: retrieve pairs within a named data entity if args.entity_type and args.entity: # Edge case: caller asked for pair within a pair (itself) if args.entity_type == 'pair': return [ args.entity.strip() ] # ...
[ "def", "pair_list", "(", "args", ")", ":", "if", "args", ".", "entity_type", "and", "args", ".", "entity", ":", "if", "args", ".", "entity_type", "==", "'pair'", ":", "return", "[", "args", ".", "entity", ".", "strip", "(", ")", "]", "elif", "args", ...
List pairs within a container.
[ "List", "pairs", "within", "a", "container", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L301-L324
train
broadinstitute/fiss
firecloud/fiss.py
sample_list
def sample_list(args): ''' List samples within a container. ''' # Case 1: retrieve samples within a named data entity if args.entity_type and args.entity: # Edge case: caller asked for samples within a sample (itself) if args.entity_type == 'sample': return [ args.entity.strip()...
python
def sample_list(args): ''' List samples within a container. ''' # Case 1: retrieve samples within a named data entity if args.entity_type and args.entity: # Edge case: caller asked for samples within a sample (itself) if args.entity_type == 'sample': return [ args.entity.strip()...
[ "def", "sample_list", "(", "args", ")", ":", "if", "args", ".", "entity_type", "and", "args", ".", "entity", ":", "if", "args", ".", "entity_type", "==", "'sample'", ":", "return", "[", "args", ".", "entity", ".", "strip", "(", ")", "]", "elif", "arg...
List samples within a container.
[ "List", "samples", "within", "a", "container", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L327-L355
train
broadinstitute/fiss
firecloud/fiss.py
entity_delete
def entity_delete(args): """ Delete entity in a workspace. """ msg = "WARNING: this will delete {0} {1} in {2}/{3}".format( args.entity_type, args.entity, args.project, args.workspace) if not (args.yes or _confirm_prompt(msg)): return json_body=[{"entityType": args.entity_type, ...
python
def entity_delete(args): """ Delete entity in a workspace. """ msg = "WARNING: this will delete {0} {1} in {2}/{3}".format( args.entity_type, args.entity, args.project, args.workspace) if not (args.yes or _confirm_prompt(msg)): return json_body=[{"entityType": args.entity_type, ...
[ "def", "entity_delete", "(", "args", ")", ":", "msg", "=", "\"WARNING: this will delete {0} {1} in {2}/{3}\"", ".", "format", "(", "args", ".", "entity_type", ",", "args", ".", "entity", ",", "args", ".", "project", ",", "args", ".", "workspace", ")", "if", ...
Delete entity in a workspace.
[ "Delete", "entity", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L363-L377
train
broadinstitute/fiss
firecloud/fiss.py
meth_wdl
def meth_wdl(args): ''' Retrieve WDL for given version of a repository method''' r = fapi.get_repository_method(args.namespace, args.method, args.snapshot_id, True) fapi._check_response_code(r, 200) return r.text
python
def meth_wdl(args): ''' Retrieve WDL for given version of a repository method''' r = fapi.get_repository_method(args.namespace, args.method, args.snapshot_id, True) fapi._check_response_code(r, 200) return r.text
[ "def", "meth_wdl", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_repository_method", "(", "args", ".", "namespace", ",", "args", ".", "method", ",", "args", ".", "snapshot_id", ",", "True", ")", "fapi", ".", "_check_response_code", "(", "r", ",", ...
Retrieve WDL for given version of a repository method
[ "Retrieve", "WDL", "for", "given", "version", "of", "a", "repository", "method" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L422-L427
train
broadinstitute/fiss
firecloud/fiss.py
meth_acl
def meth_acl(args): ''' Retrieve access control list for given version of a repository method''' r = fapi.get_repository_method_acl(args.namespace, args.method, args.snapshot_id) fapi._check_response_code(r, 200) acls = sorted(r.json(), key=lambda k: k...
python
def meth_acl(args): ''' Retrieve access control list for given version of a repository method''' r = fapi.get_repository_method_acl(args.namespace, args.method, args.snapshot_id) fapi._check_response_code(r, 200) acls = sorted(r.json(), key=lambda k: k...
[ "def", "meth_acl", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_repository_method_acl", "(", "args", ".", "namespace", ",", "args", ".", "method", ",", "args", ".", "snapshot_id", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")",...
Retrieve access control list for given version of a repository method
[ "Retrieve", "access", "control", "list", "for", "given", "version", "of", "a", "repository", "method" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L430-L436
train
broadinstitute/fiss
firecloud/fiss.py
meth_set_acl
def meth_set_acl(args): """ Assign an ACL role to a list of users for a workflow. """ acl_updates = [{"user": user, "role": args.role} \ for user in set(expand_fc_groups(args.users)) \ if user != fapi.whoami()] id = args.snapshot_id if not id: # get the lat...
python
def meth_set_acl(args): """ Assign an ACL role to a list of users for a workflow. """ acl_updates = [{"user": user, "role": args.role} \ for user in set(expand_fc_groups(args.users)) \ if user != fapi.whoami()] id = args.snapshot_id if not id: # get the lat...
[ "def", "meth_set_acl", "(", "args", ")", ":", "acl_updates", "=", "[", "{", "\"user\"", ":", "user", ",", "\"role\"", ":", "args", ".", "role", "}", "for", "user", "in", "set", "(", "expand_fc_groups", "(", "args", ".", "users", ")", ")", "if", "user...
Assign an ACL role to a list of users for a workflow.
[ "Assign", "an", "ACL", "role", "to", "a", "list", "of", "users", "for", "a", "workflow", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L439-L466
train
broadinstitute/fiss
firecloud/fiss.py
expand_fc_groups
def expand_fc_groups(users): """ If user is a firecloud group, return all members of the group. Caveat is that only group admins may do this. """ groups = None for user in users: fcgroup = None if '@' not in user: fcgroup = user elif user.lower().endswith('@firecl...
python
def expand_fc_groups(users): """ If user is a firecloud group, return all members of the group. Caveat is that only group admins may do this. """ groups = None for user in users: fcgroup = None if '@' not in user: fcgroup = user elif user.lower().endswith('@firecl...
[ "def", "expand_fc_groups", "(", "users", ")", ":", "groups", "=", "None", "for", "user", "in", "users", ":", "fcgroup", "=", "None", "if", "'@'", "not", "in", "user", ":", "fcgroup", "=", "user", "elif", "user", ".", "lower", "(", ")", ".", "endswith...
If user is a firecloud group, return all members of the group. Caveat is that only group admins may do this.
[ "If", "user", "is", "a", "firecloud", "group", "return", "all", "members", "of", "the", "group", ".", "Caveat", "is", "that", "only", "group", "admins", "may", "do", "this", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L468-L499
train
broadinstitute/fiss
firecloud/fiss.py
meth_list
def meth_list(args): """ List workflows in the methods repository """ r = fapi.list_repository_methods(namespace=args.namespace, name=args.method, snapshotId=args.snapshot_id) fapi._check_response_code(r, 200) # Parse the JSON fo...
python
def meth_list(args): """ List workflows in the methods repository """ r = fapi.list_repository_methods(namespace=args.namespace, name=args.method, snapshotId=args.snapshot_id) fapi._check_response_code(r, 200) # Parse the JSON fo...
[ "def", "meth_list", "(", "args", ")", ":", "r", "=", "fapi", ".", "list_repository_methods", "(", "namespace", "=", "args", ".", "namespace", ",", "name", "=", "args", ".", "method", ",", "snapshotId", "=", "args", ".", "snapshot_id", ")", "fapi", ".", ...
List workflows in the methods repository
[ "List", "workflows", "in", "the", "methods", "repository" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L502-L519
train
broadinstitute/fiss
firecloud/fiss.py
config_acl
def config_acl(args): ''' Retrieve access control list for a method configuration''' r = fapi.get_repository_config_acl(args.namespace, args.config, args.snapshot_id) fapi._check_response_code(r, 200) acls = sorted(r.json(), key=lambda k: k['user']) ...
python
def config_acl(args): ''' Retrieve access control list for a method configuration''' r = fapi.get_repository_config_acl(args.namespace, args.config, args.snapshot_id) fapi._check_response_code(r, 200) acls = sorted(r.json(), key=lambda k: k['user']) ...
[ "def", "config_acl", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_repository_config_acl", "(", "args", ".", "namespace", ",", "args", ".", "config", ",", "args", ".", "snapshot_id", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")...
Retrieve access control list for a method configuration
[ "Retrieve", "access", "control", "list", "for", "a", "method", "configuration" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L602-L608
train
broadinstitute/fiss
firecloud/fiss.py
config_set_acl
def config_set_acl(args): """ Assign an ACL role to a list of users for a config. """ acl_updates = [{"user": user, "role": args.role} \ for user in set(expand_fc_groups(args.users)) \ if user != fapi.whoami()] id = args.snapshot_id if not id: # get the lat...
python
def config_set_acl(args): """ Assign an ACL role to a list of users for a config. """ acl_updates = [{"user": user, "role": args.role} \ for user in set(expand_fc_groups(args.users)) \ if user != fapi.whoami()] id = args.snapshot_id if not id: # get the lat...
[ "def", "config_set_acl", "(", "args", ")", ":", "acl_updates", "=", "[", "{", "\"user\"", ":", "user", ",", "\"role\"", ":", "args", ".", "role", "}", "for", "user", "in", "set", "(", "expand_fc_groups", "(", "args", ".", "users", ")", ")", "if", "us...
Assign an ACL role to a list of users for a config.
[ "Assign", "an", "ACL", "role", "to", "a", "list", "of", "users", "for", "a", "config", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L611-L638
train
broadinstitute/fiss
firecloud/fiss.py
config_get
def config_get(args): """ Retrieve a method config from a workspace, send stdout """ r = fapi.get_workspace_config(args.project, args.workspace, args.namespace, args.config) fapi._check_response_code(r, 200) # Setting ensure_ascii to False ensures unicode string r...
python
def config_get(args): """ Retrieve a method config from a workspace, send stdout """ r = fapi.get_workspace_config(args.project, args.workspace, args.namespace, args.config) fapi._check_response_code(r, 200) # Setting ensure_ascii to False ensures unicode string r...
[ "def", "config_get", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_workspace_config", "(", "args", ".", "project", ",", "args", ".", "workspace", ",", "args", ".", "namespace", ",", "args", ".", "config", ")", "fapi", ".", "_check_response_code", "(...
Retrieve a method config from a workspace, send stdout
[ "Retrieve", "a", "method", "config", "from", "a", "workspace", "send", "stdout" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L641-L648
train
broadinstitute/fiss
firecloud/fiss.py
config_wdl
def config_wdl(args): """ Retrieve the WDL for a method config in a workspace, send stdout """ r = fapi.get_workspace_config(args.project, args.workspace, args.namespace, args.config) fapi._check_response_code(r, 200) method = r.json()["methodRepoMethod"] args....
python
def config_wdl(args): """ Retrieve the WDL for a method config in a workspace, send stdout """ r = fapi.get_workspace_config(args.project, args.workspace, args.namespace, args.config) fapi._check_response_code(r, 200) method = r.json()["methodRepoMethod"] args....
[ "def", "config_wdl", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_workspace_config", "(", "args", ".", "project", ",", "args", ".", "workspace", ",", "args", ".", "namespace", ",", "args", ".", "config", ")", "fapi", ".", "_check_response_code", "(...
Retrieve the WDL for a method config in a workspace, send stdout
[ "Retrieve", "the", "WDL", "for", "a", "method", "config", "in", "a", "workspace", "send", "stdout" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L651-L662
train
broadinstitute/fiss
firecloud/fiss.py
config_diff
def config_diff(args): """Compare method configuration definitions across workspaces. Ignores methodConfigVersion if the verbose argument is not set""" config_1 = config_get(args).splitlines() args.project = args.Project args.workspace = args.Workspace cfg_1_name = args.config if args.Con...
python
def config_diff(args): """Compare method configuration definitions across workspaces. Ignores methodConfigVersion if the verbose argument is not set""" config_1 = config_get(args).splitlines() args.project = args.Project args.workspace = args.Workspace cfg_1_name = args.config if args.Con...
[ "def", "config_diff", "(", "args", ")", ":", "config_1", "=", "config_get", "(", "args", ")", ".", "splitlines", "(", ")", "args", ".", "project", "=", "args", ".", "Project", "args", ".", "workspace", "=", "args", ".", "Workspace", "cfg_1_name", "=", ...
Compare method configuration definitions across workspaces. Ignores methodConfigVersion if the verbose argument is not set
[ "Compare", "method", "configuration", "definitions", "across", "workspaces", ".", "Ignores", "methodConfigVersion", "if", "the", "verbose", "argument", "is", "not", "set" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L665-L680
train
broadinstitute/fiss
firecloud/fiss.py
config_delete
def config_delete(args): """ Remove a method config from a workspace """ r = fapi.delete_workspace_config(args.project, args.workspace, args.namespace, args.config) fapi._check_response_code(r, [200,204]) return r.text if r.text else None
python
def config_delete(args): """ Remove a method config from a workspace """ r = fapi.delete_workspace_config(args.project, args.workspace, args.namespace, args.config) fapi._check_response_code(r, [200,204]) return r.text if r.text else None
[ "def", "config_delete", "(", "args", ")", ":", "r", "=", "fapi", ".", "delete_workspace_config", "(", "args", ".", "project", ",", "args", ".", "workspace", ",", "args", ".", "namespace", ",", "args", ".", "config", ")", "fapi", ".", "_check_response_code"...
Remove a method config from a workspace
[ "Remove", "a", "method", "config", "from", "a", "workspace" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L768-L773
train
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", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1003-L1045
train
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" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1163-L1167
train
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", ")", ":", "fiss_func", "=", "__cmd_to_func", "(", "args", ".", "action", ")", "if", "not", "fiss_func", ":", "eprint", "(", "\"invalid FISS cmd '\"", "+", "args", ".", "action", "+", "\"'\"", ")", "return", "1", "r", "=",...
Loop over all sample sets in a workspace, performing a func
[ "Loop", "over", "all", "sample", "sets", "in", "a", "workspace", "performing", "a", "func" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1304-L1333
train
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" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1336-L1353
train
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" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1356-L1381
train
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", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1389-L1419
train
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", ")", ":", "invalid_inputs", "=", "sorted", "(", "config_d", "[", "\"invalidInputs\"", "]", ")", "invalid_outputs", "=", "sorted", "(", "config_d", "[", ...
Return FISSFC validation information on config for a certain entity
[ "Return", "FISSFC", "validation", "information", "on", "config", "for", "a", "certain", "entity" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1474-L1521
train
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", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1663-L1670
train
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" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1672-L1680
train
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", "=", "[", "]", "r", "=", "fap...
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", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1682-L1714
train
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__", "]", "func", "=", "getattr", "(", "fiss_module", ",", "cmd", ",", "None", ")", "if", "func", "and", "not", "hasattr", "(", "func", ",", "'fiss_cmd...
Returns the function object in this module matching cmd.
[ "Returns", "the", "function", "object", "in", "this", "module", "matching", "cmd", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1720-L1727
train
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" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1729-L1751
train
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" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1753-L1784
train
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", ")", ":", "types", "=", "{", "e", ".", "etype", "for", "e", "in", "entities", "}", "if", "len", "(", "types", ")", "!=", "1", ":", "raise", "ValueError", "(", "\"Can't create payload with \"", "+", "str", "(", ...
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", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/entity.py#L40-L70
train
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", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/entity.py#L73-L76
train
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", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/setup.py#L16-L30
train
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", ")", "with", "common", ".", "atomic_write", "(", "input_file", ".", "name", ",", "file_factory", "=", "...
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/mogrify.py#L22-L34
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L44-L51
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L204-L217
train
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", ":", "next", "(", "reader", ...
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L641-L672
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L675-L767
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L258-L264
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L327-L330
train
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", ")", "if", "filtered", ".", "seq", "==", "r...
Apply the filter to records
[ "Apply", "the", "filter", "to", "records" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L374-L396
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L504-L516
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L575-L583
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/quality_filter.py#L597-L604
train
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", "with", "common...
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", ...
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/info.py#L98-L143
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L32-L53
train
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", "-", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L56-L67
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L70-L89
train
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", ":", "taxid"...
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L92-L114
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L117-L131
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L134-L143
train
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", ":", "drop", "=", "set", "(", "i", "for", "slice", "in", "slices", "for", "i", "in", "range", "(", "*", "slice", ".", "indices", "(", "len", "(", "rec...
Drop all columns present in ``slices`` from records
[ "Drop", "all", "columns", "present", "in", "slices", "from", "records" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L184-L194
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L242-L254
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L256-L267
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L330-L343
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L346-L359
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L362-L368
train
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", "record", ".", "description", "=", "re", ".", "sub", "(", "'^'", "+", "re", ".", "escape", "(", "old_id", ")", ",",...
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L380-L389
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L392-L402
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L405-L415
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L419-L430
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L446-L466
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L469-L476
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L510-L529
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L531-L551
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L554-L577
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L580-L596
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L711-L724
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L727-L738
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L741-L747
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L51-L62
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L70-L93
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/backtrans_align.py#L138-L148
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/fileformat.py#L45-L58
train
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", ":", "extension", "=", "os", ".", "path", ".", "splitext", "(", "base",...
Look up the BioPython file type corresponding to an input file name.
[ "Look", "up", "the", "BioPython", "file", "type", "corresponding", "to", "an", "input", "file", "name", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/fileformat.py#L61-L69
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/fileformat.py#L72-L80
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/scripts/cli.py#L32-L71
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L63-L78
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L93-L122
train
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\"", ")", "r...
Returns the hamming distance between two strings.
[ "Returns", "the", "hamming", "distance", "between", "two", "strings", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L125-L133
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L275-L280
train
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", ")", ":", "source_format", "=", "(", "arguments", ".", "source_format", "or", "fileformat", ".", "from_handle", "(", "arguments", ".", "source_file", ")", ")", "output_format", "=", "(", "arguments", ".", "output_format", "or...
Trim the alignment as specified
[ "Trim", "the", "alignment", "as", "specified" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/primer_trim.py#L287-L331
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/examples/apply-function/myfunctions.py#L11-L19
train
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", "(", ")", "if", "...
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L35-L72
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L110-L122
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L125-L178
train
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" ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/common.py#L181-L193
train
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", "." ]
1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/subcommands/convert.py#L222-L231
train
phac-nml/sistr_cmd
sistr/src/parsers.py
parse_fasta
def parse_fasta(filepath): ''' Parse a fasta file returning a generator yielding tuples of fasta headers to sequences. Note: This function should give equivalent results to SeqIO from BioPython .. code-block:: python from Bio import SeqIO # biopython to dict of hea...
python
def parse_fasta(filepath): ''' Parse a fasta file returning a generator yielding tuples of fasta headers to sequences. Note: This function should give equivalent results to SeqIO from BioPython .. code-block:: python from Bio import SeqIO # biopython to dict of hea...
[ "def", "parse_fasta", "(", "filepath", ")", ":", "with", "open", "(", "filepath", ",", "'r'", ")", "as", "f", ":", "seqs", "=", "[", "]", "header", "=", "''", "for", "line", "in", "f", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "li...
Parse a fasta file returning a generator yielding tuples of fasta headers to sequences. Note: This function should give equivalent results to SeqIO from BioPython .. code-block:: python from Bio import SeqIO # biopython to dict of header-seq hseqs_bio = {r.desc...
[ "Parse", "a", "fasta", "file", "returning", "a", "generator", "yielding", "tuples", "of", "fasta", "headers", "to", "sequences", "." ]
4630fae72439723b354a94b94fbe76ad2f9f6295
https://github.com/phac-nml/sistr_cmd/blob/4630fae72439723b354a94b94fbe76ad2f9f6295/sistr/src/parsers.py#L22-L61
train
phac-nml/sistr_cmd
sistr/src/parsers.py
fasta_format_check
def fasta_format_check(fasta_path, logger): """ Check that a file is valid FASTA format. - First non-blank line needs to begin with a '>' header character. - Sequence can only contain valid IUPAC nucleotide characters Args: fasta_str (str): FASTA file contents string Raises: ...
python
def fasta_format_check(fasta_path, logger): """ Check that a file is valid FASTA format. - First non-blank line needs to begin with a '>' header character. - Sequence can only contain valid IUPAC nucleotide characters Args: fasta_str (str): FASTA file contents string Raises: ...
[ "def", "fasta_format_check", "(", "fasta_path", ",", "logger", ")", ":", "header_count", "=", "0", "line_count", "=", "1", "nt_count", "=", "0", "with", "open", "(", "fasta_path", ")", "as", "f", ":", "for", "l", "in", "f", ":", "l", "=", "l", ".", ...
Check that a file is valid FASTA format. - First non-blank line needs to begin with a '>' header character. - Sequence can only contain valid IUPAC nucleotide characters Args: fasta_str (str): FASTA file contents string Raises: Exception: If invalid FASTA format
[ "Check", "that", "a", "file", "is", "valid", "FASTA", "format", "." ]
4630fae72439723b354a94b94fbe76ad2f9f6295
https://github.com/phac-nml/sistr_cmd/blob/4630fae72439723b354a94b94fbe76ad2f9f6295/sistr/src/parsers.py#L64-L110
train