_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q235300 | SharQServer._view_finish | train | def _view_finish(self, queue_type, queue_id, job_id):
"""Marks a job as finished in SharQ."""
response = {
'status': 'failure'
}
request_data = {
'queue_type': queue_type,
'queue_id': queue_id,
'job_id': job_id
}
try:
... | python | {
"resource": ""
} |
q235301 | SharQServer._view_interval | train | def _view_interval(self, queue_type, queue_id):
"""Updates the queue interval in SharQ."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
interval = request_data['interval']
except Exception, e:
resp... | python | {
"resource": ""
} |
q235302 | SharQServer._view_metrics | train | def _view_metrics(self, queue_type, queue_id):
"""Gets SharQ metrics based on the params."""
response = {
'status': 'failure'
}
request_data = {}
if queue_type:
request_data['queue_type'] = queue_type
if queue_id:
request_data['queue_id... | python | {
"resource": ""
} |
q235303 | SharQServer._view_clear_queue | train | def _view_clear_queue(self, queue_type, queue_id):
"""remove queueu from SharQ based on the queue_type and queue_id."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
except Exception, e:
response['message'] = e... | python | {
"resource": ""
} |
q235304 | start_patching | train | def start_patching(name=None):
# type: (Optional[str]) -> None
"""
Initiate mocking of the functions listed in `_factory_map`.
For this to work reliably all mocked helper functions should be imported
and used like this:
import dp_paypal.client as paypal
res = paypal.do_paypal_expre... | python | {
"resource": ""
} |
q235305 | stop_patching | train | def stop_patching(name=None):
# type: (Optional[str]) -> None
"""
Finish the mocking initiated by `start_patching`
Kwargs:
name (Optional[str]): if given, only unpatch the specified path, else all
defined default mocks
"""
global _patchers, _mocks
if not _patchers:
... | python | {
"resource": ""
} |
q235306 | standardize_back | train | def standardize_back(xs, offset, scale):
"""
This is function for de-standarization of input series.
**Args:**
* `xs` : standardized input (1 dimensional array)
* `offset` : offset to add (float).
* `scale` : scale (float).
**Returns:**
* `x` : original (destandardised) ser... | python | {
"resource": ""
} |
q235307 | standardize | train | def standardize(x, offset=None, scale=None):
"""
This is function for standarization of input series.
**Args:**
* `x` : series (1 dimensional array)
**Kwargs:**
* `offset` : offset to remove (float). If not given, \
the mean value of `x` is used.
* `scale` : scale (float). If... | python | {
"resource": ""
} |
q235308 | input_from_history | train | def input_from_history(a, n, bias=False):
"""
This is function for creation of input matrix.
**Args:**
* `a` : series (1 dimensional array)
* `n` : size of input matrix row (int). It means how many samples \
of previous history you want to use \
as the filter input. It also repres... | python | {
"resource": ""
} |
q235309 | AdaptiveFilter.init_weights | train | def init_weights(self, w, n=-1):
"""
This function initialises the adaptive weights of the filter.
**Args:**
* `w` : initial weights of filter. Possible values are:
* array with initial weights (1 dimensional array) of filter size
* "random" : ... | python | {
"resource": ""
} |
q235310 | AdaptiveFilter.predict | train | def predict(self, x):
"""
This function calculates the new output value `y` from input array `x`.
**Args:**
* `x` : input vector (1 dimension array) in length of filter.
**Returns:**
* `y` : output value (float) calculated from input array.
"""
y = np... | python | {
"resource": ""
} |
q235311 | AdaptiveFilter.explore_learning | train | def explore_learning(self, d, x, mu_start=0, mu_end=1., steps=100,
ntrain=0.5, epochs=1, criteria="MSE", target_w=False):
"""
Test what learning rate is the best.
**Args:**
* `d` : desired value (1 dimensional array)
* `x` : input matrix (2-dimensional array). Rows... | python | {
"resource": ""
} |
q235312 | AdaptiveFilter.check_float_param | train | def check_float_param(self, param, low, high, name):
"""
Check if the value of the given parameter is in the given range
and a float.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float ... | python | {
"resource": ""
} |
q235313 | AdaptiveFilter.check_int_param | train | def check_int_param(self, param, low, high, name):
"""
Check if the value of the given parameter is in the given range
and an int.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float wit... | python | {
"resource": ""
} |
q235314 | MAE | train | def MAE(x1, x2=-1):
"""
Mean absolute error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this sho... | python | {
"resource": ""
} |
q235315 | MSE | train | def MSE(x1, x2=-1):
"""
Mean squared error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this shou... | python | {
"resource": ""
} |
q235316 | RMSE | train | def RMSE(x1, x2=-1):
"""
Root-mean-square error - this function accepts two series of data
or directly one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this... | python | {
"resource": ""
} |
q235317 | ELBND | train | def ELBND(w, e, function="max"):
"""
This function estimates Error and Learning Based Novelty Detection measure
from given data.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
* `e` : error of adapti... | python | {
"resource": ""
} |
q235318 | LDA_base | train | def LDA_base(x, labels):
"""
Base function used for Linear Discriminant Analysis.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Returns:**
* ... | python | {
"resource": ""
} |
q235319 | LDA | train | def LDA(x, labels, n=False):
"""
Linear Discriminant Analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Kwargs:**
* `n` : number of... | python | {
"resource": ""
} |
q235320 | LDA_discriminants | train | def LDA_discriminants(x, labels):
"""
Linear Discriminant Analysis helper for determination how many columns of
data should be reduced.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
s... | python | {
"resource": ""
} |
q235321 | FilterOCNLMS.read_memory | train | def read_memory(self):
"""
This function read mean value of target`d`
and input vector `x` from history
"""
if self.mem_empty == True:
if self.mem_idx == 0:
m_x = np.zeros(self.n)
m_d = 0
else:
m_x = np.mean(... | python | {
"resource": ""
} |
q235322 | learning_entropy | train | def learning_entropy(w, m=10, order=1, alpha=False):
"""
This function estimates Learning Entropy.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
**Kwargs:**
* `m` : window size (1d array) - how man... | python | {
"resource": ""
} |
q235323 | Layer.activation | train | def activation(self, x, f="sigmoid", der=False):
"""
This function process values of layer outputs with activation function.
**Args:**
* `x` : array to process (1-dimensional array)
**Kwargs:**
* `f` : activation function
* `der` : normal output, or its deri... | python | {
"resource": ""
} |
q235324 | NetworkMLP.train | train | def train(self, x, d, epochs=10, shuffle=False):
"""
Function for batch training of MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
* `d` : input array (n-dimensional array).
Every row represen... | python | {
"resource": ""
} |
q235325 | NetworkMLP.run | train | def run(self, x):
"""
Function for batch usage of already trained and tested MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
**Returns:**
* `y`: output vector (n-dimensional array). Every ... | python | {
"resource": ""
} |
q235326 | PCA_components | train | def PCA_components(x):
"""
Principal Component Analysis helper to check out eigenvalues of components.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Returns:**
* `components`: sorted array of principal components eigenvalues
"""
# validat... | python | {
"resource": ""
} |
q235327 | PCA | train | def PCA(x, n=False):
"""
Principal component analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Kwargs:**
* `n` : number of features returned (integer) - how many columns
should the output keep
**Returns:**
* `new_x` : matrix ... | python | {
"resource": ""
} |
q235328 | clean_axis | train | def clean_axis(axis):
"""Remove ticks, tick labels, and frame from axis"""
axis.get_xaxis().set_ticks([])
axis.get_yaxis().set_ticks([])
for spine in list(axis.spines.values()):
spine.set_visible(False) | python | {
"resource": ""
} |
q235329 | get_seaborn_colorbar | train | def get_seaborn_colorbar(dfr, classes):
"""Return a colorbar representing classes, for a Seaborn plot.
The aim is to get a pd.Series for the passed dataframe columns,
in the form:
0 colour for class in col 0
1 colour for class in col 1
... colour for class in col ...
n colour for ... | python | {
"resource": ""
} |
q235330 | get_safe_seaborn_labels | train | def get_safe_seaborn_labels(dfr, labels):
"""Returns labels guaranteed to correspond to the dataframe."""
if labels is not None:
return [labels.get(i, i) for i in dfr.index]
return [i for i in dfr.index] | python | {
"resource": ""
} |
q235331 | get_seaborn_clustermap | train | def get_seaborn_clustermap(dfr, params, title=None, annot=True):
"""Returns a Seaborn clustermap."""
fig = sns.clustermap(
dfr,
cmap=params.cmap,
vmin=params.vmin,
vmax=params.vmax,
col_colors=params.colorbar,
row_colors=params.colorbar,
figsize=(params.fi... | python | {
"resource": ""
} |
q235332 | heatmap_seaborn | train | def heatmap_seaborn(dfr, outfilename=None, title=None, params=None):
"""Returns seaborn heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format)
"""
# Decide on figure layout size: a minimum size is required for
... | python | {
"resource": ""
} |
q235333 | add_mpl_dendrogram | train | def add_mpl_dendrogram(dfr, fig, heatmap_gs, orientation="col"):
"""Return a dendrogram and corresponding gridspec, attached to the fig
Modifies the fig in-place. Orientation is either 'row' or 'col' and
determines location and orientation of the rendered dendrogram.
"""
# Row or column axes?
i... | python | {
"resource": ""
} |
q235334 | get_mpl_heatmap_axes | train | def get_mpl_heatmap_axes(dfr, fig, heatmap_gs):
"""Return axis for Matplotlib heatmap."""
# Create heatmap axis
heatmap_axes = fig.add_subplot(heatmap_gs[1, 1])
heatmap_axes.set_xticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[0]))
heatmap_axes.set_yticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[... | python | {
"resource": ""
} |
q235335 | add_mpl_colorbar | train | def add_mpl_colorbar(dfr, fig, dend, params, orientation="row"):
"""Add class colorbars to Matplotlib heatmap."""
for name in dfr.index[dend["dendrogram"]["leaves"]]:
if name not in params.classes:
params.classes[name] = name
# Assign a numerical value to each class, for mpl
classdi... | python | {
"resource": ""
} |
q235336 | add_mpl_labels | train | def add_mpl_labels(heatmap_axes, rowlabels, collabels, params):
"""Add labels to Matplotlib heatmap axes, in-place."""
if params.labels:
# If a label mapping is missing, use the key text as fall back
rowlabels = [params.labels.get(lab, lab) for lab in rowlabels]
collabels = [params.label... | python | {
"resource": ""
} |
q235337 | add_mpl_colorscale | train | def add_mpl_colorscale(fig, heatmap_gs, ax_map, params, title=None):
"""Add colour scale to heatmap."""
# Set tick intervals
cbticks = [params.vmin + e * params.vdiff for e in (0, 0.25, 0.5, 0.75, 1)]
if params.vmax > 10:
exponent = int(floor(log10(params.vmax))) - 1
cbticks = [int(round... | python | {
"resource": ""
} |
q235338 | heatmap_mpl | train | def heatmap_mpl(dfr, outfilename=None, title=None, params=None):
"""Returns matplotlib heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format)
- params - a list of parameters for plotting: [colormap, vmin, vmax]
- l... | python | {
"resource": ""
} |
q235339 | run_dependency_graph | train | def run_dependency_graph(jobgraph, workers=None, logger=None):
"""Creates and runs pools of jobs based on the passed jobgraph.
- jobgraph - list of jobs, which may have dependencies.
- verbose - flag for multiprocessing verbosity
- logger - a logger module logger (optional)
The strategy here is to... | python | {
"resource": ""
} |
q235340 | populate_cmdsets | train | def populate_cmdsets(job, cmdsets, depth):
"""Creates a list of sets containing jobs at different depths of the
dependency tree.
This is a recursive function (is there something quicker in the itertools
module?) that descends each 'root' job in turn, populating each
"""
if len(cmdsets) < depth:... | python | {
"resource": ""
} |
q235341 | multiprocessing_run | train | def multiprocessing_run(cmdlines, workers=None):
"""Distributes passed command-line jobs using multiprocessing.
- cmdlines - an iterable of command line strings
Returns the sum of exit codes from each job that was run. If
all goes well, this should be 0. Anything else and the calling
function shou... | python | {
"resource": ""
} |
q235342 | get_input_files | train | def get_input_files(dirname, *ext):
"""Returns files in passed directory, filtered by extension.
- dirname - path to input directory
- *ext - list of arguments describing permitted file extensions
"""
filelist = [f for f in os.listdir(dirname) if
os.path.splitext(f)[-1] in ext]
... | python | {
"resource": ""
} |
q235343 | get_sequence_lengths | train | def get_sequence_lengths(fastafilenames):
"""Returns dictionary of sequence lengths, keyed by organism.
Biopython's SeqIO module is used to parse all sequences in the FASTA
file corresponding to each organism, and the total base count in each
is obtained.
NOTE: ambiguity symbols are not discounted... | python | {
"resource": ""
} |
q235344 | last_exception | train | def last_exception():
""" Returns last exception as a string, or use in logging.
"""
exc_type, exc_value, exc_traceback = sys.exc_info()
return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback)) | python | {
"resource": ""
} |
q235345 | make_outdir | train | def make_outdir():
"""Make the output directory, if required.
This is a little involved. If the output directory already exists,
we take the safe option by default, and stop with an error. We can,
however, choose to force the program to go on, in which case we can
either clobber the existing dire... | python | {
"resource": ""
} |
q235346 | compress_delete_outdir | train | def compress_delete_outdir(outdir):
"""Compress the contents of the passed directory to .tar.gz and delete."""
# Compress output in .tar.gz file and remove raw output
tarfn = outdir + ".tar.gz"
logger.info("\tCompressing output from %s to %s", outdir, tarfn)
with tarfile.open(tarfn, "w:gz") as fh:
... | python | {
"resource": ""
} |
q235347 | calculate_anim | train | def calculate_anim(infiles, org_lengths):
"""Returns ANIm result dataframes for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Finds ANI by the ANIm method, as described in Richter et al (2009)
Proc Natl Acad S... | python | {
"resource": ""
} |
q235348 | calculate_tetra | train | def calculate_tetra(infiles):
"""Calculate TETRA for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates TETRA correlation scores, as described in:
Richter M, Rossello-Mora R (2009) Shifting the genomic ... | python | {
"resource": ""
} |
q235349 | unified_anib | train | def unified_anib(infiles, org_lengths):
"""Calculate ANIb for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates ANI by the ANIb method, as described in Goris et al. (2007)
Int J Syst Evol Micr 57: 81-91... | python | {
"resource": ""
} |
q235350 | subsample_input | train | def subsample_input(infiles):
"""Returns a random subsample of the input files.
- infiles: a list of input files for analysis
"""
logger.info("--subsample: %s", args.subsample)
try:
samplesize = float(args.subsample)
except TypeError: # Not a number
logger.error(
"-... | python | {
"resource": ""
} |
q235351 | Job.wait | train | def wait(self, interval=SGE_WAIT):
"""Wait until the job finishes, and poll SGE on its status."""
finished = False
while not finished:
time.sleep(interval)
interval = min(2 * interval, 60)
finished = os.system("qstat -j %s > /dev/null" % (self.name)) | python | {
"resource": ""
} |
q235352 | generate_nucmer_jobs | train | def generate_nucmer_jobs(
filenames,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
jobprefix="ANINUCmer",
):
"""Return a list of Jobs describing NUCmer command-lines for ANIm
- filenames - a list of paths to input FASTA files... | python | {
"resource": ""
} |
q235353 | generate_nucmer_commands | train | def generate_nucmer_commands(
filenames,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
):
"""Return a tuple of lists of NUCmer command-lines for ANIm
The first element is a list of NUCmer commands, the second a list
of delta_... | python | {
"resource": ""
} |
q235354 | construct_nucmer_cmdline | train | def construct_nucmer_cmdline(
fname1,
fname2,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
):
"""Returns a tuple of NUCmer and delta-filter commands
The split into a tuple was made necessary by changes to SGE/OGE. The
de... | python | {
"resource": ""
} |
q235355 | process_deltadir | train | def process_deltadir(delta_dir, org_lengths, logger=None):
"""Returns a tuple of ANIm results for .deltas in passed directory.
- delta_dir - path to the directory containing .delta files
- org_lengths - dictionary of total sequence lengths, keyed by sequence
Returns the following pandas dataframes in ... | python | {
"resource": ""
} |
q235356 | set_ncbi_email | train | def set_ncbi_email():
"""Set contact email for NCBI."""
Entrez.email = args.email
logger.info("Set NCBI contact email to %s", args.email)
Entrez.tool = "genbank_get_genomes_by_taxon.py" | python | {
"resource": ""
} |
q235357 | entrez_retry | train | def entrez_retry(func, *fnargs, **fnkwargs):
"""Retries the passed function up to the number of times specified
by args.retries
"""
tries, success = 0, False
while not success and tries < args.retries:
try:
output = func(*fnargs, **fnkwargs)
success = True
exc... | python | {
"resource": ""
} |
q235358 | entrez_batch_webhistory | train | def entrez_batch_webhistory(record, expected, batchsize, *fnargs, **fnkwargs):
"""Recovers the Entrez data from a prior NCBI webhistory search, in
batches of defined size, using Efetch. Returns all results as a list.
- record: Entrez webhistory record
- expected: number of expected search returns
-... | python | {
"resource": ""
} |
q235359 | get_asm_uids | train | def get_asm_uids(taxon_uid):
"""Returns a set of NCBI UIDs associated with the passed taxon.
This query at NCBI returns all assemblies for the taxon subtree
rooted at the passed taxon_uid.
"""
query = "txid%s[Organism:exp]" % taxon_uid
logger.info("Entrez ESearch with query: %s", query)
# ... | python | {
"resource": ""
} |
q235360 | extract_filestem | train | def extract_filestem(data):
"""Extract filestem from Entrez eSummary data.
Function expects esummary['DocumentSummarySet']['DocumentSummary'][0]
Some illegal characters may occur in AssemblyName - for these, a more
robust regex replace/escape may be required. Sadly, NCBI don't just
use standard pe... | python | {
"resource": ""
} |
q235361 | write_contigs | train | def write_contigs(asm_uid, contig_uids, batchsize=10000):
"""Writes assembly contigs out to a single FASTA file in the script's
designated output directory.
FASTA records are returned, as GenBank and even GenBankWithParts format
records don't reliably give correct sequence in all cases.
The script... | python | {
"resource": ""
} |
q235362 | logreport_downloaded | train | def logreport_downloaded(accession, skippedlist, accessiondict, uidaccdict):
"""Reports to logger whether alternative assemblies for an accession that
was missing have been downloaded
"""
for vid in accessiondict[accession.split('.')[0]]:
if vid in skippedlist:
status = "NOT DOWNLOAD... | python | {
"resource": ""
} |
q235363 | calculate_tetra_zscores | train | def calculate_tetra_zscores(infilenames):
"""Returns dictionary of TETRA Z-scores for each input file.
- infilenames - collection of paths to sequence files
"""
org_tetraz = {}
for filename in infilenames:
org = os.path.splitext(os.path.split(filename)[-1])[0]
org_tetraz[org] = calc... | python | {
"resource": ""
} |
q235364 | calculate_tetra_zscore | train | def calculate_tetra_zscore(filename):
"""Returns TETRA Z-score for the sequence in the passed file.
- filename - path to sequence file
Calculates mono-, di-, tri- and tetranucleotide frequencies
for each sequence, on each strand, and follows Teeling et al. (2004)
in calculating a corresponding Z-s... | python | {
"resource": ""
} |
q235365 | calculate_correlations | train | def calculate_correlations(tetra_z):
"""Returns dataframe of Pearson correlation coefficients.
- tetra_z - dictionary of Z-scores, keyed by sequence ID
Calculates Pearson correlation coefficient from Z scores for each
tetranucleotide. This is done longhand here, which is fast enough,
but for robus... | python | {
"resource": ""
} |
q235366 | get_labels | train | def get_labels(filename, logger=None):
"""Returns a dictionary of alternative sequence labels, or None
- filename - path to file containing tab-separated table of labels
Input files should be formatted as <key>\t<label>, one pair per line.
"""
labeldict = {}
if filename is not None:
if... | python | {
"resource": ""
} |
q235367 | ANIResults.add_tot_length | train | def add_tot_length(self, qname, sname, value, sym=True):
"""Add a total length value to self.alignment_lengths."""
self.alignment_lengths.loc[qname, sname] = value
if sym:
self.alignment_lengths.loc[sname, qname] = value | python | {
"resource": ""
} |
q235368 | ANIResults.add_sim_errors | train | def add_sim_errors(self, qname, sname, value, sym=True):
"""Add a similarity error value to self.similarity_errors."""
self.similarity_errors.loc[qname, sname] = value
if sym:
self.similarity_errors.loc[sname, qname] = value | python | {
"resource": ""
} |
q235369 | ANIResults.add_pid | train | def add_pid(self, qname, sname, value, sym=True):
"""Add a percentage identity value to self.percentage_identity."""
self.percentage_identity.loc[qname, sname] = value
if sym:
self.percentage_identity.loc[sname, qname] = value | python | {
"resource": ""
} |
q235370 | ANIResults.add_coverage | train | def add_coverage(self, qname, sname, qcover, scover=None):
"""Add percentage coverage values to self.alignment_coverage."""
self.alignment_coverage.loc[qname, sname] = qcover
if scover:
self.alignment_coverage.loc[sname, qname] = scover | python | {
"resource": ""
} |
q235371 | BLASTcmds.get_db_name | train | def get_db_name(self, fname):
"""Return database filename"""
return self.funcs.db_func(fname, self.outdir, self.exes.format_exe)[1] | python | {
"resource": ""
} |
q235372 | BLASTcmds.build_blast_cmd | train | def build_blast_cmd(self, fname, dbname):
"""Return BLASTN command"""
return self.funcs.blastn_func(fname, dbname, self.outdir, self.exes.blast_exe) | python | {
"resource": ""
} |
q235373 | fragment_fasta_files | train | def fragment_fasta_files(infiles, outdirname, fragsize):
"""Chops sequences of the passed files into fragments, returns filenames.
- infiles - paths to each input sequence file
- outdirname - path to output directory
- fragsize - the size of sequence fragments
Takes every sequence from every file ... | python | {
"resource": ""
} |
q235374 | get_fraglength_dict | train | def get_fraglength_dict(fastafiles):
"""Returns dictionary of sequence fragment lengths, keyed by query name.
- fastafiles - list of FASTA input whole sequence files
Loops over input files and, for each, produces a dictionary with fragment
lengths, keyed by sequence ID. These are returned as a diction... | python | {
"resource": ""
} |
q235375 | get_fragment_lengths | train | def get_fragment_lengths(fastafile):
"""Returns dictionary of sequence fragment lengths, keyed by fragment ID.
Biopython's SeqIO module is used to parse all sequences in the FASTA
file.
NOTE: ambiguity symbols are not discounted.
"""
fraglengths = {}
for seq in SeqIO.parse(fastafile, "fast... | python | {
"resource": ""
} |
q235376 | build_db_jobs | train | def build_db_jobs(infiles, blastcmds):
"""Returns dictionary of db-building commands, keyed by dbname."""
dbjobdict = {} # Dict of database construction jobs, keyed by filename
# Create dictionary of database building jobs, keyed by db name
# defining jobnum for later use as last job index used
for... | python | {
"resource": ""
} |
q235377 | make_blastcmd_builder | train | def make_blastcmd_builder(
mode, outdir, format_exe=None, blast_exe=None, prefix="ANIBLAST"
):
"""Returns BLASTcmds object for construction of BLAST commands."""
if mode == "ANIb": # BLAST/formatting executable depends on mode
blastcmds = BLASTcmds(
BLASTfunctions(construct_makeblastdb_... | python | {
"resource": ""
} |
q235378 | make_job_graph | train | def make_job_graph(infiles, fragfiles, blastcmds):
"""Return a job dependency graph, based on the passed input sequence files.
- infiles - a list of paths to input FASTA files
- fragfiles - a list of paths to fragmented input FASTA files
By default, will run ANIb - it *is* possible to make a mess of p... | python | {
"resource": ""
} |
q235379 | construct_makeblastdb_cmd | train | def construct_makeblastdb_cmd(
filename, outdir, blastdb_exe=pyani_config.MAKEBLASTDB_DEFAULT
):
"""Returns a single makeblastdb command.
- filename - input filename
- blastdb_exe - path to the makeblastdb executable
"""
title = os.path.splitext(os.path.split(filename)[-1])[0]
outfilename =... | python | {
"resource": ""
} |
q235380 | construct_formatdb_cmd | train | def construct_formatdb_cmd(filename, outdir, blastdb_exe=pyani_config.FORMATDB_DEFAULT):
"""Returns a single formatdb command.
- filename - input filename
- blastdb_exe - path to the formatdb executable
"""
title = os.path.splitext(os.path.split(filename)[-1])[0]
newfilename = os.path.join(outd... | python | {
"resource": ""
} |
q235381 | generate_blastn_commands | train | def generate_blastn_commands(filenames, outdir, blast_exe=None, mode="ANIb"):
"""Return a list of blastn command-lines for ANIm
- filenames - a list of paths to fragmented input FASTA files
- outdir - path to output directory
- blastn_exe - path to BLASTN executable
Assumes that the fragment seque... | python | {
"resource": ""
} |
q235382 | construct_blastn_cmdline | train | def construct_blastn_cmdline(
fname1, fname2, outdir, blastn_exe=pyani_config.BLASTN_DEFAULT
):
"""Returns a single blastn command.
- filename - input filename
- blastn_exe - path to BLASTN executable
"""
fstem1 = os.path.splitext(os.path.split(fname1)[-1])[0]
fstem2 = os.path.splitext(os.p... | python | {
"resource": ""
} |
q235383 | construct_blastall_cmdline | train | def construct_blastall_cmdline(
fname1, fname2, outdir, blastall_exe=pyani_config.BLASTALL_DEFAULT
):
"""Returns a single blastall command.
- blastall_exe - path to BLASTALL executable
"""
fstem1 = os.path.splitext(os.path.split(fname1)[-1])[0]
fstem2 = os.path.splitext(os.path.split(fname2)[-1... | python | {
"resource": ""
} |
q235384 | process_blast | train | def process_blast(
blast_dir,
org_lengths,
fraglengths=None,
mode="ANIb",
identity=0.3,
coverage=0.7,
logger=None,
):
"""Returns a tuple of ANIb results for .blast_tab files in the output dir.
- blast_dir - path to the directory containing .blast_tab files
- org_lengths - the ba... | python | {
"resource": ""
} |
q235385 | split_seq | train | def split_seq(iterable, size):
"""Splits a passed iterable into chunks of a given size."""
elm = iter(iterable)
item = list(itertools.islice(elm, size))
while item:
yield item
item = list(itertools.islice(elm, size)) | python | {
"resource": ""
} |
q235386 | build_joblist | train | def build_joblist(jobgraph):
"""Returns a list of jobs, from a passed jobgraph."""
jobset = set()
for job in jobgraph:
jobset = populate_jobset(job, jobset, depth=1)
return list(jobset) | python | {
"resource": ""
} |
q235387 | compile_jobgroups_from_joblist | train | def compile_jobgroups_from_joblist(joblist, jgprefix, sgegroupsize):
"""Return list of jobgroups, rather than list of jobs."""
jobcmds = defaultdict(list)
for job in joblist:
jobcmds[job.command.split(' ', 1)[0]].append(job.command)
jobgroups = []
for cmds in list(jobcmds.items()):
#... | python | {
"resource": ""
} |
q235388 | run_dependency_graph | train | def run_dependency_graph(jobgraph, logger=None, jgprefix="ANIm_SGE_JG",
sgegroupsize=10000, sgeargs=None):
"""Creates and runs GridEngine scripts for jobs based on the passed
jobgraph.
- jobgraph - list of jobs, which may have dependencies.
- verbose - flag for multiprocessing ... | python | {
"resource": ""
} |
q235389 | populate_jobset | train | def populate_jobset(job, jobset, depth):
""" Creates a set of jobs, containing jobs at difference depths of the
dependency tree, retaining dependencies as strings, not Jobs.
"""
jobset.add(job)
if len(job.dependencies) == 0:
return jobset
for j in job.dependencies:
jobset = popul... | python | {
"resource": ""
} |
q235390 | build_job_scripts | train | def build_job_scripts(root_dir, jobs):
"""Constructs the script for each passed Job in the jobs iterable
- root_dir Path to output directory
"""
# Loop over the job list, creating each job script in turn, and then adding
# scriptPath to the Job object
for job in jobs:
scriptpath = ... | python | {
"resource": ""
} |
q235391 | extract_submittable_jobs | train | def extract_submittable_jobs(waiting):
"""Obtain a list of jobs that are able to be submitted from the passed
list of pending jobs
- waiting List of Job objects
"""
submittable = set() # Holds jobs that are able to be submitted
# Loop over each job, and check all the subjob... | python | {
"resource": ""
} |
q235392 | submit_safe_jobs | train | def submit_safe_jobs(root_dir, jobs, sgeargs=None):
"""Submit the passed list of jobs to the Grid Engine server, using the
passed directory as the root for scheduler output.
- root_dir Path to output directory
- jobs Iterable of Job objects
"""
# Loop over each job, constructing S... | python | {
"resource": ""
} |
q235393 | submit_jobs | train | def submit_jobs(root_dir, jobs, sgeargs=None):
""" Submit each of the passed jobs to the SGE server, using the passed
directory as root for SGE output.
- root_dir Path to output directory
- jobs List of Job objects
"""
waiting = list(jobs) # List of jobs still to... | python | {
"resource": ""
} |
q235394 | build_and_submit_jobs | train | def build_and_submit_jobs(root_dir, jobs, sgeargs=None):
"""Submits the passed iterable of Job objects to SGE, placing SGE's
output in the passed root directory
- root_dir Root directory for SGE and job output
- jobs List of Job objects, describing each job to be submitted
- sgeargs Addi... | python | {
"resource": ""
} |
q235395 | params_mpl | train | def params_mpl(df):
"""Returns dict of matplotlib parameters, dependent on dataframe."""
return {'ANIb_alignment_lengths': ('afmhot', df.values.min(),
df.values.max()),
'ANIb_percentage_identity': ('spbnd_BuRd', 0, 1),
'ANIb_alignment_coverage': ('B... | python | {
"resource": ""
} |
q235396 | download_file | train | def download_file(fname, target_dir=None, force=False):
"""Download fname from the datasets_url, and save it to target_dir,
unless the file already exists, and force is False.
Parameters
----------
fname : str
Name of the file to download
target_dir : str
Directory where to sto... | python | {
"resource": ""
} |
q235397 | parse_idx | train | def parse_idx(fd):
"""Parse an IDX file, and return it as a numpy array.
Parameters
----------
fd : file
File descriptor of the IDX file to parse
endian : str
Byte order of the IDX file. See [1] for available options
Returns
-------
data : numpy.ndarray
Numpy a... | python | {
"resource": ""
} |
q235398 | download_and_parse_mnist_file | train | def download_and_parse_mnist_file(fname, target_dir=None, force=False):
"""Download the IDX file named fname from the URL specified in dataset_url
and return it as a numpy array.
Parameters
----------
fname : str
File name to download and parse
target_dir : str
Directory where ... | python | {
"resource": ""
} |
q235399 | Pages.fetch_next_page | train | def fetch_next_page(self):
"""Fetch the next Page of results.
Returns:
Page: The next page of results.
"""
for page in self:
return page
else:
return Page(self._resultset.cursor, iter(())) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.