sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def sonseq(word): '''Return True if 'word' does not violate sonority sequencing.''' parts = re.split(r'([ieaouäöy]+)', word, flags=re.I | re.U) onset, coda = parts[0], parts[-1] # simplex onset Finnish complex onset if len(onset) <= 1 or onset.lower() in ONSETS: # simplex coda ...
Return True if 'word' does not violate sonority sequencing.
entailment
def harmonic(word): '''Return True if the word's vowels agree in frontness/backness.''' depth = {'ä': 0, 'ö': 0, 'y': 0, 'a': 1, 'o': 1, 'u': 1} vowels = filter(lambda ch: is_front(ch) or is_back(ch), word) depths = (depth[x.lower()] for x in vowels) return len(set(depths)) < 2
Return True if the word's vowels agree in frontness/backness.
entailment
def put(self): """Updates this task type on the saltant server. Returns: :class:`saltant.models.container_task_type.ExecutableTaskType`: An executable task type model instance representing the task type just updated. """ return self.manager.pu...
Updates this task type on the saltant server. Returns: :class:`saltant.models.container_task_type.ExecutableTaskType`: An executable task type model instance representing the task type just updated.
entailment
def create( self, name, command_to_run, description="", environment_variables=None, required_arguments=None, required_arguments_default_values=None, json_file_option=None, extra_data_to_post=None, ): """Create a container task type. ...
Create a container task type. Args: name (str): The name of the task. command_to_run (str): The command to run to execute the task. description (str, optional): The description of the task type. environment_variables (list, optional): The environment ...
entailment
def put( self, id, name, description, command_to_run, environment_variables, required_arguments, required_arguments_default_values, json_file_option, extra_data_to_put=None, ): """Updates a task type on the saltant server. ...
Updates a task type on the saltant server. Args: id (int): The ID of the task type. name (str): The name of the task type. description (str): The description of the task type. command_to_run (str): The command to run to execute the task. environment_v...
entailment
def reporter(self, analysistype='genesippr'): """ Creates a report of the genesippr results :param analysistype: The variable to use when accessing attributes in the metadata object """ logging.info('Creating {} report'.format(analysistype)) # Create a dictionary to link ...
Creates a report of the genesippr results :param analysistype: The variable to use when accessing attributes in the metadata object
entailment
def genusspecific(self, analysistype='genesippr'): """ Creates simplified genus-specific reports. Instead of the % ID and the fold coverage, a simple +/- scheme is used for presence/absence :param analysistype: The variable to use when accessing attributes in the metadata object ...
Creates simplified genus-specific reports. Instead of the % ID and the fold coverage, a simple +/- scheme is used for presence/absence :param analysistype: The variable to use when accessing attributes in the metadata object
entailment
def gdcsreporter(self, analysistype='GDCS'): """ Creates a report of the GDCS results :param analysistype: The variable to use when accessing attributes in the metadata object """ logging.info('Creating {} report'.format(analysistype)) # Initialise list to store all the G...
Creates a report of the GDCS results :param analysistype: The variable to use when accessing attributes in the metadata object
entailment
def gdcs_fai(sample, analysistype='GDCS'): """ GDCS analyses need to use the .fai file supplied in the targets folder rather than the one created following reverse baiting :param sample: sample object :param analysistype: current analysis being performed """ try: ...
GDCS analyses need to use the .fai file supplied in the targets folder rather than the one created following reverse baiting :param sample: sample object :param analysistype: current analysis being performed
entailment
def sixteensreporter(self, analysistype='sixteens_full'): """ Creates a report of the results :param analysistype: The variable to use when accessing attributes in the metadata object """ # Create the path in which the reports are stored make_path(self.reportpath) ...
Creates a report of the results :param analysistype: The variable to use when accessing attributes in the metadata object
entailment
def confindr_reporter(self, analysistype='confindr'): """ Creates a final report of all the ConFindr results """ # Initialise the data strings data = 'Strain,Genus,NumContamSNVs,ContamStatus,PercentContam,PercentContamSTD\n' with open(os.path.join(self.reportpath, analysi...
Creates a final report of all the ConFindr results
entailment
def methodreporter(self): """ Create final reports collating results from all the individual iterations through the method pipeline """ # Ensure that the analyses are set to complete self.analysescomplete = True # Reset the report path to original value self.repor...
Create final reports collating results from all the individual iterations through the method pipeline
entailment
def main(self): """ Run the methods required to create the genesippr report summary image """ self.dataframe_setup() self.figure_populate(self.outputfolder, self.image_report, self.header_list, ...
Run the methods required to create the genesippr report summary image
entailment
def data_sanitise(self, inputstring, header=None): """ Format the data to be consistent with heatmaps :param inputstring: string containing data to be formatted :param header: class of the data - certain categories have specific formatting requirements :return: the formatted outp...
Format the data to be consistent with heatmaps :param inputstring: string containing data to be formatted :param header: class of the data - certain categories have specific formatting requirements :return: the formatted output string
entailment
def dataframe_setup(self): """ Set-up a report to store the desired header: sanitized string combinations """ # Initialise a dictionary to store the sanitized headers and strings genesippr_dict = dict() # Try to open all the reports - use pandas to extract the results fro...
Set-up a report to store the desired header: sanitized string combinations
entailment
def figure_populate(outputpath, csv, xlabels, ylabels, analysistype, description, fail=False): """ Create the report image from the summary report created in self.dataframesetup :param outputpath: Path in which the outputs are to be created :param csv: Name of the report file from which ...
Create the report image from the summary report created in self.dataframesetup :param outputpath: Path in which the outputs are to be created :param csv: Name of the report file from which data are to be extracted :param xlabels: List of all the labels to use on the x-axis :param ylabels...
entailment
def add_usr_local_bin_to_path(log=False): """ adds /usr/local/bin to $PATH """ if log: bookshelf2.logging_helpers.log_green('inserts /usr/local/bin into PATH') with settings(hide('warnings', 'running', 'stdout', 'stderr'), capture=True): try: sudo('echo "export...
adds /usr/local/bin to $PATH
entailment
def dir_attribs(location, mode=None, owner=None, group=None, recursive=False, use_sudo=False): """ cuisine dir_attribs doesn't do sudo, so we implement our own Updates the mode/owner/group for the given remote directory.""" args = '' if recursive: args = args + ' -R ' if...
cuisine dir_attribs doesn't do sudo, so we implement our own Updates the mode/owner/group for the given remote directory.
entailment
def dir_ensure(location, recursive=False, mode=None, owner=None, group=None, use_sudo=False): """ cuisine dir_ensure doesn't do sudo, so we implement our own Ensures that there is a remote directory at the given location, optionally updating its mode/owner/group. If we are not updating th...
cuisine dir_ensure doesn't do sudo, so we implement our own Ensures that there is a remote directory at the given location, optionally updating its mode/owner/group. If we are not updating the owner/group then this can be done as a single ssh call, so use that method, otherwise set owner/group after cre...
entailment
def dir_exists(location, use_sudo=False): """Tells if there is a remote directory at the given location.""" with settings(hide('running', 'stdout', 'stderr'), warn_only=True): if use_sudo: # convert return code 0 to True return not bool(sudo('test -d %s' % (location)).return_code...
Tells if there is a remote directory at the given location.
entailment
def disable_env_reset_on_sudo(log=False): """ updates /etc/sudoers so that users from %wheel keep their environment when executing a sudo call """ if log: bookshelf2.logging_helpers.log_green('disabling env reset on sudo') file_append('/etc/sudoers', 'Defaults:%wheel !en...
updates /etc/sudoers so that users from %wheel keep their environment when executing a sudo call
entailment
def disable_requiretty_on_sudoers(log=False): """ allow sudo calls through ssh without a tty """ if log: bookshelf2.logging_helpers.log_green( 'disabling requiretty on sudo calls') comment_line('/etc/sudoers', '^Defaults.*requiretty', use_sudo=True) return True
allow sudo calls through ssh without a tty
entailment
def file_attribs(location, mode=None, owner=None, group=None, use_sudo=False, recursive=True): """Updates the mode/owner/group for the remote file at the given location.""" return dir_attribs(location=location, ...
Updates the mode/owner/group for the remote file at the given location.
entailment
def os_release(): """ returns /etc/os-release in a dictionary """ with settings(hide('warnings', 'running', 'stderr'), warn_only=True, capture=True): release = {} data = run('cat /etc/os-release') for line in data.split('\n'): if not line: c...
returns /etc/os-release in a dictionary
entailment
def linux_distribution(): """ returns the linux distribution in lower case """ with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True, capture=True): data = os_release() return(data['ID'])
returns the linux distribution in lower case
entailment
def lsb_release(): """ returns /etc/lsb-release in a dictionary """ with settings(hide('warnings', 'running'), capture=True): _lsb_release = {} data = sudo('cat /etc/lsb-release') for line in data.split('\n'): if not line: continue parts = line.sp...
returns /etc/lsb-release in a dictionary
entailment
def restart_service(service, log=False): """ restarts a service """ with settings(): if log: bookshelf2.logging_helpers.log_yellow( 'stoping service %s' % service) sudo('service %s stop' % service) if log: bookshelf2.logging_helpers.log_yellow( ...
restarts a service
entailment
def systemd(service, start=True, enabled=True, unmask=False, restart=False): """ manipulates systemd services """ with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True, capture=True): if restart: sudo('systemctl restart %s' % service) else:...
manipulates systemd services
entailment
def install_os_updates(distribution, force=False): """ installs OS updates """ if ('centos' in distribution or 'rhel' in distribution or 'redhat' in distribution): bookshelf2.logging_helpers.log_green('installing OS updates') sudo("yum -y --quiet clean all") sudo(...
installs OS updates
entailment
def ansi_format( self, width=64, height=12 ): """Return a human readable ANSI-terminal printout of the stats. width Custom width for the graph (in characters). height Custom height for the graph (in characters). """ from mrcrowbar.ansi import format_bar_...
Return a human readable ANSI-terminal printout of the stats. width Custom width for the graph (in characters). height Custom height for the graph (in characters).
entailment
def put(self): """Updates this task whitelist on the saltant server. Returns: :class:`saltant.models.task_whitelist.TaskWhitelist`: A task whitelist model instance representing the task whitelist just updated. """ return self.manager.put( ...
Updates this task whitelist on the saltant server. Returns: :class:`saltant.models.task_whitelist.TaskWhitelist`: A task whitelist model instance representing the task whitelist just updated.
entailment
def create( self, name, description="", whitelisted_container_task_types=None, whitelisted_executable_task_types=None, ): """Create a task whitelist. Args: name (str): The name of the task whitelist. description (str, optional): A desc...
Create a task whitelist. Args: name (str): The name of the task whitelist. description (str, optional): A description of the task whitelist. whitelisted_container_task_types (list, optional): A list of whitelisted container task type IDs. whitelis...
entailment
def patch( self, id, name=None, description=None, whitelisted_container_task_types=None, whitelisted_executable_task_types=None, ): """Partially updates a task whitelist on the saltant server. Args: id (int): The ID of the task whitelist. ...
Partially updates a task whitelist on the saltant server. Args: id (int): The ID of the task whitelist. name (str, optional): The name of the task whitelist. description (str, optional): A description of the task whitelist. whitelisted_container_task_types (list,...
entailment
def enable_logging( level='WARNING' ): """Enable sending logs to stderr. Useful for shell sessions. level Logging threshold, as defined in the logging module of the Python standard library. Defaults to 'WARNING'. """ log = logging.getLogger( 'mrcrowbar' ) log.setLevel( level ) o...
Enable sending logs to stderr. Useful for shell sessions. level Logging threshold, as defined in the logging module of the Python standard library. Defaults to 'WARNING'.
entailment
def find_all_iter( source, substring, start=None, end=None, overlap=False ): """Iterate through every location a substring can be found in a source string. source The source string to search. start Start offset to read from (default: start) end End offset to stop reading at (d...
Iterate through every location a substring can be found in a source string. source The source string to search. start Start offset to read from (default: start) end End offset to stop reading at (default: end) overlap Whether to return overlapping matches (default: fa...
entailment
def find_all( source, substring, start=None, end=None, overlap=False ): """Return every location a substring can be found in a source string. source The source string to search. start Start offset to read from (default: start) end End offset to stop reading at (default: end) ...
Return every location a substring can be found in a source string. source The source string to search. start Start offset to read from (default: start) end End offset to stop reading at (default: end) overlap Whether to return overlapping matches (default: false)
entailment
def basic_diff( source1, source2, start=None, end=None ): """Perform a basic diff between two equal-sized binary strings and return a list of (offset, size) tuples denoting the differences. source1 The first byte string source. source2 The second byte string source. start ...
Perform a basic diff between two equal-sized binary strings and return a list of (offset, size) tuples denoting the differences. source1 The first byte string source. source2 The second byte string source. start Start offset to read from (default: start) end End o...
entailment
def hexdump_iter( source, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, address_base=None ): """Return the contents of a byte string in tabular hexadecimal/ASCII format. source The byte string to print. start Start offset to read from (default: start) e...
Return the contents of a byte string in tabular hexadecimal/ASCII format. source The byte string to print. start Start offset to read from (default: start) end End offset to stop reading at (default: end) length Length to read in (optional replacement for end) ...
entailment
def hexdump( source, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, address_base=None ): """Print the contents of a byte string in tabular hexadecimal/ASCII format. source The byte string to print. start Start offset to read from (default: start) end ...
Print the contents of a byte string in tabular hexadecimal/ASCII format. source The byte string to print. start Start offset to read from (default: start) end End offset to stop reading at (default: end) length Length to read in (optional replacement for end) ...
entailment
def hexdump_diff_iter( source1, source2, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, before=2, after=2, address_base=None ): """Returns the differences between two byte strings in tabular hexadecimal/ASCII format. source1 The first byte string source. source2 ...
Returns the differences between two byte strings in tabular hexadecimal/ASCII format. source1 The first byte string source. source2 The second byte string source. start Start offset to read from (default: start) end End offset to stop reading at (default: end) le...
entailment
def hexdump_diff( source1, source2, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, before=2, after=2, address_base=None ): """Returns the differences between two byte strings in tabular hexadecimal/ASCII format. source1 The first byte string source. source2 The s...
Returns the differences between two byte strings in tabular hexadecimal/ASCII format. source1 The first byte string source. source2 The second byte string source. start Start offset to read from (default: start) end End offset to stop reading at (default: end) le...
entailment
def unpack_bits( byte ): """Expand a bitfield into a 64-bit int (8 bool bytes).""" longbits = byte & (0x00000000000000ff) longbits = (longbits | (longbits<<28)) & (0x0000000f0000000f) longbits = (longbits | (longbits<<14)) & (0x0003000300030003) longbits = (longbits | (longbits<<7)) & (0x01010101010...
Expand a bitfield into a 64-bit int (8 bool bytes).
entailment
def pack_bits( longbits ): """Crunch a 64-bit int (8 bool bytes) into a bitfield.""" byte = longbits & (0x0101010101010101) byte = (byte | (byte>>7)) & (0x0003000300030003) byte = (byte | (byte>>14)) & (0x0000000f0000000f) byte = (byte | (byte>>28)) & (0x00000000000000ff) return byte
Crunch a 64-bit int (8 bool bytes) into a bitfield.
entailment
def pixdump_iter( source, start=None, end=None, length=None, width=64, height=None, palette=None ): """Return the contents of a byte string as a 256 colour image. source The byte string to print. start Start offset to read from (default: start) end End offset to stop reading a...
Return the contents of a byte string as a 256 colour image. source The byte string to print. start Start offset to read from (default: start) end End offset to stop reading at (default: end) length Length to read in (optional replacement for end) width Wi...
entailment
def pixdump( source, start=None, end=None, length=None, width=64, height=None, palette=None ): """Print the contents of a byte string as a 256 colour image. source The byte string to print. start Start offset to read from (default: start) end End offset to stop reading at (def...
Print the contents of a byte string as a 256 colour image. source The byte string to print. start Start offset to read from (default: start) end End offset to stop reading at (default: end) length Length to read in (optional replacement for end) width Wid...
entailment
def set_offset( self, offset ): """Set the current read offset (in bytes) for the instance.""" assert offset in range( len( self.buffer ) ) self.pos = offset self._fill_buffer()
Set the current read offset (in bytes) for the instance.
entailment
def get_bits( self, count ): """Get an integer containing the next [count] bits from the source.""" result = 0 for i in range( count ): if self.bits_remaining <= 0: self._fill_buffer() if self.bits_reverse: bit = (1 if (self.current_bits & ...
Get an integer containing the next [count] bits from the source.
entailment
def put_bits( self, value, count ): """Push bits into the target. value Integer containing bits to push, ordered from least-significant bit to most-significant bit. count Number of bits to push to the target. """ for _ in range( count ): ...
Push bits into the target. value Integer containing bits to push, ordered from least-significant bit to most-significant bit. count Number of bits to push to the target.
entailment
def get_buffer( self ): """Return a byte string containing the target as currently written.""" last_byte = self.current_bits if (self.bits_remaining < 8) else None result = self.output if last_byte is not None: result = bytearray( result ) result.append( last_byt...
Return a byte string containing the target as currently written.
entailment
def get_for_update(self, connection_name='DEFAULT', **kwargs): """ http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa """ if not kwargs: raise InvalidQueryError( "Can not execute a query wit...
http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa
entailment
def syllabify(word, compound=None): '''Syllabify the given word, whether simplex or complex.''' if compound is None: compound = bool(re.search(r'(-| |=)', word)) syllabify = _syllabify_compound if compound else _syllabify syll, rules = syllabify(word) yield syll, rules n = 7 if '...
Syllabify the given word, whether simplex or complex.
entailment
def convert_case(name): """Converts name from CamelCase to snake_case""" s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
Converts name from CamelCase to snake_case
entailment
def table_name(self): """Pluralises the class_name using utterly simple algo and returns as table_name""" if not self.class_name: raise ValueError else: tbl_name = ModelCompiler.convert_case(self.class_name) last_letter = tbl_name[-1] if last_letter in ("y...
Pluralises the class_name using utterly simple algo and returns as table_name
entailment
def types(self): """All the unique types found in user supplied model""" res = [] for column in self.column_definitions: tmp = column.get('type', None) res.append(ModelCompiler.get_column_type(tmp)) if tmp else False res = list(set(res)) return res
All the unique types found in user supplied model
entailment
def basic_types(self): """Returns non-postgres types referenced in user supplied model """ if not self.foreign_key_definitions: return self.standard_types else: tmp = self.standard_types tmp.append('ForeignKey') return tmp
Returns non-postgres types referenced in user supplied model
entailment
def primary_keys(self): """Returns the primary keys referenced in user supplied model""" res = [] for column in self.column_definitions: if 'primary_key' in column.keys(): tmp = column.get('primary_key', None) res.append(column['name']) if tmp else Fal...
Returns the primary keys referenced in user supplied model
entailment
def compiled_named_imports(self): """Returns compiled named imports required for the model""" res = [] if self.postgres_types: res.append( ALCHEMY_TEMPLATES.named_import.safe_substitute( module='sqlalchemy.dialects.postgresql', ...
Returns compiled named imports required for the model
entailment
def compiled_orm_imports(self): """Returns compiled named imports required for the model""" module = 'sqlalchemy.orm' labels = [] if self.relationship_definitions: labels.append("relationship") return ALCHEMY_TEMPLATES.named_import.safe_substitute(module=module, label...
Returns compiled named imports required for the model
entailment
def compiled_columns(self): """Returns compiled column definitions""" def get_column_args(column): tmp = [] for arg_name, arg_val in column.items(): if arg_name not in ('name', 'type'): if arg_name in ('server_default', 'server_onupdate'): ...
Returns compiled column definitions
entailment
def compiled_foreign_keys(self): """Returns compiled foreign key definitions""" def get_column_args(column): tmp = [] for arg_name, arg_val in column.items(): if arg_name not in ('name', 'type', 'reference'): if arg_name in ('server_default', ...
Returns compiled foreign key definitions
entailment
def compiled_relationships(self): """Returns compiled relationship definitions""" def get_column_args(column): tmp = [] for arg_name, arg_val in column.items(): if arg_name not in ('name', 'type', 'reference', 'class'): if arg_name in ('back_p...
Returns compiled relationship definitions
entailment
def columns(self): """Return names of all the addressable columns (including foreign keys) referenced in user supplied model""" res = [col['name'] for col in self.column_definitions] res.extend([col['name'] for col in self.foreign_key_definitions]) return res
Return names of all the addressable columns (including foreign keys) referenced in user supplied model
entailment
def compiled_init_func(self): """Returns compiled init function""" def get_column_assignment(column_name): return ALCHEMY_TEMPLATES.col_assignment.safe_substitute(col_name=column_name) def get_compiled_args(arg_name): return ALCHEMY_TEMPLATES.func_arg.safe_substitute(ar...
Returns compiled init function
entailment
def compiled_update_func(self): """Returns compiled update function""" def get_not_none_col_assignment(column_name): return ALCHEMY_TEMPLATES.not_none_col_assignment.safe_substitute(col_name=column_name) def get_compiled_args(arg_name): return ALCHEMY_TEMPLATES.func_arg...
Returns compiled update function
entailment
def compiled_hash_func(self): """Returns compiled hash function based on hash of stringified primary_keys. This isn't the most efficient way""" def get_primary_key_str(pkey_name): return "str(self.{})".format(pkey_name) hash_str = "+ ".join([get_primary_key_str(n) for n in ...
Returns compiled hash function based on hash of stringified primary_keys. This isn't the most efficient way
entailment
def representation_function_compiler(self, func_name): """Generic function can be used to compile __repr__ or __unicode__ or __str__""" def get_col_accessor(col): return ALCHEMY_TEMPLATES.col_accessor.safe_substitute(col=col) def get_col_evaluator(col): return ALCHEMY_T...
Generic function can be used to compile __repr__ or __unicode__ or __str__
entailment
def compiled_model(self): """Returns compile ORM class for the user supplied model""" return ALCHEMY_TEMPLATES.model.safe_substitute(class_name=self.class_name, table_name=self.table_name, colum...
Returns compile ORM class for the user supplied model
entailment
def put(self): """Updates this task queue on the saltant server. Returns: :class:`saltant.models.task_queue.TaskQueue`: A task queue model instance representing the task queue just updated. """ return self.manager.put( id=self.id, ...
Updates this task queue on the saltant server. Returns: :class:`saltant.models.task_queue.TaskQueue`: A task queue model instance representing the task queue just updated.
entailment
def get(self, id=None, name=None): """Get a task queue. Either the id xor the name of the task type must be specified. Args: id (int, optional): The id of the task type to get. name (str, optional): The name of the task type to get. Returns: :class:...
Get a task queue. Either the id xor the name of the task type must be specified. Args: id (int, optional): The id of the task type to get. name (str, optional): The name of the task type to get. Returns: :class:`saltant.models.task_queue.TaskQueue`: ...
entailment
def create( self, name, description="", private=False, runs_executable_tasks=True, runs_docker_container_tasks=True, runs_singularity_container_tasks=True, active=True, whitelists=None, ): """Create a task queue. Args: ...
Create a task queue. Args: name (str): The name of the task queue. description (str, optional): A description of the task queue. private (bool, optional): A boolean specifying whether the queue is exclusive to its creator. Defaults to False. runs_...
entailment
def patch( self, id, name=None, description=None, private=None, runs_executable_tasks=None, runs_docker_container_tasks=None, runs_singularity_container_tasks=None, active=None, whitelists=None, ): """Partially updates a task qu...
Partially updates a task queue on the saltant server. Args: id (int): The ID of the task queue. name (str, optional): The name of the task queue. description (str, optional): The description of the task queue. private (bool, optional): A Booleon s...
entailment
def put( self, id, name, description, private, runs_executable_tasks, runs_docker_container_tasks, runs_singularity_container_tasks, active, whitelists, ): """Updates a task queue on the saltant server. Args: ...
Updates a task queue on the saltant server. Args: id (int): The ID of the task queue. name (str): The name of the task queue. description (str): The description of the task queue. private (bool): A Booleon signalling whether the queue can only be ...
entailment
def main(self): """ Run the required methods in the appropriate order """ self.targets() self.bait(k=49) self.reversebait(maskmiddle='t', k=19) self.subsample_reads()
Run the required methods in the appropriate order
entailment
def targets(self): """ Create the GenObject for the analysis type, create the hash file for baiting (if necessary) """ for sample in self.runmetadata: if sample.general.bestassemblyfile != 'NA': setattr(sample, self.analysistype, GenObject()) s...
Create the GenObject for the analysis type, create the hash file for baiting (if necessary)
entailment
def targets(self): """ Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the code """ logging.info('Performi...
Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the code
entailment
def runner(self): """ Run the necessary methods in the correct order """ logging.info('Starting {} analysis pipeline'.format(self.analysistype)) if not self.pipeline: # If the metadata has been passed from the method script, self.pipeline must still be false in order ...
Run the necessary methods in the correct order
entailment
def subsample(self): """ Subsample 1000 reads from the baited files """ # Create the threads for the analysis logging.info('Subsampling FASTQ reads') for _ in range(self.cpus): threads = Thread(target=self.subsamplethreads, args=()) threads.setDaem...
Subsample 1000 reads from the baited files
entailment
def fasta(self): """ Convert the subsampled reads to FASTA format using reformat.sh """ logging.info('Converting FASTQ files to FASTA format') # Create the threads for the analysis for _ in range(self.cpus): threads = Thread(target=self.fastathreads, args=()) ...
Convert the subsampled reads to FASTA format using reformat.sh
entailment
def makeblastdb(self): """ Makes blast database files from targets as necessary """ # Iterate through the samples to set the bait file. for sample in self.runmetadata.samples: if sample.general.bestassemblyfile != 'NA': # Remove the file extension ...
Makes blast database files from targets as necessary
entailment
def blast(self): """ Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database """ logging.info('BLASTing FASTA files against {} database'.format(self.analysistype)) for _ in range(self.cpus): threads = Thread(target=self.blastthreads, a...
Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database
entailment
def blastparse(self): """ Parse the blast results, and store necessary data in dictionaries in sample object """ logging.info('Parsing BLAST results') # Load the NCBI 16S reference database as a dictionary for sample in self.runmetadata.samples: if sample.gene...
Parse the blast results, and store necessary data in dictionaries in sample object
entailment
def reporter(self): """ Creates a report of the results """ # Create the path in which the reports are stored make_path(self.reportpath) logging.info('Creating {} report'.format(self.analysistype)) # Initialise the header and data strings header = 'Strain,...
Creates a report of the results
entailment
def add_listener(self, evt_name, fn): """添加观察者函数。 :params evt_name: 事件名称 :params fn: 要注册的触发函数函数 .. note:: 允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。 """ self._listeners.setdefault(evt_name, []) listeners = self.__get_listeners(evt_name) lis...
添加观察者函数。 :params evt_name: 事件名称 :params fn: 要注册的触发函数函数 .. note:: 允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。
entailment
def remove_listener(self, evt_name, fn, remove_all=False): """删除观察者函数。 :params evt_name: 事件名称 :params fn: 要注册的触发函数函数 :params remove_all: 是否删除fn在evt_name中的所有注册\n 如果为 `True`,则删除所有\n 如果为 `False`,则按注册先后顺序删除第一个\n .. note:: ...
删除观察者函数。 :params evt_name: 事件名称 :params fn: 要注册的触发函数函数 :params remove_all: 是否删除fn在evt_name中的所有注册\n 如果为 `True`,则删除所有\n 如果为 `False`,则按注册先后顺序删除第一个\n .. note:: 允许一个函数多次注册,多次注册意味着一次时间多次调用。
entailment
def has_listener(self, evt_name, fn): """指定listener是否存在 :params evt_name: 事件名称 :params fn: 要注册的触发函数函数 """ listeners = self.__get_listeners(evt_name) return fn in listeners
指定listener是否存在 :params evt_name: 事件名称 :params fn: 要注册的触发函数函数
entailment
def fire_event(self, evt_name, *args, **kwargs): """触发事件 :params evt_name: 事件名称 :params args: 给事件接受者的参数 :params kwargs: 给事件接受者的参数 """ listeners = self.__get_listeners(evt_name) evt = self.generate_event(evt_name) for listener in listeners: lis...
触发事件 :params evt_name: 事件名称 :params args: 给事件接受者的参数 :params kwargs: 给事件接受者的参数
entailment
def create_server_ec2(connection, region, disk_name, disk_size, ami, key_pair, instance_type, tags={}, security_groups=None, ...
Creates EC2 Instance
entailment
def destroy_ebs_volume(connection, region, volume_id, log=False): """ destroys an ebs volume """ if ebs_volume_exists(connection, region, volume_id): if log: log_yellow('destroying EBS volume ...') try: connection.delete_volume(volume_id) except: # ou...
destroys an ebs volume
entailment
def destroy_ec2(connection, region, instance_id, log=False): """ terminates the instance """ data = get_ec2_info(connection=connection, instance_id=instance_id, region=region) instance = connection.terminate_instances(instance_ids=[data['id']])[0] if log...
terminates the instance
entailment
def down_ec2(connection, instance_id, region, log=False): """ shutdown of an existing EC2 instance """ # get the instance_id from the state file, and stop the instance instance = connection.stop_instances(instance_ids=instance_id)[0] while instance.state != "stopped": if log: log_yel...
shutdown of an existing EC2 instance
entailment
def ebs_volume_exists(connection, region, volume_id): """ finds out if a ebs volume exists """ for vol in connection.get_all_volumes(): if vol.id == volume_id: return True return False
finds out if a ebs volume exists
entailment
def get_ec2_info(connection, instance_id, region, username=None): """ queries EC2 for details about a particular instance_id """ instance = connection.get_only_instances( filters={'instance_id': instance_id} )[0] data = instance.__dict_...
queries EC2 for details about a particular instance_id
entailment
def up_ec2(connection, region, instance_id, wait_for_ssh_available=True, log=False, timeout=600): """ boots an existing ec2_instance """ # boot the ec2 instance instance = connection.start_instances(instance_ids=instance_id)[0] instance.update() ...
boots an existing ec2_instance
entailment
def apply_T4(word): '''An agglutination diphthong that ends in /u, y/ usually contains a syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us], [va.ka.ut.taa].''' WORD = word.split('.') for i, v in enumerate(WORD): # i % 2 != 0 prevents this rule from applying to first, third, etc. ...
An agglutination diphthong that ends in /u, y/ usually contains a syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us], [va.ka.ut.taa].
entailment
def seqs_from_file(filename, exit_on_err=False, return_qual=False): """Extract sequences from a file Name: seqs_from_file Author(s): Martin C F Thomsen Date: 18 Jul 2013 Description: Iterator which extract sequence data from the input file Args: filename: string which...
Extract sequences from a file Name: seqs_from_file Author(s): Martin C F Thomsen Date: 18 Jul 2013 Description: Iterator which extract sequence data from the input file Args: filename: string which contain a path to the input file Supported Formats: fasta, fastq...
entailment
def open_(filename, mode=None, compresslevel=9): """Switch for both open() and gzip.open(). Determines if the file is normal or gzipped by looking at the file extension. The filename argument is required; mode defaults to 'rb' for gzip and 'r' for normal and compresslevel defaults to 9 for gzip. ...
Switch for both open() and gzip.open(). Determines if the file is normal or gzipped by looking at the file extension. The filename argument is required; mode defaults to 'rb' for gzip and 'r' for normal and compresslevel defaults to 9 for gzip. >>> import gzip >>> from contextlib import cl...
entailment
def load_json(json_object): ''' Load json from file or file name ''' content = None if isinstance(json_object, str) and os.path.exists(json_object): with open_(json_object) as f: try: content = json.load(f) except Exception as e: debug.log("Warning: Content of '%...
Load json from file or file name
entailment
def sort2groups(array, gpat=['_R1','_R2']): """ Sort an array of strings to groups by patterns """ groups = [REGroup(gp) for gp in gpat] unmatched = [] for item in array: matched = False for m in groups: if m.match(item): matched = True break if not matched...
Sort an array of strings to groups by patterns
entailment
def sort_and_distribute(array, splits=2): """ Sort an array of strings to groups by alphabetically continuous distribution """ if not isinstance(array, (list,tuple)): raise TypeError("array must be a list") if not isinstance(splits, int): raise TypeError("splits must be an integer") remaining = so...
Sort an array of strings to groups by alphabetically continuous distribution
entailment
def mkpath(filepath, permissions=0o777): """ This function executes a mkdir command for filepath and with permissions (octal number with leading 0 or string only) # eg. mkpath("path/to/file", "0o775") """ # Converting string of octal to integer, if string is given. if isinstance(permissions, str): ...
This function executes a mkdir command for filepath and with permissions (octal number with leading 0 or string only) # eg. mkpath("path/to/file", "0o775")
entailment