INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
displays the doc string of the selected element | def show_info(self):
"""
displays the doc string of the selected element
"""
sender = self.sender()
tree = sender.parent()
index = tree.selectedIndexes()
info = ''
if index != []:
index = index[0]
name = str(index.model().itemFromIn... |
opens a file dialog to get the path to a file and | def open_file_dialog(self):
"""
opens a file dialog to get the path to a file and
"""
dialog = QtWidgets.QFileDialog
filename, _ = dialog.getOpenFileName(self, 'Select a file:', self.txt_probe_log_path.text())
if str(filename) != '':
self.txt_probe_log_path.se... |
loads the elements from file filename | def load_elements(self, filename):
"""
loads the elements from file filename
"""
input_data = load_b26_file(filename)
if isinstance(input_data, dict) and self.elements_type in input_data:
return input_data[self.elements_type]
else:
return {} |
fills a tree with nested parameters
Args:
tree: QtGui.QTreeView
parameters: dictionary or Parameter object
Returns: | def fill_tree(self, tree, input_dict):
"""
fills a tree with nested parameters
Args:
tree: QtGui.QTreeView
parameters: dictionary or Parameter object
Returns:
"""
def add_element(item, key, value):
child_name = QtGui.QStandardItem(ke... |
Returns: the selected instruments | def get_values(self):
"""
Returns: the selected instruments
"""
elements_selected = {}
for index in range(self.tree_loaded_model.rowCount()):
element_name = str(self.tree_loaded_model.item(index).text())
if element_name in self.elements_old:
... |
creates a script sequence based on the script iterator type selected and the selected scripts and sends it to the tree
self.tree_loaded | def add_script_sequence(self):
"""
creates a script sequence based on the script iterator type selected and the selected scripts and sends it to the tree
self.tree_loaded
"""
def empty_tree(tree_model):
# COMMENT_ME
def add_children_to_list(item, somelis... |
Expose compiler to factory.
:param func: the callable to expose
:type func: callable
:param name: name of format
:type name: str
It can be used as a decorator::
@register(name='my:validator')
def my_validator(obj):
if obj is True:
return obj
... | def register(func=None, name=None):
"""
Expose compiler to factory.
:param func: the callable to expose
:type func: callable
:param name: name of format
:type name: str
It can be used as a decorator::
@register(name='my:validator')
def my_validator(obj):
if obj... |
Cli for testing the ped parser. | def cli(family_file, family_type, to_json, to_madeline, to_ped, to_dict,
outfile, logfile, loglevel):
"""Cli for testing the ped parser."""
from pprint import pprint as pp
my_parser = FamilyParser(family_file, family_type)
if to_json:
if outfile:
outfile.write(my_p... |
Return a individual object based on the indata.
Arguments:
family_id (str): The id for this family
sample_id (str): The id for this sample
father_id (str): The id for this samples father
mother_id (str): The id for this samples mother
sex (str... | def get_individual(self, family_id, sample_id, father_id, mother_id, sex, phenotype,
genetic_models = None, proband='.', consultand='.', alive='.'):
"""
Return a individual object based on the indata.
Arguments:
family_id (str): The id for this family
... |
Check if the line is correctly formated. Throw a SyntaxError if it is not. | def check_line_length(self, splitted_line, expected_length):
"""
Check if the line is correctly formated. Throw a SyntaxError if it is not.
"""
if len(splitted_line) != expected_length:
raise WrongLineFormat(
message='WRONG FORMATED PED LINE!',
... |
Parse .ped formatted family info.
Add all family info to the parser object
Arguments:
family_info (iterator): An iterator with family info | def ped_parser(self, family_info):
"""
Parse .ped formatted family info.
Add all family info to the parser object
Arguments:
family_info (iterator): An iterator with family info
"""
for line in family_info:
# Che... |
Parse alternative formatted family info
This parses a information with more than six columns.
For alternative information header comlumn must exist and each row
must have the same amount of columns as the header.
First six columns must be the same as in the ped format.
... | def alternative_parser(self, family_file):
"""
Parse alternative formatted family info
This parses a information with more than six columns.
For alternative information header comlumn must exist and each row
must have the same amount of columns as the header.
... |
Take the ID and check if it is following the cmms standard.
The standard is year:id-generation-indcode:affectionstatus.
Year is two digits, id three digits, generation in roman letters
indcode are digits and affection status are in ['A', 'U', 'X'].
Example 11001-II-1A.
I... | def check_cmms_id(self, ind_id):
"""
Take the ID and check if it is following the cmms standard.
The standard is year:id-generation-indcode:affectionstatus.
Year is two digits, id three digits, generation in roman letters
indcode are digits and affection status are in ['A', 'U', ... |
Check if the affection status is correct.
Args:
ind_object : An Individuals object
Yields:
bool : True if affection status is correct
False otherwise | def check_cmms_affection_status(self, ind_object):
"""
Check if the affection status is correct.
Args:
ind_object : An Individuals object
Yields:
bool : True if affection status is correct
False otherwise
"""
... |
Check if the phenotype is correct.
Args:
ind_object : An Individuals object
Yields:
bool : True if phenotype status is correct
False otherwise | def check_cmms_gender(self, ind_object):
"""
Check if the phenotype is correct.
Args:
ind_object : An Individuals object
Yields:
bool : True if phenotype status is correct
False otherwise
"""
ind_id = ind_obje... |
Check what genetic models that are found and return them as a set.
Args:
genetic_models : A string with genetic models
Yields:
correct_model_names : A set with the correct model names | def get_models(self, genetic_models):
"""
Check what genetic models that are found and return them as a set.
Args:
genetic_models : A string with genetic models
Yields:
correct_model_names : A set with the correct model names
"""
... |
Return the information from the pedigree file as a dictionary.
family id is key and a list with dictionarys for each individual
as value.
Returns:
families (dict): A dictionary with the families | def to_dict(self):
"""
Return the information from the pedigree file as a dictionary.
family id is key and a list with dictionarys for each individual
as value.
Returns:
families (dict): A dictionary with the families
"""
self.logger... |
Return a generator with the info in madeline format.
Yields:
An iterator with family info in madeline format | def to_madeline(self):
"""
Return a generator with the info in madeline format.
Yields:
An iterator with family info in madeline format
"""
madeline_header = [
'FamilyID',
'IndividualID',
'Gender',
'... |
Return a generator with the info in ped format.
Yields:
An iterator with the family info in ped format | def to_ped(self):
"""
Return a generator with the info in ped format.
Yields:
An iterator with the family info in ped format
"""
ped_header = [
'#FamilyID',
'IndividualID',
'PaternalID',
'MaternalID',
... |
deck vote tag address | def deck_vote_tag(deck: Deck) -> str:
'''deck vote tag address'''
if deck.id is None:
raise Exception("deck.id is required")
deck_vote_tag_privkey = sha256(unhexlify(deck.id) + b"vote_init").hexdigest()
deck_vote_tag_address = Kutil(network=deck.network, privkey=bytearray.fromhex(deck_vote_tag... |
decode vote init tx op_return protobuf message and validate it. | def parse_vote_info(protobuf: bytes) -> dict:
'''decode vote init tx op_return protobuf message and validate it.'''
vote = pavoteproto.Vote()
vote.ParseFromString(protobuf)
assert vote.version > 0, {"error": "Vote info incomplete, version can't be 0."}
assert vote.start_block < vote.end_block, {"e... |
initialize vote transaction, must be signed by the deck_issuer privkey | def vote_init(vote: Vote, inputs: dict, change_address: str) -> bytes:
'''initialize vote transaction, must be signed by the deck_issuer privkey'''
network_params = net_query(vote.deck.network)
deck_vote_tag_address = deck_vote_tag(vote.deck)
tx_fee = network_params.min_tx_fee # settle for min tx fee... |
find vote_inits on this deck | def find_vote_inits(provider: Provider, deck: Deck) -> Iterable[Vote]:
'''find vote_inits on this deck'''
vote_ints = provider.listtransactions(deck_vote_tag(deck))
for txid in vote_ints:
try:
raw_vote = provider.getrawtransaction(txid)
vote = parse_vote_info(read_tx_opretu... |
vote cast transaction | def vote_cast(vote: Vote, choice_index: int, inputs: dict,
change_address: str) -> bytes:
'''vote cast transaction'''
network_params = net_query(vote.deck.network)
vote_cast_addr = vote.vote_choice_address[choice_index]
tx_fee = network_params.min_tx_fee # settle for min tx fee for now
... |
find and verify vote_casts on this vote_choice_address | def find_vote_casts(provider: Provider, vote: Vote, choice_index: int) -> Iterable[VoteCast]:
'''find and verify vote_casts on this vote_choice_address'''
vote_casts = provider.listtransactions(vote.vote_choice_address[choice_index])
for tx in vote_casts:
raw_tx = provider.getrawtransaction(tx, 1)
... |
encode vote into protobuf | def to_protobuf(self) -> str:
'''encode vote into protobuf'''
vote = pavoteproto.Vote()
vote.version = self.version
vote.description = self.description
vote.count_mode = vote.MODE.Value(self.count_mode)
vote.start_block = self.start_block
vote.end_block = self.en... |
vote info as dict | def to_dict(self) -> dict:
'''vote info as dict'''
return {
"version": self.version,
"description": self.description,
"count_mode": self.count_mode,
"start_block": self.start_block,
"end_block": self.end_block,
"choices": self.choi... |
calculate the addresses on which the vote is casted. | def vote_choice_address(self) -> List[str]:
'''calculate the addresses on which the vote is casted.'''
if self.vote_id is None:
raise Exception("vote_id is required")
addresses = []
vote_init_txid = unhexlify(self.vote_id)
for choice in self.choices:
vo... |
check if VoteCast is valid | def is_valid(self) -> bool:
'''check if VoteCast is valid'''
if not (self.blocknum >= self.vote.start_block and
self.blocknum <= self.vote.end_block):
return False
if not self.confirmations >= 6:
return False
return True |
This checks to see if a sequence already exists in the reference data. If it does, then it'll return the known annotation.
:return: The Annotation of associated with the input sequence
:rtype: :ref:`ann`
Example:
>>> from Bio.Seq import Seq
>>> from seqann.models.refer... | def search_refdata(self, seq, locus):
"""
This checks to see if a sequence already exists in the reference data. If it does, then it'll return the known annotation.
:return: The Annotation of associated with the input sequence
:rtype: :ref:`ann`
Example:
>>> from B... |
Gets the Annotation from the found sequence
:return: The Annotation from the found sequence
:rtype: Annotation | def seqrecord(self, allele, locus):
"""
Gets the Annotation from the found sequence
:return: The Annotation from the found sequence
:rtype: Annotation
"""
try:
db = self.server[self.dbversion + "_" + locus]
except:
self.logger.error("The d... |
Gets the Annotation from the found sequence
:return: The Annotation from the found sequence
:rtype: Annotation | def seqannotation(self, seqrecord, allele, loc):
"""
Gets the Annotation from the found sequence
:return: The Annotation from the found sequence
:rtype: Annotation
"""
#seqrecord = self.seqrecord(allele, loc)
complete_annotation = get_features(seqrecord)
... |
updates the values of the parameter, just as a regular dictionary | def update(self, *args):
"""
updates the values of the parameter, just as a regular dictionary
"""
for d in args:
for (key, value) in d.items():
self.__setitem__(key, value) |
check is the value is valid
Args:
value: value to be tested
valid_values: allowed valid values (type or list of values)
Returns: | def is_valid(value, valid_values):
"""
check is the value is valid
Args:
value: value to be tested
valid_values: allowed valid values (type or list of values)
Returns:
"""
valid = False
if isinstance(valid_values, type) and type(value) ... |
Print, output error message and raise RuntimeError. | def error(msg, log_file=None):
"""Print, output error message and raise RuntimeError."""
UtilClass.print_msg(msg + os.linesep)
if log_file is not None:
UtilClass.writelog(log_file, msg, 'append')
raise RuntimeError(msg) |
Output log message. | def log(lines, log_file=None):
"""Output log message."""
err = False
for line in lines:
print(line)
if log_file is not None:
UtilClass.writelog(log_file, line, 'append')
if 'BAD TERMINATION' in line.upper():
err = True
... |
Write time log. | def write_time_log(logfile, time):
"""Write time log."""
if os.path.exists(logfile):
log_status = open(logfile, 'a', encoding='utf-8')
else:
log_status = open(logfile, 'w', encoding='utf-8')
log_status.write('Function Name\tRead Time\tCompute Time\tWrite Time\... |
Check the existence of the given file and directory path.
1. Raise Runtime exception of both not existed.
2. If the ``curwp`` is None, the set the base folder of ``curinf`` to it. | def check_infile_and_wp(curinf, curwp):
"""Check the existence of the given file and directory path.
1. Raise Runtime exception of both not existed.
2. If the ``curwp`` is None, the set the base folder of ``curinf`` to it.
"""
if not os.path.exists(curinf):
if c... |
Run TauDEM function.
- 1. The command will not execute if any input file does not exist.
- 2. An error will be detected after running the TauDEM command if
any output file does not exist;
Args:
function_name (str): Full path of TauDEM function.
in_files ... | def run(function_name, in_files, wp=None, in_params=None, out_files=None, mpi_params=None,
log_params=None):
"""
Run TauDEM function.
- 1. The command will not execute if any input file does not exist.
- 2. An error will be detected after running the TauDEM command if
... |
Run pit remove using the flooding approach | def pitremove(np, dem, filleddem, workingdir=None, mpiexedir=None, exedir=None, log_file=None,
runtime_file=None, hostfile=None):
"""Run pit remove using the flooding approach """
fname = TauDEM.func_name('pitremove')
return TauDEM.run(FileClass.get_executable_fullpath(fname, e... |
Run D8 flow direction | def d8flowdir(np, filleddem, flowdir, slope, workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run D8 flow direction"""
fname = TauDEM.func_name('d8flowdir')
return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir),
... |
Run Dinf flow direction | def dinfflowdir(np, filleddem, flowangle, slope, workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run Dinf flow direction"""
fname = TauDEM.func_name('dinfflowdir')
return TauDEM.run(FileClass.get_executable_fullpath(fname, ex... |
Run Accumulate area according to D8 flow direction | def aread8(np, flowdir, acc, outlet=None, streamskeleton=None, edgecontaimination=False,
workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run Accumulate area according to D8 flow direction"""
# -nc means do not consider edge... |
Run Accumulate area according to Dinf flow direction | def areadinf(np, angfile, sca, outlet=None, wg=None, edgecontaimination=False,
workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run Accumulate area according to Dinf flow direction"""
# -nc means do not consider edge con... |
Reads an ad8 contributing area file,
identifies the location of the largest ad8 value as the outlet of the largest watershed | def connectdown(np, p, acc, outlet, wtsd=None, workingdir=None, mpiexedir=None,
exedir=None, log_file=None, runtime_file=None, hostfile=None):
"""Reads an ad8 contributing area file,
identifies the location of the largest ad8 value as the outlet of the largest watershed"""
# ... |
Run gridnet | def gridnet(np, pfile, plenfile, tlenfile, gordfile, outlet=None, workingdir=None,
mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None):
"""Run gridnet"""
fname = TauDEM.func_name('gridnet')
return TauDEM.run(FileClass.get_executable_fullpath(fname, exedi... |
Run threshold for stream raster | def threshold(np, acc, stream_raster, threshold=100., workingdir=None,
mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None):
"""Run threshold for stream raster"""
fname = TauDEM.func_name('threshold')
return TauDEM.run(FileClass.get_executable_fullpath(... |
Run streamnet | def streamnet(np, filleddem, flowdir, acc, streamRaster, modifiedOutlet,
streamOrder, chNetwork, chCoord, streamNet, subbasin, workingdir=None,
mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None):
"""Run streamnet"""
fname = TauDEM.func_name(... |
Run move the given outlets to stream | def moveoutletstostrm(np, flowdir, streamRaster, outlet, modifiedOutlet,
workingdir=None, mpiexedir=None,
exedir=None, log_file=None, runtime_file=None, hostfile=None):
"""Run move the given outlets to stream"""
fname = TauDEM.func_name('moveoutletstos... |
Convert distance method to h, v, p, and s. | def convertdistmethod(method_str):
"""Convert distance method to h, v, p, and s."""
if StringClass.string_match(method_str, 'Horizontal'):
return 'h'
elif StringClass.string_match(method_str, 'Vertical'):
return 'v'
elif StringClass.string_match(method_str, 'Pytha... |
Convert statistics method to ave, min, and max. | def convertstatsmethod(method_str):
"""Convert statistics method to ave, min, and max."""
if StringClass.string_match(method_str, 'Average'):
return 'ave'
elif StringClass.string_match(method_str, 'Maximum'):
return 'max'
elif StringClass.string_match(method_str, ... |
Run D8 horizontal distance down to stream. | def d8hdisttostrm(np, p, src, dist, thresh, workingdir=None,
mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None):
"""Run D8 horizontal distance down to stream.
"""
fname = TauDEM.func_name('d8hdisttostrm')
return TauDEM.run(FileClass.get_ex... |
Run D8 distance down to stream by different method for distance.
This function is extended from d8hdisttostrm by Liangjun.
Please clone `TauDEM by lreis2415`_ and compile for this program.
.. _TauDEM by lreis2415:
https://github.com/lreis2415/TauDEM | def d8distdowntostream(np, p, fel, src, dist, distancemethod, thresh, workingdir=None,
mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run D8 distance down to stream by different method for distance.
This function is... |
Run D-inf distance down to stream | def dinfdistdown(np, ang, fel, slp, src, statsm, distm, edgecontamination, wg, dist,
workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run D-inf distance down to stream"""
in_params = {'-m': '%s %s' % (TauDEM.conv... |
Run peuker-douglas function | def peukerdouglas(np, fel, streamSkeleton, workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run peuker-douglas function"""
fname = TauDEM.func_name('peukerdouglas')
return TauDEM.run(FileClass.get_executable_fullpath(fname, ... |
Drop analysis for optimal threshold for extracting stream. | def dropanalysis(np, fel, p, ad8, ssa, outlet, minthresh, maxthresh, numthresh,
logspace, drp, workingdir=None,
mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None):
"""Drop analysis for optimal threshold for extracting stream."""
parstr... |
Watershed Delineation. | def watershed_delineation(np, dem, outlet_file=None, thresh=0, singlebasin=False,
workingdir=None, mpi_bin=None, bin_dir=None,
logfile=None, runtime_file=None, hostfile=None):
"""Watershed Delineation."""
# 1. Check directories
if not o... |
Keep the same color for the same graph.
Warning: due to the structure of Python iterators I couldn't help but
iterate over all the cycle twice. One first time to get the number of elements
in the cycle, one second time to stop just before the last. And this still
only works assuming your cycle doesn't... | def keep_color(ax=None):
''' Keep the same color for the same graph.
Warning: due to the structure of Python iterators I couldn't help but
iterate over all the cycle twice. One first time to get the number of elements
in the cycle, one second time to stop just before the last. And this still
only ... |
Return the next color to be used in the given color cycle.
Warning: due to the structure of Python iterators I couldn't help but
iterate over all the color cycle once.
If nonintrusive is True, then leave the color cycle in the same state as
before | def get_next_color(ax=None, nonintrusive=True):
''' Return the next color to be used in the given color cycle.
Warning: due to the structure of Python iterators I couldn't help but
iterate over all the color cycle once.
If nonintrusive is True, then leave the color cycle in the same state as
... |
Resolve from documents.
:param pointer: foo
:type pointer: DocumentPointer | def resolve(self, pointer):
"""Resolve from documents.
:param pointer: foo
:type pointer: DocumentPointer
"""
dp = DocumentPointer(pointer)
obj, fetcher = self.prototype(dp)
for token in dp.pointer:
obj = token.extract(obj, bypass_ref=True)
... |
align_seqs - Aligns sequences with clustalo
:param found_seqs: List of the reference sequences
:type found_seqs: ``List``
:param sequence: The input consensus sequence.
:type sequence: SeqRecord
:param locus: The gene locus associated with the sequence.
:type locus: ``str``
:param annotated... | def align_seqs(found_seqs, sequence, locus, start_pos, missing,
annotated, cutoff=0.90, verbose=False, verbosity=0):
"""
align_seqs - Aligns sequences with clustalo
:param found_seqs: List of the reference sequences
:type found_seqs: ``List``
:param sequence: The input consensus sequ... |
find_features - Finds the reference sequence features in the alignments and records the positions
:param feats: Dictonary of sequence features
:type feats: ``dict``
:param sequ: The sequence alignment for the input sequence
:type sequ: ``List``
:param annotated: dictonary of the annotated features... | def find_features(feats, sequ, annotated, start_pos, cutoff):
"""
find_features - Finds the reference sequence features in the alignments and records the positions
:param feats: Dictonary of sequence features
:type feats: ``dict``
:param sequ: The sequence alignment for the input sequence
:typ... |
resolve_feats - Resolves features from alignments
:param feat_list: List of the found features
:type feat_list: ``List``
:param seqin: The input sequence
:type seqin: ``str``
:param locus: The input locus
:type locus: ``str``
:param start: Where the sequence start in the alignment
:type... | def resolve_feats(feat_list, seqin, seqref, start, locus, missing, verbose=False, verbosity=0):
"""
resolve_feats - Resolves features from alignments
:param feat_list: List of the found features
:type feat_list: ``List``
:param seqin: The input sequence
:type seqin: ``str``
:param locus: Th... |
count_diffs - Counts the number of mismatches, gaps, and insertions and then determines if those are within an acceptable range.
:param align: The alignment
:type align: ``List``
:param feats: Dictonary of the features
:type feats: ``dict``
:param locus: The gene locus associated with the sequence.... | def count_diffs(align, feats, inseq, locus, cutoff,
verbose=False, verbosity=0):
"""
count_diffs - Counts the number of mismatches, gaps, and insertions and then determines if those are within an acceptable range.
:param align: The alignment
:type align: ``List``
:param feats: Dicto... |
Stops the instance | def cmd_stop(self, argv, help):
"""Stops the instance"""
parser = argparse.ArgumentParser(
prog="%s stop" % self.progname,
description=help,
)
instances = self.get_instances(command='stop')
parser.add_argument("instance", nargs=1,
... |
Terminates the instance | def cmd_terminate(self, argv, help):
"""Terminates the instance"""
from ploy.common import yesno
parser = argparse.ArgumentParser(
prog="%s terminate" % self.progname,
description=help,
)
instances = self.get_instances(command='terminate')
parser.a... |
Starts the instance | def cmd_start(self, argv, help):
"""Starts the instance"""
parser = argparse.ArgumentParser(
prog="%s start" % self.progname,
description=help,
)
instances = self.get_instances(command='start')
parser.add_argument("instance", nargs=1,
... |
Prints annotated config | def cmd_annotate(self, argv, help):
"""Prints annotated config"""
parser = argparse.ArgumentParser(
prog="%s annotate" % self.progname,
description=help,
)
parser.parse_args(argv)
list(self.instances.values()) # trigger instance augmentation
for g... |
Prints some debug info for this script | def cmd_debug(self, argv, help):
"""Prints some debug info for this script"""
parser = argparse.ArgumentParser(
prog="%s debug" % self.progname,
description=help,
)
instances = self.instances
parser.add_argument("instance", nargs=1,
... |
Return a list of various things | def cmd_list(self, argv, help):
"""Return a list of various things"""
parser = argparse.ArgumentParser(
prog="%s list" % self.progname,
description=help,
)
parser.add_argument("list", nargs=1,
metavar="listname",
... |
Log into the instance with ssh using the automatically generated known hosts | def cmd_ssh(self, argv, help):
"""Log into the instance with ssh using the automatically generated known hosts"""
parser = argparse.ArgumentParser(
prog="%s ssh" % self.progname,
description=help,
)
instances = self.get_instances(command='init_ssh_key')
pa... |
Print help | def cmd_help(self, argv, help):
"""Print help"""
parser = argparse.ArgumentParser(
prog="%s help" % self.progname,
description=help,
)
parser.add_argument('-z', '--zsh',
action='store_true',
help="Print info ... |
Common initialization of handlers happens here. If additional
initialization is required, this method must either be called with
``super`` or the child class must assign the ``store`` attribute and
register itself with the store. | def initialize(self, store):
"""Common initialization of handlers happens here. If additional
initialization is required, this method must either be called with
``super`` or the child class must assign the ``store`` attribute and
register itself with the store.
"""
... |
Log access. | def prepare(self):
"""Log access."""
request_time = 1000.0 * self.request.request_time()
access_log.info(
"%d %s %.2fms", self.get_status(),
self._request_summary(), request_time) |
Pushes data to a listener. | async def publish(self, message):
"""Pushes data to a listener."""
try:
self.write('data: {}\n\n'.format(message))
await self.flush()
except StreamClosedError:
self.finished = True |
Register with the publisher. | async def open(self):
"""Register with the publisher."""
self.store.register(self)
while not self.finished:
message = await self.messages.get()
await self.publish(message) |
Push a new message to the client. The data will be
available as a JSON object with the key ``data``. | async def publish(self, message):
"""Push a new message to the client. The data will be
available as a JSON object with the key ``data``.
"""
try:
self.write_message(dict(data=message))
except WebSocketClosedError:
self._close() |
Given a key, given an iv, and message
do whatever operation asked in the operation field.
Operation will be checked for: "decrypt" and "encrypt" strings.
Returns the message encrypted/decrypted.
message must be a multiple by 16 bytes (for division in 16 byte blocks)
key must be 32 byte
iv ... | def _ige(message, key, iv, operation="decrypt"):
"""Given a key, given an iv, and message
do whatever operation asked in the operation field.
Operation will be checked for: "decrypt" and "encrypt" strings.
Returns the message encrypted/decrypted.
message must be a multiple by 16 bytes (for divis... |
Switch to specific chunk
:param index: | def _useChunk(self, index) -> None:
"""
Switch to specific chunk
:param index:
"""
if self.currentChunk is not None:
if self.currentChunkIndex == index and \
not self.currentChunk.closed:
return
self.currentChunk.close... |
This will iterate only over the last chunk since the name of the last
chunk indicates how many lines in total exist in all other chunks | def numKeys(self) -> int:
"""
This will iterate only over the last chunk since the name of the last
chunk indicates how many lines in total exist in all other chunks
"""
chunks = self._listChunks()
num_chunks = len(chunks)
if num_chunks == 0:
return 0
... |
Store iterator
:return: Iterator for data in all chunks | def iterator(self, includeKey=True, includeValue=True, prefix=None):
"""
Store iterator
:return: Iterator for data in all chunks
"""
if not (includeKey or includeValue):
raise ValueError("At least one of includeKey or includeValue "
"sho... |
Expose compiler to factory.
:param compiler: the callable to expose
:type compiler: callable
:param spec: name of the spec
:type spec: str
It can be used as a decorator::
@register(spec='my:first:spec')
def my_compiler(schema, pointer, context):
return Validator(schema... | def register(compiler=None, spec=None):
"""
Expose compiler to factory.
:param compiler: the callable to expose
:type compiler: callable
:param spec: name of the spec
:type spec: str
It can be used as a decorator::
@register(spec='my:first:spec')
def my_compiler(schema, po... |
Register a new subscriber. This method should be invoked by
listeners to start receiving messages. | def register(self, subscriber):
"""Register a new subscriber. This method should be invoked by
listeners to start receiving messages.
"""
assert isinstance(subscriber, RequestHandler)
logger.debug('New subscriber')
self.subscribers.add(subscriber) |
Stop publishing to a subscriber. | def deregister(self, subscriber):
"""Stop publishing to a subscriber."""
try:
logger.debug('Subscriber left')
self.subscribers.remove(subscriber)
except KeyError:
logger.debug(
'Error removing subscriber: ' +
str(subscri... |
Stop the publishing loop. | def shutdown(self):
"""Stop the publishing loop."""
self._done.set()
self.executor.shutdown(wait=False) |
annotate - method for annotating a BioPython sequence
:param sequence: The input consensus sequence.
:type sequence: Seq
:param locus: The gene locus associated with the sequence.
:type locus: ``str``
:param nseqs: The number of blast sequences to use.
:type nseqs: ``int... | def annotate(self, sequence: Seq=None, locus: str=None,
nseqs: int=20, alignseqs: int=10,
skip: List=[],
rerun: bool=True,
full: bool=True) -> Annotation:
"""
annotate - method for annotating a BioPython sequence
:param sequenc... |
ref_align - Method for doing targeted alignments on partial annotations
:param found_seqs: The input sequence record.
:type found_seqs: Seq
:param sequence: The input sequence record.
:type sequence: Seq
:param locus: The gene locus associated with the sequence.
:type lo... | def ref_align(self, found_seqs, sequence: Seq=None,
locus: str=None, annotation: Annotation=None,
partial_ann: Annotation=None,
run: int=0,
cutoff: float=.90) -> Annotation:
"""
ref_align - Method for doing targeted alignments on pa... |
add_alignment - method for adding the alignment to an annotation
:param ref_seq: List of reference sequences
:type ref_seq: List
:param annotation: The complete annotation
:type annotation: Annotation
:rtype: Annotation | def add_alignment(self, ref_seq, annotation) -> Annotation:
"""
add_alignment - method for adding the alignment to an annotation
:param ref_seq: List of reference sequences
:type ref_seq: List
:param annotation: The complete annotation
:type annotation: Annotation
... |
r"""Convert python object to xml string.
:param data: data for build xml. If don't provide the ``root`` option, type of ``data`` must be dict and ``len(data) == 1``.
:rtype: str or unicode
.. versionadded:: 1.2 | def object2xml(self, data):
r"""Convert python object to xml string.
:param data: data for build xml. If don't provide the ``root`` option, type of ``data`` must be dict and ``len(data) == 1``.
:rtype: str or unicode
.. versionadded:: 1.2
"""
if not self.__options['enco... |
r"""Build xml tree.
:param data: data for build xml.
:param tagname: element tag name.
:param attrs: element attributes. Default:``None``.
:type attrs: dict or None
:param depth: element depth of the hierarchy. Default:``0``.
:type depth: int | def build_tree(self, data, tagname, attrs=None, depth=0):
r"""Build xml tree.
:param data: data for build xml.
:param tagname: element tag name.
:param attrs: element attributes. Default:``None``.
:type attrs: dict or None
:param depth: element depth of the hierarchy. De... |
r"""Check structure availability by ``attrkey`` and ``valuekey`` option. | def check_structure(self, keys):
r"""Check structure availability by ``attrkey`` and ``valuekey`` option.
"""
return set(keys) <= set([self.__options['attrkey'], self.__options['valuekey']]) |
r"""Pick data from ``attrkey`` and ``valuekey`` option.
:return: a pair of (attrs, values)
:rtype: tuple | def pickdata(self, data):
r"""Pick data from ``attrkey`` and ``valuekey`` option.
:return: a pair of (attrs, values)
:rtype: tuple
"""
attrs = data.get(self.__options['attrkey']) or {}
values = data.get(self.__options['valuekey']) or ''
return (attrs, values) |
r"""Convert xml special chars to entities.
:param data: the data will be converted safe.
:param cdata: whether to use cdata. Default:``True``. If not, use :func:`cgi.escape` to convert data.
:type cdata: bool
:rtype: str | def safedata(self, data, cdata=True):
r"""Convert xml special chars to entities.
:param data: the data will be converted safe.
:param cdata: whether to use cdata. Default:``True``. If not, use :func:`cgi.escape` to convert data.
:type cdata: bool
:rtype: str
"""
... |
r"""Build tag full info include the attributes.
:param tag: tag name.
:param text: tag text.
:param attrs: tag attributes. Default:``None``.
:type attrs: dict or None
:rtype: str | def build_tag(self, tag, text='', attrs=None):
r"""Build tag full info include the attributes.
:param tag: tag name.
:param text: tag text.
:param attrs: tag attributes. Default:``None``.
:type attrs: dict or None
:rtype: str
"""
return '%s%s%s' % (self.t... |
r"""Build tag attributes.
:param attrs: tag attributes
:type attrs: dict
:rtype: str | def build_attr(self, attrs):
r"""Build tag attributes.
:param attrs: tag attributes
:type attrs: dict
:rtype: str
"""
attrs = sorted(attrs.iteritems(), key=lambda x: x[0])
return ' '.join(map(lambda x: '%s="%s"' % x, attrs)) |
r"""Build started tag info.
:param tag: tag name
:param attrs: tag attributes. Default:``None``.
:type attrs: dict or None
:rtype: str | def tag_start(self, tag, attrs=None):
r"""Build started tag info.
:param tag: tag name
:param attrs: tag attributes. Default:``None``.
:type attrs: dict or None
:rtype: str
"""
return '<%s %s>' % (tag, self.build_attr(attrs)) if attrs else '<%s>' % tag |
This is the actual function that will be executed. It uses only information that is provided in the settings property
will be overwritten in the __init__ | def _function(self):
"""
This is the actual function that will be executed. It uses only information that is provided in the settings property
will be overwritten in the __init__
"""
# some generic function
import time
import random
self.data['random data... |
plots the data only the axes objects that are provided in axes_list
Args:
axes_list: a list of axes objects, this should be implemented in each subscript
data: data to be plotted if empty take self.data
Returns: None | def _plot(self, axes_list, data = None):
"""
plots the data only the axes objects that are provided in axes_list
Args:
axes_list: a list of axes objects, this should be implemented in each subscript
data: data to be plotted if empty take self.data
Returns: None
... |
updates the data in already existing plots. the axes objects are provided in axes_list
Args:
axes_list: a list of axes objects, this should be implemented in each subscript
Returns: None | def _update(self, axes_list):
"""
updates the data in already existing plots. the axes objects are provided in axes_list
Args:
axes_list: a list of axes objects, this should be implemented in each subscript
Returns: None
"""
plot_type = self.settings['plot_s... |
This is the actual function that will be executed. It uses only information that is provided in the settings property
will be overwritten in the __init__ | def _function(self):
"""
This is the actual function that will be executed. It uses only information that is provided in the settings property
will be overwritten in the __init__
"""
plant = self.instruments['plant']['instance']
controler = self.instruments['controler']['... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.