repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
iotile/coretools
iotileship/iotile/ship/recipe.py
RecipeObject.prepare
def prepare(self, variables): """Initialize all steps in this recipe using their parameters. Args: variables (dict): A dictionary of global variable definitions that may be used to replace or augment the parameters given to each step. Returns: ...
python
def prepare(self, variables): """Initialize all steps in this recipe using their parameters. Args: variables (dict): A dictionary of global variable definitions that may be used to replace or augment the parameters given to each step. Returns: ...
[ "def", "prepare", "(", "self", ",", "variables", ")", ":", "initializedsteps", "=", "[", "]", "if", "variables", "is", "None", ":", "variables", "=", "dict", "(", ")", "for", "step", ",", "params", ",", "_resources", ",", "_files", "in", "self", ".", ...
Initialize all steps in this recipe using their parameters. Args: variables (dict): A dictionary of global variable definitions that may be used to replace or augment the parameters given to each step. Returns: list of RecipeActionObject like ins...
[ "Initialize", "all", "steps", "in", "this", "recipe", "using", "their", "parameters", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L358-L376
train
iotile/coretools
iotileship/iotile/ship/recipe.py
RecipeObject._prepare_resources
def _prepare_resources(self, variables, overrides=None): """Create and optionally open all shared resources.""" if overrides is None: overrides = {} res_map = {} own_map = {} for decl in self.resources.values(): resource = overrides.get(decl.name) ...
python
def _prepare_resources(self, variables, overrides=None): """Create and optionally open all shared resources.""" if overrides is None: overrides = {} res_map = {} own_map = {} for decl in self.resources.values(): resource = overrides.get(decl.name) ...
[ "def", "_prepare_resources", "(", "self", ",", "variables", ",", "overrides", "=", "None", ")", ":", "if", "overrides", "is", "None", ":", "overrides", "=", "{", "}", "res_map", "=", "{", "}", "own_map", "=", "{", "}", "for", "decl", "in", "self", "....
Create and optionally open all shared resources.
[ "Create", "and", "optionally", "open", "all", "shared", "resources", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L378-L400
train
iotile/coretools
iotileship/iotile/ship/recipe.py
RecipeObject._cleanup_resources
def _cleanup_resources(self, initialized_resources): """Cleanup all resources that we own that are open.""" cleanup_errors = [] # Make sure we clean up all resources that we can and don't error out at the # first one. for name, res in initialized_resources.items(): ...
python
def _cleanup_resources(self, initialized_resources): """Cleanup all resources that we own that are open.""" cleanup_errors = [] # Make sure we clean up all resources that we can and don't error out at the # first one. for name, res in initialized_resources.items(): ...
[ "def", "_cleanup_resources", "(", "self", ",", "initialized_resources", ")", ":", "cleanup_errors", "=", "[", "]", "for", "name", ",", "res", "in", "initialized_resources", ".", "items", "(", ")", ":", "try", ":", "if", "res", ".", "opened", ":", "res", ...
Cleanup all resources that we own that are open.
[ "Cleanup", "all", "resources", "that", "we", "own", "that", "are", "open", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L402-L418
train
iotile/coretools
iotileship/iotile/ship/recipe.py
RecipeObject.run
def run(self, variables=None, overrides=None): """Initialize and run this recipe. By default all necessary shared resources are created and destroyed in this function unless you pass them preinitizlied in overrides, in which case they are used as is. The overrides parameter is designed...
python
def run(self, variables=None, overrides=None): """Initialize and run this recipe. By default all necessary shared resources are created and destroyed in this function unless you pass them preinitizlied in overrides, in which case they are used as is. The overrides parameter is designed...
[ "def", "run", "(", "self", ",", "variables", "=", "None", ",", "overrides", "=", "None", ")", ":", "old_dir", "=", "os", ".", "getcwd", "(", ")", "try", ":", "os", ".", "chdir", "(", "self", ".", "run_directory", ")", "initialized_steps", "=", "self"...
Initialize and run this recipe. By default all necessary shared resources are created and destroyed in this function unless you pass them preinitizlied in overrides, in which case they are used as is. The overrides parameter is designed to allow testability of iotile-ship recipes by in...
[ "Initialize", "and", "run", "this", "recipe", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L420-L463
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/yacc.py
generate
def generate(env): """Add Builders and construction variables for yacc to an Environment.""" c_file, cxx_file = SCons.Tool.createCFileBuilders(env) # C c_file.add_action('.y', YaccAction) c_file.add_emitter('.y', yEmitter) c_file.add_action('.yacc', YaccAction) c_file.add_emitter('.yacc', ...
python
def generate(env): """Add Builders and construction variables for yacc to an Environment.""" c_file, cxx_file = SCons.Tool.createCFileBuilders(env) # C c_file.add_action('.y', YaccAction) c_file.add_emitter('.y', yEmitter) c_file.add_action('.yacc', YaccAction) c_file.add_emitter('.yacc', ...
[ "def", "generate", "(", "env", ")", ":", "c_file", ",", "cxx_file", "=", "SCons", ".", "Tool", ".", "createCFileBuilders", "(", "env", ")", "c_file", ".", "add_action", "(", "'.y'", ",", "YaccAction", ")", "c_file", ".", "add_emitter", "(", "'.y'", ",", ...
Add Builders and construction variables for yacc to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "yacc", "to", "an", "Environment", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/yacc.py#L97-L123
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/ilink32.py
generate
def generate(env): """Add Builders and construction variables for Borland ilink to an Environment.""" SCons.Tool.createSharedLibBuilder(env) SCons.Tool.createProgBuilder(env) env['LINK'] = '$CC' env['LINKFLAGS'] = SCons.Util.CLVar('') env['LINKCOM'] = '$LINK -q $LINKFLAGS -e$TA...
python
def generate(env): """Add Builders and construction variables for Borland ilink to an Environment.""" SCons.Tool.createSharedLibBuilder(env) SCons.Tool.createProgBuilder(env) env['LINK'] = '$CC' env['LINKFLAGS'] = SCons.Util.CLVar('') env['LINKCOM'] = '$LINK -q $LINKFLAGS -e$TA...
[ "def", "generate", "(", "env", ")", ":", "SCons", ".", "Tool", ".", "createSharedLibBuilder", "(", "env", ")", "SCons", ".", "Tool", ".", "createProgBuilder", "(", "env", ")", "env", "[", "'LINK'", "]", "=", "'$CC'", "env", "[", "'LINKFLAGS'", "]", "="...
Add Builders and construction variables for Borland ilink to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "Borland", "ilink", "to", "an", "Environment", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/ilink32.py#L36-L48
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/MSCommon/sdk.py
SDKDefinition.find_sdk_dir
def find_sdk_dir(self): """Try to find the MS SDK from the registry. Return None if failed or the directory does not exist. """ if not SCons.Util.can_read_reg: debug('find_sdk_dir(): can not read registry') return None hkey = self.HKEY_FMT % self.hkey_da...
python
def find_sdk_dir(self): """Try to find the MS SDK from the registry. Return None if failed or the directory does not exist. """ if not SCons.Util.can_read_reg: debug('find_sdk_dir(): can not read registry') return None hkey = self.HKEY_FMT % self.hkey_da...
[ "def", "find_sdk_dir", "(", "self", ")", ":", "if", "not", "SCons", ".", "Util", ".", "can_read_reg", ":", "debug", "(", "'find_sdk_dir(): can not read registry'", ")", "return", "None", "hkey", "=", "self", ".", "HKEY_FMT", "%", "self", ".", "hkey_data", "d...
Try to find the MS SDK from the registry. Return None if failed or the directory does not exist.
[ "Try", "to", "find", "the", "MS", "SDK", "from", "the", "registry", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/MSCommon/sdk.py#L69-L98
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/MSCommon/sdk.py
SDKDefinition.get_sdk_dir
def get_sdk_dir(self): """Return the MSSSDK given the version string.""" try: return self._sdk_dir except AttributeError: sdk_dir = self.find_sdk_dir() self._sdk_dir = sdk_dir return sdk_dir
python
def get_sdk_dir(self): """Return the MSSSDK given the version string.""" try: return self._sdk_dir except AttributeError: sdk_dir = self.find_sdk_dir() self._sdk_dir = sdk_dir return sdk_dir
[ "def", "get_sdk_dir", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_sdk_dir", "except", "AttributeError", ":", "sdk_dir", "=", "self", ".", "find_sdk_dir", "(", ")", "self", ".", "_sdk_dir", "=", "sdk_dir", "return", "sdk_dir" ]
Return the MSSSDK given the version string.
[ "Return", "the", "MSSSDK", "given", "the", "version", "string", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/MSCommon/sdk.py#L100-L107
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/MSCommon/sdk.py
SDKDefinition.get_sdk_vc_script
def get_sdk_vc_script(self,host_arch, target_arch): """ Return the script to initialize the VC compiler installed by SDK """ if (host_arch == 'amd64' and target_arch == 'x86'): # No cross tools needed compiling 32 bits on 64 bit machine host_arch=target_arch arc...
python
def get_sdk_vc_script(self,host_arch, target_arch): """ Return the script to initialize the VC compiler installed by SDK """ if (host_arch == 'amd64' and target_arch == 'x86'): # No cross tools needed compiling 32 bits on 64 bit machine host_arch=target_arch arc...
[ "def", "get_sdk_vc_script", "(", "self", ",", "host_arch", ",", "target_arch", ")", ":", "if", "(", "host_arch", "==", "'amd64'", "and", "target_arch", "==", "'x86'", ")", ":", "host_arch", "=", "target_arch", "arch_string", "=", "target_arch", "if", "(", "h...
Return the script to initialize the VC compiler installed by SDK
[ "Return", "the", "script", "to", "initialize", "the", "VC", "compiler", "installed", "by", "SDK" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/MSCommon/sdk.py#L109-L126
train
iotile/coretools
iotileemulate/iotile/emulate/utilities/format_rpc.py
format_rpc
def format_rpc(data): """Format an RPC call and response. Args: data (tuple): A tuple containing the address, rpc_id, argument and response payloads and any error code. Returns: str: The formated RPC string. """ address, rpc_id, args, resp, _status = data name = r...
python
def format_rpc(data): """Format an RPC call and response. Args: data (tuple): A tuple containing the address, rpc_id, argument and response payloads and any error code. Returns: str: The formated RPC string. """ address, rpc_id, args, resp, _status = data name = r...
[ "def", "format_rpc", "(", "data", ")", ":", "address", ",", "rpc_id", ",", "args", ",", "resp", ",", "_status", "=", "data", "name", "=", "rpc_name", "(", "rpc_id", ")", "if", "isinstance", "(", "args", ",", "(", "bytes", ",", "bytearray", ")", ")", ...
Format an RPC call and response. Args: data (tuple): A tuple containing the address, rpc_id, argument and response payloads and any error code. Returns: str: The formated RPC string.
[ "Format", "an", "RPC", "call", "and", "response", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/utilities/format_rpc.py#L6-L32
train
iotile/coretools
transport_plugins/bled112/iotile_transport_bled112/server_bled112.py
BLED112Server.start
async def start(self): """Start serving access to devices over bluetooth.""" self._command_task.start() try: await self._cleanup_old_connections() except Exception: await self.stop() raise #FIXME: This is a temporary hack, get the actual dev...
python
async def start(self): """Start serving access to devices over bluetooth.""" self._command_task.start() try: await self._cleanup_old_connections() except Exception: await self.stop() raise #FIXME: This is a temporary hack, get the actual dev...
[ "async", "def", "start", "(", "self", ")", ":", "self", ".", "_command_task", ".", "start", "(", ")", "try", ":", "await", "self", ".", "_cleanup_old_connections", "(", ")", "except", "Exception", ":", "await", "self", ".", "stop", "(", ")", "raise", "...
Start serving access to devices over bluetooth.
[ "Start", "serving", "access", "to", "devices", "over", "bluetooth", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/server_bled112.py#L126-L144
train
iotile/coretools
transport_plugins/bled112/iotile_transport_bled112/server_bled112.py
BLED112Server.stop
async def stop(self): """Safely shut down this interface""" await self._command_task.future_command(['_set_mode', 0, 0]) # Disable advertising await self._cleanup_old_connections() self._command_task.stop() self._stream.stop() self._serial_port.close() await su...
python
async def stop(self): """Safely shut down this interface""" await self._command_task.future_command(['_set_mode', 0, 0]) # Disable advertising await self._cleanup_old_connections() self._command_task.stop() self._stream.stop() self._serial_port.close() await su...
[ "async", "def", "stop", "(", "self", ")", ":", "await", "self", ".", "_command_task", ".", "future_command", "(", "[", "'_set_mode'", ",", "0", ",", "0", "]", ")", "await", "self", ".", "_cleanup_old_connections", "(", ")", "self", ".", "_command_task", ...
Safely shut down this interface
[ "Safely", "shut", "down", "this", "interface" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/server_bled112.py#L146-L155
train
iotile/coretools
transport_plugins/bled112/iotile_transport_bled112/server_bled112.py
BLED112Server._call_rpc
async def _call_rpc(self, header): """Call an RPC given a header and possibly a previously sent payload Args: header (bytearray): The RPC header we should call """ length, _, cmd, feature, address = struct.unpack("<BBBBB", bytes(header)) rpc_id = (feature << 8) | cm...
python
async def _call_rpc(self, header): """Call an RPC given a header and possibly a previously sent payload Args: header (bytearray): The RPC header we should call """ length, _, cmd, feature, address = struct.unpack("<BBBBB", bytes(header)) rpc_id = (feature << 8) | cm...
[ "async", "def", "_call_rpc", "(", "self", ",", "header", ")", ":", "length", ",", "_", ",", "cmd", ",", "feature", ",", "address", "=", "struct", ".", "unpack", "(", "\"<BBBBB\"", ",", "bytes", "(", "header", ")", ")", "rpc_id", "=", "(", "feature", ...
Call an RPC given a header and possibly a previously sent payload Args: header (bytearray): The RPC header we should call
[ "Call", "an", "RPC", "given", "a", "header", "and", "possibly", "a", "previously", "sent", "payload" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/server_bled112.py#L308-L339
train
iotile/coretools
iotilesensorgraph/iotile/sg/output_formats/script.py
format_script
def format_script(sensor_graph): """Create a binary script containing this sensor graph. This function produces a repeatable script by applying a known sorting order to all constants and config variables when iterating over those dictionaries. Args: sensor_graph (SensorGraph): the sensor g...
python
def format_script(sensor_graph): """Create a binary script containing this sensor graph. This function produces a repeatable script by applying a known sorting order to all constants and config variables when iterating over those dictionaries. Args: sensor_graph (SensorGraph): the sensor g...
[ "def", "format_script", "(", "sensor_graph", ")", ":", "records", "=", "[", "]", "records", ".", "append", "(", "SetGraphOnlineRecord", "(", "False", ",", "address", "=", "8", ")", ")", "records", ".", "append", "(", "ClearDataRecord", "(", "address", "=",...
Create a binary script containing this sensor graph. This function produces a repeatable script by applying a known sorting order to all constants and config variables when iterating over those dictionaries. Args: sensor_graph (SensorGraph): the sensor graph that we want to format Returns...
[ "Create", "a", "binary", "script", "containing", "this", "sensor", "graph", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/output_formats/script.py#L12-L60
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.dump
def dump(self): """Dump the state of this SensorLog. The purpose of this method is to be able to restore the same state later. However there are links in the SensorLog for stream walkers. So the dump process saves the state of each stream walker and upon restore, it looks thro...
python
def dump(self): """Dump the state of this SensorLog. The purpose of this method is to be able to restore the same state later. However there are links in the SensorLog for stream walkers. So the dump process saves the state of each stream walker and upon restore, it looks thro...
[ "def", "dump", "(", "self", ")", ":", "walkers", "=", "{", "}", "walkers", ".", "update", "(", "{", "str", "(", "walker", ".", "selector", ")", ":", "walker", ".", "dump", "(", ")", "for", "walker", "in", "self", ".", "_queue_walkers", "}", ")", ...
Dump the state of this SensorLog. The purpose of this method is to be able to restore the same state later. However there are links in the SensorLog for stream walkers. So the dump process saves the state of each stream walker and upon restore, it looks through the current set of stre...
[ "Dump", "the", "state", "of", "this", "SensorLog", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L74-L98
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.set_rollover
def set_rollover(self, area, enabled): """Configure whether rollover is enabled for streaming or storage streams. Normally a SensorLog is used in ring-buffer mode which means that old readings are automatically overwritten as needed when new data is saved. However, you can configure it...
python
def set_rollover(self, area, enabled): """Configure whether rollover is enabled for streaming or storage streams. Normally a SensorLog is used in ring-buffer mode which means that old readings are automatically overwritten as needed when new data is saved. However, you can configure it...
[ "def", "set_rollover", "(", "self", ",", "area", ",", "enabled", ")", ":", "if", "area", "==", "u'streaming'", ":", "self", ".", "_rollover_streaming", "=", "enabled", "elif", "area", "==", "u'storage'", ":", "self", ".", "_rollover_storage", "=", "enabled",...
Configure whether rollover is enabled for streaming or storage streams. Normally a SensorLog is used in ring-buffer mode which means that old readings are automatically overwritten as needed when new data is saved. However, you can configure it into fill-stop mode by using: set_rollove...
[ "Configure", "whether", "rollover", "is", "enabled", "for", "streaming", "or", "storage", "streams", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L146-L168
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.watch
def watch(self, selector, callback): """Call a function whenever a stream changes. Args: selector (DataStreamSelector): The selector to watch. If this is None, it is treated as a wildcard selector that matches every stream. callback (callable): Th...
python
def watch(self, selector, callback): """Call a function whenever a stream changes. Args: selector (DataStreamSelector): The selector to watch. If this is None, it is treated as a wildcard selector that matches every stream. callback (callable): Th...
[ "def", "watch", "(", "self", ",", "selector", ",", "callback", ")", ":", "if", "selector", "not", "in", "self", ".", "_monitors", ":", "self", ".", "_monitors", "[", "selector", "]", "=", "set", "(", ")", "self", ".", "_monitors", "[", "selector", "]...
Call a function whenever a stream changes. Args: selector (DataStreamSelector): The selector to watch. If this is None, it is treated as a wildcard selector that matches every stream. callback (callable): The function to call when a new re...
[ "Call", "a", "function", "whenever", "a", "stream", "changes", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L190-L205
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.create_walker
def create_walker(self, selector, skip_all=True): """Create a stream walker based on the given selector. This function returns a StreamWalker subclass that will remain up to date and allow iterating over and popping readings from the stream(s) specified by the selector. When th...
python
def create_walker(self, selector, skip_all=True): """Create a stream walker based on the given selector. This function returns a StreamWalker subclass that will remain up to date and allow iterating over and popping readings from the stream(s) specified by the selector. When th...
[ "def", "create_walker", "(", "self", ",", "selector", ",", "skip_all", "=", "True", ")", ":", "if", "selector", ".", "buffered", ":", "walker", "=", "BufferedStreamWalker", "(", "selector", ",", "self", ".", "_engine", ",", "skip_all", "=", "skip_all", ")"...
Create a stream walker based on the given selector. This function returns a StreamWalker subclass that will remain up to date and allow iterating over and popping readings from the stream(s) specified by the selector. When the stream walker is done, it should be passed to destr...
[ "Create", "a", "stream", "walker", "based", "on", "the", "given", "selector", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L207-L242
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.destroy_walker
def destroy_walker(self, walker): """Destroy a previously created stream walker. Args: walker (StreamWalker): The walker to remove from internal updating lists. """ if walker.buffered: self._queue_walkers.remove(walker) else: ...
python
def destroy_walker(self, walker): """Destroy a previously created stream walker. Args: walker (StreamWalker): The walker to remove from internal updating lists. """ if walker.buffered: self._queue_walkers.remove(walker) else: ...
[ "def", "destroy_walker", "(", "self", ",", "walker", ")", ":", "if", "walker", ".", "buffered", ":", "self", ".", "_queue_walkers", ".", "remove", "(", "walker", ")", "else", ":", "self", ".", "_virtual_walkers", ".", "remove", "(", "walker", ")" ]
Destroy a previously created stream walker. Args: walker (StreamWalker): The walker to remove from internal updating lists.
[ "Destroy", "a", "previously", "created", "stream", "walker", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L244-L255
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.restore_walker
def restore_walker(self, dumped_state): """Restore a stream walker that was previously serialized. Since stream walkers need to be tracked in an internal list for notification purposes, we need to be careful with how we restore them to make sure they remain part of the right list. ...
python
def restore_walker(self, dumped_state): """Restore a stream walker that was previously serialized. Since stream walkers need to be tracked in an internal list for notification purposes, we need to be careful with how we restore them to make sure they remain part of the right list. ...
[ "def", "restore_walker", "(", "self", ",", "dumped_state", ")", ":", "selector_string", "=", "dumped_state", ".", "get", "(", "u'selector'", ")", "if", "selector_string", "is", "None", ":", "raise", "ArgumentError", "(", "\"Invalid stream walker state in restore_walke...
Restore a stream walker that was previously serialized. Since stream walkers need to be tracked in an internal list for notification purposes, we need to be careful with how we restore them to make sure they remain part of the right list. Args: dumped_state (dict): The dump...
[ "Restore", "a", "stream", "walker", "that", "was", "previously", "serialized", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L257-L280
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.clear
def clear(self): """Clear all data from this sensor_log. All readings in all walkers are skipped and buffered data is destroyed. """ for walker in self._virtual_walkers: walker.skip_all() self._engine.clear() for walker in self._queue_walkers: ...
python
def clear(self): """Clear all data from this sensor_log. All readings in all walkers are skipped and buffered data is destroyed. """ for walker in self._virtual_walkers: walker.skip_all() self._engine.clear() for walker in self._queue_walkers: ...
[ "def", "clear", "(", "self", ")", ":", "for", "walker", "in", "self", ".", "_virtual_walkers", ":", "walker", ".", "skip_all", "(", ")", "self", ".", "_engine", ".", "clear", "(", ")", "for", "walker", "in", "self", ".", "_queue_walkers", ":", "walker"...
Clear all data from this sensor_log. All readings in all walkers are skipped and buffered data is destroyed.
[ "Clear", "all", "data", "from", "this", "sensor_log", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L297-L312
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.push
def push(self, stream, reading): """Push a reading into a stream, updating any associated stream walkers. Args: stream (DataStream): the stream to push the reading into reading (IOTileReading): the reading to push """ # Make sure the stream is correct re...
python
def push(self, stream, reading): """Push a reading into a stream, updating any associated stream walkers. Args: stream (DataStream): the stream to push the reading into reading (IOTileReading): the reading to push """ # Make sure the stream is correct re...
[ "def", "push", "(", "self", ",", "stream", ",", "reading", ")", ":", "reading", "=", "copy", ".", "copy", "(", "reading", ")", "reading", ".", "stream", "=", "stream", ".", "encode", "(", ")", "if", "stream", ".", "buffered", ":", "output_buffer", "=...
Push a reading into a stream, updating any associated stream walkers. Args: stream (DataStream): the stream to push the reading into reading (IOTileReading): the reading to push
[ "Push", "a", "reading", "into", "a", "stream", "updating", "any", "associated", "stream", "walkers", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L314-L359
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog._erase_buffer
def _erase_buffer(self, output_buffer): """Erase readings in the specified buffer to make space.""" erase_size = self._model.get(u'buffer_erase_size') buffer_type = u'storage' if output_buffer: buffer_type = u'streaming' old_readings = self._engine.popn(buffer_type...
python
def _erase_buffer(self, output_buffer): """Erase readings in the specified buffer to make space.""" erase_size = self._model.get(u'buffer_erase_size') buffer_type = u'storage' if output_buffer: buffer_type = u'streaming' old_readings = self._engine.popn(buffer_type...
[ "def", "_erase_buffer", "(", "self", ",", "output_buffer", ")", ":", "erase_size", "=", "self", ".", "_model", ".", "get", "(", "u'buffer_erase_size'", ")", "buffer_type", "=", "u'storage'", "if", "output_buffer", ":", "buffer_type", "=", "u'streaming'", "old_re...
Erase readings in the specified buffer to make space.
[ "Erase", "readings", "in", "the", "specified", "buffer", "to", "make", "space", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L361-L380
train
iotile/coretools
iotilesensorgraph/iotile/sg/sensor_log.py
SensorLog.inspect_last
def inspect_last(self, stream, only_allocated=False): """Return the last value pushed into a stream. This function works even if the stream is virtual and no virtual walker has been created for it. It is primarily useful to aid in debugging sensor graphs. Args: str...
python
def inspect_last(self, stream, only_allocated=False): """Return the last value pushed into a stream. This function works even if the stream is virtual and no virtual walker has been created for it. It is primarily useful to aid in debugging sensor graphs. Args: str...
[ "def", "inspect_last", "(", "self", ",", "stream", ",", "only_allocated", "=", "False", ")", ":", "if", "only_allocated", ":", "found", "=", "False", "for", "walker", "in", "self", ".", "_virtual_walkers", ":", "if", "walker", ".", "matches", "(", "stream"...
Return the last value pushed into a stream. This function works even if the stream is virtual and no virtual walker has been created for it. It is primarily useful to aid in debugging sensor graphs. Args: stream (DataStream): The stream to inspect. only_allocat...
[ "Return", "the", "last", "value", "pushed", "into", "a", "stream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L382-L419
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/exitfuncs.py
_run_exitfuncs
def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out. """ while _exithandlers: func, targs, kargs = _exithandlers.pop() func(*targs, **kargs)
python
def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out. """ while _exithandlers: func, targs, kargs = _exithandlers.pop() func(*targs, **kargs)
[ "def", "_run_exitfuncs", "(", ")", ":", "while", "_exithandlers", ":", "func", ",", "targs", ",", "kargs", "=", "_exithandlers", ".", "pop", "(", ")", "func", "(", "*", "targs", ",", "**", "kargs", ")" ]
run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out.
[ "run", "any", "registered", "exit", "functions" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/exitfuncs.py#L36-L45
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py
_windowsLdmodTargets
def _windowsLdmodTargets(target, source, env, for_signature): """Get targets for loadable modules.""" return _dllTargets(target, source, env, for_signature, 'LDMODULE')
python
def _windowsLdmodTargets(target, source, env, for_signature): """Get targets for loadable modules.""" return _dllTargets(target, source, env, for_signature, 'LDMODULE')
[ "def", "_windowsLdmodTargets", "(", "target", ",", "source", ",", "env", ",", "for_signature", ")", ":", "return", "_dllTargets", "(", "target", ",", "source", ",", "env", ",", "for_signature", ",", "'LDMODULE'", ")" ]
Get targets for loadable modules.
[ "Get", "targets", "for", "loadable", "modules", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py#L87-L89
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py
_windowsLdmodSources
def _windowsLdmodSources(target, source, env, for_signature): """Get sources for loadable modules.""" return _dllSources(target, source, env, for_signature, 'LDMODULE')
python
def _windowsLdmodSources(target, source, env, for_signature): """Get sources for loadable modules.""" return _dllSources(target, source, env, for_signature, 'LDMODULE')
[ "def", "_windowsLdmodSources", "(", "target", ",", "source", ",", "env", ",", "for_signature", ")", ":", "return", "_dllSources", "(", "target", ",", "source", ",", "env", ",", "for_signature", ",", "'LDMODULE'", ")" ]
Get sources for loadable modules.
[ "Get", "sources", "for", "loadable", "modules", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py#L91-L93
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py
_dllEmitter
def _dllEmitter(target, source, env, paramtp): """Common implementation of dll emitter.""" SCons.Tool.msvc.validate_vars(env) extratargets = [] extrasources = [] dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) no_import_lib = env.get('no_import_lib', 0) if not dll: ...
python
def _dllEmitter(target, source, env, paramtp): """Common implementation of dll emitter.""" SCons.Tool.msvc.validate_vars(env) extratargets = [] extrasources = [] dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) no_import_lib = env.get('no_import_lib', 0) if not dll: ...
[ "def", "_dllEmitter", "(", "target", ",", "source", ",", "env", ",", "paramtp", ")", ":", "SCons", ".", "Tool", ".", "msvc", ".", "validate_vars", "(", "env", ")", "extratargets", "=", "[", "]", "extrasources", "=", "[", "]", "dll", "=", "env", ".", ...
Common implementation of dll emitter.
[ "Common", "implementation", "of", "dll", "emitter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py#L95-L153
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py
embedManifestDllCheck
def embedManifestDllCheck(target, source, env): """Function run by embedManifestDllCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestDllAction if so.""" if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + ...
python
def embedManifestDllCheck(target, source, env): """Function run by embedManifestDllCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestDllAction if so.""" if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + ...
[ "def", "embedManifestDllCheck", "(", "target", ",", "source", ",", "env", ")", ":", "if", "env", ".", "get", "(", "'WINDOWS_EMBED_MANIFEST'", ",", "0", ")", ":", "manifestSrc", "=", "target", "[", "0", "]", ".", "get_abspath", "(", ")", "+", "'.manifest'...
Function run by embedManifestDllCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestDllAction if so.
[ "Function", "run", "by", "embedManifestDllCheckAction", "to", "check", "for", "existence", "of", "manifest", "and", "other", "conditions", "and", "embed", "the", "manifest", "by", "calling", "embedManifestDllAction", "if", "so", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py#L215-L227
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py
embedManifestExeCheck
def embedManifestExeCheck(target, source, env): """Function run by embedManifestExeCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestExeAction if so.""" if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + ...
python
def embedManifestExeCheck(target, source, env): """Function run by embedManifestExeCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestExeAction if so.""" if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + ...
[ "def", "embedManifestExeCheck", "(", "target", ",", "source", ",", "env", ")", ":", "if", "env", ".", "get", "(", "'WINDOWS_EMBED_MANIFEST'", ",", "0", ")", ":", "manifestSrc", "=", "target", "[", "0", "]", ".", "get_abspath", "(", ")", "+", "'.manifest'...
Function run by embedManifestExeCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestExeAction if so.
[ "Function", "run", "by", "embedManifestExeCheckAction", "to", "check", "for", "existence", "of", "manifest", "and", "other", "conditions", "and", "embed", "the", "manifest", "by", "calling", "embedManifestExeAction", "if", "so", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mslink.py#L229-L241
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/dvips.py
generate
def generate(env): """Add Builders and construction variables for dvips to an Environment.""" global PSAction if PSAction is None: PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR') global DVIPSAction if DVIPSAction is None: DVIPSAction = SCons.Action.Action(DviPsFunction, strfun...
python
def generate(env): """Add Builders and construction variables for dvips to an Environment.""" global PSAction if PSAction is None: PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR') global DVIPSAction if DVIPSAction is None: DVIPSAction = SCons.Action.Action(DviPsFunction, strfun...
[ "def", "generate", "(", "env", ")", ":", "global", "PSAction", "if", "PSAction", "is", "None", ":", "PSAction", "=", "SCons", ".", "Action", ".", "Action", "(", "'$PSCOM'", ",", "'$PSCOMSTR'", ")", "global", "DVIPSAction", "if", "DVIPSAction", "is", "None"...
Add Builders and construction variables for dvips to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "dvips", "to", "an", "Environment", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/dvips.py#L58-L85
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/arm.py
build_library
def build_library(tile, libname, chip): """Build a static ARM cortex library""" dirs = chip.build_dirs() output_name = '%s_%s.a' % (libname, chip.arch_name()) # Support both firmware/src and just src locations for source code if os.path.exists('firmware'): VariantDir(dirs['build'], os.pat...
python
def build_library(tile, libname, chip): """Build a static ARM cortex library""" dirs = chip.build_dirs() output_name = '%s_%s.a' % (libname, chip.arch_name()) # Support both firmware/src and just src locations for source code if os.path.exists('firmware'): VariantDir(dirs['build'], os.pat...
[ "def", "build_library", "(", "tile", ",", "libname", ",", "chip", ")", ":", "dirs", "=", "chip", ".", "build_dirs", "(", ")", "output_name", "=", "'%s_%s.a'", "%", "(", "libname", ",", "chip", ".", "arch_name", "(", ")", ")", "if", "os", ".", "path",...
Build a static ARM cortex library
[ "Build", "a", "static", "ARM", "cortex", "library" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L129-L165
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/arm.py
setup_environment
def setup_environment(chip, args_file=None): """Setup the SCons environment for compiling arm cortex code. This will return an env that has all of the correct settings and create a command line arguments file for GCC that contains all of the required flags. The use of a command line argument file passe...
python
def setup_environment(chip, args_file=None): """Setup the SCons environment for compiling arm cortex code. This will return an env that has all of the correct settings and create a command line arguments file for GCC that contains all of the required flags. The use of a command line argument file passe...
[ "def", "setup_environment", "(", "chip", ",", "args_file", "=", "None", ")", ":", "config", "=", "ConfigManager", "(", ")", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "env", "=", "Environment", "(", "tools", "=", "[", "'mingw'", ...
Setup the SCons environment for compiling arm cortex code. This will return an env that has all of the correct settings and create a command line arguments file for GCC that contains all of the required flags. The use of a command line argument file passed with @./file_path is important since there can...
[ "Setup", "the", "SCons", "environment", "for", "compiling", "arm", "cortex", "code", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L168-L234
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/arm.py
tb_h_file_creation
def tb_h_file_creation(target, source, env): """Compile tilebus file into only .h files corresponding to config variables for inclusion in a library""" files = [str(x) for x in source] try: desc = TBDescriptor(files) except pyparsing.ParseException as e: raise BuildError("Could not par...
python
def tb_h_file_creation(target, source, env): """Compile tilebus file into only .h files corresponding to config variables for inclusion in a library""" files = [str(x) for x in source] try: desc = TBDescriptor(files) except pyparsing.ParseException as e: raise BuildError("Could not par...
[ "def", "tb_h_file_creation", "(", "target", ",", "source", ",", "env", ")", ":", "files", "=", "[", "str", "(", "x", ")", "for", "x", "in", "source", "]", "try", ":", "desc", "=", "TBDescriptor", "(", "files", ")", "except", "pyparsing", ".", "ParseE...
Compile tilebus file into only .h files corresponding to config variables for inclusion in a library
[ "Compile", "tilebus", "file", "into", "only", ".", "h", "files", "corresponding", "to", "config", "variables", "for", "inclusion", "in", "a", "library" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L316-L328
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/arm.py
checksum_creation_action
def checksum_creation_action(target, source, env): """Create a linker command file for patching an application checksum into a firmware image""" # Important Notes: # There are apparently many ways to calculate a CRC-32 checksum, we use the following options # Initial seed value prepended to the input: ...
python
def checksum_creation_action(target, source, env): """Create a linker command file for patching an application checksum into a firmware image""" # Important Notes: # There are apparently many ways to calculate a CRC-32 checksum, we use the following options # Initial seed value prepended to the input: ...
[ "def", "checksum_creation_action", "(", "target", ",", "source", ",", "env", ")", ":", "import", "crcmod", "crc32_func", "=", "crcmod", ".", "mkCrcFun", "(", "0x104C11DB7", ",", "initCrc", "=", "0xFFFFFFFF", ",", "rev", "=", "False", ",", "xorOut", "=", "0...
Create a linker command file for patching an application checksum into a firmware image
[ "Create", "a", "linker", "command", "file", "for", "patching", "an", "application", "checksum", "into", "a", "firmware", "image" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L331-L367
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/arm.py
create_arg_file
def create_arg_file(target, source, env): """Create an argument file containing -I and -D arguments to gcc. This file will be passed to gcc using @<path>. """ output_name = str(target[0]) with open(output_name, "w") as outfile: for define in env.get('CPPDEFINES', []): outfile....
python
def create_arg_file(target, source, env): """Create an argument file containing -I and -D arguments to gcc. This file will be passed to gcc using @<path>. """ output_name = str(target[0]) with open(output_name, "w") as outfile: for define in env.get('CPPDEFINES', []): outfile....
[ "def", "create_arg_file", "(", "target", ",", "source", ",", "env", ")", ":", "output_name", "=", "str", "(", "target", "[", "0", "]", ")", "with", "open", "(", "output_name", ",", "\"w\"", ")", "as", "outfile", ":", "for", "define", "in", "env", "."...
Create an argument file containing -I and -D arguments to gcc. This file will be passed to gcc using @<path>.
[ "Create", "an", "argument", "file", "containing", "-", "I", "and", "-", "D", "arguments", "to", "gcc", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L370-L391
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/arm.py
merge_hex_executables
def merge_hex_executables(target, source, env): """Combine all hex files into a singular executable file.""" output_name = str(target[0]) hex_final = IntelHex() for image in source: file = str(image) root, ext = os.path.splitext(file) file_format = ext[1:] if file_format...
python
def merge_hex_executables(target, source, env): """Combine all hex files into a singular executable file.""" output_name = str(target[0]) hex_final = IntelHex() for image in source: file = str(image) root, ext = os.path.splitext(file) file_format = ext[1:] if file_format...
[ "def", "merge_hex_executables", "(", "target", ",", "source", ",", "env", ")", ":", "output_name", "=", "str", "(", "target", "[", "0", "]", ")", "hex_final", "=", "IntelHex", "(", ")", "for", "image", "in", "source", ":", "file", "=", "str", "(", "i...
Combine all hex files into a singular executable file.
[ "Combine", "all", "hex", "files", "into", "a", "singular", "executable", "file", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L394-L413
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/arm.py
ensure_image_is_hex
def ensure_image_is_hex(input_path): """Return a path to a hex version of a firmware image. If the input file is already in hex format then input_path is returned and nothing is done. If it is not in hex format then an SCons action is added to convert it to hex and the target output file path is r...
python
def ensure_image_is_hex(input_path): """Return a path to a hex version of a firmware image. If the input file is already in hex format then input_path is returned and nothing is done. If it is not in hex format then an SCons action is added to convert it to hex and the target output file path is r...
[ "def", "ensure_image_is_hex", "(", "input_path", ")", ":", "family", "=", "utilities", ".", "get_family", "(", "'module_settings.json'", ")", "target", "=", "family", ".", "platform_independent_target", "(", ")", "build_dir", "=", "target", ".", "build_dirs", "(",...
Return a path to a hex version of a firmware image. If the input file is already in hex format then input_path is returned and nothing is done. If it is not in hex format then an SCons action is added to convert it to hex and the target output file path is returned. A cache is kept so that each f...
[ "Return", "a", "path", "to", "a", "hex", "version", "of", "a", "firmware", "image", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L419-L469
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_device.py
EmulatedDevice._dispatch_rpc
def _dispatch_rpc(self, address, rpc_id, arg_payload): """Background work queue handler to dispatch RPCs.""" if self.emulator.is_tile_busy(address): self._track_change('device.rpc_busy_response', (address, rpc_id, arg_payload, None, None), formatter=format_rpc) raise BusyRPCResp...
python
def _dispatch_rpc(self, address, rpc_id, arg_payload): """Background work queue handler to dispatch RPCs.""" if self.emulator.is_tile_busy(address): self._track_change('device.rpc_busy_response', (address, rpc_id, arg_payload, None, None), formatter=format_rpc) raise BusyRPCResp...
[ "def", "_dispatch_rpc", "(", "self", ",", "address", ",", "rpc_id", ",", "arg_payload", ")", ":", "if", "self", ".", "emulator", ".", "is_tile_busy", "(", "address", ")", ":", "self", ".", "_track_change", "(", "'device.rpc_busy_response'", ",", "(", "addres...
Background work queue handler to dispatch RPCs.
[ "Background", "work", "queue", "handler", "to", "dispatch", "RPCs", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_device.py#L46-L64
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_device.py
EmulatedDevice.rpc
def rpc(self, address, rpc_id, *args, **kwargs): """Immediately dispatch an RPC inside this EmulatedDevice. This function is meant to be used for testing purposes as well as by tiles inside a complex EmulatedDevice subclass that need to communicate with each other. It should only be ca...
python
def rpc(self, address, rpc_id, *args, **kwargs): """Immediately dispatch an RPC inside this EmulatedDevice. This function is meant to be used for testing purposes as well as by tiles inside a complex EmulatedDevice subclass that need to communicate with each other. It should only be ca...
[ "def", "rpc", "(", "self", ",", "address", ",", "rpc_id", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "isinstance", "(", "rpc_id", ",", "RPCDeclaration", ")", ":", "arg_format", "=", "rpc_id", ".", "arg_format", "resp_format", "=", "rpc_id", ...
Immediately dispatch an RPC inside this EmulatedDevice. This function is meant to be used for testing purposes as well as by tiles inside a complex EmulatedDevice subclass that need to communicate with each other. It should only be called from the main virtual device thread where start...
[ "Immediately", "dispatch", "an", "RPC", "inside", "this", "EmulatedDevice", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_device.py#L133-L175
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_device.py
EmulatedDevice.trace_sync
def trace_sync(self, data, timeout=5.0): """Send tracing data and wait for it to finish. This awaitable coroutine wraps VirtualIOTileDevice.trace() and turns the callback into an awaitable object. The appropriate usage of this method is by calling it inside the event loop as: ...
python
def trace_sync(self, data, timeout=5.0): """Send tracing data and wait for it to finish. This awaitable coroutine wraps VirtualIOTileDevice.trace() and turns the callback into an awaitable object. The appropriate usage of this method is by calling it inside the event loop as: ...
[ "def", "trace_sync", "(", "self", ",", "data", ",", "timeout", "=", "5.0", ")", ":", "done", "=", "AwaitableResponse", "(", ")", "self", ".", "trace", "(", "data", ",", "callback", "=", "done", ".", "set_result", ")", "return", "done", ".", "wait", "...
Send tracing data and wait for it to finish. This awaitable coroutine wraps VirtualIOTileDevice.trace() and turns the callback into an awaitable object. The appropriate usage of this method is by calling it inside the event loop as: await device.trace_sync(data) Args: ...
[ "Send", "tracing", "data", "and", "wait", "for", "it", "to", "finish", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_device.py#L194-L221
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_device.py
EmulatedDevice.stream_sync
def stream_sync(self, report, timeout=120.0): """Send a report and wait for it to finish. This awaitable coroutine wraps VirtualIOTileDevice.stream() and turns the callback into an awaitable object. The appropriate usage of this method is by calling it inside the event loop as: ...
python
def stream_sync(self, report, timeout=120.0): """Send a report and wait for it to finish. This awaitable coroutine wraps VirtualIOTileDevice.stream() and turns the callback into an awaitable object. The appropriate usage of this method is by calling it inside the event loop as: ...
[ "def", "stream_sync", "(", "self", ",", "report", ",", "timeout", "=", "120.0", ")", ":", "done", "=", "AwaitableResponse", "(", ")", "self", ".", "stream", "(", "report", ",", "callback", "=", "done", ".", "set_result", ")", "return", "done", ".", "wa...
Send a report and wait for it to finish. This awaitable coroutine wraps VirtualIOTileDevice.stream() and turns the callback into an awaitable object. The appropriate usage of this method is by calling it inside the event loop as: await device.stream_sync(data) Args: ...
[ "Send", "a", "report", "and", "wait", "for", "it", "to", "finish", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_device.py#L223-L250
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_device.py
EmulatedDevice.synchronize_task
def synchronize_task(self, func, *args, **kwargs): """Run callable in the rpc thread and wait for it to finish. The callable ``func`` will be passed into the EmulationLoop and run there. This method will block until ``func`` is finished and return/raise whatever that callable returns/r...
python
def synchronize_task(self, func, *args, **kwargs): """Run callable in the rpc thread and wait for it to finish. The callable ``func`` will be passed into the EmulationLoop and run there. This method will block until ``func`` is finished and return/raise whatever that callable returns/r...
[ "def", "synchronize_task", "(", "self", ",", "func", ",", "*", "args", ",", "**", "kwargs", ")", ":", "async", "def", "_runner", "(", ")", ":", "return", "func", "(", "*", "args", ",", "**", "kwargs", ")", "return", "self", ".", "emulator", ".", "r...
Run callable in the rpc thread and wait for it to finish. The callable ``func`` will be passed into the EmulationLoop and run there. This method will block until ``func`` is finished and return/raise whatever that callable returns/raises. This method is mainly useful for performing an...
[ "Run", "callable", "in", "the", "rpc", "thread", "and", "wait", "for", "it", "to", "finish", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_device.py#L252-L279
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_device.py
EmulatedDevice.load_metascenario
def load_metascenario(self, scenario_list): """Load one or more scenarios from a list. Each entry in scenario_list should be a dict containing at least a name key and an optional tile key and args key. If tile is present and its value is not None, the scenario specified will be loaded ...
python
def load_metascenario(self, scenario_list): """Load one or more scenarios from a list. Each entry in scenario_list should be a dict containing at least a name key and an optional tile key and args key. If tile is present and its value is not None, the scenario specified will be loaded ...
[ "def", "load_metascenario", "(", "self", ",", "scenario_list", ")", ":", "for", "scenario", "in", "scenario_list", ":", "name", "=", "scenario", ".", "get", "(", "'name'", ")", "if", "name", "is", "None", ":", "raise", "DataError", "(", "\"Scenario in scenar...
Load one or more scenarios from a list. Each entry in scenario_list should be a dict containing at least a name key and an optional tile key and args key. If tile is present and its value is not None, the scenario specified will be loaded into the given tile only. Otherwise it will be...
[ "Load", "one", "or", "more", "scenarios", "from", "a", "list", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_device.py#L320-L352
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStream.associated_stream
def associated_stream(self): """Return the corresponding output or storage stream for an important system input. Certain system inputs are designed as important and automatically copied to output streams without requiring any manual interaction. This method returns the corresponding st...
python
def associated_stream(self): """Return the corresponding output or storage stream for an important system input. Certain system inputs are designed as important and automatically copied to output streams without requiring any manual interaction. This method returns the corresponding st...
[ "def", "associated_stream", "(", "self", ")", ":", "if", "not", "self", ".", "important", ":", "raise", "InternalError", "(", "\"You may only call autocopied_stream on when DataStream.important is True\"", ",", "stream", "=", "self", ")", "if", "self", ".", "stream_id...
Return the corresponding output or storage stream for an important system input. Certain system inputs are designed as important and automatically copied to output streams without requiring any manual interaction. This method returns the corresponding stream for an important system inp...
[ "Return", "the", "corresponding", "output", "or", "storage", "stream", "for", "an", "important", "system", "input", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L80-L105
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStream.FromString
def FromString(cls, string_rep): """Create a DataStream from a string representation. The format for stream designators when encoded as strings is: [system] (buffered|unbuffered|constant|input|count|output) <integer> Args: string_rep (str): The string representation to turn...
python
def FromString(cls, string_rep): """Create a DataStream from a string representation. The format for stream designators when encoded as strings is: [system] (buffered|unbuffered|constant|input|count|output) <integer> Args: string_rep (str): The string representation to turn...
[ "def", "FromString", "(", "cls", ",", "string_rep", ")", ":", "rep", "=", "str", "(", "string_rep", ")", "parts", "=", "rep", ".", "split", "(", ")", "if", "len", "(", "parts", ")", ">", "3", ":", "raise", "ArgumentError", "(", "\"Too many whitespace s...
Create a DataStream from a string representation. The format for stream designators when encoded as strings is: [system] (buffered|unbuffered|constant|input|count|output) <integer> Args: string_rep (str): The string representation to turn into a DataStream
[ "Create", "a", "DataStream", "from", "a", "string", "representation", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L108-L149
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStream.FromEncoded
def FromEncoded(self, encoded): """Create a DataStream from an encoded 16-bit unsigned integer. Returns: DataStream: The decoded DataStream object """ stream_type = (encoded >> 12) & 0b1111 stream_system = bool(encoded & (1 << 11)) stream_id = (encoded & ((1...
python
def FromEncoded(self, encoded): """Create a DataStream from an encoded 16-bit unsigned integer. Returns: DataStream: The decoded DataStream object """ stream_type = (encoded >> 12) & 0b1111 stream_system = bool(encoded & (1 << 11)) stream_id = (encoded & ((1...
[ "def", "FromEncoded", "(", "self", ",", "encoded", ")", ":", "stream_type", "=", "(", "encoded", ">>", "12", ")", "&", "0b1111", "stream_system", "=", "bool", "(", "encoded", "&", "(", "1", "<<", "11", ")", ")", "stream_id", "=", "(", "encoded", "&",...
Create a DataStream from an encoded 16-bit unsigned integer. Returns: DataStream: The decoded DataStream object
[ "Create", "a", "DataStream", "from", "an", "encoded", "16", "-", "bit", "unsigned", "integer", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L152-L163
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStreamSelector.as_stream
def as_stream(self): """Convert this selector to a DataStream. This function will only work if this is a singular selector that matches exactly one DataStream. """ if not self.singular: raise ArgumentError("Attempted to convert a non-singular selector to a data stre...
python
def as_stream(self): """Convert this selector to a DataStream. This function will only work if this is a singular selector that matches exactly one DataStream. """ if not self.singular: raise ArgumentError("Attempted to convert a non-singular selector to a data stre...
[ "def", "as_stream", "(", "self", ")", ":", "if", "not", "self", ".", "singular", ":", "raise", "ArgumentError", "(", "\"Attempted to convert a non-singular selector to a data stream, it matches multiple\"", ",", "selector", "=", "self", ")", "return", "DataStream", "(",...
Convert this selector to a DataStream. This function will only work if this is a singular selector that matches exactly one DataStream.
[ "Convert", "this", "selector", "to", "a", "DataStream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L270-L280
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStreamSelector.FromStream
def FromStream(cls, stream): """Create a DataStreamSelector from a DataStream. Args: stream (DataStream): The data stream that we want to convert. """ if stream.system: specifier = DataStreamSelector.MatchSystemOnly else: specifier = DataStre...
python
def FromStream(cls, stream): """Create a DataStreamSelector from a DataStream. Args: stream (DataStream): The data stream that we want to convert. """ if stream.system: specifier = DataStreamSelector.MatchSystemOnly else: specifier = DataStre...
[ "def", "FromStream", "(", "cls", ",", "stream", ")", ":", "if", "stream", ".", "system", ":", "specifier", "=", "DataStreamSelector", ".", "MatchSystemOnly", "else", ":", "specifier", "=", "DataStreamSelector", ".", "MatchUserOnly", "return", "DataStreamSelector",...
Create a DataStreamSelector from a DataStream. Args: stream (DataStream): The data stream that we want to convert.
[ "Create", "a", "DataStreamSelector", "from", "a", "DataStream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L283-L295
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStreamSelector.FromEncoded
def FromEncoded(cls, encoded): """Create a DataStreamSelector from an encoded 16-bit value. The binary value must be equivalent to what is produced by a call to self.encode() and will turn that value back into a a DataStreamSelector. Note that the following operation is a no-op...
python
def FromEncoded(cls, encoded): """Create a DataStreamSelector from an encoded 16-bit value. The binary value must be equivalent to what is produced by a call to self.encode() and will turn that value back into a a DataStreamSelector. Note that the following operation is a no-op...
[ "def", "FromEncoded", "(", "cls", ",", "encoded", ")", ":", "match_spec", "=", "encoded", "&", "(", "(", "1", "<<", "11", ")", "|", "(", "1", "<<", "15", ")", ")", "match_type", "=", "(", "encoded", "&", "(", "0b111", "<<", "12", ")", ")", ">>"...
Create a DataStreamSelector from an encoded 16-bit value. The binary value must be equivalent to what is produced by a call to self.encode() and will turn that value back into a a DataStreamSelector. Note that the following operation is a no-op: DataStreamSelector.FromEncode(v...
[ "Create", "a", "DataStreamSelector", "from", "an", "encoded", "16", "-", "bit", "value", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L298-L330
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStreamSelector.FromString
def FromString(cls, string_rep): """Create a DataStreamSelector from a string. The format of the string should either be: all <type> OR <type> <id> Where type is [system] <stream type>, with <stream type> defined as in DataStream Args: rep ...
python
def FromString(cls, string_rep): """Create a DataStreamSelector from a string. The format of the string should either be: all <type> OR <type> <id> Where type is [system] <stream type>, with <stream type> defined as in DataStream Args: rep ...
[ "def", "FromString", "(", "cls", ",", "string_rep", ")", ":", "rep", "=", "str", "(", "string_rep", ")", "rep", "=", "rep", ".", "replace", "(", "u'node'", ",", "''", ")", "rep", "=", "rep", ".", "replace", "(", "u'nodes'", ",", "''", ")", "if", ...
Create a DataStreamSelector from a string. The format of the string should either be: all <type> OR <type> <id> Where type is [system] <stream type>, with <stream type> defined as in DataStream Args: rep (str): The string representation to convert ...
[ "Create", "a", "DataStreamSelector", "from", "a", "string", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L333-L386
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStreamSelector.matches
def matches(self, stream): """Check if this selector matches the given stream Args: stream (DataStream): The stream to check Returns: bool: True if this selector matches the stream """ if self.match_type != stream.stream_type: return False ...
python
def matches(self, stream): """Check if this selector matches the given stream Args: stream (DataStream): The stream to check Returns: bool: True if this selector matches the stream """ if self.match_type != stream.stream_type: return False ...
[ "def", "matches", "(", "self", ",", "stream", ")", ":", "if", "self", ".", "match_type", "!=", "stream", ".", "stream_type", ":", "return", "False", "if", "self", ".", "match_id", "is", "not", "None", ":", "return", "self", ".", "match_id", "==", "stre...
Check if this selector matches the given stream Args: stream (DataStream): The stream to check Returns: bool: True if this selector matches the stream
[ "Check", "if", "this", "selector", "matches", "the", "given", "stream" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L407-L432
train
iotile/coretools
iotilesensorgraph/iotile/sg/stream.py
DataStreamSelector.encode
def encode(self): """Encode this stream as a packed 16-bit unsigned integer. Returns: int: The packed encoded stream """ match_id = self.match_id if match_id is None: match_id = (1 << 11) - 1 return (self.match_type << 12) | DataStreamSelector.S...
python
def encode(self): """Encode this stream as a packed 16-bit unsigned integer. Returns: int: The packed encoded stream """ match_id = self.match_id if match_id is None: match_id = (1 << 11) - 1 return (self.match_type << 12) | DataStreamSelector.S...
[ "def", "encode", "(", "self", ")", ":", "match_id", "=", "self", ".", "match_id", "if", "match_id", "is", "None", ":", "match_id", "=", "(", "1", "<<", "11", ")", "-", "1", "return", "(", "self", ".", "match_type", "<<", "12", ")", "|", "DataStream...
Encode this stream as a packed 16-bit unsigned integer. Returns: int: The packed encoded stream
[ "Encode", "this", "stream", "as", "a", "packed", "16", "-", "bit", "unsigned", "integer", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/stream.py#L434-L445
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/m4.py
generate
def generate(env): """Add Builders and construction variables for m4 to an Environment.""" M4Action = SCons.Action.Action('$M4COM', '$M4COMSTR') bld = SCons.Builder.Builder(action = M4Action, src_suffix = '.m4') env['BUILDERS']['M4'] = bld # .m4 files might include other files, and it would be pre...
python
def generate(env): """Add Builders and construction variables for m4 to an Environment.""" M4Action = SCons.Action.Action('$M4COM', '$M4COMSTR') bld = SCons.Builder.Builder(action = M4Action, src_suffix = '.m4') env['BUILDERS']['M4'] = bld # .m4 files might include other files, and it would be pre...
[ "def", "generate", "(", "env", ")", ":", "M4Action", "=", "SCons", ".", "Action", ".", "Action", "(", "'$M4COM'", ",", "'$M4COMSTR'", ")", "bld", "=", "SCons", ".", "Builder", ".", "Builder", "(", "action", "=", "M4Action", ",", "src_suffix", "=", "'.m...
Add Builders and construction variables for m4 to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "m4", "to", "an", "Environment", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/m4.py#L40-L54
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/latex.py
generate
def generate(env): """Add Builders and construction variables for LaTeX to an Environment.""" env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes) from . import dvi dvi.generate(env) from . import pdf pdf.generate(env) bld = env['BUILDERS']['DVI'] bld.add_action('.ltx', LaTeXAuxA...
python
def generate(env): """Add Builders and construction variables for LaTeX to an Environment.""" env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes) from . import dvi dvi.generate(env) from . import pdf pdf.generate(env) bld = env['BUILDERS']['DVI'] bld.add_action('.ltx', LaTeXAuxA...
[ "def", "generate", "(", "env", ")", ":", "env", ".", "AppendUnique", "(", "LATEXSUFFIXES", "=", "SCons", ".", "Tool", ".", "LaTeXSuffixes", ")", "from", ".", "import", "dvi", "dvi", ".", "generate", "(", "env", ")", "from", ".", "import", "pdf", "pdf",...
Add Builders and construction variables for LaTeX to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "LaTeX", "to", "an", "Environment", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/latex.py#L53-L70
train
jobec/rfc5424-logging-handler
rfc5424logging/handler.py
Rfc5424SysLogHandler.encode_priority
def encode_priority(self, facility, priority): """ Encode the facility and priority. You can pass in strings or integers - if strings are passed, the facility_names and priority_names mapping dictionaries are used to convert them to integers. """ return (facility ...
python
def encode_priority(self, facility, priority): """ Encode the facility and priority. You can pass in strings or integers - if strings are passed, the facility_names and priority_names mapping dictionaries are used to convert them to integers. """ return (facility ...
[ "def", "encode_priority", "(", "self", ",", "facility", ",", "priority", ")", ":", "return", "(", "facility", "<<", "3", ")", "|", "self", ".", "priority_map", ".", "get", "(", "priority", ",", "self", ".", "LOG_WARNING", ")" ]
Encode the facility and priority. You can pass in strings or integers - if strings are passed, the facility_names and priority_names mapping dictionaries are used to convert them to integers.
[ "Encode", "the", "facility", "and", "priority", ".", "You", "can", "pass", "in", "strings", "or", "integers", "-", "if", "strings", "are", "passed", "the", "facility_names", "and", "priority_names", "mapping", "dictionaries", "are", "used", "to", "convert", "t...
9c4f669c5e54cf382936cd950e2204caeb6d05f0
https://github.com/jobec/rfc5424-logging-handler/blob/9c4f669c5e54cf382936cd950e2204caeb6d05f0/rfc5424logging/handler.py#L250-L257
train
jobec/rfc5424-logging-handler
rfc5424logging/handler.py
Rfc5424SysLogHandler.close
def close(self): """ Closes the socket. """ self.acquire() try: if self.transport is not None: self.transport.close() super(Rfc5424SysLogHandler, self).close() finally: self.release()
python
def close(self): """ Closes the socket. """ self.acquire() try: if self.transport is not None: self.transport.close() super(Rfc5424SysLogHandler, self).close() finally: self.release()
[ "def", "close", "(", "self", ")", ":", "self", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "transport", "is", "not", "None", ":", "self", ".", "transport", ".", "close", "(", ")", "super", "(", "Rfc5424SysLogHandler", ",", "self", ")", ...
Closes the socket.
[ "Closes", "the", "socket", "." ]
9c4f669c5e54cf382936cd950e2204caeb6d05f0
https://github.com/jobec/rfc5424-logging-handler/blob/9c4f669c5e54cf382936cd950e2204caeb6d05f0/rfc5424logging/handler.py#L478-L488
train
benedictpaten/sonLib
misc.py
sonTraceRootPath
def sonTraceRootPath(): """ function for finding external location """ import sonLib.bioio i = os.path.abspath(sonLib.bioio.__file__) return os.path.split(os.path.split(os.path.split(i)[0])[0])[0]
python
def sonTraceRootPath(): """ function for finding external location """ import sonLib.bioio i = os.path.abspath(sonLib.bioio.__file__) return os.path.split(os.path.split(os.path.split(i)[0])[0])[0]
[ "def", "sonTraceRootPath", "(", ")", ":", "import", "sonLib", ".", "bioio", "i", "=", "os", ".", "path", ".", "abspath", "(", "sonLib", ".", "bioio", ".", "__file__", ")", "return", "os", ".", "path", ".", "split", "(", "os", ".", "path", ".", "spl...
function for finding external location
[ "function", "for", "finding", "external", "location" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/misc.py#L20-L26
train
benedictpaten/sonLib
misc.py
linOriginRegression
def linOriginRegression(points): """ computes a linear regression starting at zero """ j = sum([ i[0] for i in points ]) k = sum([ i[1] for i in points ]) if j != 0: return k/j, j, k return 1, j, k
python
def linOriginRegression(points): """ computes a linear regression starting at zero """ j = sum([ i[0] for i in points ]) k = sum([ i[1] for i in points ]) if j != 0: return k/j, j, k return 1, j, k
[ "def", "linOriginRegression", "(", "points", ")", ":", "j", "=", "sum", "(", "[", "i", "[", "0", "]", "for", "i", "in", "points", "]", ")", "k", "=", "sum", "(", "[", "i", "[", "1", "]", "for", "i", "in", "points", "]", ")", "if", "j", "!="...
computes a linear regression starting at zero
[ "computes", "a", "linear", "regression", "starting", "at", "zero" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/misc.py#L28-L36
train
benedictpaten/sonLib
misc.py
close
def close(i, j, tolerance): """ check two float values are within a bound of one another """ return i <= j + tolerance and i >= j - tolerance
python
def close(i, j, tolerance): """ check two float values are within a bound of one another """ return i <= j + tolerance and i >= j - tolerance
[ "def", "close", "(", "i", ",", "j", ",", "tolerance", ")", ":", "return", "i", "<=", "j", "+", "tolerance", "and", "i", ">=", "j", "-", "tolerance" ]
check two float values are within a bound of one another
[ "check", "two", "float", "values", "are", "within", "a", "bound", "of", "one", "another" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/misc.py#L38-L42
train
benedictpaten/sonLib
misc.py
filterOverlappingAlignments
def filterOverlappingAlignments(alignments): """Filter alignments to be non-overlapping. """ l = [] alignments = alignments[:] sortAlignments(alignments) alignments.reverse() for pA1 in alignments: for pA2 in l: if pA1.contig1 == pA2.contig1 and getPositiveCoordinateRange...
python
def filterOverlappingAlignments(alignments): """Filter alignments to be non-overlapping. """ l = [] alignments = alignments[:] sortAlignments(alignments) alignments.reverse() for pA1 in alignments: for pA2 in l: if pA1.contig1 == pA2.contig1 and getPositiveCoordinateRange...
[ "def", "filterOverlappingAlignments", "(", "alignments", ")", ":", "l", "=", "[", "]", "alignments", "=", "alignments", "[", ":", "]", "sortAlignments", "(", "alignments", ")", "alignments", ".", "reverse", "(", ")", "for", "pA1", "in", "alignments", ":", ...
Filter alignments to be non-overlapping.
[ "Filter", "alignments", "to", "be", "non", "-", "overlapping", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/misc.py#L86-L106
train
benedictpaten/sonLib
tree.py
binaryTree_depthFirstNumbers
def binaryTree_depthFirstNumbers(binaryTree, labelTree=True, dontStopAtID=True): """ get mid-order depth first tree numbers """ traversalIDs = {} def traverse(binaryTree, mid=0, leafNo=0): if binaryTree.internal and (dontStopAtID or binaryTree.iD is None): midStart = mid ...
python
def binaryTree_depthFirstNumbers(binaryTree, labelTree=True, dontStopAtID=True): """ get mid-order depth first tree numbers """ traversalIDs = {} def traverse(binaryTree, mid=0, leafNo=0): if binaryTree.internal and (dontStopAtID or binaryTree.iD is None): midStart = mid ...
[ "def", "binaryTree_depthFirstNumbers", "(", "binaryTree", ",", "labelTree", "=", "True", ",", "dontStopAtID", "=", "True", ")", ":", "traversalIDs", "=", "{", "}", "def", "traverse", "(", "binaryTree", ",", "mid", "=", "0", ",", "leafNo", "=", "0", ")", ...
get mid-order depth first tree numbers
[ "get", "mid", "-", "order", "depth", "first", "tree", "numbers" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L52-L74
train
benedictpaten/sonLib
tree.py
binaryTree_nodeNames
def binaryTree_nodeNames(binaryTree): """ creates names for the leave and internal nodes of the newick tree from the leaf labels """ def fn(binaryTree, labels): if binaryTree.internal: fn(binaryTree.left, labels) fn(binaryTree.right, labels) labels[binaryT...
python
def binaryTree_nodeNames(binaryTree): """ creates names for the leave and internal nodes of the newick tree from the leaf labels """ def fn(binaryTree, labels): if binaryTree.internal: fn(binaryTree.left, labels) fn(binaryTree.right, labels) labels[binaryT...
[ "def", "binaryTree_nodeNames", "(", "binaryTree", ")", ":", "def", "fn", "(", "binaryTree", ",", "labels", ")", ":", "if", "binaryTree", ".", "internal", ":", "fn", "(", "binaryTree", ".", "left", ",", "labels", ")", "fn", "(", "binaryTree", ".", "right"...
creates names for the leave and internal nodes of the newick tree from the leaf labels
[ "creates", "names", "for", "the", "leave", "and", "internal", "nodes", "of", "the", "newick", "tree", "from", "the", "leaf", "labels" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L76-L92
train
benedictpaten/sonLib
tree.py
makeRandomBinaryTree
def makeRandomBinaryTree(leafNodeNumber=None): """Creates a random binary tree. """ while True: nodeNo = [-1] def fn(): nodeNo[0] += 1 if random.random() > 0.6: i = str(nodeNo[0]) return BinaryTree(0.00001 + random.random()*0.8, True, f...
python
def makeRandomBinaryTree(leafNodeNumber=None): """Creates a random binary tree. """ while True: nodeNo = [-1] def fn(): nodeNo[0] += 1 if random.random() > 0.6: i = str(nodeNo[0]) return BinaryTree(0.00001 + random.random()*0.8, True, f...
[ "def", "makeRandomBinaryTree", "(", "leafNodeNumber", "=", "None", ")", ":", "while", "True", ":", "nodeNo", "=", "[", "-", "1", "]", "def", "fn", "(", ")", ":", "nodeNo", "[", "0", "]", "+=", "1", "if", "random", ".", "random", "(", ")", ">", "0...
Creates a random binary tree.
[ "Creates", "a", "random", "binary", "tree", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L123-L141
train
benedictpaten/sonLib
tree.py
getRandomBinaryTreeLeafNode
def getRandomBinaryTreeLeafNode(binaryTree): """Get random binary tree node. """ if binaryTree.internal == True: if random.random() > 0.5: return getRandomBinaryTreeLeafNode(binaryTree.left) else: return getRandomBinaryTreeLeafNode(binaryTree.right) else: ...
python
def getRandomBinaryTreeLeafNode(binaryTree): """Get random binary tree node. """ if binaryTree.internal == True: if random.random() > 0.5: return getRandomBinaryTreeLeafNode(binaryTree.left) else: return getRandomBinaryTreeLeafNode(binaryTree.right) else: ...
[ "def", "getRandomBinaryTreeLeafNode", "(", "binaryTree", ")", ":", "if", "binaryTree", ".", "internal", "==", "True", ":", "if", "random", ".", "random", "(", ")", ">", "0.5", ":", "return", "getRandomBinaryTreeLeafNode", "(", "binaryTree", ".", "left", ")", ...
Get random binary tree node.
[ "Get", "random", "binary", "tree", "node", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L143-L152
train
benedictpaten/sonLib
tree.py
transformByDistance
def transformByDistance(wV, subModel, alphabetSize=4): """ transform wV by given substitution matrix """ nc = [0.0]*alphabetSize for i in xrange(0, alphabetSize): j = wV[i] k = subModel[i] for l in xrange(0, alphabetSize): nc[l] += j * k[l] return nc
python
def transformByDistance(wV, subModel, alphabetSize=4): """ transform wV by given substitution matrix """ nc = [0.0]*alphabetSize for i in xrange(0, alphabetSize): j = wV[i] k = subModel[i] for l in xrange(0, alphabetSize): nc[l] += j * k[l] return nc
[ "def", "transformByDistance", "(", "wV", ",", "subModel", ",", "alphabetSize", "=", "4", ")", ":", "nc", "=", "[", "0.0", "]", "*", "alphabetSize", "for", "i", "in", "xrange", "(", "0", ",", "alphabetSize", ")", ":", "j", "=", "wV", "[", "i", "]", ...
transform wV by given substitution matrix
[ "transform", "wV", "by", "given", "substitution", "matrix" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L162-L172
train
benedictpaten/sonLib
tree.py
normaliseWV
def normaliseWV(wV, normFac=1.0): """ make char probs divisible by one """ f = sum(wV) / normFac return [ i/f for i in wV ]
python
def normaliseWV(wV, normFac=1.0): """ make char probs divisible by one """ f = sum(wV) / normFac return [ i/f for i in wV ]
[ "def", "normaliseWV", "(", "wV", ",", "normFac", "=", "1.0", ")", ":", "f", "=", "sum", "(", "wV", ")", "/", "normFac", "return", "[", "i", "/", "f", "for", "i", "in", "wV", "]" ]
make char probs divisible by one
[ "make", "char", "probs", "divisible", "by", "one" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L180-L185
train
benedictpaten/sonLib
tree.py
felsensteins
def felsensteins(binaryTree, subMatrices, ancestorProbs, leaves, alphabetSize): """ calculates the un-normalised probabilties of each non-gap residue position """ l = {} def upPass(binaryTree): if binaryTree.internal: #is internal binaryTree i = branchUp(binaryTree.left) ...
python
def felsensteins(binaryTree, subMatrices, ancestorProbs, leaves, alphabetSize): """ calculates the un-normalised probabilties of each non-gap residue position """ l = {} def upPass(binaryTree): if binaryTree.internal: #is internal binaryTree i = branchUp(binaryTree.left) ...
[ "def", "felsensteins", "(", "binaryTree", ",", "subMatrices", ",", "ancestorProbs", ",", "leaves", ",", "alphabetSize", ")", ":", "l", "=", "{", "}", "def", "upPass", "(", "binaryTree", ")", ":", "if", "binaryTree", ".", "internal", ":", "i", "=", "branc...
calculates the un-normalised probabilties of each non-gap residue position
[ "calculates", "the", "un", "-", "normalised", "probabilties", "of", "each", "non", "-", "gap", "residue", "position" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L194-L220
train
benedictpaten/sonLib
tree.py
annotateTree
def annotateTree(bT, fn): """ annotate a tree in an external array using the given function """ l = [None]*bT.traversalID.midEnd def fn2(bT): l[bT.traversalID.mid] = fn(bT) if bT.internal: fn2(bT.left) fn2(bT.right) fn2(bT) return l
python
def annotateTree(bT, fn): """ annotate a tree in an external array using the given function """ l = [None]*bT.traversalID.midEnd def fn2(bT): l[bT.traversalID.mid] = fn(bT) if bT.internal: fn2(bT.left) fn2(bT.right) fn2(bT) return l
[ "def", "annotateTree", "(", "bT", ",", "fn", ")", ":", "l", "=", "[", "None", "]", "*", "bT", ".", "traversalID", ".", "midEnd", "def", "fn2", "(", "bT", ")", ":", "l", "[", "bT", ".", "traversalID", ".", "mid", "]", "=", "fn", "(", "bT", ")"...
annotate a tree in an external array using the given function
[ "annotate", "a", "tree", "in", "an", "external", "array", "using", "the", "given", "function" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L543-L554
train
benedictpaten/sonLib
tree.py
remodelTreeRemovingRoot
def remodelTreeRemovingRoot(root, node): """ Node is mid order number """ import bioio assert root.traversalID.mid != node hash = {} def fn(bT): if bT.traversalID.mid == node: assert bT.internal == False return [ bT ] elif bT.internal: i = ...
python
def remodelTreeRemovingRoot(root, node): """ Node is mid order number """ import bioio assert root.traversalID.mid != node hash = {} def fn(bT): if bT.traversalID.mid == node: assert bT.internal == False return [ bT ] elif bT.internal: i = ...
[ "def", "remodelTreeRemovingRoot", "(", "root", ",", "node", ")", ":", "import", "bioio", "assert", "root", ".", "traversalID", ".", "mid", "!=", "node", "hash", "=", "{", "}", "def", "fn", "(", "bT", ")", ":", "if", "bT", ".", "traversalID", ".", "mi...
Node is mid order number
[ "Node", "is", "mid", "order", "number" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L595-L629
train
benedictpaten/sonLib
tree.py
moveRoot
def moveRoot(root, branch): """ Removes the old root and places the new root at the mid point along the given branch """ import bioio if root.traversalID.mid == branch: return bioio.newickTreeParser(bioio.printBinaryTree(root, True)) def fn2(tree, seq): if seq is not None: ...
python
def moveRoot(root, branch): """ Removes the old root and places the new root at the mid point along the given branch """ import bioio if root.traversalID.mid == branch: return bioio.newickTreeParser(bioio.printBinaryTree(root, True)) def fn2(tree, seq): if seq is not None: ...
[ "def", "moveRoot", "(", "root", ",", "branch", ")", ":", "import", "bioio", "if", "root", ".", "traversalID", ".", "mid", "==", "branch", ":", "return", "bioio", ".", "newickTreeParser", "(", "bioio", ".", "printBinaryTree", "(", "root", ",", "True", ")"...
Removes the old root and places the new root at the mid point along the given branch
[ "Removes", "the", "old", "root", "and", "places", "the", "new", "root", "at", "the", "mid", "point", "along", "the", "given", "branch" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L631-L660
train
benedictpaten/sonLib
tree.py
checkGeneTreeMatchesSpeciesTree
def checkGeneTreeMatchesSpeciesTree(speciesTree, geneTree, processID): """ Function to check ids in gene tree all match nodes in species tree """ def fn(tree, l): if tree.internal: fn(tree.left, l) fn(tree.right, l) else: l.append(processID(tree.iD)) ...
python
def checkGeneTreeMatchesSpeciesTree(speciesTree, geneTree, processID): """ Function to check ids in gene tree all match nodes in species tree """ def fn(tree, l): if tree.internal: fn(tree.left, l) fn(tree.right, l) else: l.append(processID(tree.iD)) ...
[ "def", "checkGeneTreeMatchesSpeciesTree", "(", "speciesTree", ",", "geneTree", ",", "processID", ")", ":", "def", "fn", "(", "tree", ",", "l", ")", ":", "if", "tree", ".", "internal", ":", "fn", "(", "tree", ".", "left", ",", "l", ")", "fn", "(", "tr...
Function to check ids in gene tree all match nodes in species tree
[ "Function", "to", "check", "ids", "in", "gene", "tree", "all", "match", "nodes", "in", "species", "tree" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L662-L678
train
benedictpaten/sonLib
tree.py
calculateProbableRootOfGeneTree
def calculateProbableRootOfGeneTree(speciesTree, geneTree, processID=lambda x : x): """ Goes through each root possible branch making it the root. Returns tree that requires the minimum number of duplications. """ #get all rooted trees #run dup calc on each tree #return tree with fewest num...
python
def calculateProbableRootOfGeneTree(speciesTree, geneTree, processID=lambda x : x): """ Goes through each root possible branch making it the root. Returns tree that requires the minimum number of duplications. """ #get all rooted trees #run dup calc on each tree #return tree with fewest num...
[ "def", "calculateProbableRootOfGeneTree", "(", "speciesTree", ",", "geneTree", ",", "processID", "=", "lambda", "x", ":", "x", ")", ":", "if", "geneTree", ".", "traversalID", ".", "midEnd", "<=", "3", ":", "return", "(", "0", ",", "0", ",", "geneTree", "...
Goes through each root possible branch making it the root. Returns tree that requires the minimum number of duplications.
[ "Goes", "through", "each", "root", "possible", "branch", "making", "it", "the", "root", ".", "Returns", "tree", "that", "requires", "the", "minimum", "number", "of", "duplications", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L753-L776
train
benedictpaten/sonLib
bioio.py
redirectLoggerStreamHandlers
def redirectLoggerStreamHandlers(oldStream, newStream): """Redirect the stream of a stream handler to a different stream """ for handler in list(logger.handlers): #Remove old handlers if handler.stream == oldStream: handler.close() logger.removeHandler(handler) for handle...
python
def redirectLoggerStreamHandlers(oldStream, newStream): """Redirect the stream of a stream handler to a different stream """ for handler in list(logger.handlers): #Remove old handlers if handler.stream == oldStream: handler.close() logger.removeHandler(handler) for handle...
[ "def", "redirectLoggerStreamHandlers", "(", "oldStream", ",", "newStream", ")", ":", "for", "handler", "in", "list", "(", "logger", ".", "handlers", ")", ":", "if", "handler", ".", "stream", "==", "oldStream", ":", "handler", ".", "close", "(", ")", "logge...
Redirect the stream of a stream handler to a different stream
[ "Redirect", "the", "stream", "of", "a", "stream", "handler", "to", "a", "different", "stream" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L52-L62
train
benedictpaten/sonLib
bioio.py
popen
def popen(command, tempFile): """Runs a command and captures standard out in the given temp file. """ fileHandle = open(tempFile, 'w') logger.debug("Running the command: %s" % command) sts = subprocess.call(command, shell=True, stdout=fileHandle, bufsize=-1) fileHandle.close() if sts != 0: ...
python
def popen(command, tempFile): """Runs a command and captures standard out in the given temp file. """ fileHandle = open(tempFile, 'w') logger.debug("Running the command: %s" % command) sts = subprocess.call(command, shell=True, stdout=fileHandle, bufsize=-1) fileHandle.close() if sts != 0: ...
[ "def", "popen", "(", "command", ",", "tempFile", ")", ":", "fileHandle", "=", "open", "(", "tempFile", ",", "'w'", ")", "logger", ".", "debug", "(", "\"Running the command: %s\"", "%", "command", ")", "sts", "=", "subprocess", ".", "call", "(", "command", ...
Runs a command and captures standard out in the given temp file.
[ "Runs", "a", "command", "and", "captures", "standard", "out", "in", "the", "given", "temp", "file", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L188-L197
train
benedictpaten/sonLib
bioio.py
popenCatch
def popenCatch(command, stdinString=None): """Runs a command and return standard out. """ logger.debug("Running the command: %s" % command) if stdinString != None: process = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bu...
python
def popenCatch(command, stdinString=None): """Runs a command and return standard out. """ logger.debug("Running the command: %s" % command) if stdinString != None: process = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bu...
[ "def", "popenCatch", "(", "command", ",", "stdinString", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"Running the command: %s\"", "%", "command", ")", "if", "stdinString", "!=", "None", ":", "process", "=", "subprocess", ".", "Popen", "(", "command...
Runs a command and return standard out.
[ "Runs", "a", "command", "and", "return", "standard", "out", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L199-L213
train
benedictpaten/sonLib
bioio.py
getTotalCpuTimeAndMemoryUsage
def getTotalCpuTimeAndMemoryUsage(): """Gives the total cpu time and memory usage of itself and its children. """ me = resource.getrusage(resource.RUSAGE_SELF) childs = resource.getrusage(resource.RUSAGE_CHILDREN) totalCpuTime = me.ru_utime+me.ru_stime+childs.ru_utime+childs.ru_stime totalMemory...
python
def getTotalCpuTimeAndMemoryUsage(): """Gives the total cpu time and memory usage of itself and its children. """ me = resource.getrusage(resource.RUSAGE_SELF) childs = resource.getrusage(resource.RUSAGE_CHILDREN) totalCpuTime = me.ru_utime+me.ru_stime+childs.ru_utime+childs.ru_stime totalMemory...
[ "def", "getTotalCpuTimeAndMemoryUsage", "(", ")", ":", "me", "=", "resource", ".", "getrusage", "(", "resource", ".", "RUSAGE_SELF", ")", "childs", "=", "resource", ".", "getrusage", "(", "resource", ".", "RUSAGE_CHILDREN", ")", "totalCpuTime", "=", "me", ".",...
Gives the total cpu time and memory usage of itself and its children.
[ "Gives", "the", "total", "cpu", "time", "and", "memory", "usage", "of", "itself", "and", "its", "children", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L231-L238
train
benedictpaten/sonLib
bioio.py
saveInputs
def saveInputs(savedInputsDir, listOfFilesAndDirsToSave): """Copies the list of files to a directory created in the save inputs dir, and returns the name of this directory. """ logger.info("Saving the inputs: %s to the directory: %s" % (" ".join(listOfFilesAndDirsToSave), savedInputsDir)) assert os....
python
def saveInputs(savedInputsDir, listOfFilesAndDirsToSave): """Copies the list of files to a directory created in the save inputs dir, and returns the name of this directory. """ logger.info("Saving the inputs: %s to the directory: %s" % (" ".join(listOfFilesAndDirsToSave), savedInputsDir)) assert os....
[ "def", "saveInputs", "(", "savedInputsDir", ",", "listOfFilesAndDirsToSave", ")", ":", "logger", ".", "info", "(", "\"Saving the inputs: %s to the directory: %s\"", "%", "(", "\" \"", ".", "join", "(", "listOfFilesAndDirsToSave", ")", ",", "savedInputsDir", ")", ")", ...
Copies the list of files to a directory created in the save inputs dir, and returns the name of this directory.
[ "Copies", "the", "list", "of", "files", "to", "a", "directory", "created", "in", "the", "save", "inputs", "dir", "and", "returns", "the", "name", "of", "this", "directory", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L318-L334
train
benedictpaten/sonLib
bioio.py
nameValue
def nameValue(name, value, valueType=str, quotes=False): """Little function to make it easier to make name value strings for commands. """ if valueType == bool: if value: return "--%s" % name return "" if value is None: return "" if quotes: return "--%s '%...
python
def nameValue(name, value, valueType=str, quotes=False): """Little function to make it easier to make name value strings for commands. """ if valueType == bool: if value: return "--%s" % name return "" if value is None: return "" if quotes: return "--%s '%...
[ "def", "nameValue", "(", "name", ",", "value", ",", "valueType", "=", "str", ",", "quotes", "=", "False", ")", ":", "if", "valueType", "==", "bool", ":", "if", "value", ":", "return", "\"--%s\"", "%", "name", "return", "\"\"", "if", "value", "is", "N...
Little function to make it easier to make name value strings for commands.
[ "Little", "function", "to", "make", "it", "easier", "to", "make", "name", "value", "strings", "for", "commands", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L400-L411
train
benedictpaten/sonLib
bioio.py
makeSubDir
def makeSubDir(dirName): """Makes a given subdirectory if it doesn't already exist, making sure it us public. """ if not os.path.exists(dirName): os.mkdir(dirName) os.chmod(dirName, 0777) return dirName
python
def makeSubDir(dirName): """Makes a given subdirectory if it doesn't already exist, making sure it us public. """ if not os.path.exists(dirName): os.mkdir(dirName) os.chmod(dirName, 0777) return dirName
[ "def", "makeSubDir", "(", "dirName", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "dirName", ")", ":", "os", ".", "mkdir", "(", "dirName", ")", "os", ".", "chmod", "(", "dirName", ",", "0777", ")", "return", "dirName" ]
Makes a given subdirectory if it doesn't already exist, making sure it us public.
[ "Makes", "a", "given", "subdirectory", "if", "it", "doesn", "t", "already", "exist", "making", "sure", "it", "us", "public", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L426-L432
train
benedictpaten/sonLib
bioio.py
getTempFile
def getTempFile(suffix="", rootDir=None): """Returns a string representing a temporary file, that must be manually deleted """ if rootDir is None: handle, tmpFile = tempfile.mkstemp(suffix) os.close(handle) return tmpFile else: tmpFile = os.path.join(rootDir, "tmp_" + get...
python
def getTempFile(suffix="", rootDir=None): """Returns a string representing a temporary file, that must be manually deleted """ if rootDir is None: handle, tmpFile = tempfile.mkstemp(suffix) os.close(handle) return tmpFile else: tmpFile = os.path.join(rootDir, "tmp_" + get...
[ "def", "getTempFile", "(", "suffix", "=", "\"\"", ",", "rootDir", "=", "None", ")", ":", "if", "rootDir", "is", "None", ":", "handle", ",", "tmpFile", "=", "tempfile", ".", "mkstemp", "(", "suffix", ")", "os", ".", "close", "(", "handle", ")", "retur...
Returns a string representing a temporary file, that must be manually deleted
[ "Returns", "a", "string", "representing", "a", "temporary", "file", "that", "must", "be", "manually", "deleted" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L434-L445
train
benedictpaten/sonLib
bioio.py
getTempDirectory
def getTempDirectory(rootDir=None): """ returns a temporary directory that must be manually deleted. rootDir will be created if it does not exist. """ if rootDir is None: return tempfile.mkdtemp() else: if not os.path.exists(rootDir): try: os.makedirs(...
python
def getTempDirectory(rootDir=None): """ returns a temporary directory that must be manually deleted. rootDir will be created if it does not exist. """ if rootDir is None: return tempfile.mkdtemp() else: if not os.path.exists(rootDir): try: os.makedirs(...
[ "def", "getTempDirectory", "(", "rootDir", "=", "None", ")", ":", "if", "rootDir", "is", "None", ":", "return", "tempfile", ".", "mkdtemp", "(", ")", "else", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "rootDir", ")", ":", "try", ":", ...
returns a temporary directory that must be manually deleted. rootDir will be created if it does not exist.
[ "returns", "a", "temporary", "directory", "that", "must", "be", "manually", "deleted", ".", "rootDir", "will", "be", "created", "if", "it", "does", "not", "exist", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L447-L472
train
benedictpaten/sonLib
bioio.py
catFiles
def catFiles(filesToCat, catFile): """Cats a bunch of files into one file. Ensures a no more than maxCat files are concatenated at each step. """ if len(filesToCat) == 0: #We must handle this case or the cat call will hang waiting for input open(catFile, 'w').close() return maxCat = ...
python
def catFiles(filesToCat, catFile): """Cats a bunch of files into one file. Ensures a no more than maxCat files are concatenated at each step. """ if len(filesToCat) == 0: #We must handle this case or the cat call will hang waiting for input open(catFile, 'w').close() return maxCat = ...
[ "def", "catFiles", "(", "filesToCat", ",", "catFile", ")", ":", "if", "len", "(", "filesToCat", ")", "==", "0", ":", "open", "(", "catFile", ",", "'w'", ")", ".", "close", "(", ")", "return", "maxCat", "=", "25", "system", "(", "\"cat %s > %s\"", "%"...
Cats a bunch of files into one file. Ensures a no more than maxCat files are concatenated at each step.
[ "Cats", "a", "bunch", "of", "files", "into", "one", "file", ".", "Ensures", "a", "no", "more", "than", "maxCat", "files", "are", "concatenated", "at", "each", "step", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L651-L663
train
benedictpaten/sonLib
bioio.py
prettyXml
def prettyXml(elem): """ Return a pretty-printed XML string for the ElementTree Element. """ roughString = ET.tostring(elem, "utf-8") reparsed = minidom.parseString(roughString) return reparsed.toprettyxml(indent=" ")
python
def prettyXml(elem): """ Return a pretty-printed XML string for the ElementTree Element. """ roughString = ET.tostring(elem, "utf-8") reparsed = minidom.parseString(roughString) return reparsed.toprettyxml(indent=" ")
[ "def", "prettyXml", "(", "elem", ")", ":", "roughString", "=", "ET", ".", "tostring", "(", "elem", ",", "\"utf-8\"", ")", "reparsed", "=", "minidom", ".", "parseString", "(", "roughString", ")", "return", "reparsed", ".", "toprettyxml", "(", "indent", "=",...
Return a pretty-printed XML string for the ElementTree Element.
[ "Return", "a", "pretty", "-", "printed", "XML", "string", "for", "the", "ElementTree", "Element", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L665-L670
train
benedictpaten/sonLib
bioio.py
fastaEncodeHeader
def fastaEncodeHeader(attributes): """Decodes the fasta header """ for i in attributes: assert len(str(i).split()) == 1 return "|".join([ str(i) for i in attributes ])
python
def fastaEncodeHeader(attributes): """Decodes the fasta header """ for i in attributes: assert len(str(i).split()) == 1 return "|".join([ str(i) for i in attributes ])
[ "def", "fastaEncodeHeader", "(", "attributes", ")", ":", "for", "i", "in", "attributes", ":", "assert", "len", "(", "str", "(", "i", ")", ".", "split", "(", ")", ")", "==", "1", "return", "\"|\"", ".", "join", "(", "[", "str", "(", "i", ")", "for...
Decodes the fasta header
[ "Decodes", "the", "fasta", "header" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L700-L705
train
benedictpaten/sonLib
bioio.py
fastaWrite
def fastaWrite(fileHandleOrFile, name, seq, mode="w"): """Writes out fasta file """ fileHandle = _getFileHandle(fileHandleOrFile, mode) valid_chars = {x for x in string.ascii_letters + "-"} try: assert any([isinstance(seq, unicode), isinstance(seq, str)]) except AssertionError: r...
python
def fastaWrite(fileHandleOrFile, name, seq, mode="w"): """Writes out fasta file """ fileHandle = _getFileHandle(fileHandleOrFile, mode) valid_chars = {x for x in string.ascii_letters + "-"} try: assert any([isinstance(seq, unicode), isinstance(seq, str)]) except AssertionError: r...
[ "def", "fastaWrite", "(", "fileHandleOrFile", ",", "name", ",", "seq", ",", "mode", "=", "\"w\"", ")", ":", "fileHandle", "=", "_getFileHandle", "(", "fileHandleOrFile", ",", "mode", ")", "valid_chars", "=", "{", "x", "for", "x", "in", "string", ".", "as...
Writes out fasta file
[ "Writes", "out", "fasta", "file" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L741-L760
train
benedictpaten/sonLib
bioio.py
fastqRead
def fastqRead(fileHandleOrFile): """Reads a fastq file iteratively """ fileHandle = _getFileHandle(fileHandleOrFile) line = fileHandle.readline() while line != '': if line[0] == '@': name = line[1:-1] seq = fileHandle.readline()[:-1] plus = fileHandle.read...
python
def fastqRead(fileHandleOrFile): """Reads a fastq file iteratively """ fileHandle = _getFileHandle(fileHandleOrFile) line = fileHandle.readline() while line != '': if line[0] == '@': name = line[1:-1] seq = fileHandle.readline()[:-1] plus = fileHandle.read...
[ "def", "fastqRead", "(", "fileHandleOrFile", ")", ":", "fileHandle", "=", "_getFileHandle", "(", "fileHandleOrFile", ")", "line", "=", "fileHandle", ".", "readline", "(", ")", "while", "line", "!=", "''", ":", "if", "line", "[", "0", "]", "==", "'@'", ":...
Reads a fastq file iteratively
[ "Reads", "a", "fastq", "file", "iteratively" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L762-L789
train
benedictpaten/sonLib
bioio.py
_getMultiFastaOffsets
def _getMultiFastaOffsets(fasta): """Reads in columns of multiple alignment and returns them iteratively """ f = open(fasta, 'r') i = 0 j = f.read(1) l = [] while j != '': i += 1 if j == '>': i += 1 while f.read(1) != '\n': i += 1 ...
python
def _getMultiFastaOffsets(fasta): """Reads in columns of multiple alignment and returns them iteratively """ f = open(fasta, 'r') i = 0 j = f.read(1) l = [] while j != '': i += 1 if j == '>': i += 1 while f.read(1) != '\n': i += 1 ...
[ "def", "_getMultiFastaOffsets", "(", "fasta", ")", ":", "f", "=", "open", "(", "fasta", ",", "'r'", ")", "i", "=", "0", "j", "=", "f", ".", "read", "(", "1", ")", "l", "=", "[", "]", "while", "j", "!=", "''", ":", "i", "+=", "1", "if", "j",...
Reads in columns of multiple alignment and returns them iteratively
[ "Reads", "in", "columns", "of", "multiple", "alignment", "and", "returns", "them", "iteratively" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L811-L827
train
benedictpaten/sonLib
bioio.py
fastaReadHeaders
def fastaReadHeaders(fasta): """Returns a list of fasta header lines, excluding """ headers = [] fileHandle = open(fasta, 'r') line = fileHandle.readline() while line != '': assert line[-1] == '\n' if line[0] == '>': headers.append(line[1:-1]) line = fileHandl...
python
def fastaReadHeaders(fasta): """Returns a list of fasta header lines, excluding """ headers = [] fileHandle = open(fasta, 'r') line = fileHandle.readline() while line != '': assert line[-1] == '\n' if line[0] == '>': headers.append(line[1:-1]) line = fileHandl...
[ "def", "fastaReadHeaders", "(", "fasta", ")", ":", "headers", "=", "[", "]", "fileHandle", "=", "open", "(", "fasta", ",", "'r'", ")", "line", "=", "fileHandle", ".", "readline", "(", ")", "while", "line", "!=", "''", ":", "assert", "line", "[", "-",...
Returns a list of fasta header lines, excluding
[ "Returns", "a", "list", "of", "fasta", "header", "lines", "excluding" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L829-L841
train
benedictpaten/sonLib
bioio.py
fastaAlignmentRead
def fastaAlignmentRead(fasta, mapFn=(lambda x : x), l=None): """ reads in columns of multiple alignment and returns them iteratively """ if l is None: l = _getMultiFastaOffsets(fasta) else: l = l[:] seqNo = len(l) for i in xrange(0, seqNo): j = open(fasta, 'r') ...
python
def fastaAlignmentRead(fasta, mapFn=(lambda x : x), l=None): """ reads in columns of multiple alignment and returns them iteratively """ if l is None: l = _getMultiFastaOffsets(fasta) else: l = l[:] seqNo = len(l) for i in xrange(0, seqNo): j = open(fasta, 'r') ...
[ "def", "fastaAlignmentRead", "(", "fasta", ",", "mapFn", "=", "(", "lambda", "x", ":", "x", ")", ",", "l", "=", "None", ")", ":", "if", "l", "is", "None", ":", "l", "=", "_getMultiFastaOffsets", "(", "fasta", ")", "else", ":", "l", "=", "l", "[",...
reads in columns of multiple alignment and returns them iteratively
[ "reads", "in", "columns", "of", "multiple", "alignment", "and", "returns", "them", "iteratively" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L843-L873
train
benedictpaten/sonLib
bioio.py
fastaAlignmentWrite
def fastaAlignmentWrite(columnAlignment, names, seqNo, fastaFile, filter=lambda x : True): """ Writes out column alignment to given file multi-fasta format """ fastaFile = open(fastaFile, 'w') columnAlignment = [ i for i in columnAlignment if filter(i) ] for seq in xrange...
python
def fastaAlignmentWrite(columnAlignment, names, seqNo, fastaFile, filter=lambda x : True): """ Writes out column alignment to given file multi-fasta format """ fastaFile = open(fastaFile, 'w') columnAlignment = [ i for i in columnAlignment if filter(i) ] for seq in xrange...
[ "def", "fastaAlignmentWrite", "(", "columnAlignment", ",", "names", ",", "seqNo", ",", "fastaFile", ",", "filter", "=", "lambda", "x", ":", "True", ")", ":", "fastaFile", "=", "open", "(", "fastaFile", ",", "'w'", ")", "columnAlignment", "=", "[", "i", "...
Writes out column alignment to given file multi-fasta format
[ "Writes", "out", "column", "alignment", "to", "given", "file", "multi", "-", "fasta", "format" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L875-L887
train
benedictpaten/sonLib
bioio.py
getRandomSequence
def getRandomSequence(length=500): """Generates a random name and sequence. """ fastaHeader = "" for i in xrange(int(random.random()*100)): fastaHeader = fastaHeader + random.choice([ 'A', 'C', '0', '9', ' ', '\t' ]) return (fastaHeader, \ "".join([ random.choice([ 'A', 'C', 'T',...
python
def getRandomSequence(length=500): """Generates a random name and sequence. """ fastaHeader = "" for i in xrange(int(random.random()*100)): fastaHeader = fastaHeader + random.choice([ 'A', 'C', '0', '9', ' ', '\t' ]) return (fastaHeader, \ "".join([ random.choice([ 'A', 'C', 'T',...
[ "def", "getRandomSequence", "(", "length", "=", "500", ")", ":", "fastaHeader", "=", "\"\"", "for", "i", "in", "xrange", "(", "int", "(", "random", ".", "random", "(", ")", "*", "100", ")", ")", ":", "fastaHeader", "=", "fastaHeader", "+", "random", ...
Generates a random name and sequence.
[ "Generates", "a", "random", "name", "and", "sequence", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L889-L896
train
benedictpaten/sonLib
bioio.py
mutateSequence
def mutateSequence(seq, distance): """Mutates the DNA sequence for use in testing. """ subProb=distance inProb=0.05*distance deProb=0.05*distance contProb=0.9 l = [] bases = [ 'A', 'C', 'T', 'G' ] i=0 while i < len(seq): if random.random() < subProb: l.append(...
python
def mutateSequence(seq, distance): """Mutates the DNA sequence for use in testing. """ subProb=distance inProb=0.05*distance deProb=0.05*distance contProb=0.9 l = [] bases = [ 'A', 'C', 'T', 'G' ] i=0 while i < len(seq): if random.random() < subProb: l.append(...
[ "def", "mutateSequence", "(", "seq", ",", "distance", ")", ":", "subProb", "=", "distance", "inProb", "=", "0.05", "*", "distance", "deProb", "=", "0.05", "*", "distance", "contProb", "=", "0.9", "l", "=", "[", "]", "bases", "=", "[", "'A'", ",", "'C...
Mutates the DNA sequence for use in testing.
[ "Mutates", "the", "DNA", "sequence", "for", "use", "in", "testing", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L903-L923
train
benedictpaten/sonLib
bioio.py
newickTreeParser
def newickTreeParser(newickTree, defaultDistance=DEFAULT_DISTANCE, \ sortNonBinaryNodes=False, reportUnaryNodes=False): """ lax newick tree parser """ newickTree = newickTree.replace("(", " ( ") newickTree = newickTree.replace(")", " ) ") newickTree = newickTree.replace(":",...
python
def newickTreeParser(newickTree, defaultDistance=DEFAULT_DISTANCE, \ sortNonBinaryNodes=False, reportUnaryNodes=False): """ lax newick tree parser """ newickTree = newickTree.replace("(", " ( ") newickTree = newickTree.replace(")", " ) ") newickTree = newickTree.replace(":",...
[ "def", "newickTreeParser", "(", "newickTree", ",", "defaultDistance", "=", "DEFAULT_DISTANCE", ",", "sortNonBinaryNodes", "=", "False", ",", "reportUnaryNodes", "=", "False", ")", ":", "newickTree", "=", "newickTree", ".", "replace", "(", "\"(\"", ",", "\" ( \"", ...
lax newick tree parser
[ "lax", "newick", "tree", "parser" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L944-L1007
train
benedictpaten/sonLib
bioio.py
pWMRead
def pWMRead(fileHandle, alphabetSize=4): """reads in standard position weight matrix format, rows are different types of base, columns are individual residues """ lines = fileHandle.readlines() assert len(lines) == alphabetSize l = [ [ float(i) ] for i in lines[0].split() ] for line in lines...
python
def pWMRead(fileHandle, alphabetSize=4): """reads in standard position weight matrix format, rows are different types of base, columns are individual residues """ lines = fileHandle.readlines() assert len(lines) == alphabetSize l = [ [ float(i) ] for i in lines[0].split() ] for line in lines...
[ "def", "pWMRead", "(", "fileHandle", ",", "alphabetSize", "=", "4", ")", ":", "lines", "=", "fileHandle", ".", "readlines", "(", ")", "assert", "len", "(", "lines", ")", "==", "alphabetSize", "l", "=", "[", "[", "float", "(", "i", ")", "]", "for", ...
reads in standard position weight matrix format, rows are different types of base, columns are individual residues
[ "reads", "in", "standard", "position", "weight", "matrix", "format", "rows", "are", "different", "types", "of", "base", "columns", "are", "individual", "residues" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L1036-L1051
train
benedictpaten/sonLib
bioio.py
pWMWrite
def pWMWrite(fileHandle, pWM, alphabetSize=4): """Writes file in standard PWM format, is reverse of pWMParser """ for i in xrange(0, alphabetSize): fileHandle.write("%s\n" % ' '.join([ str(pWM[j][i]) for j in xrange(0, len(pWM)) ]))
python
def pWMWrite(fileHandle, pWM, alphabetSize=4): """Writes file in standard PWM format, is reverse of pWMParser """ for i in xrange(0, alphabetSize): fileHandle.write("%s\n" % ' '.join([ str(pWM[j][i]) for j in xrange(0, len(pWM)) ]))
[ "def", "pWMWrite", "(", "fileHandle", ",", "pWM", ",", "alphabetSize", "=", "4", ")", ":", "for", "i", "in", "xrange", "(", "0", ",", "alphabetSize", ")", ":", "fileHandle", ".", "write", "(", "\"%s\\n\"", "%", "' '", ".", "join", "(", "[", "str", ...
Writes file in standard PWM format, is reverse of pWMParser
[ "Writes", "file", "in", "standard", "PWM", "format", "is", "reverse", "of", "pWMParser" ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L1053-L1057
train
benedictpaten/sonLib
bioio.py
cigarRead
def cigarRead(fileHandleOrFile): """Reads a list of pairwise alignments into a pairwise alignment structure. Query and target are reversed! """ fileHandle = _getFileHandle(fileHandleOrFile) #p = re.compile("cigar:\\s+(.+)\\s+([0-9]+)\\s+([0-9]+)\\s+([\\+\\-\\.])\\s+(.+)\\s+([0-9]+)\\s+([0-9]+)\\s+(...
python
def cigarRead(fileHandleOrFile): """Reads a list of pairwise alignments into a pairwise alignment structure. Query and target are reversed! """ fileHandle = _getFileHandle(fileHandleOrFile) #p = re.compile("cigar:\\s+(.+)\\s+([0-9]+)\\s+([0-9]+)\\s+([\\+\\-\\.])\\s+(.+)\\s+([0-9]+)\\s+([0-9]+)\\s+(...
[ "def", "cigarRead", "(", "fileHandleOrFile", ")", ":", "fileHandle", "=", "_getFileHandle", "(", "fileHandleOrFile", ")", "p", "=", "re", ".", "compile", "(", "\"cigar:\\\\s+(.+)\\\\s+([0-9]+)\\\\s+([0-9]+)\\\\s+([\\\\+\\\\-\\\\.])\\\\s+(.+)\\\\s+([0-9]+)\\\\s+([0-9]+)\\\\s+([\\\...
Reads a list of pairwise alignments into a pairwise alignment structure. Query and target are reversed!
[ "Reads", "a", "list", "of", "pairwise", "alignments", "into", "a", "pairwise", "alignment", "structure", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L1184-L1199
train
benedictpaten/sonLib
bioio.py
cigarWrite
def cigarWrite(fileHandle, pairwiseAlignment, withProbs=True): """Writes out the pairwiseAlignment to the file stream. Query and target are reversed from normal order. """ if len(pairwiseAlignment.operationList) == 0: logger.info("Writing zero length pairwiseAlignment to file!") strand1 = ...
python
def cigarWrite(fileHandle, pairwiseAlignment, withProbs=True): """Writes out the pairwiseAlignment to the file stream. Query and target are reversed from normal order. """ if len(pairwiseAlignment.operationList) == 0: logger.info("Writing zero length pairwiseAlignment to file!") strand1 = ...
[ "def", "cigarWrite", "(", "fileHandle", ",", "pairwiseAlignment", ",", "withProbs", "=", "True", ")", ":", "if", "len", "(", "pairwiseAlignment", ".", "operationList", ")", "==", "0", ":", "logger", ".", "info", "(", "\"Writing zero length pairwiseAlignment to fil...
Writes out the pairwiseAlignment to the file stream. Query and target are reversed from normal order.
[ "Writes", "out", "the", "pairwiseAlignment", "to", "the", "file", "stream", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L1201-L1228
train
benedictpaten/sonLib
bioio.py
getRandomPairwiseAlignment
def getRandomPairwiseAlignment(): """Gets a random pairwiseAlignment. """ i, j, k, l = _getRandomSegment() m, n, o, p = _getRandomSegment() score = random.choice(xrange(-1000, 1000)) return PairwiseAlignment(i, j, k, l, m, n, o, p, score, getRandomOperationList(abs(k - j), abs(o - n)))
python
def getRandomPairwiseAlignment(): """Gets a random pairwiseAlignment. """ i, j, k, l = _getRandomSegment() m, n, o, p = _getRandomSegment() score = random.choice(xrange(-1000, 1000)) return PairwiseAlignment(i, j, k, l, m, n, o, p, score, getRandomOperationList(abs(k - j), abs(o - n)))
[ "def", "getRandomPairwiseAlignment", "(", ")", ":", "i", ",", "j", ",", "k", ",", "l", "=", "_getRandomSegment", "(", ")", "m", ",", "n", ",", "o", ",", "p", "=", "_getRandomSegment", "(", ")", "score", "=", "random", ".", "choice", "(", "xrange", ...
Gets a random pairwiseAlignment.
[ "Gets", "a", "random", "pairwiseAlignment", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L1260-L1266
train
benedictpaten/sonLib
bioio.py
addEdgeToGraph
def addEdgeToGraph(parentNodeName, childNodeName, graphFileHandle, colour="black", length="10", weight="1", dir="none", label="", style=""): """Links two nodes in the graph together. """ graphFileHandle.write('edge[color=%s,len=%s,weight=%s,dir=%s,label="%s",style=%s];\n' % (colour, length, weight, dir, lab...
python
def addEdgeToGraph(parentNodeName, childNodeName, graphFileHandle, colour="black", length="10", weight="1", dir="none", label="", style=""): """Links two nodes in the graph together. """ graphFileHandle.write('edge[color=%s,len=%s,weight=%s,dir=%s,label="%s",style=%s];\n' % (colour, length, weight, dir, lab...
[ "def", "addEdgeToGraph", "(", "parentNodeName", ",", "childNodeName", ",", "graphFileHandle", ",", "colour", "=", "\"black\"", ",", "length", "=", "\"10\"", ",", "weight", "=", "\"1\"", ",", "dir", "=", "\"none\"", ",", "label", "=", "\"\"", ",", "style", ...
Links two nodes in the graph together.
[ "Links", "two", "nodes", "in", "the", "graph", "together", "." ]
1decb75bb439b70721ec776f685ce98e25217d26
https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L1282-L1286
train