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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
maykinmedia/django-timeline-logger
timeline_logger/management/commands/report_mailing.py
Command.get_recipients
def get_recipients(self, **options): """ Figures out the recipients """ if options['recipients_from_setting']: return settings.TIMELINE_DIGEST_EMAIL_RECIPIENTS users = get_user_model()._default_manager.all() if options['staff']: users = users.filt...
python
def get_recipients(self, **options): """ Figures out the recipients """ if options['recipients_from_setting']: return settings.TIMELINE_DIGEST_EMAIL_RECIPIENTS users = get_user_model()._default_manager.all() if options['staff']: users = users.filt...
[ "def", "get_recipients", "(", "self", ",", "*", "*", "options", ")", ":", "if", "options", "[", "'recipients_from_setting'", "]", ":", "return", "settings", ".", "TIMELINE_DIGEST_EMAIL_RECIPIENTS", "users", "=", "get_user_model", "(", ")", ".", "_default_manager",...
Figures out the recipients
[ "Figures", "out", "the", "recipients" ]
1bc67b6283eb94c84e0936e3a882e1b63cfb5ed3
https://github.com/maykinmedia/django-timeline-logger/blob/1bc67b6283eb94c84e0936e3a882e1b63cfb5ed3/timeline_logger/management/commands/report_mailing.py#L63-L75
train
65,100
bouncer-app/bouncer
bouncer/models.py
Ability.expand_actions
def expand_actions(self, actions): """Accepts an array of actions and returns an array of actions which match. This should be called before "matches?" and other checking methods since they rely on the actions to be expanded.""" results = list() for action in actions: ...
python
def expand_actions(self, actions): """Accepts an array of actions and returns an array of actions which match. This should be called before "matches?" and other checking methods since they rely on the actions to be expanded.""" results = list() for action in actions: ...
[ "def", "expand_actions", "(", "self", ",", "actions", ")", ":", "results", "=", "list", "(", ")", "for", "action", "in", "actions", ":", "if", "action", "in", "self", ".", "aliased_actions", ":", "results", ".", "append", "(", "action", ")", "for", "it...
Accepts an array of actions and returns an array of actions which match. This should be called before "matches?" and other checking methods since they rely on the actions to be expanded.
[ "Accepts", "an", "array", "of", "actions", "and", "returns", "an", "array", "of", "actions", "which", "match", ".", "This", "should", "be", "called", "before", "matches?", "and", "other", "checking", "methods", "since", "they", "rely", "on", "the", "actions"...
2d645dce18e3849d338d21380529abf8db5eeb9d
https://github.com/bouncer-app/bouncer/blob/2d645dce18e3849d338d21380529abf8db5eeb9d/bouncer/models.py#L190-L204
train
65,101
cytomine/Cytomine-python-client
cytomine/cytomine_job.py
_software_params_to_argparse
def _software_params_to_argparse(parameters): """ Converts a SoftwareParameterCollection into an ArgumentParser object. Parameters ---------- parameters: SoftwareParameterCollection The software parameters Returns ------- argparse: ArgumentParser An initialized argument ...
python
def _software_params_to_argparse(parameters): """ Converts a SoftwareParameterCollection into an ArgumentParser object. Parameters ---------- parameters: SoftwareParameterCollection The software parameters Returns ------- argparse: ArgumentParser An initialized argument ...
[ "def", "_software_params_to_argparse", "(", "parameters", ")", ":", "# Check software parameters", "argparse", "=", "ArgumentParser", "(", ")", "boolean_defaults", "=", "{", "}", "for", "parameter", "in", "parameters", ":", "arg_desc", "=", "{", "\"dest\"", ":", "...
Converts a SoftwareParameterCollection into an ArgumentParser object. Parameters ---------- parameters: SoftwareParameterCollection The software parameters Returns ------- argparse: ArgumentParser An initialized argument parser
[ "Converts", "a", "SoftwareParameterCollection", "into", "an", "ArgumentParser", "object", "." ]
bac19722b900dd32c6cfd6bdb9354fc784d33bc4
https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/cytomine_job.py#L80-L108
train
65,102
cytomine/Cytomine-python-client
cytomine/cytomine_job.py
CytomineJob.start
def start(self): """ Connect to the Cytomine server and switch to job connection Incurs dataflows """ run_by_ui = False if not self.current_user.algo: # If user connects as a human (CLI execution) self._job = Job(self._project.id, self._software.i...
python
def start(self): """ Connect to the Cytomine server and switch to job connection Incurs dataflows """ run_by_ui = False if not self.current_user.algo: # If user connects as a human (CLI execution) self._job = Job(self._project.id, self._software.i...
[ "def", "start", "(", "self", ")", ":", "run_by_ui", "=", "False", "if", "not", "self", ".", "current_user", ".", "algo", ":", "# If user connects as a human (CLI execution)", "self", ".", "_job", "=", "Job", "(", "self", ".", "_project", ".", "id", ",", "s...
Connect to the Cytomine server and switch to job connection Incurs dataflows
[ "Connect", "to", "the", "Cytomine", "server", "and", "switch", "to", "job", "connection", "Incurs", "dataflows" ]
bac19722b900dd32c6cfd6bdb9354fc784d33bc4
https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/cytomine_job.py#L257-L288
train
65,103
cytomine/Cytomine-python-client
cytomine/cytomine_job.py
CytomineJob.close
def close(self, value): """ Notify the Cytomine server of the job's end Incurs a dataflows """ if value is None: status = Job.TERMINATED status_comment = "Job successfully terminated" else: status = Job.FAILED status_comment...
python
def close(self, value): """ Notify the Cytomine server of the job's end Incurs a dataflows """ if value is None: status = Job.TERMINATED status_comment = "Job successfully terminated" else: status = Job.FAILED status_comment...
[ "def", "close", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "status", "=", "Job", ".", "TERMINATED", "status_comment", "=", "\"Job successfully terminated\"", "else", ":", "status", "=", "Job", ".", "FAILED", "status_comment", "=",...
Notify the Cytomine server of the job's end Incurs a dataflows
[ "Notify", "the", "Cytomine", "server", "of", "the", "job", "s", "end", "Incurs", "a", "dataflows" ]
bac19722b900dd32c6cfd6bdb9354fc784d33bc4
https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/cytomine_job.py#L290-L304
train
65,104
pyecore/pyecoregen
pyecoregen/cli.py
generate_from_cli
def generate_from_cli(args): """CLI entry point.""" parser = argparse.ArgumentParser(description="Generate Python classes from an Ecore model.") parser.add_argument( '--ecore-model', '-e', help="Path to Ecore XMI file.", required=True ) parser.add_argument( '-...
python
def generate_from_cli(args): """CLI entry point.""" parser = argparse.ArgumentParser(description="Generate Python classes from an Ecore model.") parser.add_argument( '--ecore-model', '-e', help="Path to Ecore XMI file.", required=True ) parser.add_argument( '-...
[ "def", "generate_from_cli", "(", "args", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Generate Python classes from an Ecore model.\"", ")", "parser", ".", "add_argument", "(", "'--ecore-model'", ",", "'-e'", ",", "help", "=...
CLI entry point.
[ "CLI", "entry", "point", "." ]
8c7a792f46d7d94e5d13e00e2967dd237351a4cf
https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/cli.py#L18-L62
train
65,105
pyecore/pyecoregen
pyecoregen/cli.py
select_uri_implementation
def select_uri_implementation(ecore_model_path): """Select the right URI implementation regarding the Ecore model path schema.""" if URL_PATTERN.match(ecore_model_path): return pyecore.resources.resource.HttpURI return pyecore.resources.URI
python
def select_uri_implementation(ecore_model_path): """Select the right URI implementation regarding the Ecore model path schema.""" if URL_PATTERN.match(ecore_model_path): return pyecore.resources.resource.HttpURI return pyecore.resources.URI
[ "def", "select_uri_implementation", "(", "ecore_model_path", ")", ":", "if", "URL_PATTERN", ".", "match", "(", "ecore_model_path", ")", ":", "return", "pyecore", ".", "resources", ".", "resource", ".", "HttpURI", "return", "pyecore", ".", "resources", ".", "URI"...
Select the right URI implementation regarding the Ecore model path schema.
[ "Select", "the", "right", "URI", "implementation", "regarding", "the", "Ecore", "model", "path", "schema", "." ]
8c7a792f46d7d94e5d13e00e2967dd237351a4cf
https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/cli.py#L77-L81
train
65,106
pyecore/pyecoregen
pyecoregen/cli.py
load_model
def load_model(ecore_model_path): """Load a single Ecore model and return the root package.""" rset = pyecore.resources.ResourceSet() uri_implementation = select_uri_implementation(ecore_model_path) resource = rset.get_resource(uri_implementation(ecore_model_path)) return resource.contents[0]
python
def load_model(ecore_model_path): """Load a single Ecore model and return the root package.""" rset = pyecore.resources.ResourceSet() uri_implementation = select_uri_implementation(ecore_model_path) resource = rset.get_resource(uri_implementation(ecore_model_path)) return resource.contents[0]
[ "def", "load_model", "(", "ecore_model_path", ")", ":", "rset", "=", "pyecore", ".", "resources", ".", "ResourceSet", "(", ")", "uri_implementation", "=", "select_uri_implementation", "(", "ecore_model_path", ")", "resource", "=", "rset", ".", "get_resource", "(",...
Load a single Ecore model and return the root package.
[ "Load", "a", "single", "Ecore", "model", "and", "return", "the", "root", "package", "." ]
8c7a792f46d7d94e5d13e00e2967dd237351a4cf
https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/cli.py#L84-L89
train
65,107
galaxy-genome-annotation/python-apollo
apollo/client.py
Client.post
def post(self, client_method, data, post_params=None, is_json=True): """Make a POST request""" url = self._wa.apollo_url + self.CLIENT_BASE + client_method if post_params is None: post_params = {} headers = { 'Content-Type': 'application/json' } ...
python
def post(self, client_method, data, post_params=None, is_json=True): """Make a POST request""" url = self._wa.apollo_url + self.CLIENT_BASE + client_method if post_params is None: post_params = {} headers = { 'Content-Type': 'application/json' } ...
[ "def", "post", "(", "self", ",", "client_method", ",", "data", ",", "post_params", "=", "None", ",", "is_json", "=", "True", ")", ":", "url", "=", "self", ".", "_wa", ".", "apollo_url", "+", "self", ".", "CLIENT_BASE", "+", "client_method", "if", "post...
Make a POST request
[ "Make", "a", "POST", "request" ]
2bc9991302abe4402ec2885dcaac35915475b387
https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/client.py#L29-L65
train
65,108
galaxy-genome-annotation/python-apollo
apollo/client.py
Client.get
def get(self, client_method, get_params, is_json=True): """Make a GET request""" url = self._wa.apollo_url + self.CLIENT_BASE + client_method headers = {} response = requests.get(url, headers=headers, verify=self.__verify, params=get_params, ...
python
def get(self, client_method, get_params, is_json=True): """Make a GET request""" url = self._wa.apollo_url + self.CLIENT_BASE + client_method headers = {} response = requests.get(url, headers=headers, verify=self.__verify, params=get_params, ...
[ "def", "get", "(", "self", ",", "client_method", ",", "get_params", ",", "is_json", "=", "True", ")", ":", "url", "=", "self", ".", "_wa", ".", "apollo_url", "+", "self", ".", "CLIENT_BASE", "+", "client_method", "headers", "=", "{", "}", "response", "...
Make a GET request
[ "Make", "a", "GET", "request" ]
2bc9991302abe4402ec2885dcaac35915475b387
https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/client.py#L67-L83
train
65,109
bouncer-app/bouncer
bouncer/__init__.py
can
def can(user, action, subject): """Checks if a given user has the ability to perform the action on a subject :param user: A user object :param action: an action string, typically 'read', 'edit', 'manage'. Use bouncer.constants for readability :param subject: the resource in question. Either a Class o...
python
def can(user, action, subject): """Checks if a given user has the ability to perform the action on a subject :param user: A user object :param action: an action string, typically 'read', 'edit', 'manage'. Use bouncer.constants for readability :param subject: the resource in question. Either a Class o...
[ "def", "can", "(", "user", ",", "action", ",", "subject", ")", ":", "ability", "=", "Ability", "(", "user", ",", "get_authorization_method", "(", ")", ")", "return", "ability", ".", "can", "(", "action", ",", "subject", ")" ]
Checks if a given user has the ability to perform the action on a subject :param user: A user object :param action: an action string, typically 'read', 'edit', 'manage'. Use bouncer.constants for readability :param subject: the resource in question. Either a Class or an instance of a class. Pass the cla...
[ "Checks", "if", "a", "given", "user", "has", "the", "ability", "to", "perform", "the", "action", "on", "a", "subject" ]
2d645dce18e3849d338d21380529abf8db5eeb9d
https://github.com/bouncer-app/bouncer/blob/2d645dce18e3849d338d21380529abf8db5eeb9d/bouncer/__init__.py#L16-L28
train
65,110
bouncer-app/bouncer
bouncer/__init__.py
cannot
def cannot(user, action, subject): """inverse of ``can``""" ability = Ability(user, get_authorization_method()) return ability.cannot(action, subject)
python
def cannot(user, action, subject): """inverse of ``can``""" ability = Ability(user, get_authorization_method()) return ability.cannot(action, subject)
[ "def", "cannot", "(", "user", ",", "action", ",", "subject", ")", ":", "ability", "=", "Ability", "(", "user", ",", "get_authorization_method", "(", ")", ")", "return", "ability", ".", "cannot", "(", "action", ",", "subject", ")" ]
inverse of ``can``
[ "inverse", "of", "can" ]
2d645dce18e3849d338d21380529abf8db5eeb9d
https://github.com/bouncer-app/bouncer/blob/2d645dce18e3849d338d21380529abf8db5eeb9d/bouncer/__init__.py#L31-L34
train
65,111
bouncer-app/bouncer
bouncer/__init__.py
ensure
def ensure(user, action, subject): """ Similar to ``can`` but will raise a AccessDenied Exception if does not have access""" ability = Ability(user, get_authorization_method()) if ability.cannot(action, subject): raise AccessDenied()
python
def ensure(user, action, subject): """ Similar to ``can`` but will raise a AccessDenied Exception if does not have access""" ability = Ability(user, get_authorization_method()) if ability.cannot(action, subject): raise AccessDenied()
[ "def", "ensure", "(", "user", ",", "action", ",", "subject", ")", ":", "ability", "=", "Ability", "(", "user", ",", "get_authorization_method", "(", ")", ")", "if", "ability", ".", "cannot", "(", "action", ",", "subject", ")", ":", "raise", "AccessDenied...
Similar to ``can`` but will raise a AccessDenied Exception if does not have access
[ "Similar", "to", "can", "but", "will", "raise", "a", "AccessDenied", "Exception", "if", "does", "not", "have", "access" ]
2d645dce18e3849d338d21380529abf8db5eeb9d
https://github.com/bouncer-app/bouncer/blob/2d645dce18e3849d338d21380529abf8db5eeb9d/bouncer/__init__.py#L37-L41
train
65,112
cytomine/Cytomine-python-client
cytomine/models/annotation.py
Annotation.dump
def dump(self, dest_pattern="{id}.jpg", override=True, mask=False, alpha=False, bits=8, zoom=None, max_size=None, increase_area=None, contrast=None, gamma=None, colormap=None, inverse=None): """ Download the annotation crop, with optional image modifications. Parameters ---...
python
def dump(self, dest_pattern="{id}.jpg", override=True, mask=False, alpha=False, bits=8, zoom=None, max_size=None, increase_area=None, contrast=None, gamma=None, colormap=None, inverse=None): """ Download the annotation crop, with optional image modifications. Parameters ---...
[ "def", "dump", "(", "self", ",", "dest_pattern", "=", "\"{id}.jpg\"", ",", "override", "=", "True", ",", "mask", "=", "False", ",", "alpha", "=", "False", ",", "bits", "=", "8", ",", "zoom", "=", "None", ",", "max_size", "=", "None", ",", "increase_a...
Download the annotation crop, with optional image modifications. Parameters ---------- dest_pattern : str, optional Destination path for the downloaded image. "{X}" patterns are replaced by the value of X attribute if it exists. override : bool, optional ...
[ "Download", "the", "annotation", "crop", "with", "optional", "image", "modifications", "." ]
bac19722b900dd32c6cfd6bdb9354fc784d33bc4
https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/models/annotation.py#L62-L144
train
65,113
galaxy-genome-annotation/python-apollo
arrow/commands/annotations/set_sequence.py
cli
def cli(ctx, organism, sequence): """Set the sequence for subsequent requests. Mostly used in client scripts to avoid passing the sequence and organism on every function call. Output: None """ return ctx.gi.annotations.set_sequence(organism, sequence)
python
def cli(ctx, organism, sequence): """Set the sequence for subsequent requests. Mostly used in client scripts to avoid passing the sequence and organism on every function call. Output: None """ return ctx.gi.annotations.set_sequence(organism, sequence)
[ "def", "cli", "(", "ctx", ",", "organism", ",", "sequence", ")", ":", "return", "ctx", ".", "gi", ".", "annotations", ".", "set_sequence", "(", "organism", ",", "sequence", ")" ]
Set the sequence for subsequent requests. Mostly used in client scripts to avoid passing the sequence and organism on every function call. Output: None
[ "Set", "the", "sequence", "for", "subsequent", "requests", ".", "Mostly", "used", "in", "client", "scripts", "to", "avoid", "passing", "the", "sequence", "and", "organism", "on", "every", "function", "call", "." ]
2bc9991302abe4402ec2885dcaac35915475b387
https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/arrow/commands/annotations/set_sequence.py#L12-L19
train
65,114
hearsaycorp/normalize
normalize/selector.py
MultiFieldSelector.path
def path(self): """The path attribute returns a stringified, concise representation of the MultiFieldSelector. It can be reversed by the ``from_path`` constructor. """ if len(self.heads) == 1: return _fmt_mfs_path(self.heads.keys()[0], self.heads.values()[0]) ...
python
def path(self): """The path attribute returns a stringified, concise representation of the MultiFieldSelector. It can be reversed by the ``from_path`` constructor. """ if len(self.heads) == 1: return _fmt_mfs_path(self.heads.keys()[0], self.heads.values()[0]) ...
[ "def", "path", "(", "self", ")", ":", "if", "len", "(", "self", ".", "heads", ")", "==", "1", ":", "return", "_fmt_mfs_path", "(", "self", ".", "heads", ".", "keys", "(", ")", "[", "0", "]", ",", "self", ".", "heads", ".", "values", "(", ")", ...
The path attribute returns a stringified, concise representation of the MultiFieldSelector. It can be reversed by the ``from_path`` constructor.
[ "The", "path", "attribute", "returns", "a", "stringified", "concise", "representation", "of", "the", "MultiFieldSelector", ".", "It", "can", "be", "reversed", "by", "the", "from_path", "constructor", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/selector.py#L626-L636
train
65,115
hearsaycorp/normalize
normalize/selector.py
MultiFieldSelector.get
def get(self, obj): """Creates a copy of the passed object which only contains the parts which are pointed to by one of the FieldSelectors that were used to construct the MultiFieldSelector. Can be used to produce 'filtered' versions of objects. """ ctor = type(obj) ...
python
def get(self, obj): """Creates a copy of the passed object which only contains the parts which are pointed to by one of the FieldSelectors that were used to construct the MultiFieldSelector. Can be used to produce 'filtered' versions of objects. """ ctor = type(obj) ...
[ "def", "get", "(", "self", ",", "obj", ")", ":", "ctor", "=", "type", "(", "obj", ")", "if", "isinstance", "(", "obj", ",", "(", "list", ",", "ListCollection", ")", ")", ":", "if", "self", ".", "has_string", ":", "raise", "TypeError", "(", "\"Multi...
Creates a copy of the passed object which only contains the parts which are pointed to by one of the FieldSelectors that were used to construct the MultiFieldSelector. Can be used to produce 'filtered' versions of objects.
[ "Creates", "a", "copy", "of", "the", "passed", "object", "which", "only", "contains", "the", "parts", "which", "are", "pointed", "to", "by", "one", "of", "the", "FieldSelectors", "that", "were", "used", "to", "construct", "the", "MultiFieldSelector", ".", "C...
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/selector.py#L785-L835
train
65,116
hearsaycorp/normalize
normalize/selector.py
MultiFieldSelector.delete
def delete(self, obj, force=False): """Deletes all of the fields at the specified locations. args: ``obj=``\ *OBJECT* the object to remove the fields from ``force=``\ *BOOL* if True, missing attributes do not raise errors. Otherwise, ...
python
def delete(self, obj, force=False): """Deletes all of the fields at the specified locations. args: ``obj=``\ *OBJECT* the object to remove the fields from ``force=``\ *BOOL* if True, missing attributes do not raise errors. Otherwise, ...
[ "def", "delete", "(", "self", ",", "obj", ",", "force", "=", "False", ")", ":", "# TODO: this could be a whole lot more efficient!", "if", "not", "force", ":", "for", "fs", "in", "self", ":", "try", ":", "fs", ".", "get", "(", "obj", ")", "except", "Fiel...
Deletes all of the fields at the specified locations. args: ``obj=``\ *OBJECT* the object to remove the fields from ``force=``\ *BOOL* if True, missing attributes do not raise errors. Otherwise, the first failure raises an exception wit...
[ "Deletes", "all", "of", "the", "fields", "at", "the", "specified", "locations", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/selector.py#L837-L862
train
65,117
merll/docker-fabric
dockerfabric/tasks.py
reset_socat
def reset_socat(use_sudo=False): """ Finds and closes all processes of `socat`. :param use_sudo: Use `sudo` command. As Docker-Fabric does not run `socat` with `sudo`, this is by default set to ``False``. Setting it to ``True`` could unintentionally remove instances from other users. :type use_su...
python
def reset_socat(use_sudo=False): """ Finds and closes all processes of `socat`. :param use_sudo: Use `sudo` command. As Docker-Fabric does not run `socat` with `sudo`, this is by default set to ``False``. Setting it to ``True`` could unintentionally remove instances from other users. :type use_su...
[ "def", "reset_socat", "(", "use_sudo", "=", "False", ")", ":", "output", "=", "stdout_result", "(", "'ps -o pid -C socat'", ",", "quiet", "=", "True", ")", "pids", "=", "output", ".", "split", "(", "'\\n'", ")", "[", "1", ":", "]", "puts", "(", "\"Remo...
Finds and closes all processes of `socat`. :param use_sudo: Use `sudo` command. As Docker-Fabric does not run `socat` with `sudo`, this is by default set to ``False``. Setting it to ``True`` could unintentionally remove instances from other users. :type use_sudo: bool
[ "Finds", "and", "closes", "all", "processes", "of", "socat", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L63-L75
train
65,118
merll/docker-fabric
dockerfabric/tasks.py
version
def version(): """ Shows version information of the remote Docker service, similar to ``docker version``. """ output = docker_fabric().version() col_len = max(map(len, output.keys())) + 1 puts('') for k, v in six.iteritems(output): fastprint('{0:{1}} {2}'.format(''.join((k, ':')), co...
python
def version(): """ Shows version information of the remote Docker service, similar to ``docker version``. """ output = docker_fabric().version() col_len = max(map(len, output.keys())) + 1 puts('') for k, v in six.iteritems(output): fastprint('{0:{1}} {2}'.format(''.join((k, ':')), co...
[ "def", "version", "(", ")", ":", "output", "=", "docker_fabric", "(", ")", ".", "version", "(", ")", "col_len", "=", "max", "(", "map", "(", "len", ",", "output", ".", "keys", "(", ")", ")", ")", "+", "1", "puts", "(", "''", ")", "for", "k", ...
Shows version information of the remote Docker service, similar to ``docker version``.
[ "Shows", "version", "information", "of", "the", "remote", "Docker", "service", "similar", "to", "docker", "version", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L79-L88
train
65,119
merll/docker-fabric
dockerfabric/tasks.py
list_images
def list_images(list_all=False, full_ids=False): """ Lists images on the Docker remote host, similar to ``docker images``. :param list_all: Lists all images (e.g. dependencies). Default is ``False``, only shows named images. :type list_all: bool :param full_ids: Shows the full ids. When ``False`` (...
python
def list_images(list_all=False, full_ids=False): """ Lists images on the Docker remote host, similar to ``docker images``. :param list_all: Lists all images (e.g. dependencies). Default is ``False``, only shows named images. :type list_all: bool :param full_ids: Shows the full ids. When ``False`` (...
[ "def", "list_images", "(", "list_all", "=", "False", ",", "full_ids", "=", "False", ")", ":", "images", "=", "docker_fabric", "(", ")", ".", "images", "(", "all", "=", "list_all", ")", "_format_output_table", "(", "images", ",", "IMAGE_COLUMNS", ",", "full...
Lists images on the Docker remote host, similar to ``docker images``. :param list_all: Lists all images (e.g. dependencies). Default is ``False``, only shows named images. :type list_all: bool :param full_ids: Shows the full ids. When ``False`` (default) only shows the first 12 characters. :type full_i...
[ "Lists", "images", "on", "the", "Docker", "remote", "host", "similar", "to", "docker", "images", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L116-L126
train
65,120
merll/docker-fabric
dockerfabric/tasks.py
list_containers
def list_containers(list_all=True, short_image=True, full_ids=False, full_cmd=False): """ Lists containers on the Docker remote host, similar to ``docker ps``. :param list_all: Shows all containers. Default is ``False``, which omits exited containers. :type list_all: bool :param short_image: Hides ...
python
def list_containers(list_all=True, short_image=True, full_ids=False, full_cmd=False): """ Lists containers on the Docker remote host, similar to ``docker ps``. :param list_all: Shows all containers. Default is ``False``, which omits exited containers. :type list_all: bool :param short_image: Hides ...
[ "def", "list_containers", "(", "list_all", "=", "True", ",", "short_image", "=", "True", ",", "full_ids", "=", "False", ",", "full_cmd", "=", "False", ")", ":", "containers", "=", "docker_fabric", "(", ")", ".", "containers", "(", "all", "=", "list_all", ...
Lists containers on the Docker remote host, similar to ``docker ps``. :param list_all: Shows all containers. Default is ``False``, which omits exited containers. :type list_all: bool :param short_image: Hides the repository prefix for preserving space. Default is ``True``. :type short_image: bool :...
[ "Lists", "containers", "on", "the", "Docker", "remote", "host", "similar", "to", "docker", "ps", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L130-L144
train
65,121
merll/docker-fabric
dockerfabric/tasks.py
list_networks
def list_networks(full_ids=False): """ Lists networks on the Docker remote host, similar to ``docker network ls``. :param full_ids: Shows the full network ids. When ``False`` (default) only shows the first 12 characters. :type full_ids: bool """ networks = docker_fabric().networks() _format...
python
def list_networks(full_ids=False): """ Lists networks on the Docker remote host, similar to ``docker network ls``. :param full_ids: Shows the full network ids. When ``False`` (default) only shows the first 12 characters. :type full_ids: bool """ networks = docker_fabric().networks() _format...
[ "def", "list_networks", "(", "full_ids", "=", "False", ")", ":", "networks", "=", "docker_fabric", "(", ")", ".", "networks", "(", ")", "_format_output_table", "(", "networks", ",", "NETWORK_COLUMNS", ",", "full_ids", ")" ]
Lists networks on the Docker remote host, similar to ``docker network ls``. :param full_ids: Shows the full network ids. When ``False`` (default) only shows the first 12 characters. :type full_ids: bool
[ "Lists", "networks", "on", "the", "Docker", "remote", "host", "similar", "to", "docker", "network", "ls", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L148-L156
train
65,122
merll/docker-fabric
dockerfabric/tasks.py
cleanup_containers
def cleanup_containers(**kwargs): """ Removes all containers that have finished running. Similar to the ``prune`` functionality in newer Docker versions. """ containers = docker_fabric().cleanup_containers(**kwargs) if kwargs.get('list_only'): puts('Existing containers:') for c_id, c...
python
def cleanup_containers(**kwargs): """ Removes all containers that have finished running. Similar to the ``prune`` functionality in newer Docker versions. """ containers = docker_fabric().cleanup_containers(**kwargs) if kwargs.get('list_only'): puts('Existing containers:') for c_id, c...
[ "def", "cleanup_containers", "(", "*", "*", "kwargs", ")", ":", "containers", "=", "docker_fabric", "(", ")", ".", "cleanup_containers", "(", "*", "*", "kwargs", ")", "if", "kwargs", ".", "get", "(", "'list_only'", ")", ":", "puts", "(", "'Existing contain...
Removes all containers that have finished running. Similar to the ``prune`` functionality in newer Docker versions.
[ "Removes", "all", "containers", "that", "have", "finished", "running", ".", "Similar", "to", "the", "prune", "functionality", "in", "newer", "Docker", "versions", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L169-L177
train
65,123
merll/docker-fabric
dockerfabric/tasks.py
cleanup_images
def cleanup_images(remove_old=False, **kwargs): """ Removes all images that have no name, and that are not references as dependency by any other named image. Similar to the ``prune`` functionality in newer Docker versions, but supports more filters. :param remove_old: Also remove images that do have a ...
python
def cleanup_images(remove_old=False, **kwargs): """ Removes all images that have no name, and that are not references as dependency by any other named image. Similar to the ``prune`` functionality in newer Docker versions, but supports more filters. :param remove_old: Also remove images that do have a ...
[ "def", "cleanup_images", "(", "remove_old", "=", "False", ",", "*", "*", "kwargs", ")", ":", "keep_tags", "=", "env", ".", "get", "(", "'docker_keep_tags'", ")", "if", "keep_tags", "is", "not", "None", ":", "kwargs", ".", "setdefault", "(", "'keep_tags'", ...
Removes all images that have no name, and that are not references as dependency by any other named image. Similar to the ``prune`` functionality in newer Docker versions, but supports more filters. :param remove_old: Also remove images that do have a name, but no `latest` tag. :type remove_old: bool
[ "Removes", "all", "images", "that", "have", "no", "name", "and", "that", "are", "not", "references", "as", "dependency", "by", "any", "other", "named", "image", ".", "Similar", "to", "the", "prune", "functionality", "in", "newer", "Docker", "versions", "but"...
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L181-L196
train
65,124
merll/docker-fabric
dockerfabric/tasks.py
save_image
def save_image(image, filename=None): """ Saves a Docker image from the remote to a local files. For performance reasons, uses the Docker command line client on the host, generates a gzip-tarball and downloads that. :param image: Image name or id. :type image: unicode :param filename: File name...
python
def save_image(image, filename=None): """ Saves a Docker image from the remote to a local files. For performance reasons, uses the Docker command line client on the host, generates a gzip-tarball and downloads that. :param image: Image name or id. :type image: unicode :param filename: File name...
[ "def", "save_image", "(", "image", ",", "filename", "=", "None", ")", ":", "local_name", "=", "filename", "or", "'{0}.tar.gz'", ".", "format", "(", "image", ")", "cli", ".", "save_image", "(", "image", ",", "local_name", ")" ]
Saves a Docker image from the remote to a local files. For performance reasons, uses the Docker command line client on the host, generates a gzip-tarball and downloads that. :param image: Image name or id. :type image: unicode :param filename: File name to store the local file. If not provided, will us...
[ "Saves", "a", "Docker", "image", "from", "the", "remote", "to", "a", "local", "files", ".", "For", "performance", "reasons", "uses", "the", "Docker", "command", "line", "client", "on", "the", "host", "generates", "a", "gzip", "-", "tarball", "and", "downlo...
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L214-L226
train
65,125
merll/docker-fabric
dockerfabric/tasks.py
load_image
def load_image(filename, timeout=120): """ Uploads an image from a local file to a Docker remote. Note that this temporarily has to extend the service timeout period. :param filename: Local file name. :type filename: unicode :param timeout: Timeout in seconds to set temporarily for the upload. ...
python
def load_image(filename, timeout=120): """ Uploads an image from a local file to a Docker remote. Note that this temporarily has to extend the service timeout period. :param filename: Local file name. :type filename: unicode :param timeout: Timeout in seconds to set temporarily for the upload. ...
[ "def", "load_image", "(", "filename", ",", "timeout", "=", "120", ")", ":", "c", "=", "docker_fabric", "(", ")", "with", "open", "(", "expand_path", "(", "filename", ")", ",", "'r'", ")", "as", "f", ":", "_timeout", "=", "c", ".", "_timeout", "c", ...
Uploads an image from a local file to a Docker remote. Note that this temporarily has to extend the service timeout period. :param filename: Local file name. :type filename: unicode :param timeout: Timeout in seconds to set temporarily for the upload. :type timeout: int
[ "Uploads", "an", "image", "from", "a", "local", "file", "to", "a", "Docker", "remote", ".", "Note", "that", "this", "temporarily", "has", "to", "extend", "the", "service", "timeout", "period", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/tasks.py#L230-L247
train
65,126
hearsaycorp/normalize
normalize/record/__init__.py
Record.diff_iter
def diff_iter(self, other, **kwargs): """Generator method which returns the differences from the invocant to the argument. args: ``other=``\ *Record*\ \|\ *Anything* The thing to compare against; the types must match, unless ``duck_type=True`` is p...
python
def diff_iter(self, other, **kwargs): """Generator method which returns the differences from the invocant to the argument. args: ``other=``\ *Record*\ \|\ *Anything* The thing to compare against; the types must match, unless ``duck_type=True`` is p...
[ "def", "diff_iter", "(", "self", ",", "other", ",", "*", "*", "kwargs", ")", ":", "from", "normalize", ".", "diff", "import", "diff_iter", "return", "diff_iter", "(", "self", ",", "other", ",", "*", "*", "kwargs", ")" ]
Generator method which returns the differences from the invocant to the argument. args: ``other=``\ *Record*\ \|\ *Anything* The thing to compare against; the types must match, unless ``duck_type=True`` is passed. *diff_option*\ =\ *value* ...
[ "Generator", "method", "which", "returns", "the", "differences", "from", "the", "invocant", "to", "the", "argument", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/record/__init__.py#L153-L168
train
65,127
zhanglab/psamm
psamm/commands/primarypairs.py
_parse_weights
def _parse_weights(weight_args, default_weight=0.6): """Parse list of weight assignments.""" weights_dict = {} r_group_weight = default_weight for weight_arg in weight_args: for weight_assignment in weight_arg.split(','): if '=' not in weight_assignment: raise ValueEr...
python
def _parse_weights(weight_args, default_weight=0.6): """Parse list of weight assignments.""" weights_dict = {} r_group_weight = default_weight for weight_arg in weight_args: for weight_assignment in weight_arg.split(','): if '=' not in weight_assignment: raise ValueEr...
[ "def", "_parse_weights", "(", "weight_args", ",", "default_weight", "=", "0.6", ")", ":", "weights_dict", "=", "{", "}", "r_group_weight", "=", "default_weight", "for", "weight_arg", "in", "weight_args", ":", "for", "weight_assignment", "in", "weight_arg", ".", ...
Parse list of weight assignments.
[ "Parse", "list", "of", "weight", "assignments", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/primarypairs.py#L215-L236
train
65,128
zhanglab/psamm
psamm/commands/primarypairs.py
PrimaryPairsCommand._combine_transfers
def _combine_transfers(self, result): """Combine multiple pair transfers into one.""" transfers = {} for reaction_id, c1, c2, form in result: key = reaction_id, c1, c2 combined_form = transfers.setdefault(key, Formula()) transfers[key] = combined_form | form ...
python
def _combine_transfers(self, result): """Combine multiple pair transfers into one.""" transfers = {} for reaction_id, c1, c2, form in result: key = reaction_id, c1, c2 combined_form = transfers.setdefault(key, Formula()) transfers[key] = combined_form | form ...
[ "def", "_combine_transfers", "(", "self", ",", "result", ")", ":", "transfers", "=", "{", "}", "for", "reaction_id", ",", "c1", ",", "c2", ",", "form", "in", "result", ":", "key", "=", "reaction_id", ",", "c1", ",", "c2", "combined_form", "=", "transfe...
Combine multiple pair transfers into one.
[ "Combine", "multiple", "pair", "transfers", "into", "one", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/primarypairs.py#L162-L171
train
65,129
merll/docker-fabric
dockerfabric/cli.py
copy_resource
def copy_resource(container, resource, local_filename, contents_only=True): """ Copies a resource from a container to a compressed tarball and downloads it. :param container: Container name or id. :type container: unicode :param resource: Name of resource to copy. :type resource: unicode :p...
python
def copy_resource(container, resource, local_filename, contents_only=True): """ Copies a resource from a container to a compressed tarball and downloads it. :param container: Container name or id. :type container: unicode :param resource: Name of resource to copy. :type resource: unicode :p...
[ "def", "copy_resource", "(", "container", ",", "resource", ",", "local_filename", ",", "contents_only", "=", "True", ")", ":", "with", "temp_dir", "(", ")", "as", "remote_tmp", ":", "base_name", "=", "os", ".", "path", ".", "basename", "(", "resource", ")"...
Copies a resource from a container to a compressed tarball and downloads it. :param container: Container name or id. :type container: unicode :param resource: Name of resource to copy. :type resource: unicode :param local_filename: Path to store the tarball locally. :type local_filename: unicod...
[ "Copies", "a", "resource", "from", "a", "container", "to", "a", "compressed", "tarball", "and", "downloads", "it", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/cli.py#L290-L320
train
65,130
merll/docker-fabric
dockerfabric/cli.py
save_image
def save_image(image, local_filename): """ Saves a Docker image as a compressed tarball. This command line client method is a suitable alternative, if the Remove API method is too slow. :param image: Image id or tag. :type image: unicode :param local_filename: Local file name to store the image...
python
def save_image(image, local_filename): """ Saves a Docker image as a compressed tarball. This command line client method is a suitable alternative, if the Remove API method is too slow. :param image: Image id or tag. :type image: unicode :param local_filename: Local file name to store the image...
[ "def", "save_image", "(", "image", ",", "local_filename", ")", ":", "r_name", ",", "__", ",", "i_name", "=", "image", ".", "rpartition", "(", "'/'", ")", "i_name", ",", "__", ",", "__", "=", "i_name", ".", "partition", "(", "':'", ")", "with", "temp_...
Saves a Docker image as a compressed tarball. This command line client method is a suitable alternative, if the Remove API method is too slow. :param image: Image id or tag. :type image: unicode :param local_filename: Local file name to store the image into. If this is a directory, the image will be st...
[ "Saves", "a", "Docker", "image", "as", "a", "compressed", "tarball", ".", "This", "command", "line", "client", "method", "is", "a", "suitable", "alternative", "if", "the", "Remove", "API", "method", "is", "too", "slow", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/cli.py#L410-L425
train
65,131
zhanglab/psamm
psamm/datasource/modelseed.py
decode_name
def decode_name(s): """Decode names in ModelSEED files""" # Some names contain XML-like entity codes return re.sub(r'&#(\d+);', lambda x: chr(int(x.group(1))), s)
python
def decode_name(s): """Decode names in ModelSEED files""" # Some names contain XML-like entity codes return re.sub(r'&#(\d+);', lambda x: chr(int(x.group(1))), s)
[ "def", "decode_name", "(", "s", ")", ":", "# Some names contain XML-like entity codes", "return", "re", ".", "sub", "(", "r'&#(\\d+);'", ",", "lambda", "x", ":", "chr", "(", "int", "(", "x", ".", "group", "(", "1", ")", ")", ")", ",", "s", ")" ]
Decode names in ModelSEED files
[ "Decode", "names", "in", "ModelSEED", "files" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/modelseed.py#L31-L34
train
65,132
zhanglab/psamm
psamm/datasource/modelseed.py
parse_compound_file
def parse_compound_file(f, context=None): """Iterate over the compound entries in the given file""" f.readline() # Skip header for lineno, row in enumerate(csv.reader(f, delimiter='\t')): compound_id, names, formula = row[:3] names = (decode_name(name) for name in names.split(',<br>')) ...
python
def parse_compound_file(f, context=None): """Iterate over the compound entries in the given file""" f.readline() # Skip header for lineno, row in enumerate(csv.reader(f, delimiter='\t')): compound_id, names, formula = row[:3] names = (decode_name(name) for name in names.split(',<br>')) ...
[ "def", "parse_compound_file", "(", "f", ",", "context", "=", "None", ")", ":", "f", ".", "readline", "(", ")", "# Skip header", "for", "lineno", ",", "row", "in", "enumerate", "(", "csv", ".", "reader", "(", "f", ",", "delimiter", "=", "'\\t'", ")", ...
Iterate over the compound entries in the given file
[ "Iterate", "over", "the", "compound", "entries", "in", "the", "given", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/modelseed.py#L88-L111
train
65,133
zhanglab/psamm
psamm/commands/search.py
SearchCommand.init_parser
def init_parser(cls, parser): """Initialize argument parser""" subparsers = parser.add_subparsers(title='Search domain') # Compound subcommand parser_compound = subparsers.add_parser( 'compound', help='Search in compounds') parser_compound.set_defaults(which='compoun...
python
def init_parser(cls, parser): """Initialize argument parser""" subparsers = parser.add_subparsers(title='Search domain') # Compound subcommand parser_compound = subparsers.add_parser( 'compound', help='Search in compounds') parser_compound.set_defaults(which='compoun...
[ "def", "init_parser", "(", "cls", ",", "parser", ")", ":", "subparsers", "=", "parser", ".", "add_subparsers", "(", "title", "=", "'Search domain'", ")", "# Compound subcommand", "parser_compound", "=", "subparsers", ".", "add_parser", "(", "'compound'", ",", "h...
Initialize argument parser
[ "Initialize", "argument", "parser" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/search.py#L36-L64
train
65,134
zhanglab/psamm
psamm/commands/search.py
SearchCommand.run
def run(self): """Run search command.""" which_command = self._args.which if which_command == 'compound': self._search_compound() elif which_command == 'reaction': self._search_reaction()
python
def run(self): """Run search command.""" which_command = self._args.which if which_command == 'compound': self._search_compound() elif which_command == 'reaction': self._search_reaction()
[ "def", "run", "(", "self", ")", ":", "which_command", "=", "self", ".", "_args", ".", "which", "if", "which_command", "==", "'compound'", ":", "self", ".", "_search_compound", "(", ")", "elif", "which_command", "==", "'reaction'", ":", "self", ".", "_searc...
Run search command.
[ "Run", "search", "command", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/search.py#L66-L73
train
65,135
hearsaycorp/normalize
normalize/property/json.py
JsonProperty.to_json
def to_json(self, propval, extraneous=False, to_json_func=None): """This function calls the ``json_out`` function, if it was specified, otherwise continues with JSON conversion of the value in the slot by calling ``to_json_func`` on it. """ if self.json_out: return se...
python
def to_json(self, propval, extraneous=False, to_json_func=None): """This function calls the ``json_out`` function, if it was specified, otherwise continues with JSON conversion of the value in the slot by calling ``to_json_func`` on it. """ if self.json_out: return se...
[ "def", "to_json", "(", "self", ",", "propval", ",", "extraneous", "=", "False", ",", "to_json_func", "=", "None", ")", ":", "if", "self", ".", "json_out", ":", "return", "self", ".", "json_out", "(", "propval", ")", "else", ":", "if", "not", "to_json_f...
This function calls the ``json_out`` function, if it was specified, otherwise continues with JSON conversion of the value in the slot by calling ``to_json_func`` on it.
[ "This", "function", "calls", "the", "json_out", "function", "if", "it", "was", "specified", "otherwise", "continues", "with", "JSON", "conversion", "of", "the", "value", "in", "the", "slot", "by", "calling", "to_json_func", "on", "it", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/property/json.py#L78-L89
train
65,136
zhanglab/psamm
psamm/datasource/reaction.py
parse_compound
def parse_compound(s, global_compartment=None): """Parse a compound specification. If no compartment is specified in the string, the global compartment will be used. """ m = re.match(r'^\|(.*)\|$', s) if m: s = m.group(1) m = re.match(r'^(.+)\[(\S+)\]$', s) if m: compou...
python
def parse_compound(s, global_compartment=None): """Parse a compound specification. If no compartment is specified in the string, the global compartment will be used. """ m = re.match(r'^\|(.*)\|$', s) if m: s = m.group(1) m = re.match(r'^(.+)\[(\S+)\]$', s) if m: compou...
[ "def", "parse_compound", "(", "s", ",", "global_compartment", "=", "None", ")", ":", "m", "=", "re", ".", "match", "(", "r'^\\|(.*)\\|$'", ",", "s", ")", "if", "m", ":", "s", "=", "m", ".", "group", "(", "1", ")", "m", "=", "re", ".", "match", ...
Parse a compound specification. If no compartment is specified in the string, the global compartment will be used.
[ "Parse", "a", "compound", "specification", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/reaction.py#L226-L244
train
65,137
zhanglab/psamm
psamm/randomsparse.py
random_sparse
def random_sparse(strategy, prob, obj_reaction, flux_threshold): """Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be ...
python
def random_sparse(strategy, prob, obj_reaction, flux_threshold): """Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be ...
[ "def", "random_sparse", "(", "strategy", ",", "prob", ",", "obj_reaction", ",", "flux_threshold", ")", ":", "essential", "=", "set", "(", ")", "deleted", "=", "set", "(", ")", "for", "entity", ",", "deleted_reactions", "in", "strategy", ".", "iter_tests", ...
Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be deleted. It works with two strategies: deleting reactions or deletin...
[ "Find", "a", "random", "minimal", "network", "of", "model", "reactions", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/randomsparse.py#L152-L224
train
65,138
zhanglab/psamm
psamm/commands/gapcheck.py
GapCheckCommand.run_sink_check
def run_sink_check(self, model, solver, threshold, implicit_sinks=True): """Run sink production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reactions: lower, upper = model.limits[reaction_id] ...
python
def run_sink_check(self, model, solver, threshold, implicit_sinks=True): """Run sink production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reactions: lower, upper = model.limits[reaction_id] ...
[ "def", "run_sink_check", "(", "self", ",", "model", ",", "solver", ",", "threshold", ",", "implicit_sinks", "=", "True", ")", ":", "prob", "=", "solver", ".", "create_problem", "(", ")", "# Create flux variables", "v", "=", "prob", ".", "namespace", "(", "...
Run sink production check method.
[ "Run", "sink", "production", "check", "method", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/gapcheck.py#L112-L157
train
65,139
zhanglab/psamm
psamm/commands/gapcheck.py
GapCheckCommand.run_reaction_production_check
def run_reaction_production_check(self, model, solver, threshold, implicit_sinks=True): """Run reaction production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reaction...
python
def run_reaction_production_check(self, model, solver, threshold, implicit_sinks=True): """Run reaction production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reaction...
[ "def", "run_reaction_production_check", "(", "self", ",", "model", ",", "solver", ",", "threshold", ",", "implicit_sinks", "=", "True", ")", ":", "prob", "=", "solver", ".", "create_problem", "(", ")", "# Create flux variables", "v", "=", "prob", ".", "namespa...
Run reaction production check method.
[ "Run", "reaction", "production", "check", "method", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/gapcheck.py#L159-L217
train
65,140
zhanglab/psamm
psamm/lpsolver/cplex.py
Problem.add_linear_constraints
def add_linear_constraints(self, *relations): """Add constraints to the problem Each constraint is represented by a Relation, and the expression in that relation can be a set expression. """ constraints = [] for relation in relations: if self._check_relation...
python
def add_linear_constraints(self, *relations): """Add constraints to the problem Each constraint is represented by a Relation, and the expression in that relation can be a set expression. """ constraints = [] for relation in relations: if self._check_relation...
[ "def", "add_linear_constraints", "(", "self", ",", "*", "relations", ")", ":", "constraints", "=", "[", "]", "for", "relation", "in", "relations", ":", "if", "self", ".", "_check_relation", "(", "relation", ")", ":", "constraints", ".", "append", "(", "Con...
Add constraints to the problem Each constraint is represented by a Relation, and the expression in that relation can be a set expression.
[ "Add", "constraints", "to", "the", "problem" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L206-L221
train
65,141
zhanglab/psamm
psamm/lpsolver/cplex.py
Problem.set_objective
def set_objective(self, expression): """Set objective expression of the problem.""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression(offset=expression) linear = [...
python
def set_objective(self, expression): """Set objective expression of the problem.""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression(offset=expression) linear = [...
[ "def", "set_objective", "(", "self", ",", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "numbers", ".", "Number", ")", ":", "# Allow expressions with no variables as objective,", "# represented as a number", "expression", "=", "Expression", "(", ...
Set objective expression of the problem.
[ "Set", "objective", "expression", "of", "the", "problem", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L223-L270
train
65,142
zhanglab/psamm
psamm/lpsolver/cplex.py
Problem._reset_problem_type
def _reset_problem_type(self): """Reset problem type to whatever is appropriate.""" # Only need to reset the type after the first solve. This also works # around a bug in Cplex where get_num_binary() is some rare cases # causes a segfault. if self._solve_count > 0: i...
python
def _reset_problem_type(self): """Reset problem type to whatever is appropriate.""" # Only need to reset the type after the first solve. This also works # around a bug in Cplex where get_num_binary() is some rare cases # causes a segfault. if self._solve_count > 0: i...
[ "def", "_reset_problem_type", "(", "self", ")", ":", "# Only need to reset the type after the first solve. This also works", "# around a bug in Cplex where get_num_binary() is some rare cases", "# causes a segfault.", "if", "self", ".", "_solve_count", ">", "0", ":", "integer_count",...
Reset problem type to whatever is appropriate.
[ "Reset", "problem", "type", "to", "whatever", "is", "appropriate", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L288-L341
train
65,143
zhanglab/psamm
psamm/lpsolver/cplex.py
Result.get_value
def get_value(self, expression): """Return value of expression.""" self._check_valid() return super(Result, self).get_value(expression)
python
def get_value(self, expression): """Return value of expression.""" self._check_valid() return super(Result, self).get_value(expression)
[ "def", "get_value", "(", "self", ",", "expression", ")", ":", "self", ".", "_check_valid", "(", ")", "return", "super", "(", "Result", ",", "self", ")", ".", "get_value", "(", "expression", ")" ]
Return value of expression.
[ "Return", "value", "of", "expression", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L468-L471
train
65,144
zhanglab/psamm
psamm/formula.py
_parse_formula
def _parse_formula(s): """Parse formula string.""" scanner = re.compile(r''' (\s+) | # whitespace (\(|\)) | # group ([A-Z][a-z]*) | # element (\d+) | # number ([a-z]) | # variable (\Z) | # end (.) # error ...
python
def _parse_formula(s): """Parse formula string.""" scanner = re.compile(r''' (\s+) | # whitespace (\(|\)) | # group ([A-Z][a-z]*) | # element (\d+) | # number ([a-z]) | # variable (\Z) | # end (.) # error ...
[ "def", "_parse_formula", "(", "s", ")", ":", "scanner", "=", "re", ".", "compile", "(", "r'''\n (\\s+) | # whitespace\n (\\(|\\)) | # group\n ([A-Z][a-z]*) | # element\n (\\d+) | # number\n ([a-z]) | # variable\n (\\Z) | ...
Parse formula string.
[ "Parse", "formula", "string", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/formula.py#L425-L510
train
65,145
hearsaycorp/normalize
normalize/visitor.py
Visitor.copy
def copy(self): """Be sure to implement this method when sub-classing, otherwise you will lose any specialization context.""" doppel = type(self)( self.unpack, self.apply, self.collect, self.reduce, apply_empty_slots=self.apply_empty_slots, extraneous=self.ext...
python
def copy(self): """Be sure to implement this method when sub-classing, otherwise you will lose any specialization context.""" doppel = type(self)( self.unpack, self.apply, self.collect, self.reduce, apply_empty_slots=self.apply_empty_slots, extraneous=self.ext...
[ "def", "copy", "(", "self", ")", ":", "doppel", "=", "type", "(", "self", ")", "(", "self", ".", "unpack", ",", "self", ".", "apply", ",", "self", ".", "collect", ",", "self", ".", "reduce", ",", "apply_empty_slots", "=", "self", ".", "apply_empty_sl...
Be sure to implement this method when sub-classing, otherwise you will lose any specialization context.
[ "Be", "sure", "to", "implement", "this", "method", "when", "sub", "-", "classing", "otherwise", "you", "will", "lose", "any", "specialization", "context", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L105-L119
train
65,146
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.unpack
def unpack(cls, value, value_type, visitor): """Unpack a value during a 'visit' args: ``value=``\ *object* The instance being visited ``value_type=``\ *RecordType* The expected type of the instance ``visitor=``\ *Visitor* ...
python
def unpack(cls, value, value_type, visitor): """Unpack a value during a 'visit' args: ``value=``\ *object* The instance being visited ``value_type=``\ *RecordType* The expected type of the instance ``visitor=``\ *Visitor* ...
[ "def", "unpack", "(", "cls", ",", "value", ",", "value_type", ",", "visitor", ")", ":", "if", "issubclass", "(", "value_type", ",", "Collection", ")", ":", "try", ":", "generator", "=", "value", ".", "itertuples", "(", ")", "except", "AttributeError", ":...
Unpack a value during a 'visit' args: ``value=``\ *object* The instance being visited ``value_type=``\ *RecordType* The expected type of the instance ``visitor=``\ *Visitor* The context/options returns a tuple with ...
[ "Unpack", "a", "value", "during", "a", "visit" ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L196-L247
train
65,147
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.apply
def apply(cls, value, prop, visitor): """'apply' is a general place to put a function which is called on every extant record slot. This is usually the most important function to implement when sub-classing. The default implementation passes through the slot value as-is, but exp...
python
def apply(cls, value, prop, visitor): """'apply' is a general place to put a function which is called on every extant record slot. This is usually the most important function to implement when sub-classing. The default implementation passes through the slot value as-is, but exp...
[ "def", "apply", "(", "cls", ",", "value", ",", "prop", ",", "visitor", ")", ":", "return", "(", "None", "if", "isinstance", "(", "value", ",", "(", "AttributeError", ",", "KeyError", ")", ")", "else", "value", ")" ]
apply' is a general place to put a function which is called on every extant record slot. This is usually the most important function to implement when sub-classing. The default implementation passes through the slot value as-is, but expected exceptions are converted to ``None``. ...
[ "apply", "is", "a", "general", "place", "to", "put", "a", "function", "which", "is", "called", "on", "every", "extant", "record", "slot", ".", "This", "is", "usually", "the", "most", "important", "function", "to", "implement", "when", "sub", "-", "classing...
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L250-L284
train
65,148
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.aggregate
def aggregate(self, mapped_coll_generator, coll_type, visitor): """Hook called for each normalize.coll.Collection, after mapping over each of the items in the collection. The default implementation calls :py:meth:`normalize.coll.Collection.tuples_to_coll` with ``coerce=False``, ...
python
def aggregate(self, mapped_coll_generator, coll_type, visitor): """Hook called for each normalize.coll.Collection, after mapping over each of the items in the collection. The default implementation calls :py:meth:`normalize.coll.Collection.tuples_to_coll` with ``coerce=False``, ...
[ "def", "aggregate", "(", "self", ",", "mapped_coll_generator", ",", "coll_type", ",", "visitor", ")", ":", "return", "coll_type", ".", "tuples_to_coll", "(", "mapped_coll_generator", ",", "coerce", "=", "False", ")" ]
Hook called for each normalize.coll.Collection, after mapping over each of the items in the collection. The default implementation calls :py:meth:`normalize.coll.Collection.tuples_to_coll` with ``coerce=False``, which just re-assembles the collection into a native python collect...
[ "Hook", "called", "for", "each", "normalize", ".", "coll", ".", "Collection", "after", "mapping", "over", "each", "of", "the", "items", "in", "the", "collection", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L287-L309
train
65,149
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.reduce
def reduce(self, mapped_props, aggregated, value_type, visitor): """This reduction is called to combine the mapped slot and collection item values into a single value for return. The default implementation tries to behave naturally; you'll almost always get a dict back when mapping over...
python
def reduce(self, mapped_props, aggregated, value_type, visitor): """This reduction is called to combine the mapped slot and collection item values into a single value for return. The default implementation tries to behave naturally; you'll almost always get a dict back when mapping over...
[ "def", "reduce", "(", "self", ",", "mapped_props", ",", "aggregated", ",", "value_type", ",", "visitor", ")", ":", "reduced", "=", "None", "if", "mapped_props", ":", "reduced", "=", "dict", "(", "(", "k", ".", "name", ",", "v", ")", "for", "k", ",", ...
This reduction is called to combine the mapped slot and collection item values into a single value for return. The default implementation tries to behave naturally; you'll almost always get a dict back when mapping over a record, and list or some other collection when mapping over colle...
[ "This", "reduction", "is", "called", "to", "combine", "the", "mapped", "slot", "and", "collection", "item", "values", "into", "a", "single", "value", "for", "return", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L312-L359
train
65,150
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.reflect
def reflect(cls, X, **kwargs): """Reflect is for visitors where you are exposing some information about the types reachable from a starting type to an external system. For example, a front-end, a REST URL router and documentation framework, an avro schema definition, etc. X can ...
python
def reflect(cls, X, **kwargs): """Reflect is for visitors where you are exposing some information about the types reachable from a starting type to an external system. For example, a front-end, a REST URL router and documentation framework, an avro schema definition, etc. X can ...
[ "def", "reflect", "(", "cls", ",", "X", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "X", ",", "type", ")", ":", "value", "=", "None", "value_type", "=", "X", "else", ":", "value", "=", "X", "value_type", "=", "type", "(", "X", "...
Reflect is for visitors where you are exposing some information about the types reachable from a starting type to an external system. For example, a front-end, a REST URL router and documentation framework, an avro schema definition, etc. X can be a type or an instance. This AP...
[ "Reflect", "is", "for", "visitors", "where", "you", "are", "exposing", "some", "information", "about", "the", "types", "reachable", "from", "a", "starting", "type", "to", "an", "external", "system", ".", "For", "example", "a", "front", "-", "end", "a", "RE...
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L482-L506
train
65,151
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.map
def map(cls, visitor, value, value_type): """The common visitor API used by all three visitor implementations. args: ``visitor=``\ *Visitor* Visitor options instance: contains the callbacks to use to implement the visiting, as well as traversal & filtering ...
python
def map(cls, visitor, value, value_type): """The common visitor API used by all three visitor implementations. args: ``visitor=``\ *Visitor* Visitor options instance: contains the callbacks to use to implement the visiting, as well as traversal & filtering ...
[ "def", "map", "(", "cls", ",", "visitor", ",", "value", ",", "value_type", ")", ":", "unpacked", "=", "visitor", ".", "unpack", "(", "value", ",", "value_type", ",", "visitor", ")", "if", "unpacked", "==", "cls", ".", "StopVisiting", "or", "isinstance", ...
The common visitor API used by all three visitor implementations. args: ``visitor=``\ *Visitor* Visitor options instance: contains the callbacks to use to implement the visiting, as well as traversal & filtering options. ``value=``\ *Obj...
[ "The", "common", "visitor", "API", "used", "by", "all", "three", "visitor", "implementations", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L591-L639
train
65,152
zhanglab/psamm
psamm/fluxanalysis.py
_get_fba_problem
def _get_fba_problem(model, tfba, solver): """Convenience function for returning the right FBA problem instance""" p = FluxBalanceProblem(model, solver) if tfba: p.add_thermodynamic() return p
python
def _get_fba_problem(model, tfba, solver): """Convenience function for returning the right FBA problem instance""" p = FluxBalanceProblem(model, solver) if tfba: p.add_thermodynamic() return p
[ "def", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", ":", "p", "=", "FluxBalanceProblem", "(", "model", ",", "solver", ")", "if", "tfba", ":", "p", ".", "add_thermodynamic", "(", ")", "return", "p" ]
Convenience function for returning the right FBA problem instance
[ "Convenience", "function", "for", "returning", "the", "right", "FBA", "problem", "instance" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L35-L40
train
65,153
zhanglab/psamm
psamm/fluxanalysis.py
flux_balance
def flux_balance(model, reaction, tfba, solver): """Run flux balance analysis on the given model. Yields the reaction id and flux value for each reaction in the model. This is a convenience function for sertting up and running the FluxBalanceProblem. If the FBA is solved for more than one parameter ...
python
def flux_balance(model, reaction, tfba, solver): """Run flux balance analysis on the given model. Yields the reaction id and flux value for each reaction in the model. This is a convenience function for sertting up and running the FluxBalanceProblem. If the FBA is solved for more than one parameter ...
[ "def", "flux_balance", "(", "model", ",", "reaction", ",", "tfba", ",", "solver", ")", ":", "fba", "=", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", "fba", ".", "maximize", "(", "reaction", ")", "for", "reaction", "in", "model", "...
Run flux balance analysis on the given model. Yields the reaction id and flux value for each reaction in the model. This is a convenience function for sertting up and running the FluxBalanceProblem. If the FBA is solved for more than one parameter it is recommended to setup and reuse the FluxBalancePr...
[ "Run", "flux", "balance", "analysis", "on", "the", "given", "model", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L293-L320
train
65,154
zhanglab/psamm
psamm/fluxanalysis.py
flux_variability
def flux_variability(model, reactions, fixed, tfba, solver): """Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value ma...
python
def flux_variability(model, reactions, fixed, tfba, solver): """Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value ma...
[ "def", "flux_variability", "(", "model", ",", "reactions", ",", "fixed", ",", "tfba", ",", "solver", ")", ":", "fba", "=", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", "for", "reaction_id", ",", "value", "in", "iteritems", "(", "fix...
Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value mapping. This is an implementation of flux variability analysis (...
[ "Find", "the", "variability", "of", "each", "reaction", "while", "fixing", "certain", "fluxes", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L323-L357
train
65,155
zhanglab/psamm
psamm/fluxanalysis.py
flux_minimization
def flux_minimization(model, fixed, solver, weights={}): """Minimize flux of all reactions while keeping certain fluxes fixed. The fixed reactions are given in a dictionary as reaction id to value mapping. The weighted L1-norm of the fluxes is minimized. Args: model: MetabolicModel to solve. ...
python
def flux_minimization(model, fixed, solver, weights={}): """Minimize flux of all reactions while keeping certain fluxes fixed. The fixed reactions are given in a dictionary as reaction id to value mapping. The weighted L1-norm of the fluxes is minimized. Args: model: MetabolicModel to solve. ...
[ "def", "flux_minimization", "(", "model", ",", "fixed", ",", "solver", ",", "weights", "=", "{", "}", ")", ":", "fba", "=", "FluxBalanceProblem", "(", "model", ",", "solver", ")", "for", "reaction_id", ",", "value", "in", "iteritems", "(", "fixed", ")", ...
Minimize flux of all reactions while keeping certain fluxes fixed. The fixed reactions are given in a dictionary as reaction id to value mapping. The weighted L1-norm of the fluxes is minimized. Args: model: MetabolicModel to solve. fixed: dict of additional lower bounds on reaction fluxes...
[ "Minimize", "flux", "of", "all", "reactions", "while", "keeping", "certain", "fluxes", "fixed", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L360-L385
train
65,156
zhanglab/psamm
psamm/fluxanalysis.py
flux_randomization
def flux_randomization(model, threshold, tfba, solver): """Find a random flux solution on the boundary of the solution space. The reactions in the threshold dictionary are constrained with the associated lower bound. Args: model: MetabolicModel to solve. threshold: dict of additional l...
python
def flux_randomization(model, threshold, tfba, solver): """Find a random flux solution on the boundary of the solution space. The reactions in the threshold dictionary are constrained with the associated lower bound. Args: model: MetabolicModel to solve. threshold: dict of additional l...
[ "def", "flux_randomization", "(", "model", ",", "threshold", ",", "tfba", ",", "solver", ")", ":", "optimize", "=", "{", "}", "for", "reaction_id", "in", "model", ".", "reactions", ":", "if", "model", ".", "is_reversible", "(", "reaction_id", ")", ":", "...
Find a random flux solution on the boundary of the solution space. The reactions in the threshold dictionary are constrained with the associated lower bound. Args: model: MetabolicModel to solve. threshold: dict of additional lower bounds on reaction fluxes. tfba: If True enable th...
[ "Find", "a", "random", "flux", "solution", "on", "the", "boundary", "of", "the", "solution", "space", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L388-L417
train
65,157
zhanglab/psamm
psamm/fluxanalysis.py
consistency_check
def consistency_check(model, subset, epsilon, tfba, solver): """Check that reaction subset of model is consistent using FBA. Yields all reactions that are *not* flux consistent. A reaction is consistent if there is at least one flux solution to the model that both respects the model constraints and als...
python
def consistency_check(model, subset, epsilon, tfba, solver): """Check that reaction subset of model is consistent using FBA. Yields all reactions that are *not* flux consistent. A reaction is consistent if there is at least one flux solution to the model that both respects the model constraints and als...
[ "def", "consistency_check", "(", "model", ",", "subset", ",", "epsilon", ",", "tfba", ",", "solver", ")", ":", "fba", "=", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", "subset", "=", "set", "(", "subset", ")", "while", "len", "(",...
Check that reaction subset of model is consistent using FBA. Yields all reactions that are *not* flux consistent. A reaction is consistent if there is at least one flux solution to the model that both respects the model constraints and also allows the reaction in question to have non-zero flux. Th...
[ "Check", "that", "reaction", "subset", "of", "model", "is", "consistent", "using", "FBA", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L420-L470
train
65,158
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.add_thermodynamic
def add_thermodynamic(self, em=1000): """Apply thermodynamic constraints to the model. Adding these constraints restricts the solution space to only contain solutions that have no internal loops [Schilling00]_. This is solved as a MILP problem as described in [Muller13]_. The time to so...
python
def add_thermodynamic(self, em=1000): """Apply thermodynamic constraints to the model. Adding these constraints restricts the solution space to only contain solutions that have no internal loops [Schilling00]_. This is solved as a MILP problem as described in [Muller13]_. The time to so...
[ "def", "add_thermodynamic", "(", "self", ",", "em", "=", "1000", ")", ":", "internal", "=", "set", "(", "r", "for", "r", "in", "self", ".", "_model", ".", "reactions", "if", "not", "self", ".", "_model", ".", "is_exchange", "(", "r", ")", ")", "# R...
Apply thermodynamic constraints to the model. Adding these constraints restricts the solution space to only contain solutions that have no internal loops [Schilling00]_. This is solved as a MILP problem as described in [Muller13]_. The time to solve a problem with thermodynamic constrai...
[ "Apply", "thermodynamic", "constraints", "to", "the", "model", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L110-L168
train
65,159
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.maximize
def maximize(self, reaction): """Solve the model by maximizing the given reaction. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction will have zero weight). """ self._prob.set_objective(se...
python
def maximize(self, reaction): """Solve the model by maximizing the given reaction. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction will have zero weight). """ self._prob.set_objective(se...
[ "def", "maximize", "(", "self", ",", "reaction", ")", ":", "self", ".", "_prob", ".", "set_objective", "(", "self", ".", "flux_expr", "(", "reaction", ")", ")", "self", ".", "_solve", "(", ")" ]
Solve the model by maximizing the given reaction. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction will have zero weight).
[ "Solve", "the", "model", "by", "maximizing", "the", "given", "reaction", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L170-L179
train
65,160
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.flux_bound
def flux_bound(self, reaction, direction): """Return the flux bound of the reaction. Direction must be a positive number to obtain the upper bound or a negative number to obtain the lower bound. A value of inf or -inf is returned if the problem is unbounded. """ try: ...
python
def flux_bound(self, reaction, direction): """Return the flux bound of the reaction. Direction must be a positive number to obtain the upper bound or a negative number to obtain the lower bound. A value of inf or -inf is returned if the problem is unbounded. """ try: ...
[ "def", "flux_bound", "(", "self", ",", "reaction", ",", "direction", ")", ":", "try", ":", "self", ".", "maximize", "(", "{", "reaction", ":", "direction", "}", ")", "except", "FluxBalanceError", "as", "e", ":", "if", "not", "e", ".", "result", ".", ...
Return the flux bound of the reaction. Direction must be a positive number to obtain the upper bound or a negative number to obtain the lower bound. A value of inf or -inf is returned if the problem is unbounded.
[ "Return", "the", "flux", "bound", "of", "the", "reaction", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L181-L195
train
65,161
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem._add_minimization_vars
def _add_minimization_vars(self): """Add variables and constraints for L1 norm minimization.""" self._z = self._prob.namespace(self._model.reactions, lower=0) # Define constraints v = self._v.set(self._model.reactions) z = self._z.set(self._model.reactions) self._prob....
python
def _add_minimization_vars(self): """Add variables and constraints for L1 norm minimization.""" self._z = self._prob.namespace(self._model.reactions, lower=0) # Define constraints v = self._v.set(self._model.reactions) z = self._z.set(self._model.reactions) self._prob....
[ "def", "_add_minimization_vars", "(", "self", ")", ":", "self", ".", "_z", "=", "self", ".", "_prob", ".", "namespace", "(", "self", ".", "_model", ".", "reactions", ",", "lower", "=", "0", ")", "# Define constraints", "v", "=", "self", ".", "_v", ".",...
Add variables and constraints for L1 norm minimization.
[ "Add", "variables", "and", "constraints", "for", "L1", "norm", "minimization", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L197-L206
train
65,162
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.minimize_l1
def minimize_l1(self, weights={}): """Solve the model by minimizing the L1 norm of the fluxes. If the weights dictionary is given, the weighted L1 norm if minimized instead. The dictionary contains the weights of each reaction (default 1). """ if self._z is None: ...
python
def minimize_l1(self, weights={}): """Solve the model by minimizing the L1 norm of the fluxes. If the weights dictionary is given, the weighted L1 norm if minimized instead. The dictionary contains the weights of each reaction (default 1). """ if self._z is None: ...
[ "def", "minimize_l1", "(", "self", ",", "weights", "=", "{", "}", ")", ":", "if", "self", ".", "_z", "is", "None", ":", "self", ".", "_add_minimization_vars", "(", ")", "objective", "=", "self", ".", "_z", ".", "expr", "(", "(", "reaction_id", ",", ...
Solve the model by minimizing the L1 norm of the fluxes. If the weights dictionary is given, the weighted L1 norm if minimized instead. The dictionary contains the weights of each reaction (default 1).
[ "Solve", "the", "model", "by", "minimizing", "the", "L1", "norm", "of", "the", "fluxes", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L208-L224
train
65,163
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.max_min_l1
def max_min_l1(self, reaction, weights={}): """Maximize flux of reaction then minimize the L1 norm. During minimization the given reaction will be fixed at the maximum obtained from the first solution. If reaction is a dictionary object, each entry is interpreted as a weight on the obje...
python
def max_min_l1(self, reaction, weights={}): """Maximize flux of reaction then minimize the L1 norm. During minimization the given reaction will be fixed at the maximum obtained from the first solution. If reaction is a dictionary object, each entry is interpreted as a weight on the obje...
[ "def", "max_min_l1", "(", "self", ",", "reaction", ",", "weights", "=", "{", "}", ")", ":", "self", ".", "maximize", "(", "reaction", ")", "if", "isinstance", "(", "reaction", ",", "dict", ")", ":", "reactions", "=", "list", "(", "reaction", ")", "el...
Maximize flux of reaction then minimize the L1 norm. During minimization the given reaction will be fixed at the maximum obtained from the first solution. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction ...
[ "Maximize", "flux", "of", "reaction", "then", "minimize", "the", "L1", "norm", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L226-L251
train
65,164
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem._solve
def _solve(self): """Solve the problem with the current objective.""" # Remove temporary constraints while len(self._remove_constr) > 0: self._remove_constr.pop().delete() try: self._prob.solve(lp.ObjectiveSense.Maximize) except lp.SolverError as e: ...
python
def _solve(self): """Solve the problem with the current objective.""" # Remove temporary constraints while len(self._remove_constr) > 0: self._remove_constr.pop().delete() try: self._prob.solve(lp.ObjectiveSense.Maximize) except lp.SolverError as e: ...
[ "def", "_solve", "(", "self", ")", ":", "# Remove temporary constraints", "while", "len", "(", "self", ".", "_remove_constr", ")", ">", "0", ":", "self", ".", "_remove_constr", ".", "pop", "(", ")", ".", "delete", "(", ")", "try", ":", "self", ".", "_p...
Solve the problem with the current objective.
[ "Solve", "the", "problem", "with", "the", "current", "objective", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L261-L276
train
65,165
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.flux_expr
def flux_expr(self, reaction): """Get LP expression representing the reaction flux.""" if isinstance(reaction, dict): return self._v.expr(iteritems(reaction)) return self._v(reaction)
python
def flux_expr(self, reaction): """Get LP expression representing the reaction flux.""" if isinstance(reaction, dict): return self._v.expr(iteritems(reaction)) return self._v(reaction)
[ "def", "flux_expr", "(", "self", ",", "reaction", ")", ":", "if", "isinstance", "(", "reaction", ",", "dict", ")", ":", "return", "self", ".", "_v", ".", "expr", "(", "iteritems", "(", "reaction", ")", ")", "return", "self", ".", "_v", "(", "reaction...
Get LP expression representing the reaction flux.
[ "Get", "LP", "expression", "representing", "the", "reaction", "flux", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L282-L286
train
65,166
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.get_flux
def get_flux(self, reaction): """Get resulting flux value for reaction.""" return self._prob.result.get_value(self._v(reaction))
python
def get_flux(self, reaction): """Get resulting flux value for reaction.""" return self._prob.result.get_value(self._v(reaction))
[ "def", "get_flux", "(", "self", ",", "reaction", ")", ":", "return", "self", ".", "_prob", ".", "result", ".", "get_value", "(", "self", ".", "_v", "(", "reaction", ")", ")" ]
Get resulting flux value for reaction.
[ "Get", "resulting", "flux", "value", "for", "reaction", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L288-L290
train
65,167
zhanglab/psamm
psamm/lpsolver/qsoptex.py
Problem.set_objective
def set_objective(self, expression): """Set linear objective of problem""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression() self._p.set_linear_objective( ...
python
def set_objective(self, expression): """Set linear objective of problem""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression() self._p.set_linear_objective( ...
[ "def", "set_objective", "(", "self", ",", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "numbers", ".", "Number", ")", ":", "# Allow expressions with no variables as objective,", "# represented as a number", "expression", "=", "Expression", "(", ...
Set linear objective of problem
[ "Set", "linear", "objective", "of", "problem" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/qsoptex.py#L150-L160
train
65,168
zhanglab/psamm
psamm/lpsolver/qsoptex.py
Result.unbounded
def unbounded(self): """Whether the solution is unbounded""" self._check_valid() return (self._problem._p.get_status() == qsoptex.SolutionStatus.UNBOUNDED)
python
def unbounded(self): """Whether the solution is unbounded""" self._check_valid() return (self._problem._p.get_status() == qsoptex.SolutionStatus.UNBOUNDED)
[ "def", "unbounded", "(", "self", ")", ":", "self", ".", "_check_valid", "(", ")", "return", "(", "self", ".", "_problem", ".", "_p", ".", "get_status", "(", ")", "==", "qsoptex", ".", "SolutionStatus", ".", "UNBOUNDED", ")" ]
Whether the solution is unbounded
[ "Whether", "the", "solution", "is", "unbounded" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/qsoptex.py#L245-L249
train
65,169
smartfile/python-librsync
librsync/__init__.py
_execute
def _execute(job, f, o=None): """ Executes a librsync "job" by reading bytes from `f` and writing results to `o` if provided. If `o` is omitted, the output is ignored. """ # Re-use the same buffer for output, we will read from it after each # iteration. out = ctypes.create_string_buffer(RS_J...
python
def _execute(job, f, o=None): """ Executes a librsync "job" by reading bytes from `f` and writing results to `o` if provided. If `o` is omitted, the output is ignored. """ # Re-use the same buffer for output, we will read from it after each # iteration. out = ctypes.create_string_buffer(RS_J...
[ "def", "_execute", "(", "job", ",", "f", ",", "o", "=", "None", ")", ":", "# Re-use the same buffer for output, we will read from it after each", "# iteration.", "out", "=", "ctypes", ".", "create_string_buffer", "(", "RS_JOB_BLOCKSIZE", ")", "while", "True", ":", "...
Executes a librsync "job" by reading bytes from `f` and writing results to `o` if provided. If `o` is omitted, the output is ignored.
[ "Executes", "a", "librsync", "job", "by", "reading", "bytes", "from", "f", "and", "writing", "results", "to", "o", "if", "provided", ".", "If", "o", "is", "omitted", "the", "output", "is", "ignored", "." ]
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L118-L152
train
65,170
smartfile/python-librsync
librsync/__init__.py
signature
def signature(f, s=None, block_size=RS_DEFAULT_BLOCK_LEN): """ Generate a signature for the file `f`. The signature will be written to `s`. If `s` is omitted, a temporary file will be used. This function returns the signature file `s`. You can specify the size of the blocks using the optional `block...
python
def signature(f, s=None, block_size=RS_DEFAULT_BLOCK_LEN): """ Generate a signature for the file `f`. The signature will be written to `s`. If `s` is omitted, a temporary file will be used. This function returns the signature file `s`. You can specify the size of the blocks using the optional `block...
[ "def", "signature", "(", "f", ",", "s", "=", "None", ",", "block_size", "=", "RS_DEFAULT_BLOCK_LEN", ")", ":", "if", "s", "is", "None", ":", "s", "=", "tempfile", ".", "SpooledTemporaryFile", "(", "max_size", "=", "MAX_SPOOL", ",", "mode", "=", "'wb+'", ...
Generate a signature for the file `f`. The signature will be written to `s`. If `s` is omitted, a temporary file will be used. This function returns the signature file `s`. You can specify the size of the blocks using the optional `block_size` parameter.
[ "Generate", "a", "signature", "for", "the", "file", "f", ".", "The", "signature", "will", "be", "written", "to", "s", ".", "If", "s", "is", "omitted", "a", "temporary", "file", "will", "be", "used", ".", "This", "function", "returns", "the", "signature",...
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L161-L175
train
65,171
smartfile/python-librsync
librsync/__init__.py
delta
def delta(f, s, d=None): """ Create a delta for the file `f` using the signature read from `s`. The delta will be written to `d`. If `d` is omitted, a temporary file will be used. This function returns the delta file `d`. All parameters must be file-like objects. """ if d is None: d ...
python
def delta(f, s, d=None): """ Create a delta for the file `f` using the signature read from `s`. The delta will be written to `d`. If `d` is omitted, a temporary file will be used. This function returns the delta file `d`. All parameters must be file-like objects. """ if d is None: d ...
[ "def", "delta", "(", "f", ",", "s", ",", "d", "=", "None", ")", ":", "if", "d", "is", "None", ":", "d", "=", "tempfile", ".", "SpooledTemporaryFile", "(", "max_size", "=", "MAX_SPOOL", ",", "mode", "=", "'wb+'", ")", "sig", "=", "ctypes", ".", "c...
Create a delta for the file `f` using the signature read from `s`. The delta will be written to `d`. If `d` is omitted, a temporary file will be used. This function returns the delta file `d`. All parameters must be file-like objects.
[ "Create", "a", "delta", "for", "the", "file", "f", "using", "the", "signature", "read", "from", "s", ".", "The", "delta", "will", "be", "written", "to", "d", ".", "If", "d", "is", "omitted", "a", "temporary", "file", "will", "be", "used", ".", "This"...
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L179-L205
train
65,172
smartfile/python-librsync
librsync/__init__.py
patch
def patch(f, d, o=None): """ Patch the file `f` using the delta `d`. The patched file will be written to `o`. If `o` is omitted, a temporary file will be used. This function returns the be patched file `o`. All parameters should be file-like objects. `f` is required to be seekable. """ if o ...
python
def patch(f, d, o=None): """ Patch the file `f` using the delta `d`. The patched file will be written to `o`. If `o` is omitted, a temporary file will be used. This function returns the be patched file `o`. All parameters should be file-like objects. `f` is required to be seekable. """ if o ...
[ "def", "patch", "(", "f", ",", "d", ",", "o", "=", "None", ")", ":", "if", "o", "is", "None", ":", "o", "=", "tempfile", ".", "SpooledTemporaryFile", "(", "max_size", "=", "MAX_SPOOL", ",", "mode", "=", "'wb+'", ")", "@", "patch_callback", "def", "...
Patch the file `f` using the delta `d`. The patched file will be written to `o`. If `o` is omitted, a temporary file will be used. This function returns the be patched file `o`. All parameters should be file-like objects. `f` is required to be seekable.
[ "Patch", "the", "file", "f", "using", "the", "delta", "d", ".", "The", "patched", "file", "will", "be", "written", "to", "o", ".", "If", "o", "is", "omitted", "a", "temporary", "file", "will", "be", "used", ".", "This", "function", "returns", "the", ...
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L209-L235
train
65,173
zhanglab/psamm
psamm/gapfill.py
_find_integer_tolerance
def _find_integer_tolerance(epsilon, v_max, min_tol): """Find appropriate integer tolerance for gap-filling problems.""" int_tol = min(epsilon / (10 * v_max), 0.1) min_tol = max(1e-10, min_tol) if int_tol < min_tol: eps_lower = min_tol * 10 * v_max logger.warning( 'When the m...
python
def _find_integer_tolerance(epsilon, v_max, min_tol): """Find appropriate integer tolerance for gap-filling problems.""" int_tol = min(epsilon / (10 * v_max), 0.1) min_tol = max(1e-10, min_tol) if int_tol < min_tol: eps_lower = min_tol * 10 * v_max logger.warning( 'When the m...
[ "def", "_find_integer_tolerance", "(", "epsilon", ",", "v_max", ",", "min_tol", ")", ":", "int_tol", "=", "min", "(", "epsilon", "/", "(", "10", "*", "v_max", ")", ",", "0.1", ")", "min_tol", "=", "max", "(", "1e-10", ",", "min_tol", ")", "if", "int_...
Find appropriate integer tolerance for gap-filling problems.
[ "Find", "appropriate", "integer", "tolerance", "for", "gap", "-", "filling", "problems", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfill.py#L36-L49
train
65,174
zhanglab/psamm
psamm/gapfill.py
gapfind
def gapfind(model, solver, epsilon=0.001, v_max=1000, implicit_sinks=True): """Identify compounds in the model that cannot be produced. Yields all compounds that cannot be produced. This method assumes implicit sinks for all compounds in the model so the only factor that influences whether a compound c...
python
def gapfind(model, solver, epsilon=0.001, v_max=1000, implicit_sinks=True): """Identify compounds in the model that cannot be produced. Yields all compounds that cannot be produced. This method assumes implicit sinks for all compounds in the model so the only factor that influences whether a compound c...
[ "def", "gapfind", "(", "model", ",", "solver", ",", "epsilon", "=", "0.001", ",", "v_max", "=", "1000", ",", "implicit_sinks", "=", "True", ")", ":", "prob", "=", "solver", ".", "create_problem", "(", ")", "# Set integrality tolerance such that w constraints are...
Identify compounds in the model that cannot be produced. Yields all compounds that cannot be produced. This method assumes implicit sinks for all compounds in the model so the only factor that influences whether a compound can be produced is the presence of the compounds needed to produce it. Epsi...
[ "Identify", "compounds", "in", "the", "model", "that", "cannot", "be", "produced", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfill.py#L52-L140
train
65,175
zhanglab/psamm
psamm/datasource/native.py
float_constructor
def float_constructor(loader, node): """Construct Decimal from YAML float encoding.""" s = loader.construct_scalar(node) if s == '.inf': return Decimal('Infinity') elif s == '-.inf': return -Decimal('Infinity') elif s == '.nan': return Decimal('NaN') return Decimal(s)
python
def float_constructor(loader, node): """Construct Decimal from YAML float encoding.""" s = loader.construct_scalar(node) if s == '.inf': return Decimal('Infinity') elif s == '-.inf': return -Decimal('Infinity') elif s == '.nan': return Decimal('NaN') return Decimal(s)
[ "def", "float_constructor", "(", "loader", ",", "node", ")", ":", "s", "=", "loader", ".", "construct_scalar", "(", "node", ")", "if", "s", "==", "'.inf'", ":", "return", "Decimal", "(", "'Infinity'", ")", "elif", "s", "==", "'-.inf'", ":", "return", "...
Construct Decimal from YAML float encoding.
[ "Construct", "Decimal", "from", "YAML", "float", "encoding", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L64-L73
train
65,176
zhanglab/psamm
psamm/datasource/native.py
yaml_load
def yaml_load(stream): """Load YAML file using safe loader.""" # Surprisingly, the CSafeLoader does not seem to be used by default. # Check whether the CSafeLoader is available and provide a log message # if it is not available. global _HAS_YAML_LIBRARY if _HAS_YAML_LIBRARY is None: _HA...
python
def yaml_load(stream): """Load YAML file using safe loader.""" # Surprisingly, the CSafeLoader does not seem to be used by default. # Check whether the CSafeLoader is available and provide a log message # if it is not available. global _HAS_YAML_LIBRARY if _HAS_YAML_LIBRARY is None: _HA...
[ "def", "yaml_load", "(", "stream", ")", ":", "# Surprisingly, the CSafeLoader does not seem to be used by default.", "# Check whether the CSafeLoader is available and provide a log message", "# if it is not available.", "global", "_HAS_YAML_LIBRARY", "if", "_HAS_YAML_LIBRARY", "is", "Non...
Load YAML file using safe loader.
[ "Load", "YAML", "file", "using", "safe", "loader", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L76-L94
train
65,177
zhanglab/psamm
psamm/datasource/native.py
_check_id
def _check_id(entity, entity_type): """Check whether the ID is valid. First check if the ID is missing, and then check if it is a qualified string type, finally check if the string is empty. For all checks, it would raise a ParseError with the corresponding message. Args: entity: a string ...
python
def _check_id(entity, entity_type): """Check whether the ID is valid. First check if the ID is missing, and then check if it is a qualified string type, finally check if the string is empty. For all checks, it would raise a ParseError with the corresponding message. Args: entity: a string ...
[ "def", "_check_id", "(", "entity", ",", "entity_type", ")", ":", "if", "entity", "is", "None", ":", "raise", "ParseError", "(", "'{} ID missing'", ".", "format", "(", "entity_type", ")", ")", "elif", "not", "isinstance", "(", "entity", ",", "string_types", ...
Check whether the ID is valid. First check if the ID is missing, and then check if it is a qualified string type, finally check if the string is empty. For all checks, it would raise a ParseError with the corresponding message. Args: entity: a string type object to be checked. entity_t...
[ "Check", "whether", "the", "ID", "is", "valid", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L620-L644
train
65,178
zhanglab/psamm
psamm/datasource/native.py
parse_compound
def parse_compound(compound_def, context=None): """Parse a structured compound definition as obtained from a YAML file Returns a CompoundEntry.""" compound_id = compound_def.get('id') _check_id(compound_id, 'Compound') mark = FileMark(context, None, None) return CompoundEntry(compound_def, ma...
python
def parse_compound(compound_def, context=None): """Parse a structured compound definition as obtained from a YAML file Returns a CompoundEntry.""" compound_id = compound_def.get('id') _check_id(compound_id, 'Compound') mark = FileMark(context, None, None) return CompoundEntry(compound_def, ma...
[ "def", "parse_compound", "(", "compound_def", ",", "context", "=", "None", ")", ":", "compound_id", "=", "compound_def", ".", "get", "(", "'id'", ")", "_check_id", "(", "compound_id", ",", "'Compound'", ")", "mark", "=", "FileMark", "(", "context", ",", "N...
Parse a structured compound definition as obtained from a YAML file Returns a CompoundEntry.
[ "Parse", "a", "structured", "compound", "definition", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L647-L656
train
65,179
zhanglab/psamm
psamm/datasource/native.py
parse_compound_list
def parse_compound_list(path, compounds): """Parse a structured list of compounds as obtained from a YAML file Yields CompoundEntries. Path can be given as a string or a context. """ context = FilePathContext(path) for compound_def in compounds: if 'include' in compound_def: f...
python
def parse_compound_list(path, compounds): """Parse a structured list of compounds as obtained from a YAML file Yields CompoundEntries. Path can be given as a string or a context. """ context = FilePathContext(path) for compound_def in compounds: if 'include' in compound_def: f...
[ "def", "parse_compound_list", "(", "path", ",", "compounds", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "compound_def", "in", "compounds", ":", "if", "'include'", "in", "compound_def", ":", "file_format", "=", "compound_def", ".", "g...
Parse a structured list of compounds as obtained from a YAML file Yields CompoundEntries. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "compounds", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L659-L674
train
65,180
zhanglab/psamm
psamm/datasource/native.py
parse_compound_table_file
def parse_compound_table_file(path, f): """Parse a tab-separated file containing compound IDs and properties The compound properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for i, row in enumerate(csv.D...
python
def parse_compound_table_file(path, f): """Parse a tab-separated file containing compound IDs and properties The compound properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for i, row in enumerate(csv.D...
[ "def", "parse_compound_table_file", "(", "path", ",", "f", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "i", ",", "row", "in", "enumerate", "(", "csv", ".", "DictReader", "(", "f", ",", "delimiter", "=", "str", "(", "'\\t'", ")...
Parse a tab-separated file containing compound IDs and properties The compound properties are parsed according to the header which specifies which property is contained in each column.
[ "Parse", "a", "tab", "-", "separated", "file", "containing", "compound", "IDs", "and", "properties" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L677-L696
train
65,181
zhanglab/psamm
psamm/datasource/native.py
parse_compound_file
def parse_compound_file(path, format): """Open and parse reaction file based on file extension or given format Path can be given as a string or a context. """ context = FilePathContext(path) # YAML files do not need to explicitly specify format format = resolve_format(format, context.filepath...
python
def parse_compound_file(path, format): """Open and parse reaction file based on file extension or given format Path can be given as a string or a context. """ context = FilePathContext(path) # YAML files do not need to explicitly specify format format = resolve_format(format, context.filepath...
[ "def", "parse_compound_file", "(", "path", ",", "format", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "# YAML files do not need to explicitly specify format", "format", "=", "resolve_format", "(", "format", ",", "context", ".", "filepath", ")", "i...
Open and parse reaction file based on file extension or given format Path can be given as a string or a context.
[ "Open", "and", "parse", "reaction", "file", "based", "on", "file", "extension", "or", "given", "format" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L720-L750
train
65,182
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_equation_string
def parse_reaction_equation_string(equation, default_compartment): """Parse a string representation of a reaction equation. Converts undefined compartments to the default compartment. """ def _translate_compartments(reaction, compartment): """Translate compound with missing compartments. ...
python
def parse_reaction_equation_string(equation, default_compartment): """Parse a string representation of a reaction equation. Converts undefined compartments to the default compartment. """ def _translate_compartments(reaction, compartment): """Translate compound with missing compartments. ...
[ "def", "parse_reaction_equation_string", "(", "equation", ",", "default_compartment", ")", ":", "def", "_translate_compartments", "(", "reaction", ",", "compartment", ")", ":", "\"\"\"Translate compound with missing compartments.\n\n These compounds will have the specified com...
Parse a string representation of a reaction equation. Converts undefined compartments to the default compartment.
[ "Parse", "a", "string", "representation", "of", "a", "reaction", "equation", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L753-L772
train
65,183
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_equation
def parse_reaction_equation(equation_def, default_compartment): """Parse a structured reaction equation as obtained from a YAML file Returns a Reaction. """ def parse_compound_list(l, compartment): """Parse a list of reactants or metabolites""" for compound_def in l: compou...
python
def parse_reaction_equation(equation_def, default_compartment): """Parse a structured reaction equation as obtained from a YAML file Returns a Reaction. """ def parse_compound_list(l, compartment): """Parse a list of reactants or metabolites""" for compound_def in l: compou...
[ "def", "parse_reaction_equation", "(", "equation_def", ",", "default_compartment", ")", ":", "def", "parse_compound_list", "(", "l", ",", "compartment", ")", ":", "\"\"\"Parse a list of reactants or metabolites\"\"\"", "for", "compound_def", "in", "l", ":", "compound_id",...
Parse a structured reaction equation as obtained from a YAML file Returns a Reaction.
[ "Parse", "a", "structured", "reaction", "equation", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L775-L812
train
65,184
zhanglab/psamm
psamm/datasource/native.py
parse_reaction
def parse_reaction(reaction_def, default_compartment, context=None): """Parse a structured reaction definition as obtained from a YAML file Returns a ReactionEntry. """ reaction_id = reaction_def.get('id') _check_id(reaction_id, 'Reaction') reaction_props = dict(reaction_def) # Parse rea...
python
def parse_reaction(reaction_def, default_compartment, context=None): """Parse a structured reaction definition as obtained from a YAML file Returns a ReactionEntry. """ reaction_id = reaction_def.get('id') _check_id(reaction_id, 'Reaction') reaction_props = dict(reaction_def) # Parse rea...
[ "def", "parse_reaction", "(", "reaction_def", ",", "default_compartment", ",", "context", "=", "None", ")", ":", "reaction_id", "=", "reaction_def", ".", "get", "(", "'id'", ")", "_check_id", "(", "reaction_id", ",", "'Reaction'", ")", "reaction_props", "=", "...
Parse a structured reaction definition as obtained from a YAML file Returns a ReactionEntry.
[ "Parse", "a", "structured", "reaction", "definition", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L815-L832
train
65,185
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_list
def parse_reaction_list(path, reactions, default_compartment=None): """Parse a structured list of reactions as obtained from a YAML file Yields tuples of reaction ID and reaction object. Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_def in reacti...
python
def parse_reaction_list(path, reactions, default_compartment=None): """Parse a structured list of reactions as obtained from a YAML file Yields tuples of reaction ID and reaction object. Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_def in reacti...
[ "def", "parse_reaction_list", "(", "path", ",", "reactions", ",", "default_compartment", "=", "None", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "reaction_def", "in", "reactions", ":", "if", "'include'", "in", "reaction_def", ":", "i...
Parse a structured list of reactions as obtained from a YAML file Yields tuples of reaction ID and reaction object. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "reactions", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L835-L851
train
65,186
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_table_file
def parse_reaction_table_file(path, f, default_compartment): """Parse a tab-separated file containing reaction IDs and properties The reaction properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for line...
python
def parse_reaction_table_file(path, f, default_compartment): """Parse a tab-separated file containing reaction IDs and properties The reaction properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for line...
[ "def", "parse_reaction_table_file", "(", "path", ",", "f", ",", "default_compartment", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "lineno", ",", "row", "in", "enumerate", "(", "csv", ".", "DictReader", "(", "f", ",", "delimiter", ...
Parse a tab-separated file containing reaction IDs and properties The reaction properties are parsed according to the header which specifies which property is contained in each column.
[ "Parse", "a", "tab", "-", "separated", "file", "containing", "reaction", "IDs", "and", "properties" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L863-L883
train
65,187
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_file
def parse_reaction_file(path, default_compartment=None): """Open and parse reaction file based on file extension Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv': logger.debug('Parsing re...
python
def parse_reaction_file(path, default_compartment=None): """Open and parse reaction file based on file extension Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv': logger.debug('Parsing re...
[ "def", "parse_reaction_file", "(", "path", ",", "default_compartment", "=", "None", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "format", "=", "resolve_format", "(", "None", ",", "context", ".", "filepath", ")", "if", "format", "==", "'tsv...
Open and parse reaction file based on file extension Path can be given as a string or a context.
[ "Open", "and", "parse", "reaction", "file", "based", "on", "file", "extension" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L886-L911
train
65,188
zhanglab/psamm
psamm/datasource/native.py
parse_exchange
def parse_exchange(exchange_def, default_compartment): """Parse a structured exchange definition as obtained from a YAML file. Returns in iterator of compound, reaction, lower and upper bounds. """ default_compartment = exchange_def.get('compartment', default_compartment) for compound_def in exch...
python
def parse_exchange(exchange_def, default_compartment): """Parse a structured exchange definition as obtained from a YAML file. Returns in iterator of compound, reaction, lower and upper bounds. """ default_compartment = exchange_def.get('compartment', default_compartment) for compound_def in exch...
[ "def", "parse_exchange", "(", "exchange_def", ",", "default_compartment", ")", ":", "default_compartment", "=", "exchange_def", ".", "get", "(", "'compartment'", ",", "default_compartment", ")", "for", "compound_def", "in", "exchange_def", ".", "get", "(", "'compoun...
Parse a structured exchange definition as obtained from a YAML file. Returns in iterator of compound, reaction, lower and upper bounds.
[ "Parse", "a", "structured", "exchange", "definition", "as", "obtained", "from", "a", "YAML", "file", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L929-L942
train
65,189
zhanglab/psamm
psamm/datasource/native.py
parse_exchange_list
def parse_exchange_list(path, exchange, default_compartment): """Parse a structured exchange list as obtained from a YAML file. Yields tuples of compound, reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for exchange_def...
python
def parse_exchange_list(path, exchange, default_compartment): """Parse a structured exchange list as obtained from a YAML file. Yields tuples of compound, reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for exchange_def...
[ "def", "parse_exchange_list", "(", "path", ",", "exchange", ",", "default_compartment", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "exchange_def", "in", "exchange", ":", "if", "'include'", "in", "exchange_def", ":", "include_context", ...
Parse a structured exchange list as obtained from a YAML file. Yields tuples of compound, reaction ID, lower and upper flux bounds. Path can be given as a string or a context.
[ "Parse", "a", "structured", "exchange", "list", "as", "obtained", "from", "a", "YAML", "file", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L953-L971
train
65,190
zhanglab/psamm
psamm/datasource/native.py
parse_exchange_table_file
def parse_exchange_table_file(f): """Parse a space-separated file containing exchange compound flux limits. The first two columns contain compound IDs and compartment while the third column contains the lower flux limits. The fourth column is optional and contains the upper flux limit. """ for...
python
def parse_exchange_table_file(f): """Parse a space-separated file containing exchange compound flux limits. The first two columns contain compound IDs and compartment while the third column contains the lower flux limits. The fourth column is optional and contains the upper flux limit. """ for...
[ "def", "parse_exchange_table_file", "(", "f", ")", ":", "for", "line", "in", "f", ":", "line", ",", "_", ",", "comment", "=", "line", ".", "partition", "(", "'#'", ")", "line", "=", "line", ".", "strip", "(", ")", "if", "line", "==", "''", ":", "...
Parse a space-separated file containing exchange compound flux limits. The first two columns contain compound IDs and compartment while the third column contains the lower flux limits. The fourth column is optional and contains the upper flux limit.
[ "Parse", "a", "space", "-", "separated", "file", "containing", "exchange", "compound", "flux", "limits", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L999-L1027
train
65,191
zhanglab/psamm
psamm/datasource/native.py
parse_exchange_file
def parse_exchange_file(path, default_compartment): """Parse a file as a list of exchange compounds with flux limits. The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, c...
python
def parse_exchange_file(path, default_compartment): """Parse a file as a list of exchange compounds with flux limits. The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, c...
[ "def", "parse_exchange_file", "(", "path", ",", "default_compartment", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "format", "=", "resolve_format", "(", "None", ",", "context", ".", "filepath", ")", "if", "format", "==", "'tsv'", ":", "log...
Parse a file as a list of exchange compounds with flux limits. The file format is detected and the file is parsed accordingly. Path can be given as a string or a context.
[ "Parse", "a", "file", "as", "a", "list", "of", "exchange", "compounds", "with", "flux", "limits", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1038-L1063
train
65,192
zhanglab/psamm
psamm/datasource/native.py
parse_limit
def parse_limit(limit_def): """Parse a structured flux limit definition as obtained from a YAML file Returns a tuple of reaction, lower and upper bound. """ lower, upper = get_limits(limit_def) reaction = limit_def.get('reaction') return reaction, lower, upper
python
def parse_limit(limit_def): """Parse a structured flux limit definition as obtained from a YAML file Returns a tuple of reaction, lower and upper bound. """ lower, upper = get_limits(limit_def) reaction = limit_def.get('reaction') return reaction, lower, upper
[ "def", "parse_limit", "(", "limit_def", ")", ":", "lower", ",", "upper", "=", "get_limits", "(", "limit_def", ")", "reaction", "=", "limit_def", ".", "get", "(", "'reaction'", ")", "return", "reaction", ",", "lower", ",", "upper" ]
Parse a structured flux limit definition as obtained from a YAML file Returns a tuple of reaction, lower and upper bound.
[ "Parse", "a", "structured", "flux", "limit", "definition", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1074-L1083
train
65,193
zhanglab/psamm
psamm/datasource/native.py
parse_limits_list
def parse_limits_list(path, limits): """Parse a structured list of flux limits as obtained from a YAML file Yields tuples of reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for limit_def in limits: if 'include' ...
python
def parse_limits_list(path, limits): """Parse a structured list of flux limits as obtained from a YAML file Yields tuples of reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for limit_def in limits: if 'include' ...
[ "def", "parse_limits_list", "(", "path", ",", "limits", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "limit_def", "in", "limits", ":", "if", "'include'", "in", "limit_def", ":", "include_context", "=", "context", ".", "resolve", "(",...
Parse a structured list of flux limits as obtained from a YAML file Yields tuples of reaction ID, lower and upper flux bounds. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "flux", "limits", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1086-L1101
train
65,194
zhanglab/psamm
psamm/datasource/native.py
parse_limits_table_file
def parse_limits_table_file(f): """Parse a space-separated file containing reaction flux limits The first column contains reaction IDs while the second column contains the lower flux limits. The third column is optional and contains the upper flux limit. """ for line in f: line, _, com...
python
def parse_limits_table_file(f): """Parse a space-separated file containing reaction flux limits The first column contains reaction IDs while the second column contains the lower flux limits. The third column is optional and contains the upper flux limit. """ for line in f: line, _, com...
[ "def", "parse_limits_table_file", "(", "f", ")", ":", "for", "line", "in", "f", ":", "line", ",", "_", ",", "comment", "=", "line", ".", "partition", "(", "'#'", ")", "line", "=", "line", ".", "strip", "(", ")", "if", "line", "==", "''", ":", "co...
Parse a space-separated file containing reaction flux limits The first column contains reaction IDs while the second column contains the lower flux limits. The third column is optional and contains the upper flux limit.
[ "Parse", "a", "space", "-", "separated", "file", "containing", "reaction", "flux", "limits" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1104-L1131
train
65,195
zhanglab/psamm
psamm/datasource/native.py
parse_limits_file
def parse_limits_file(path): """Parse a file as a list of reaction flux limits The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv'...
python
def parse_limits_file(path): """Parse a file as a list of reaction flux limits The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv'...
[ "def", "parse_limits_file", "(", "path", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "format", "=", "resolve_format", "(", "None", ",", "context", ".", "filepath", ")", "if", "format", "==", "'tsv'", ":", "logger", ".", "debug", "(", "...
Parse a file as a list of reaction flux limits The file format is detected and the file is parsed accordingly. Path can be given as a string or a context.
[ "Parse", "a", "file", "as", "a", "list", "of", "reaction", "flux", "limits" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1143-L1167
train
65,196
zhanglab/psamm
psamm/datasource/native.py
parse_model_group
def parse_model_group(path, group): """Parse a structured model group as obtained from a YAML file Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_id in group.get('reactions', []): yield reaction_id # Parse subgroups for reaction_id in...
python
def parse_model_group(path, group): """Parse a structured model group as obtained from a YAML file Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_id in group.get('reactions', []): yield reaction_id # Parse subgroups for reaction_id in...
[ "def", "parse_model_group", "(", "path", ",", "group", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "reaction_id", "in", "group", ".", "get", "(", "'reactions'", ",", "[", "]", ")", ":", "yield", "reaction_id", "# Parse subgroups", ...
Parse a structured model group as obtained from a YAML file Path can be given as a string or a context.
[ "Parse", "a", "structured", "model", "group", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1170-L1184
train
65,197
zhanglab/psamm
psamm/datasource/native.py
parse_model_group_list
def parse_model_group_list(path, groups): """Parse a structured list of model groups as obtained from a YAML file Yields reaction IDs. Path can be given as a string or a context. """ context = FilePathContext(path) for model_group in groups: if 'include' in model_group: include...
python
def parse_model_group_list(path, groups): """Parse a structured list of model groups as obtained from a YAML file Yields reaction IDs. Path can be given as a string or a context. """ context = FilePathContext(path) for model_group in groups: if 'include' in model_group: include...
[ "def", "parse_model_group_list", "(", "path", ",", "groups", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "model_group", "in", "groups", ":", "if", "'include'", "in", "model_group", ":", "include_context", "=", "context", ".", "resolve...
Parse a structured list of model groups as obtained from a YAML file Yields reaction IDs. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "model", "groups", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1187-L1201
train
65,198
zhanglab/psamm
psamm/datasource/native.py
_reaction_representer
def _reaction_representer(dumper, data): """Generate a parsable reaction representation to the YAML parser. Check the number of compounds in the reaction, if it is larger than 10, then transform the reaction data into a list of directories with all attributes in the reaction; otherwise, just return the...
python
def _reaction_representer(dumper, data): """Generate a parsable reaction representation to the YAML parser. Check the number of compounds in the reaction, if it is larger than 10, then transform the reaction data into a list of directories with all attributes in the reaction; otherwise, just return the...
[ "def", "_reaction_representer", "(", "dumper", ",", "data", ")", ":", "if", "len", "(", "data", ".", "compounds", ")", ">", "_MAX_REACTION_LENGTH", ":", "def", "dict_make", "(", "compounds", ")", ":", "for", "compound", ",", "value", "in", "compounds", ":"...
Generate a parsable reaction representation to the YAML parser. Check the number of compounds in the reaction, if it is larger than 10, then transform the reaction data into a list of directories with all attributes in the reaction; otherwise, just return the text_type format of the reaction data.
[ "Generate", "a", "parsable", "reaction", "representation", "to", "the", "YAML", "parser", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1278-L1310
train
65,199