repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
vanheeringen-lab/gimmemotifs
gimmemotifs/denovo.py
rename_motifs
def rename_motifs(motifs, stats=None): """Rename motifs to GimmeMotifs_1..GimmeMotifs_N. If stats object is passed, stats will be copied.""" final_motifs = [] for i, motif in enumerate(motifs): old = str(motif) motif.id = "GimmeMotifs_{}".format(i + 1) final_motifs.append(mo...
python
def rename_motifs(motifs, stats=None): """Rename motifs to GimmeMotifs_1..GimmeMotifs_N. If stats object is passed, stats will be copied.""" final_motifs = [] for i, motif in enumerate(motifs): old = str(motif) motif.id = "GimmeMotifs_{}".format(i + 1) final_motifs.append(mo...
[ "def", "rename_motifs", "(", "motifs", ",", "stats", "=", "None", ")", ":", "final_motifs", "=", "[", "]", "for", "i", ",", "motif", "in", "enumerate", "(", "motifs", ")", ":", "old", "=", "str", "(", "motif", ")", "motif", ".", "id", "=", "\"Gimme...
Rename motifs to GimmeMotifs_1..GimmeMotifs_N. If stats object is passed, stats will be copied.
[ "Rename", "motifs", "to", "GimmeMotifs_1", "..", "GimmeMotifs_N", ".", "If", "stats", "object", "is", "passed", "stats", "will", "be", "copied", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/denovo.py#L468-L483
vanheeringen-lab/gimmemotifs
gimmemotifs/denovo.py
gimme_motifs
def gimme_motifs(inputfile, outdir, params=None, filter_significant=True, cluster=True, create_report=True): """De novo motif prediction based on an ensemble of different tools. Parameters ---------- inputfile : str Filename of input. Can be either BED, narrowPeak or FASTA. outdir : str ...
python
def gimme_motifs(inputfile, outdir, params=None, filter_significant=True, cluster=True, create_report=True): """De novo motif prediction based on an ensemble of different tools. Parameters ---------- inputfile : str Filename of input. Can be either BED, narrowPeak or FASTA. outdir : str ...
[ "def", "gimme_motifs", "(", "inputfile", ",", "outdir", ",", "params", "=", "None", ",", "filter_significant", "=", "True", ",", "cluster", "=", "True", ",", "create_report", "=", "True", ")", ":", "if", "outdir", "is", "None", ":", "outdir", "=", "\"gim...
De novo motif prediction based on an ensemble of different tools. Parameters ---------- inputfile : str Filename of input. Can be either BED, narrowPeak or FASTA. outdir : str Name of output directory. params : dict, optional Optional parameters. filter_significant : ...
[ "De", "novo", "motif", "prediction", "based", "on", "an", "ensemble", "of", "different", "tools", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/denovo.py#L485-L661
vanheeringen-lab/gimmemotifs
gimmemotifs/db/__init__.py
MotifDb.register_db
def register_db(cls, dbname): """Register method to keep list of dbs.""" def decorator(subclass): """Register as decorator function.""" cls._dbs[dbname] = subclass subclass.name = dbname return subclass return decorator
python
def register_db(cls, dbname): """Register method to keep list of dbs.""" def decorator(subclass): """Register as decorator function.""" cls._dbs[dbname] = subclass subclass.name = dbname return subclass return decorator
[ "def", "register_db", "(", "cls", ",", "dbname", ")", ":", "def", "decorator", "(", "subclass", ")", ":", "\"\"\"Register as decorator function.\"\"\"", "cls", ".", "_dbs", "[", "dbname", "]", "=", "subclass", "subclass", ".", "name", "=", "dbname", "return", ...
Register method to keep list of dbs.
[ "Register", "method", "to", "keep", "list", "of", "dbs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/db/__init__.py#L53-L60
vanheeringen-lab/gimmemotifs
gimmemotifs/moap.py
moap
def moap(inputfile, method="hypergeom", scoring=None, outfile=None, motiffile=None, pwmfile=None, genome=None, fpr=0.01, ncpus=None, subsample=None): """Run a single motif activity prediction algorithm. Parameters ---------- inputfile : str :1File with regions (chr:start-end) in fir...
python
def moap(inputfile, method="hypergeom", scoring=None, outfile=None, motiffile=None, pwmfile=None, genome=None, fpr=0.01, ncpus=None, subsample=None): """Run a single motif activity prediction algorithm. Parameters ---------- inputfile : str :1File with regions (chr:start-end) in fir...
[ "def", "moap", "(", "inputfile", ",", "method", "=", "\"hypergeom\"", ",", "scoring", "=", "None", ",", "outfile", "=", "None", ",", "motiffile", "=", "None", ",", "pwmfile", "=", "None", ",", "genome", "=", "None", ",", "fpr", "=", "0.01", ",", "ncp...
Run a single motif activity prediction algorithm. Parameters ---------- inputfile : str :1File with regions (chr:start-end) in first column and either cluster name in second column or a table with values. method : str, optional Motif activity method to use. Any of 'hyp...
[ "Run", "a", "single", "motif", "activity", "prediction", "algorithm", ".", "Parameters", "----------", "inputfile", ":", "str", ":", "1File", "with", "regions", "(", "chr", ":", "start", "-", "end", ")", "in", "first", "column", "and", "either", "cluster", ...
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/moap.py#L817-L955
vanheeringen-lab/gimmemotifs
gimmemotifs/moap.py
Moap.create
def create(cls, name, ncpus=None): """Create a Moap instance based on the predictor name. Parameters ---------- name : str Name of the predictor (eg. Xgboost, BayesianRidge, ...) ncpus : int, optional Number of threads. Default is the number spec...
python
def create(cls, name, ncpus=None): """Create a Moap instance based on the predictor name. Parameters ---------- name : str Name of the predictor (eg. Xgboost, BayesianRidge, ...) ncpus : int, optional Number of threads. Default is the number spec...
[ "def", "create", "(", "cls", ",", "name", ",", "ncpus", "=", "None", ")", ":", "try", ":", "return", "cls", ".", "_predictors", "[", "name", ".", "lower", "(", ")", "]", "(", "ncpus", "=", "ncpus", ")", "except", "KeyError", ":", "raise", "Exceptio...
Create a Moap instance based on the predictor name. Parameters ---------- name : str Name of the predictor (eg. Xgboost, BayesianRidge, ...) ncpus : int, optional Number of threads. Default is the number specified in the config. Returns ...
[ "Create", "a", "Moap", "instance", "based", "on", "the", "predictor", "name", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/moap.py#L65-L84
vanheeringen-lab/gimmemotifs
gimmemotifs/moap.py
Moap.register_predictor
def register_predictor(cls, name): """Register method to keep list of predictors.""" def decorator(subclass): """Register as decorator function.""" cls._predictors[name.lower()] = subclass subclass.name = name.lower() return subclass return decorat...
python
def register_predictor(cls, name): """Register method to keep list of predictors.""" def decorator(subclass): """Register as decorator function.""" cls._predictors[name.lower()] = subclass subclass.name = name.lower() return subclass return decorat...
[ "def", "register_predictor", "(", "cls", ",", "name", ")", ":", "def", "decorator", "(", "subclass", ")", ":", "\"\"\"Register as decorator function.\"\"\"", "cls", ".", "_predictors", "[", "name", ".", "lower", "(", ")", "]", "=", "subclass", "subclass", ".",...
Register method to keep list of predictors.
[ "Register", "method", "to", "keep", "list", "of", "predictors", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/moap.py#L87-L94
vanheeringen-lab/gimmemotifs
gimmemotifs/moap.py
Moap.list_classification_predictors
def list_classification_predictors(self): """List available classification predictors.""" preds = [self.create(x) for x in self._predictors.keys()] return [x.name for x in preds if x.ptype == "classification"]
python
def list_classification_predictors(self): """List available classification predictors.""" preds = [self.create(x) for x in self._predictors.keys()] return [x.name for x in preds if x.ptype == "classification"]
[ "def", "list_classification_predictors", "(", "self", ")", ":", "preds", "=", "[", "self", ".", "create", "(", "x", ")", "for", "x", "in", "self", ".", "_predictors", ".", "keys", "(", ")", "]", "return", "[", "x", ".", "name", "for", "x", "in", "p...
List available classification predictors.
[ "List", "available", "classification", "predictors", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/moap.py#L102-L105
pescadores/pescador
pescador/core.py
Streamer._activate
def _activate(self): """Activates the stream.""" if six.callable(self.streamer): # If it's a function, create the stream. self.stream_ = self.streamer(*(self.args), **(self.kwargs)) else: # If it's iterable, use it directly. self.stream_ = iter(se...
python
def _activate(self): """Activates the stream.""" if six.callable(self.streamer): # If it's a function, create the stream. self.stream_ = self.streamer(*(self.args), **(self.kwargs)) else: # If it's iterable, use it directly. self.stream_ = iter(se...
[ "def", "_activate", "(", "self", ")", ":", "if", "six", ".", "callable", "(", "self", ".", "streamer", ")", ":", "# If it's a function, create the stream.", "self", ".", "stream_", "=", "self", ".", "streamer", "(", "*", "(", "self", ".", "args", ")", ",...
Activates the stream.
[ "Activates", "the", "stream", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/core.py#L169-L177
pescadores/pescador
pescador/core.py
Streamer.iterate
def iterate(self, max_iter=None): '''Instantiate an iterator. Parameters ---------- max_iter : None or int > 0 Maximum number of iterations to yield. If ``None``, exhaust the stream. Yields ------ obj : Objects yielded by the streamer pro...
python
def iterate(self, max_iter=None): '''Instantiate an iterator. Parameters ---------- max_iter : None or int > 0 Maximum number of iterations to yield. If ``None``, exhaust the stream. Yields ------ obj : Objects yielded by the streamer pro...
[ "def", "iterate", "(", "self", ",", "max_iter", "=", "None", ")", ":", "# Use self as context manager / calls __enter__() => _activate()", "with", "self", "as", "active_streamer", ":", "for", "n", ",", "obj", "in", "enumerate", "(", "active_streamer", ".", "stream_"...
Instantiate an iterator. Parameters ---------- max_iter : None or int > 0 Maximum number of iterations to yield. If ``None``, exhaust the stream. Yields ------ obj : Objects yielded by the streamer provided on init. See Also ----...
[ "Instantiate", "an", "iterator", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/core.py#L179-L202
pescadores/pescador
pescador/core.py
Streamer.cycle
def cycle(self, max_iter=None): '''Iterate from the streamer infinitely. This function will force an infinite stream, restarting the streamer even if a StopIteration is raised. Parameters ---------- max_iter : None or int > 0 Maximum number of iterations to ...
python
def cycle(self, max_iter=None): '''Iterate from the streamer infinitely. This function will force an infinite stream, restarting the streamer even if a StopIteration is raised. Parameters ---------- max_iter : None or int > 0 Maximum number of iterations to ...
[ "def", "cycle", "(", "self", ",", "max_iter", "=", "None", ")", ":", "count", "=", "0", "while", "True", ":", "for", "obj", "in", "self", ".", "iterate", "(", ")", ":", "count", "+=", "1", "if", "max_iter", "is", "not", "None", "and", "count", ">...
Iterate from the streamer infinitely. This function will force an infinite stream, restarting the streamer even if a StopIteration is raised. Parameters ---------- max_iter : None or int > 0 Maximum number of iterations to yield. If `None`, iterate indef...
[ "Iterate", "from", "the", "streamer", "infinitely", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/core.py#L204-L227
vanheeringen-lab/gimmemotifs
gimmemotifs/stats.py
calc_stats_iterator
def calc_stats_iterator(motifs, fg_file, bg_file, genome=None, stats=None, ncpus=None): """Calculate motif enrichment metrics. Parameters ---------- motifs : str, list or Motif instance A file with motifs in pwm format, a list of Motif instances or a single Motif instance. fg_file...
python
def calc_stats_iterator(motifs, fg_file, bg_file, genome=None, stats=None, ncpus=None): """Calculate motif enrichment metrics. Parameters ---------- motifs : str, list or Motif instance A file with motifs in pwm format, a list of Motif instances or a single Motif instance. fg_file...
[ "def", "calc_stats_iterator", "(", "motifs", ",", "fg_file", ",", "bg_file", ",", "genome", "=", "None", ",", "stats", "=", "None", ",", "ncpus", "=", "None", ")", ":", "if", "not", "stats", ":", "stats", "=", "rocmetrics", ".", "__all__", "if", "isins...
Calculate motif enrichment metrics. Parameters ---------- motifs : str, list or Motif instance A file with motifs in pwm format, a list of Motif instances or a single Motif instance. fg_file : str Filename of a FASTA, BED or region file with positive sequences. bg_file : ...
[ "Calculate", "motif", "enrichment", "metrics", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/stats.py#L16-L82
vanheeringen-lab/gimmemotifs
gimmemotifs/stats.py
calc_stats
def calc_stats(motifs, fg_file, bg_file, genome=None, stats=None, ncpus=None): """Calculate motif enrichment metrics. Parameters ---------- motifs : str, list or Motif instance A file with motifs in pwm format, a list of Motif instances or a single Motif instance. fg_file : str ...
python
def calc_stats(motifs, fg_file, bg_file, genome=None, stats=None, ncpus=None): """Calculate motif enrichment metrics. Parameters ---------- motifs : str, list or Motif instance A file with motifs in pwm format, a list of Motif instances or a single Motif instance. fg_file : str ...
[ "def", "calc_stats", "(", "motifs", ",", "fg_file", ",", "bg_file", ",", "genome", "=", "None", ",", "stats", "=", "None", ",", "ncpus", "=", "None", ")", ":", "result", "=", "{", "}", "for", "batch_result", "in", "calc_stats_iterator", "(", "motifs", ...
Calculate motif enrichment metrics. Parameters ---------- motifs : str, list or Motif instance A file with motifs in pwm format, a list of Motif instances or a single Motif instance. fg_file : str Filename of a FASTA, BED or region file with positive sequences. bg_file : ...
[ "Calculate", "motif", "enrichment", "metrics", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/stats.py#L84-L122
vanheeringen-lab/gimmemotifs
gimmemotifs/stats.py
rank_motifs
def rank_motifs(stats, metrics=("roc_auc", "recall_at_fdr")): """Determine mean rank of motifs based on metrics.""" rank = {} combined_metrics = [] motif_ids = stats.keys() background = list(stats.values())[0].keys() for metric in metrics: mean_metric_stats = [np.mean( [stats...
python
def rank_motifs(stats, metrics=("roc_auc", "recall_at_fdr")): """Determine mean rank of motifs based on metrics.""" rank = {} combined_metrics = [] motif_ids = stats.keys() background = list(stats.values())[0].keys() for metric in metrics: mean_metric_stats = [np.mean( [stats...
[ "def", "rank_motifs", "(", "stats", ",", "metrics", "=", "(", "\"roc_auc\"", ",", "\"recall_at_fdr\"", ")", ")", ":", "rank", "=", "{", "}", "combined_metrics", "=", "[", "]", "motif_ids", "=", "stats", ".", "keys", "(", ")", "background", "=", "list", ...
Determine mean rank of motifs based on metrics.
[ "Determine", "mean", "rank", "of", "motifs", "based", "on", "metrics", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/stats.py#L202-L217
vanheeringen-lab/gimmemotifs
gimmemotifs/stats.py
write_stats
def write_stats(stats, fname, header=None): """write motif statistics to text file.""" # Write stats output to file for bg in list(stats.values())[0].keys(): f = open(fname.format(bg), "w") if header: f.write(header) stat_keys = sorted(list(list(stats.values())[...
python
def write_stats(stats, fname, header=None): """write motif statistics to text file.""" # Write stats output to file for bg in list(stats.values())[0].keys(): f = open(fname.format(bg), "w") if header: f.write(header) stat_keys = sorted(list(list(stats.values())[...
[ "def", "write_stats", "(", "stats", ",", "fname", ",", "header", "=", "None", ")", ":", "# Write stats output to file", "for", "bg", "in", "list", "(", "stats", ".", "values", "(", ")", ")", "[", "0", "]", ".", "keys", "(", ")", ":", "f", "=", "ope...
write motif statistics to text file.
[ "write", "motif", "statistics", "to", "text", "file", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/stats.py#L219-L243
vanheeringen-lab/gimmemotifs
gimmemotifs/report.py
get_roc_values
def get_roc_values(motif, fg_file, bg_file): """Calculate ROC AUC values for ROC plots.""" #print(calc_stats(motif, fg_file, bg_file, stats=["roc_values"], ncpus=1)) #["roc_values"]) try: # fg_result = motif.pwm_scan_score(Fasta(fg_file), cutoff=0.0, nreport=1) # fg_vals = [sorted(x)[...
python
def get_roc_values(motif, fg_file, bg_file): """Calculate ROC AUC values for ROC plots.""" #print(calc_stats(motif, fg_file, bg_file, stats=["roc_values"], ncpus=1)) #["roc_values"]) try: # fg_result = motif.pwm_scan_score(Fasta(fg_file), cutoff=0.0, nreport=1) # fg_vals = [sorted(x)[...
[ "def", "get_roc_values", "(", "motif", ",", "fg_file", ",", "bg_file", ")", ":", "#print(calc_stats(motif, fg_file, bg_file, stats=[\"roc_values\"], ncpus=1))", "#[\"roc_values\"])", "try", ":", "# fg_result = motif.pwm_scan_score(Fasta(fg_file), cutoff=0.0, nreport=1)", "# ...
Calculate ROC AUC values for ROC plots.
[ "Calculate", "ROC", "AUC", "values", "for", "ROC", "plots", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/report.py#L33-L54
vanheeringen-lab/gimmemotifs
gimmemotifs/report.py
create_roc_plots
def create_roc_plots(pwmfile, fgfa, background, outdir): """Make ROC plots for all motifs.""" motifs = read_motifs(pwmfile, fmt="pwm", as_dict=True) ncpus = int(MotifConfig().get_default_params()['ncpus']) pool = Pool(processes=ncpus) jobs = {} for bg,fname in background.items(): for m_i...
python
def create_roc_plots(pwmfile, fgfa, background, outdir): """Make ROC plots for all motifs.""" motifs = read_motifs(pwmfile, fmt="pwm", as_dict=True) ncpus = int(MotifConfig().get_default_params()['ncpus']) pool = Pool(processes=ncpus) jobs = {} for bg,fname in background.items(): for m_i...
[ "def", "create_roc_plots", "(", "pwmfile", ",", "fgfa", ",", "background", ",", "outdir", ")", ":", "motifs", "=", "read_motifs", "(", "pwmfile", ",", "fmt", "=", "\"pwm\"", ",", "as_dict", "=", "True", ")", "ncpus", "=", "int", "(", "MotifConfig", "(", ...
Make ROC plots for all motifs.
[ "Make", "ROC", "plots", "for", "all", "motifs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/report.py#L56-L84
vanheeringen-lab/gimmemotifs
gimmemotifs/report.py
_create_text_report
def _create_text_report(inputfile, motifs, closest_match, stats, outdir): """Create text report of motifs with statistics and database match.""" my_stats = {} for motif in motifs: match = closest_match[motif.id] my_stats[str(motif)] = {} for bg in list(stats.values())[0].keys(): ...
python
def _create_text_report(inputfile, motifs, closest_match, stats, outdir): """Create text report of motifs with statistics and database match.""" my_stats = {} for motif in motifs: match = closest_match[motif.id] my_stats[str(motif)] = {} for bg in list(stats.values())[0].keys(): ...
[ "def", "_create_text_report", "(", "inputfile", ",", "motifs", ",", "closest_match", ",", "stats", ",", "outdir", ")", ":", "my_stats", "=", "{", "}", "for", "motif", "in", "motifs", ":", "match", "=", "closest_match", "[", "motif", ".", "id", "]", "my_s...
Create text report of motifs with statistics and database match.
[ "Create", "text", "report", "of", "motifs", "with", "statistics", "and", "database", "match", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/report.py#L86-L108
vanheeringen-lab/gimmemotifs
gimmemotifs/report.py
_create_graphical_report
def _create_graphical_report(inputfile, pwm, background, closest_match, outdir, stats, best_id=None): """Create main gimme_motifs output html report.""" if best_id is None: best_id = {} logger.debug("Creating graphical report") class ReportMotif(object): """Placeholder for motif st...
python
def _create_graphical_report(inputfile, pwm, background, closest_match, outdir, stats, best_id=None): """Create main gimme_motifs output html report.""" if best_id is None: best_id = {} logger.debug("Creating graphical report") class ReportMotif(object): """Placeholder for motif st...
[ "def", "_create_graphical_report", "(", "inputfile", ",", "pwm", ",", "background", ",", "closest_match", ",", "outdir", ",", "stats", ",", "best_id", "=", "None", ")", ":", "if", "best_id", "is", "None", ":", "best_id", "=", "{", "}", "logger", ".", "de...
Create main gimme_motifs output html report.
[ "Create", "main", "gimme_motifs", "output", "html", "report", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/report.py#L110-L194
vanheeringen-lab/gimmemotifs
gimmemotifs/report.py
create_denovo_motif_report
def create_denovo_motif_report(inputfile, pwmfile, fgfa, background, locfa, outdir, params, stats=None): """Create text and graphical (.html) motif reports.""" logger.info("creating reports") motifs = read_motifs(pwmfile, fmt="pwm") # ROC plots create_roc_plots(pwmfile, fgfa, background, outdi...
python
def create_denovo_motif_report(inputfile, pwmfile, fgfa, background, locfa, outdir, params, stats=None): """Create text and graphical (.html) motif reports.""" logger.info("creating reports") motifs = read_motifs(pwmfile, fmt="pwm") # ROC plots create_roc_plots(pwmfile, fgfa, background, outdi...
[ "def", "create_denovo_motif_report", "(", "inputfile", ",", "pwmfile", ",", "fgfa", ",", "background", ",", "locfa", ",", "outdir", ",", "params", ",", "stats", "=", "None", ")", ":", "logger", ".", "info", "(", "\"creating reports\"", ")", "motifs", "=", ...
Create text and graphical (.html) motif reports.
[ "Create", "text", "and", "graphical", "(", ".", "html", ")", "motif", "reports", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/report.py#L196-L233
vanheeringen-lab/gimmemotifs
gimmemotifs/plot.py
axes_off
def axes_off(ax): """Get rid of all axis ticks, lines, etc. """ ax.set_frame_on(False) ax.axes.get_yaxis().set_visible(False) ax.axes.get_xaxis().set_visible(False)
python
def axes_off(ax): """Get rid of all axis ticks, lines, etc. """ ax.set_frame_on(False) ax.axes.get_yaxis().set_visible(False) ax.axes.get_xaxis().set_visible(False)
[ "def", "axes_off", "(", "ax", ")", ":", "ax", ".", "set_frame_on", "(", "False", ")", "ax", ".", "axes", ".", "get_yaxis", "(", ")", ".", "set_visible", "(", "False", ")", "ax", ".", "axes", ".", "get_xaxis", "(", ")", ".", "set_visible", "(", "Fal...
Get rid of all axis ticks, lines, etc.
[ "Get", "rid", "of", "all", "axis", "ticks", "lines", "etc", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/plot.py#L33-L38
vanheeringen-lab/gimmemotifs
gimmemotifs/plot.py
match_plot
def match_plot(plotdata, outfile): """Plot list of motifs with database match and p-value "param plotdata: list of (motif, dbmotif, pval) """ fig_h = 2 fig_w = 7 nrows = len(plotdata) ncols = 2 fig = plt.figure(figsize=(fig_w, nrows * fig_h)) for i, (motif, dbmotif, pval) in e...
python
def match_plot(plotdata, outfile): """Plot list of motifs with database match and p-value "param plotdata: list of (motif, dbmotif, pval) """ fig_h = 2 fig_w = 7 nrows = len(plotdata) ncols = 2 fig = plt.figure(figsize=(fig_w, nrows * fig_h)) for i, (motif, dbmotif, pval) in e...
[ "def", "match_plot", "(", "plotdata", ",", "outfile", ")", ":", "fig_h", "=", "2", "fig_w", "=", "7", "nrows", "=", "len", "(", "plotdata", ")", "ncols", "=", "2", "fig", "=", "plt", ".", "figure", "(", "figsize", "=", "(", "fig_w", ",", "nrows", ...
Plot list of motifs with database match and p-value "param plotdata: list of (motif, dbmotif, pval)
[ "Plot", "list", "of", "motifs", "with", "database", "match", "and", "p", "-", "value", "param", "plotdata", ":", "list", "of", "(", "motif", "dbmotif", "pval", ")" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/plot.py#L94-L132
vanheeringen-lab/gimmemotifs
gimmemotifs/plot.py
motif_tree_plot
def motif_tree_plot(outfile, tree, data, circle=True, vmin=None, vmax=None, dpi=300): """ Plot a "phylogenetic" tree """ try: from ete3 import Tree, faces, AttrFace, TreeStyle, NodeStyle except ImportError: print("Please install ete3 to use this functionality") sys.exit(1) ...
python
def motif_tree_plot(outfile, tree, data, circle=True, vmin=None, vmax=None, dpi=300): """ Plot a "phylogenetic" tree """ try: from ete3 import Tree, faces, AttrFace, TreeStyle, NodeStyle except ImportError: print("Please install ete3 to use this functionality") sys.exit(1) ...
[ "def", "motif_tree_plot", "(", "outfile", ",", "tree", ",", "data", ",", "circle", "=", "True", ",", "vmin", "=", "None", ",", "vmax", "=", "None", ",", "dpi", "=", "300", ")", ":", "try", ":", "from", "ete3", "import", "Tree", ",", "faces", ",", ...
Plot a "phylogenetic" tree
[ "Plot", "a", "phylogenetic", "tree" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/plot.py#L349-L370
vanheeringen-lab/gimmemotifs
gimmemotifs/validation.py
check_bed_file
def check_bed_file(fname): """ Check if the inputfile is a valid bed-file """ if not os.path.exists(fname): logger.error("Inputfile %s does not exist!", fname) sys.exit(1) for i, line in enumerate(open(fname)): if line.startswith("#") or line.startswith("track") or line.startswith("...
python
def check_bed_file(fname): """ Check if the inputfile is a valid bed-file """ if not os.path.exists(fname): logger.error("Inputfile %s does not exist!", fname) sys.exit(1) for i, line in enumerate(open(fname)): if line.startswith("#") or line.startswith("track") or line.startswith("...
[ "def", "check_bed_file", "(", "fname", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "fname", ")", ":", "logger", ".", "error", "(", "\"Inputfile %s does not exist!\"", ",", "fname", ")", "sys", ".", "exit", "(", "1", ")", "for", "i", ...
Check if the inputfile is a valid bed-file
[ "Check", "if", "the", "inputfile", "is", "a", "valid", "bed", "-", "file" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/validation.py#L13-L37
vanheeringen-lab/gimmemotifs
gimmemotifs/validation.py
check_denovo_input
def check_denovo_input(inputfile, params): """ Check if an input file is valid, which means BED, narrowPeak or FASTA """ background = params["background"] input_type = determine_file_type(inputfile) if input_type == "fasta": valid_bg = FA_VALID_BGS elif input_type in ["...
python
def check_denovo_input(inputfile, params): """ Check if an input file is valid, which means BED, narrowPeak or FASTA """ background = params["background"] input_type = determine_file_type(inputfile) if input_type == "fasta": valid_bg = FA_VALID_BGS elif input_type in ["...
[ "def", "check_denovo_input", "(", "inputfile", ",", "params", ")", ":", "background", "=", "params", "[", "\"background\"", "]", "input_type", "=", "determine_file_type", "(", "inputfile", ")", "if", "input_type", "==", "\"fasta\"", ":", "valid_bg", "=", "FA_VAL...
Check if an input file is valid, which means BED, narrowPeak or FASTA
[ "Check", "if", "an", "input", "file", "is", "valid", "which", "means", "BED", "narrowPeak", "or", "FASTA" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/validation.py#L41-L74
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
scan_to_best_match
def scan_to_best_match(fname, motifs, ncpus=None, genome=None, score=False): """Scan a FASTA file with motifs. Scan a FASTA file and return a dictionary with the best match per motif. Parameters ---------- fname : str Filename of a sequence file in FASTA format. motifs : list ...
python
def scan_to_best_match(fname, motifs, ncpus=None, genome=None, score=False): """Scan a FASTA file with motifs. Scan a FASTA file and return a dictionary with the best match per motif. Parameters ---------- fname : str Filename of a sequence file in FASTA format. motifs : list ...
[ "def", "scan_to_best_match", "(", "fname", ",", "motifs", ",", "ncpus", "=", "None", ",", "genome", "=", "None", ",", "score", "=", "False", ")", ":", "# Initialize scanner", "s", "=", "Scanner", "(", "ncpus", "=", "ncpus", ")", "s", ".", "set_motifs", ...
Scan a FASTA file with motifs. Scan a FASTA file and return a dictionary with the best match per motif. Parameters ---------- fname : str Filename of a sequence file in FASTA format. motifs : list List of motif instances. Returns ------- result : dict Dictiona...
[ "Scan", "a", "FASTA", "file", "with", "motifs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L55-L96
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
Scanner.set_background
def set_background(self, fname=None, genome=None, length=200, nseq=10000): """Set the background to use for FPR and z-score calculations. Background can be specified either as a genome name or as the name of a FASTA file. Parameters ---------- fname : str, opti...
python
def set_background(self, fname=None, genome=None, length=200, nseq=10000): """Set the background to use for FPR and z-score calculations. Background can be specified either as a genome name or as the name of a FASTA file. Parameters ---------- fname : str, opti...
[ "def", "set_background", "(", "self", ",", "fname", "=", "None", ",", "genome", "=", "None", ",", "length", "=", "200", ",", "nseq", "=", "10000", ")", ":", "length", "=", "int", "(", "length", ")", "if", "genome", "and", "fname", ":", "raise", "Va...
Set the background to use for FPR and z-score calculations. Background can be specified either as a genome name or as the name of a FASTA file. Parameters ---------- fname : str, optional Name of FASTA file to use as background. genome : str, optio...
[ "Set", "the", "background", "to", "use", "for", "FPR", "and", "z", "-", "score", "calculations", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L378-L428
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
Scanner.set_threshold
def set_threshold(self, fpr=None, threshold=None): """Set motif scanning threshold based on background sequences. Parameters ---------- fpr : float, optional Desired FPR, between 0.0 and 1.0. threshold : float or str, optional Desired motif threshold, ex...
python
def set_threshold(self, fpr=None, threshold=None): """Set motif scanning threshold based on background sequences. Parameters ---------- fpr : float, optional Desired FPR, between 0.0 and 1.0. threshold : float or str, optional Desired motif threshold, ex...
[ "def", "set_threshold", "(", "self", ",", "fpr", "=", "None", ",", "threshold", "=", "None", ")", ":", "if", "threshold", "and", "fpr", ":", "raise", "ValueError", "(", "\"Need either fpr or threshold.\"", ")", "if", "fpr", ":", "fpr", "=", "float", "(", ...
Set motif scanning threshold based on background sequences. Parameters ---------- fpr : float, optional Desired FPR, between 0.0 and 1.0. threshold : float or str, optional Desired motif threshold, expressed as the fraction of the difference between...
[ "Set", "motif", "scanning", "threshold", "based", "on", "background", "sequences", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L430-L499
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
Scanner.count
def count(self, seqs, nreport=100, scan_rc=True): """ count the number of matches above the cutoff returns an iterator of lists containing integer counts """ for matches in self.scan(seqs, nreport, scan_rc): counts = [len(m) for m in matches] yield counts
python
def count(self, seqs, nreport=100, scan_rc=True): """ count the number of matches above the cutoff returns an iterator of lists containing integer counts """ for matches in self.scan(seqs, nreport, scan_rc): counts = [len(m) for m in matches] yield counts
[ "def", "count", "(", "self", ",", "seqs", ",", "nreport", "=", "100", ",", "scan_rc", "=", "True", ")", ":", "for", "matches", "in", "self", ".", "scan", "(", "seqs", ",", "nreport", ",", "scan_rc", ")", ":", "counts", "=", "[", "len", "(", "m", ...
count the number of matches above the cutoff returns an iterator of lists containing integer counts
[ "count", "the", "number", "of", "matches", "above", "the", "cutoff", "returns", "an", "iterator", "of", "lists", "containing", "integer", "counts" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L515-L522
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
Scanner.total_count
def total_count(self, seqs, nreport=100, scan_rc=True): """ count the number of matches above the cutoff returns an iterator of lists containing integer counts """ count_table = [counts for counts in self.count(seqs, nreport, scan_rc)] return np.sum(np.array(coun...
python
def total_count(self, seqs, nreport=100, scan_rc=True): """ count the number of matches above the cutoff returns an iterator of lists containing integer counts """ count_table = [counts for counts in self.count(seqs, nreport, scan_rc)] return np.sum(np.array(coun...
[ "def", "total_count", "(", "self", ",", "seqs", ",", "nreport", "=", "100", ",", "scan_rc", "=", "True", ")", ":", "count_table", "=", "[", "counts", "for", "counts", "in", "self", ".", "count", "(", "seqs", ",", "nreport", ",", "scan_rc", ")", "]", ...
count the number of matches above the cutoff returns an iterator of lists containing integer counts
[ "count", "the", "number", "of", "matches", "above", "the", "cutoff", "returns", "an", "iterator", "of", "lists", "containing", "integer", "counts" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L524-L531
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
Scanner.best_score
def best_score(self, seqs, scan_rc=True, normalize=False): """ give the score of the best match of each motif in each sequence returns an iterator of lists containing floats """ self.set_threshold(threshold=0.0) if normalize and len(self.meanstd) == 0: self.se...
python
def best_score(self, seqs, scan_rc=True, normalize=False): """ give the score of the best match of each motif in each sequence returns an iterator of lists containing floats """ self.set_threshold(threshold=0.0) if normalize and len(self.meanstd) == 0: self.se...
[ "def", "best_score", "(", "self", ",", "seqs", ",", "scan_rc", "=", "True", ",", "normalize", "=", "False", ")", ":", "self", ".", "set_threshold", "(", "threshold", "=", "0.0", ")", "if", "normalize", "and", "len", "(", "self", ".", "meanstd", ")", ...
give the score of the best match of each motif in each sequence returns an iterator of lists containing floats
[ "give", "the", "score", "of", "the", "best", "match", "of", "each", "motif", "in", "each", "sequence", "returns", "an", "iterator", "of", "lists", "containing", "floats" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L533-L548
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
Scanner.best_match
def best_match(self, seqs, scan_rc=True): """ give the best match of each motif in each sequence returns an iterator of nested lists containing tuples: (score, position, strand) """ self.set_threshold(threshold=0.0) for matches in self.scan(seqs, 1, scan_rc): ...
python
def best_match(self, seqs, scan_rc=True): """ give the best match of each motif in each sequence returns an iterator of nested lists containing tuples: (score, position, strand) """ self.set_threshold(threshold=0.0) for matches in self.scan(seqs, 1, scan_rc): ...
[ "def", "best_match", "(", "self", ",", "seqs", ",", "scan_rc", "=", "True", ")", ":", "self", ".", "set_threshold", "(", "threshold", "=", "0.0", ")", "for", "matches", "in", "self", ".", "scan", "(", "seqs", ",", "1", ",", "scan_rc", ")", ":", "yi...
give the best match of each motif in each sequence returns an iterator of nested lists containing tuples: (score, position, strand)
[ "give", "the", "best", "match", "of", "each", "motif", "in", "each", "sequence", "returns", "an", "iterator", "of", "nested", "lists", "containing", "tuples", ":", "(", "score", "position", "strand", ")" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L550-L558
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
Scanner.scan
def scan(self, seqs, nreport=100, scan_rc=True, normalize=False): """ scan a set of regions / sequences """ if not self.threshold: sys.stderr.write( "Using default threshold of 0.95. " "This is likely not optimal!\n" ) ...
python
def scan(self, seqs, nreport=100, scan_rc=True, normalize=False): """ scan a set of regions / sequences """ if not self.threshold: sys.stderr.write( "Using default threshold of 0.95. " "This is likely not optimal!\n" ) ...
[ "def", "scan", "(", "self", ",", "seqs", ",", "nreport", "=", "100", ",", "scan_rc", "=", "True", ",", "normalize", "=", "False", ")", ":", "if", "not", "self", ".", "threshold", ":", "sys", ".", "stderr", ".", "write", "(", "\"Using default threshold ...
scan a set of regions / sequences
[ "scan", "a", "set", "of", "regions", "/", "sequences" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L560-L593
vanheeringen-lab/gimmemotifs
gimmemotifs/commands/roc.py
roc
def roc(args): """ Calculate ROC_AUC and other metrics and optionally plot ROC curve.""" outputfile = args.outfile # Default extension for image if outputfile and not outputfile.endswith(".png"): outputfile += ".png" motifs = read_motifs(args.pwmfile, fmt="pwm") ids = [] if arg...
python
def roc(args): """ Calculate ROC_AUC and other metrics and optionally plot ROC curve.""" outputfile = args.outfile # Default extension for image if outputfile and not outputfile.endswith(".png"): outputfile += ".png" motifs = read_motifs(args.pwmfile, fmt="pwm") ids = [] if arg...
[ "def", "roc", "(", "args", ")", ":", "outputfile", "=", "args", ".", "outfile", "# Default extension for image", "if", "outputfile", "and", "not", "outputfile", ".", "endswith", "(", "\".png\"", ")", ":", "outputfile", "+=", "\".png\"", "motifs", "=", "read_mo...
Calculate ROC_AUC and other metrics and optionally plot ROC curve.
[ "Calculate", "ROC_AUC", "and", "other", "metrics", "and", "optionally", "plot", "ROC", "curve", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/commands/roc.py#L85-L161
vanheeringen-lab/gimmemotifs
gimmemotifs/comparison.py
ssd
def ssd(p1, p2): """Calculates motif position similarity based on sum of squared distances. Parameters ---------- p1 : list Motif position 1. p2 : list Motif position 2. Returns ------- score : float """ return 2 - np.sum([(a-b)**2 for a,b in zip(p1...
python
def ssd(p1, p2): """Calculates motif position similarity based on sum of squared distances. Parameters ---------- p1 : list Motif position 1. p2 : list Motif position 2. Returns ------- score : float """ return 2 - np.sum([(a-b)**2 for a,b in zip(p1...
[ "def", "ssd", "(", "p1", ",", "p2", ")", ":", "return", "2", "-", "np", ".", "sum", "(", "[", "(", "a", "-", "b", ")", "**", "2", "for", "a", ",", "b", "in", "zip", "(", "p1", ",", "p2", ")", "]", ")" ]
Calculates motif position similarity based on sum of squared distances. Parameters ---------- p1 : list Motif position 1. p2 : list Motif position 2. Returns ------- score : float
[ "Calculates", "motif", "position", "similarity", "based", "on", "sum", "of", "squared", "distances", ".", "Parameters", "----------", "p1", ":", "list", "Motif", "position", "1", ".", "p2", ":", "list", "Motif", "position", "2", ".", "Returns", "-------", "s...
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/comparison.py#L196-L211
vanheeringen-lab/gimmemotifs
gimmemotifs/comparison.py
seqcor
def seqcor(m1, m2, seq=None): """Calculates motif similarity based on Pearson correlation of scores. Based on Kielbasa (2015) and Grau (2015). Scores are calculated based on scanning a de Bruijn sequence of 7-mers. This sequence is taken from ShortCAKE (Orenstein & Shamir, 2015). Optionally anothe...
python
def seqcor(m1, m2, seq=None): """Calculates motif similarity based on Pearson correlation of scores. Based on Kielbasa (2015) and Grau (2015). Scores are calculated based on scanning a de Bruijn sequence of 7-mers. This sequence is taken from ShortCAKE (Orenstein & Shamir, 2015). Optionally anothe...
[ "def", "seqcor", "(", "m1", ",", "m2", ",", "seq", "=", "None", ")", ":", "l1", "=", "len", "(", "m1", ")", "l2", "=", "len", "(", "m2", ")", "l", "=", "max", "(", "l1", ",", "l2", ")", "if", "seq", "is", "None", ":", "seq", "=", "RCDB", ...
Calculates motif similarity based on Pearson correlation of scores. Based on Kielbasa (2015) and Grau (2015). Scores are calculated based on scanning a de Bruijn sequence of 7-mers. This sequence is taken from ShortCAKE (Orenstein & Shamir, 2015). Optionally another sequence can be given as an argumen...
[ "Calculates", "motif", "similarity", "based", "on", "Pearson", "correlation", "of", "scores", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/comparison.py#L213-L266
vanheeringen-lab/gimmemotifs
gimmemotifs/comparison.py
MotifComparer.compare_motifs
def compare_motifs(self, m1, m2, match="total", metric="wic", combine="mean", pval=False): """Compare two motifs. The similarity metric can be any of seqcor, pcc, ed, distance, wic, chisq, akl or ssd. If match is 'total' the similarity score is calculated for the whole match, ...
python
def compare_motifs(self, m1, m2, match="total", metric="wic", combine="mean", pval=False): """Compare two motifs. The similarity metric can be any of seqcor, pcc, ed, distance, wic, chisq, akl or ssd. If match is 'total' the similarity score is calculated for the whole match, ...
[ "def", "compare_motifs", "(", "self", ",", "m1", ",", "m2", ",", "match", "=", "\"total\"", ",", "metric", "=", "\"wic\"", ",", "combine", "=", "\"mean\"", ",", "pval", "=", "False", ")", ":", "if", "metric", "==", "\"seqcor\"", ":", "return", "seqcor"...
Compare two motifs. The similarity metric can be any of seqcor, pcc, ed, distance, wic, chisq, akl or ssd. If match is 'total' the similarity score is calculated for the whole match, including positions that are not present in both motifs. If match is partial or subtotal, onl...
[ "Compare", "two", "motifs", ".", "The", "similarity", "metric", "can", "be", "any", "of", "seqcor", "pcc", "ed", "distance", "wic", "chisq", "akl", "or", "ssd", ".", "If", "match", "is", "total", "the", "similarity", "score", "is", "calculated", "for", "...
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/comparison.py#L322-L386
vanheeringen-lab/gimmemotifs
gimmemotifs/comparison.py
MotifComparer.get_all_scores
def get_all_scores(self, motifs, dbmotifs, match, metric, combine, pval=False, parallel=True, trim=None, ncpus=None): """Pairwise comparison of a set of motifs compared to reference motifs. Parameters ---------- motifs : list List of Motif instan...
python
def get_all_scores(self, motifs, dbmotifs, match, metric, combine, pval=False, parallel=True, trim=None, ncpus=None): """Pairwise comparison of a set of motifs compared to reference motifs. Parameters ---------- motifs : list List of Motif instan...
[ "def", "get_all_scores", "(", "self", ",", "motifs", ",", "dbmotifs", ",", "match", ",", "metric", ",", "combine", ",", "pval", "=", "False", ",", "parallel", "=", "True", ",", "trim", "=", "None", ",", "ncpus", "=", "None", ")", ":", "# trim motifs fi...
Pairwise comparison of a set of motifs compared to reference motifs. Parameters ---------- motifs : list List of Motif instances. dbmotifs : list List of Motif instances. match : str Match can be "partial", "subtotal" or "total". Not all met...
[ "Pairwise", "comparison", "of", "a", "set", "of", "motifs", "compared", "to", "reference", "motifs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/comparison.py#L574-L660
vanheeringen-lab/gimmemotifs
gimmemotifs/comparison.py
MotifComparer.get_closest_match
def get_closest_match(self, motifs, dbmotifs=None, match="partial", metric="wic",combine="mean", parallel=True, ncpus=None): """Return best match in database for motifs. Parameters ---------- motifs : list or str Filename of motifs or list of motifs. dbmotifs : list...
python
def get_closest_match(self, motifs, dbmotifs=None, match="partial", metric="wic",combine="mean", parallel=True, ncpus=None): """Return best match in database for motifs. Parameters ---------- motifs : list or str Filename of motifs or list of motifs. dbmotifs : list...
[ "def", "get_closest_match", "(", "self", ",", "motifs", ",", "dbmotifs", "=", "None", ",", "match", "=", "\"partial\"", ",", "metric", "=", "\"wic\"", ",", "combine", "=", "\"mean\"", ",", "parallel", "=", "True", ",", "ncpus", "=", "None", ")", ":", "...
Return best match in database for motifs. Parameters ---------- motifs : list or str Filename of motifs or list of motifs. dbmotifs : list or str, optional Database motifs, default will be used if not specified. match : str, optional metric : s...
[ "Return", "best", "match", "in", "database", "for", "motifs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/comparison.py#L662-L711
eofs/aws
aws/main.py
list_regions
def list_regions(service): """ List regions for the service """ for region in service.regions(): print '%(name)s: %(endpoint)s' % { 'name': region.name, 'endpoint': region.endpoint, }
python
def list_regions(service): """ List regions for the service """ for region in service.regions(): print '%(name)s: %(endpoint)s' % { 'name': region.name, 'endpoint': region.endpoint, }
[ "def", "list_regions", "(", "service", ")", ":", "for", "region", "in", "service", ".", "regions", "(", ")", ":", "print", "'%(name)s: %(endpoint)s'", "%", "{", "'name'", ":", "region", ".", "name", ",", "'endpoint'", ":", "region", ".", "endpoint", ",", ...
List regions for the service
[ "List", "regions", "for", "the", "service" ]
train
https://github.com/eofs/aws/blob/479cbe27a9f289b43f32f8e3de7d048a4a8993fe/aws/main.py#L18-L26
eofs/aws
aws/main.py
elb_table
def elb_table(balancers): """ Print nice looking table of information from list of load balancers """ t = prettytable.PrettyTable(['Name', 'DNS', 'Ports', 'Zones', 'Created']) t.align = 'l' for b in balancers: ports = ['%s: %s -> %s' % (l[2], l[0], l[1]) for l in b.listeners] por...
python
def elb_table(balancers): """ Print nice looking table of information from list of load balancers """ t = prettytable.PrettyTable(['Name', 'DNS', 'Ports', 'Zones', 'Created']) t.align = 'l' for b in balancers: ports = ['%s: %s -> %s' % (l[2], l[0], l[1]) for l in b.listeners] por...
[ "def", "elb_table", "(", "balancers", ")", ":", "t", "=", "prettytable", ".", "PrettyTable", "(", "[", "'Name'", ",", "'DNS'", ",", "'Ports'", ",", "'Zones'", ",", "'Created'", "]", ")", "t", ".", "align", "=", "'l'", "for", "b", "in", "balancers", "...
Print nice looking table of information from list of load balancers
[ "Print", "nice", "looking", "table", "of", "information", "from", "list", "of", "load", "balancers" ]
train
https://github.com/eofs/aws/blob/479cbe27a9f289b43f32f8e3de7d048a4a8993fe/aws/main.py#L29-L40
eofs/aws
aws/main.py
ec2_table
def ec2_table(instances): """ Print nice looking table of information from list of instances """ t = prettytable.PrettyTable(['ID', 'State', 'Monitored', 'Image', 'Name', 'Type', 'SSH key', 'DNS']) t.align = 'l' for i in instances: name = i.tags.get('Name', '') t.add_row([i.id, i...
python
def ec2_table(instances): """ Print nice looking table of information from list of instances """ t = prettytable.PrettyTable(['ID', 'State', 'Monitored', 'Image', 'Name', 'Type', 'SSH key', 'DNS']) t.align = 'l' for i in instances: name = i.tags.get('Name', '') t.add_row([i.id, i...
[ "def", "ec2_table", "(", "instances", ")", ":", "t", "=", "prettytable", ".", "PrettyTable", "(", "[", "'ID'", ",", "'State'", ",", "'Monitored'", ",", "'Image'", ",", "'Name'", ",", "'Type'", ",", "'SSH key'", ",", "'DNS'", "]", ")", "t", ".", "align"...
Print nice looking table of information from list of instances
[ "Print", "nice", "looking", "table", "of", "information", "from", "list", "of", "instances" ]
train
https://github.com/eofs/aws/blob/479cbe27a9f289b43f32f8e3de7d048a4a8993fe/aws/main.py#L43-L52
eofs/aws
aws/main.py
ec2_image_table
def ec2_image_table(images): """ Print nice looking table of information from images """ t = prettytable.PrettyTable(['ID', 'State', 'Name', 'Owner', 'Root device', 'Is public', 'Description']) t.align = 'l' for i in images: t.add_row([i.id, i.state, i.name, i.ownerId, i.root_device_type...
python
def ec2_image_table(images): """ Print nice looking table of information from images """ t = prettytable.PrettyTable(['ID', 'State', 'Name', 'Owner', 'Root device', 'Is public', 'Description']) t.align = 'l' for i in images: t.add_row([i.id, i.state, i.name, i.ownerId, i.root_device_type...
[ "def", "ec2_image_table", "(", "images", ")", ":", "t", "=", "prettytable", ".", "PrettyTable", "(", "[", "'ID'", ",", "'State'", ",", "'Name'", ",", "'Owner'", ",", "'Root device'", ",", "'Is public'", ",", "'Description'", "]", ")", "t", ".", "align", ...
Print nice looking table of information from images
[ "Print", "nice", "looking", "table", "of", "information", "from", "images" ]
train
https://github.com/eofs/aws/blob/479cbe27a9f289b43f32f8e3de7d048a4a8993fe/aws/main.py#L54-L62
eofs/aws
aws/main.py
ec2_fab
def ec2_fab(service, args): """ Run Fabric commands against EC2 instances """ instance_ids = args.instances instances = service.list(elb=args.elb, instance_ids=instance_ids) hosts = service.resolve_hosts(instances) fab.env.hosts = hosts fab.env.key_filename = settings.get('SSH', 'KEY_FI...
python
def ec2_fab(service, args): """ Run Fabric commands against EC2 instances """ instance_ids = args.instances instances = service.list(elb=args.elb, instance_ids=instance_ids) hosts = service.resolve_hosts(instances) fab.env.hosts = hosts fab.env.key_filename = settings.get('SSH', 'KEY_FI...
[ "def", "ec2_fab", "(", "service", ",", "args", ")", ":", "instance_ids", "=", "args", ".", "instances", "instances", "=", "service", ".", "list", "(", "elb", "=", "args", ".", "elb", ",", "instance_ids", "=", "instance_ids", ")", "hosts", "=", "service",...
Run Fabric commands against EC2 instances
[ "Run", "Fabric", "commands", "against", "EC2", "instances" ]
train
https://github.com/eofs/aws/blob/479cbe27a9f289b43f32f8e3de7d048a4a8993fe/aws/main.py#L64-L92
eofs/aws
aws/main.py
main
def main(): """ AWS support script's main method """ p = argparse.ArgumentParser(description='Manage Amazon AWS services', prog='aws', version=__version__) subparsers = p.add_subparsers(help='Select Amazon AWS service to use') # Au...
python
def main(): """ AWS support script's main method """ p = argparse.ArgumentParser(description='Manage Amazon AWS services', prog='aws', version=__version__) subparsers = p.add_subparsers(help='Select Amazon AWS service to use') # Au...
[ "def", "main", "(", ")", ":", "p", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Manage Amazon AWS services'", ",", "prog", "=", "'aws'", ",", "version", "=", "__version__", ")", "subparsers", "=", "p", ".", "add_subparsers", "(", "help"...
AWS support script's main method
[ "AWS", "support", "script", "s", "main", "method" ]
train
https://github.com/eofs/aws/blob/479cbe27a9f289b43f32f8e3de7d048a4a8993fe/aws/main.py#L222-L330
pescadores/pescador
pescador/maps.py
buffer_stream
def buffer_stream(stream, buffer_size, partial=False, axis=None): '''Buffer "data" from an stream into one data object. Parameters ---------- stream : stream The stream to buffer buffer_size : int > 0 The number of examples to retain per batch. partial : bool, default=False ...
python
def buffer_stream(stream, buffer_size, partial=False, axis=None): '''Buffer "data" from an stream into one data object. Parameters ---------- stream : stream The stream to buffer buffer_size : int > 0 The number of examples to retain per batch. partial : bool, default=False ...
[ "def", "buffer_stream", "(", "stream", ",", "buffer_size", ",", "partial", "=", "False", ",", "axis", "=", "None", ")", ":", "data", "=", "[", "]", "count", "=", "0", "for", "item", "in", "stream", ":", "data", ".", "append", "(", "item", ")", "cou...
Buffer "data" from an stream into one data object. Parameters ---------- stream : stream The stream to buffer buffer_size : int > 0 The number of examples to retain per batch. partial : bool, default=False If True, yield a final partial batch on under-run. axis : int ...
[ "Buffer", "data", "from", "an", "stream", "into", "one", "data", "object", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/maps.py#L34-L84
pescadores/pescador
pescador/maps.py
tuples
def tuples(stream, *keys): """Reformat data as tuples. Parameters ---------- stream : iterable Stream of data objects. *keys : strings Keys to use for ordering data. Yields ------ items : tuple of np.ndarrays Data object reformated as a tuple. Raises -...
python
def tuples(stream, *keys): """Reformat data as tuples. Parameters ---------- stream : iterable Stream of data objects. *keys : strings Keys to use for ordering data. Yields ------ items : tuple of np.ndarrays Data object reformated as a tuple. Raises -...
[ "def", "tuples", "(", "stream", ",", "*", "keys", ")", ":", "if", "not", "keys", ":", "raise", "PescadorError", "(", "'Unable to generate tuples from '", "'an empty item set'", ")", "for", "data", "in", "stream", ":", "try", ":", "yield", "tuple", "(", "data...
Reformat data as tuples. Parameters ---------- stream : iterable Stream of data objects. *keys : strings Keys to use for ordering data. Yields ------ items : tuple of np.ndarrays Data object reformated as a tuple. Raises ------ DataError If the...
[ "Reformat", "data", "as", "tuples", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/maps.py#L87-L117
pescadores/pescador
pescador/maps.py
keras_tuples
def keras_tuples(stream, inputs=None, outputs=None): """Reformat data objects as keras-compatible tuples. For more detail: https://keras.io/models/model/#fit Parameters ---------- stream : iterable Stream of data objects. inputs : string or iterable of strings, None Keys to us...
python
def keras_tuples(stream, inputs=None, outputs=None): """Reformat data objects as keras-compatible tuples. For more detail: https://keras.io/models/model/#fit Parameters ---------- stream : iterable Stream of data objects. inputs : string or iterable of strings, None Keys to us...
[ "def", "keras_tuples", "(", "stream", ",", "inputs", "=", "None", ",", "outputs", "=", "None", ")", ":", "flatten_inputs", ",", "flatten_outputs", "=", "False", ",", "False", "if", "inputs", "and", "isinstance", "(", "inputs", ",", "six", ".", "string_type...
Reformat data objects as keras-compatible tuples. For more detail: https://keras.io/models/model/#fit Parameters ---------- stream : iterable Stream of data objects. inputs : string or iterable of strings, None Keys to use for ordered input data. If not specified, returns ...
[ "Reformat", "data", "objects", "as", "keras", "-", "compatible", "tuples", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/maps.py#L120-L179
vanheeringen-lab/gimmemotifs
gimmemotifs/commands/location.py
location
def location(args): """ Creates histrogram of motif location. Parameters ---------- args : argparse object Command line arguments. """ fastafile = args.fastafile pwmfile = args.pwmfile lwidth = args.width if not lwidth: f = Fasta(fastafile) lwidth = len(...
python
def location(args): """ Creates histrogram of motif location. Parameters ---------- args : argparse object Command line arguments. """ fastafile = args.fastafile pwmfile = args.pwmfile lwidth = args.width if not lwidth: f = Fasta(fastafile) lwidth = len(...
[ "def", "location", "(", "args", ")", ":", "fastafile", "=", "args", ".", "fastafile", "pwmfile", "=", "args", ".", "pwmfile", "lwidth", "=", "args", ".", "width", "if", "not", "lwidth", ":", "f", "=", "Fasta", "(", "fastafile", ")", "lwidth", "=", "l...
Creates histrogram of motif location. Parameters ---------- args : argparse object Command line arguments.
[ "Creates", "histrogram", "of", "motif", "location", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/commands/location.py#L18-L54
vanheeringen-lab/gimmemotifs
gimmemotifs/shutils.py
which
def which(fname): """Find location of executable.""" if "PATH" not in os.environ or not os.environ["PATH"]: path = os.defpath else: path = os.environ["PATH"] for p in [fname] + [os.path.join(x, fname) for x in path.split(os.pathsep)]: p = os.path.abspath(p) if os.access(...
python
def which(fname): """Find location of executable.""" if "PATH" not in os.environ or not os.environ["PATH"]: path = os.defpath else: path = os.environ["PATH"] for p in [fname] + [os.path.join(x, fname) for x in path.split(os.pathsep)]: p = os.path.abspath(p) if os.access(...
[ "def", "which", "(", "fname", ")", ":", "if", "\"PATH\"", "not", "in", "os", ".", "environ", "or", "not", "os", ".", "environ", "[", "\"PATH\"", "]", ":", "path", "=", "os", ".", "defpath", "else", ":", "path", "=", "os", ".", "environ", "[", "\"...
Find location of executable.
[ "Find", "location", "of", "executable", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/shutils.py#L11-L30
vanheeringen-lab/gimmemotifs
gimmemotifs/shutils.py
find_by_ext
def find_by_ext(dirname, ext): """Find all files in a directory by extension.""" # Get all fasta-files try: files = os.listdir(dirname) except OSError: if os.path.exists(dirname): cmd = "find {0} -maxdepth 1 -name \"*\"".format(dirname) p = sp.Popen(cmd, shel...
python
def find_by_ext(dirname, ext): """Find all files in a directory by extension.""" # Get all fasta-files try: files = os.listdir(dirname) except OSError: if os.path.exists(dirname): cmd = "find {0} -maxdepth 1 -name \"*\"".format(dirname) p = sp.Popen(cmd, shel...
[ "def", "find_by_ext", "(", "dirname", ",", "ext", ")", ":", "# Get all fasta-files", "try", ":", "files", "=", "os", ".", "listdir", "(", "dirname", ")", "except", "OSError", ":", "if", "os", ".", "path", ".", "exists", "(", "dirname", ")", ":", "cmd",...
Find all files in a directory by extension.
[ "Find", "all", "files", "in", "a", "directory", "by", "extension", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/shutils.py#L32-L49
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
default_motifs
def default_motifs(): """Return list of Motif instances from default motif database.""" config = MotifConfig() d = config.get_motif_dir() m = config.get_default_params()['motif_db'] if not d or not m: raise ValueError("default motif database not configured") fname = os.path.join(d, m) ...
python
def default_motifs(): """Return list of Motif instances from default motif database.""" config = MotifConfig() d = config.get_motif_dir() m = config.get_default_params()['motif_db'] if not d or not m: raise ValueError("default motif database not configured") fname = os.path.join(d, m) ...
[ "def", "default_motifs", "(", ")", ":", "config", "=", "MotifConfig", "(", ")", "d", "=", "config", ".", "get_motif_dir", "(", ")", "m", "=", "config", ".", "get_default_params", "(", ")", "[", "'motif_db'", "]", "if", "not", "d", "or", "not", "m", "...
Return list of Motif instances from default motif database.
[ "Return", "list", "of", "Motif", "instances", "from", "default", "motif", "database", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L1079-L1092
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
motif_from_align
def motif_from_align(align): """Convert alignment to motif. Converts a list with sequences to a motif. Sequences should be the same length. Parameters ---------- align : list List with sequences (A,C,G,T). Returns ------- m : Motif instance Motif created from ...
python
def motif_from_align(align): """Convert alignment to motif. Converts a list with sequences to a motif. Sequences should be the same length. Parameters ---------- align : list List with sequences (A,C,G,T). Returns ------- m : Motif instance Motif created from ...
[ "def", "motif_from_align", "(", "align", ")", ":", "width", "=", "len", "(", "align", "[", "0", "]", ")", "nucs", "=", "{", "\"A\"", ":", "0", ",", "\"C\"", ":", "1", ",", "\"G\"", ":", "2", ",", "\"T\"", ":", "3", "}", "pfm", "=", "[", "[", ...
Convert alignment to motif. Converts a list with sequences to a motif. Sequences should be the same length. Parameters ---------- align : list List with sequences (A,C,G,T). Returns ------- m : Motif instance Motif created from the aligned sequences.
[ "Convert", "alignment", "to", "motif", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L1094-L1118
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
motif_from_consensus
def motif_from_consensus(cons, n=12): """Convert consensus sequence to motif. Converts a consensus sequences using the nucleotide IUPAC alphabet to a motif. Parameters ---------- cons : str Consensus sequence using the IUPAC alphabet. n : int , optional Count used to conv...
python
def motif_from_consensus(cons, n=12): """Convert consensus sequence to motif. Converts a consensus sequences using the nucleotide IUPAC alphabet to a motif. Parameters ---------- cons : str Consensus sequence using the IUPAC alphabet. n : int , optional Count used to conv...
[ "def", "motif_from_consensus", "(", "cons", ",", "n", "=", "12", ")", ":", "width", "=", "len", "(", "cons", ")", "nucs", "=", "{", "\"A\"", ":", "0", ",", "\"C\"", ":", "1", ",", "\"G\"", ":", "2", ",", "\"T\"", ":", "3", "}", "pfm", "=", "[...
Convert consensus sequence to motif. Converts a consensus sequences using the nucleotide IUPAC alphabet to a motif. Parameters ---------- cons : str Consensus sequence using the IUPAC alphabet. n : int , optional Count used to convert the sequence to a PFM. Returns ...
[ "Convert", "consensus", "sequence", "to", "motif", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L1120-L1147
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
parse_motifs
def parse_motifs(motifs): """Parse motifs in a variety of formats to return a list of motifs. Parameters ---------- motifs : list or str Filename of motif, list of motifs or single Motif instance. Returns ------- motifs : list List of Motif instances. """ if isin...
python
def parse_motifs(motifs): """Parse motifs in a variety of formats to return a list of motifs. Parameters ---------- motifs : list or str Filename of motif, list of motifs or single Motif instance. Returns ------- motifs : list List of Motif instances. """ if isin...
[ "def", "parse_motifs", "(", "motifs", ")", ":", "if", "isinstance", "(", "motifs", ",", "six", ".", "string_types", ")", ":", "with", "open", "(", "motifs", ")", "as", "f", ":", "if", "motifs", ".", "endswith", "(", "\"pwm\"", ")", "or", "motifs", "....
Parse motifs in a variety of formats to return a list of motifs. Parameters ---------- motifs : list or str Filename of motif, list of motifs or single Motif instance. Returns ------- motifs : list List of Motif instances.
[ "Parse", "motifs", "in", "a", "variety", "of", "formats", "to", "return", "a", "list", "of", "motifs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L1149-L1178
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
_read_motifs_from_filehandle
def _read_motifs_from_filehandle(handle, fmt): """ Read motifs from a file-like object. Parameters ---------- handle : file-like object Motifs. fmt : string, optional Motif format, can be 'pwm', 'transfac', 'xxmotif', 'jaspar' or 'align'. Returns ------- motifs...
python
def _read_motifs_from_filehandle(handle, fmt): """ Read motifs from a file-like object. Parameters ---------- handle : file-like object Motifs. fmt : string, optional Motif format, can be 'pwm', 'transfac', 'xxmotif', 'jaspar' or 'align'. Returns ------- motifs...
[ "def", "_read_motifs_from_filehandle", "(", "handle", ",", "fmt", ")", ":", "if", "fmt", ".", "lower", "(", ")", "==", "\"pwm\"", ":", "motifs", "=", "_read_motifs_pwm", "(", "handle", ")", "if", "fmt", ".", "lower", "(", ")", "==", "\"transfac\"", ":", ...
Read motifs from a file-like object. Parameters ---------- handle : file-like object Motifs. fmt : string, optional Motif format, can be 'pwm', 'transfac', 'xxmotif', 'jaspar' or 'align'. Returns ------- motifs : list List of Motif instances.
[ "Read", "motifs", "from", "a", "file", "-", "like", "object", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L1180-L1233
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
read_motifs
def read_motifs(infile=None, fmt="pwm", as_dict=False): """ Read motifs from a file or stream or file-like object. Parameters ---------- infile : string or file-like object, optional Motif database, filename of motif file or file-like object. If infile is not specified the default...
python
def read_motifs(infile=None, fmt="pwm", as_dict=False): """ Read motifs from a file or stream or file-like object. Parameters ---------- infile : string or file-like object, optional Motif database, filename of motif file or file-like object. If infile is not specified the default...
[ "def", "read_motifs", "(", "infile", "=", "None", ",", "fmt", "=", "\"pwm\"", ",", "as_dict", "=", "False", ")", ":", "if", "infile", "is", "None", "or", "isinstance", "(", "infile", ",", "six", ".", "string_types", ")", ":", "infile", "=", "pwmfile_lo...
Read motifs from a file or stream or file-like object. Parameters ---------- infile : string or file-like object, optional Motif database, filename of motif file or file-like object. If infile is not specified the default motifs as specified in the config file will be returned. ...
[ "Read", "motifs", "from", "a", "file", "or", "stream", "or", "file", "-", "like", "object", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L1236-L1269
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.information_content
def information_content(self): """Return the total information content of the motif. Return ------ ic : float Motif information content. """ ic = 0 for row in self.pwm: ic += 2.0 + np.sum([row[x] * log(row[x])/log(2) for x in range(4) if r...
python
def information_content(self): """Return the total information content of the motif. Return ------ ic : float Motif information content. """ ic = 0 for row in self.pwm: ic += 2.0 + np.sum([row[x] * log(row[x])/log(2) for x in range(4) if r...
[ "def", "information_content", "(", "self", ")", ":", "ic", "=", "0", "for", "row", "in", "self", ".", "pwm", ":", "ic", "+=", "2.0", "+", "np", ".", "sum", "(", "[", "row", "[", "x", "]", "*", "log", "(", "row", "[", "x", "]", ")", "/", "lo...
Return the total information content of the motif. Return ------ ic : float Motif information content.
[ "Return", "the", "total", "information", "content", "of", "the", "motif", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L167-L178
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.pwm_min_score
def pwm_min_score(self): """Return the minimum PWM score. Returns ------- score : float Minimum PWM score. """ if self.min_score is None: score = 0 for row in self.pwm: score += log(min(row) / 0.25 + 0.01) s...
python
def pwm_min_score(self): """Return the minimum PWM score. Returns ------- score : float Minimum PWM score. """ if self.min_score is None: score = 0 for row in self.pwm: score += log(min(row) / 0.25 + 0.01) s...
[ "def", "pwm_min_score", "(", "self", ")", ":", "if", "self", ".", "min_score", "is", "None", ":", "score", "=", "0", "for", "row", "in", "self", ".", "pwm", ":", "score", "+=", "log", "(", "min", "(", "row", ")", "/", "0.25", "+", "0.01", ")", ...
Return the minimum PWM score. Returns ------- score : float Minimum PWM score.
[ "Return", "the", "minimum", "PWM", "score", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L180-L194
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.pwm_max_score
def pwm_max_score(self): """Return the maximum PWM score. Returns ------- score : float Maximum PWM score. """ if self.max_score is None: score = 0 for row in self.pwm: score += log(max(row) / 0.25 + 0.01) s...
python
def pwm_max_score(self): """Return the maximum PWM score. Returns ------- score : float Maximum PWM score. """ if self.max_score is None: score = 0 for row in self.pwm: score += log(max(row) / 0.25 + 0.01) s...
[ "def", "pwm_max_score", "(", "self", ")", ":", "if", "self", ".", "max_score", "is", "None", ":", "score", "=", "0", "for", "row", "in", "self", ".", "pwm", ":", "score", "+=", "log", "(", "max", "(", "row", ")", "/", "0.25", "+", "0.01", ")", ...
Return the maximum PWM score. Returns ------- score : float Maximum PWM score.
[ "Return", "the", "maximum", "PWM", "score", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L196-L210
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.score_kmer
def score_kmer(self, kmer): """Calculate the log-odds score for a specific k-mer. Parameters ---------- kmer : str String representing a kmer. Should be the same length as the motif. Returns ------- score : float Log-odd score. ...
python
def score_kmer(self, kmer): """Calculate the log-odds score for a specific k-mer. Parameters ---------- kmer : str String representing a kmer. Should be the same length as the motif. Returns ------- score : float Log-odd score. ...
[ "def", "score_kmer", "(", "self", ",", "kmer", ")", ":", "if", "len", "(", "kmer", ")", "!=", "len", "(", "self", ".", "pwm", ")", ":", "raise", "Exception", "(", "\"incorrect k-mer length\"", ")", "score", "=", "0.0", "d", "=", "{", "\"A\"", ":", ...
Calculate the log-odds score for a specific k-mer. Parameters ---------- kmer : str String representing a kmer. Should be the same length as the motif. Returns ------- score : float Log-odd score.
[ "Calculate", "the", "log", "-", "odds", "score", "for", "a", "specific", "k", "-", "mer", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L212-L233
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.pfm_to_pwm
def pfm_to_pwm(self, pfm, pseudo=0.001): """Convert PFM with counts to a PFM with fractions. Parameters ---------- pfm : list 2-dimensional list with counts. pseudo : float Pseudocount used in conversion. Returns ------- p...
python
def pfm_to_pwm(self, pfm, pseudo=0.001): """Convert PFM with counts to a PFM with fractions. Parameters ---------- pfm : list 2-dimensional list with counts. pseudo : float Pseudocount used in conversion. Returns ------- p...
[ "def", "pfm_to_pwm", "(", "self", ",", "pfm", ",", "pseudo", "=", "0.001", ")", ":", "return", "[", "[", "(", "x", "+", "pseudo", ")", "/", "(", "float", "(", "np", ".", "sum", "(", "row", ")", ")", "+", "pseudo", "*", "4", ")", "for", "x", ...
Convert PFM with counts to a PFM with fractions. Parameters ---------- pfm : list 2-dimensional list with counts. pseudo : float Pseudocount used in conversion. Returns ------- pwm : list 2-dimensional list with fracti...
[ "Convert", "PFM", "with", "counts", "to", "a", "PFM", "with", "fractions", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L235-L250
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.to_motevo
def to_motevo(self): """Return motif formatted in MotEvo (TRANSFAC-like) format Returns ------- m : str String of motif in MotEvo format. """ m = "//\n" m += "NA {}\n".format(self.id) m += "P0\tA\tC\tG\tT\n" for i, row in enume...
python
def to_motevo(self): """Return motif formatted in MotEvo (TRANSFAC-like) format Returns ------- m : str String of motif in MotEvo format. """ m = "//\n" m += "NA {}\n".format(self.id) m += "P0\tA\tC\tG\tT\n" for i, row in enume...
[ "def", "to_motevo", "(", "self", ")", ":", "m", "=", "\"//\\n\"", "m", "+=", "\"NA {}\\n\"", ".", "format", "(", "self", ".", "id", ")", "m", "+=", "\"P0\\tA\\tC\\tG\\tT\\n\"", "for", "i", ",", "row", "in", "enumerate", "(", "self", ".", "pfm", ")", ...
Return motif formatted in MotEvo (TRANSFAC-like) format Returns ------- m : str String of motif in MotEvo format.
[ "Return", "motif", "formatted", "in", "MotEvo", "(", "TRANSFAC", "-", "like", ")", "format", "Returns", "-------", "m", ":", "str", "String", "of", "motif", "in", "MotEvo", "format", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L252-L266
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.to_transfac
def to_transfac(self): """Return motif formatted in TRANSFAC format Returns ------- m : str String of motif in TRANSFAC format. """ m = "%s\t%s\t%s\n" % ("DE", self.id, "unknown") for i, (row, cons) in enumerate(zip(self.pfm, self.to_consensus...
python
def to_transfac(self): """Return motif formatted in TRANSFAC format Returns ------- m : str String of motif in TRANSFAC format. """ m = "%s\t%s\t%s\n" % ("DE", self.id, "unknown") for i, (row, cons) in enumerate(zip(self.pfm, self.to_consensus...
[ "def", "to_transfac", "(", "self", ")", ":", "m", "=", "\"%s\\t%s\\t%s\\n\"", "%", "(", "\"DE\"", ",", "self", ".", "id", ",", "\"unknown\"", ")", "for", "i", ",", "(", "row", ",", "cons", ")", "in", "enumerate", "(", "zip", "(", "self", ".", "pfm"...
Return motif formatted in TRANSFAC format Returns ------- m : str String of motif in TRANSFAC format.
[ "Return", "motif", "formatted", "in", "TRANSFAC", "format", "Returns", "-------", "m", ":", "str", "String", "of", "motif", "in", "TRANSFAC", "format", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L268-L280
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.to_meme
def to_meme(self): """Return motif formatted in MEME format Returns ------- m : str String of motif in MEME format. """ motif_id = self.id.replace(" ", "_") m = "MOTIF %s\n" % motif_id m += "BL MOTIF %s width=0 seqs=0\n"% motif_id ...
python
def to_meme(self): """Return motif formatted in MEME format Returns ------- m : str String of motif in MEME format. """ motif_id = self.id.replace(" ", "_") m = "MOTIF %s\n" % motif_id m += "BL MOTIF %s width=0 seqs=0\n"% motif_id ...
[ "def", "to_meme", "(", "self", ")", ":", "motif_id", "=", "self", ".", "id", ".", "replace", "(", "\" \"", ",", "\"_\"", ")", "m", "=", "\"MOTIF %s\\n\"", "%", "motif_id", "m", "+=", "\"BL MOTIF %s width=0 seqs=0\\n\"", "%", "motif_id", "m", "+=", "\"let...
Return motif formatted in MEME format Returns ------- m : str String of motif in MEME format.
[ "Return", "motif", "formatted", "in", "MEME", "format", "Returns", "-------", "m", ":", "str", "String", "of", "motif", "in", "MEME", "format", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L282-L295
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.ic_pos
def ic_pos(self, row1, row2=None): """Calculate the information content of one position. Returns ------- score : float Information content. """ if row2 is None: row2 = [0.25,0.25,0.25,0.25] score = 0 for a,b in zip(row1, row2): ...
python
def ic_pos(self, row1, row2=None): """Calculate the information content of one position. Returns ------- score : float Information content. """ if row2 is None: row2 = [0.25,0.25,0.25,0.25] score = 0 for a,b in zip(row1, row2): ...
[ "def", "ic_pos", "(", "self", ",", "row1", ",", "row2", "=", "None", ")", ":", "if", "row2", "is", "None", ":", "row2", "=", "[", "0.25", ",", "0.25", ",", "0.25", ",", "0.25", "]", "score", "=", "0", "for", "a", ",", "b", "in", "zip", "(", ...
Calculate the information content of one position. Returns ------- score : float Information content.
[ "Calculate", "the", "information", "content", "of", "one", "position", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L297-L312
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.pcc_pos
def pcc_pos(self, row1, row2): """Calculate the Pearson correlation coefficient of one position compared to another position. Returns ------- score : float Pearson correlation coefficient. """ mean1 = np.mean(row1) mean2 = np.mean(row2) ...
python
def pcc_pos(self, row1, row2): """Calculate the Pearson correlation coefficient of one position compared to another position. Returns ------- score : float Pearson correlation coefficient. """ mean1 = np.mean(row1) mean2 = np.mean(row2) ...
[ "def", "pcc_pos", "(", "self", ",", "row1", ",", "row2", ")", ":", "mean1", "=", "np", ".", "mean", "(", "row1", ")", "mean2", "=", "np", ".", "mean", "(", "row2", ")", "a", "=", "0", "x", "=", "0", "y", "=", "0", "for", "n1", ",", "n2", ...
Calculate the Pearson correlation coefficient of one position compared to another position. Returns ------- score : float Pearson correlation coefficient.
[ "Calculate", "the", "Pearson", "correlation", "coefficient", "of", "one", "position", "compared", "to", "another", "position", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L314-L337
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.rc
def rc(self): """Return the reverse complemented motif. Returns ------- m : Motif instance New Motif instance with the reverse complement of the input motif. """ m = Motif() m.pfm = [row[::-1] for row in self.pfm[::-1]] m.pwm = [row[::-1] for ...
python
def rc(self): """Return the reverse complemented motif. Returns ------- m : Motif instance New Motif instance with the reverse complement of the input motif. """ m = Motif() m.pfm = [row[::-1] for row in self.pfm[::-1]] m.pwm = [row[::-1] for ...
[ "def", "rc", "(", "self", ")", ":", "m", "=", "Motif", "(", ")", "m", ".", "pfm", "=", "[", "row", "[", ":", ":", "-", "1", "]", "for", "row", "in", "self", ".", "pfm", "[", ":", ":", "-", "1", "]", "]", "m", ".", "pwm", "=", "[", "ro...
Return the reverse complemented motif. Returns ------- m : Motif instance New Motif instance with the reverse complement of the input motif.
[ "Return", "the", "reverse", "complemented", "motif", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L339-L351
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.trim
def trim(self, edge_ic_cutoff=0.4): """Trim positions with an information content lower than the threshold. The default threshold is set to 0.4. The Motif will be changed in-place. Parameters ---------- edge_ic_cutoff : float, optional Information content threshold....
python
def trim(self, edge_ic_cutoff=0.4): """Trim positions with an information content lower than the threshold. The default threshold is set to 0.4. The Motif will be changed in-place. Parameters ---------- edge_ic_cutoff : float, optional Information content threshold....
[ "def", "trim", "(", "self", ",", "edge_ic_cutoff", "=", "0.4", ")", ":", "pwm", "=", "self", ".", "pwm", "[", ":", "]", "while", "len", "(", "pwm", ")", ">", "0", "and", "self", ".", "ic_pos", "(", "pwm", "[", "0", "]", ")", "<", "edge_ic_cutof...
Trim positions with an information content lower than the threshold. The default threshold is set to 0.4. The Motif will be changed in-place. Parameters ---------- edge_ic_cutoff : float, optional Information content threshold. All motif positions at the flanks ...
[ "Trim", "positions", "with", "an", "information", "content", "lower", "than", "the", "threshold", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L353-L383
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.consensus_scan
def consensus_scan(self, fa): """Scan FASTA with the motif as a consensus sequence. Parameters ---------- fa : Fasta object Fasta object to scan Returns ------- matches : dict Dictionaru with matches. """ regexp = ...
python
def consensus_scan(self, fa): """Scan FASTA with the motif as a consensus sequence. Parameters ---------- fa : Fasta object Fasta object to scan Returns ------- matches : dict Dictionaru with matches. """ regexp = ...
[ "def", "consensus_scan", "(", "self", ",", "fa", ")", ":", "regexp", "=", "\"\"", ".", "join", "(", "[", "\"[\"", "+", "\"\"", ".", "join", "(", "self", ".", "iupac", "[", "x", ".", "upper", "(", ")", "]", ")", "+", "\"]\"", "for", "x", "in", ...
Scan FASTA with the motif as a consensus sequence. Parameters ---------- fa : Fasta object Fasta object to scan Returns ------- matches : dict Dictionaru with matches.
[ "Scan", "FASTA", "with", "the", "motif", "as", "a", "consensus", "sequence", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L385-L406
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.pwm_scan
def pwm_scan(self, fa, cutoff=0.9, nreport=50, scan_rc=True): """Scan sequences with this motif. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nreport to 1, the best match for every sequence will be ret...
python
def pwm_scan(self, fa, cutoff=0.9, nreport=50, scan_rc=True): """Scan sequences with this motif. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nreport to 1, the best match for every sequence will be ret...
[ "def", "pwm_scan", "(", "self", ",", "fa", ",", "cutoff", "=", "0.9", ",", "nreport", "=", "50", ",", "scan_rc", "=", "True", ")", ":", "c", "=", "self", ".", "pwm_min_score", "(", ")", "+", "(", "self", ".", "pwm_max_score", "(", ")", "-", "self...
Scan sequences with this motif. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nreport to 1, the best match for every sequence will be returned. Only the position of the matches is returned. Par...
[ "Scan", "sequences", "with", "this", "motif", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L408-L443
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.pwm_scan_all
def pwm_scan_all(self, fa, cutoff=0.9, nreport=50, scan_rc=True): """Scan sequences with this motif. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nreport to 1, the best match for every sequence will be...
python
def pwm_scan_all(self, fa, cutoff=0.9, nreport=50, scan_rc=True): """Scan sequences with this motif. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nreport to 1, the best match for every sequence will be...
[ "def", "pwm_scan_all", "(", "self", ",", "fa", ",", "cutoff", "=", "0.9", ",", "nreport", "=", "50", ",", "scan_rc", "=", "True", ")", ":", "c", "=", "self", ".", "pwm_min_score", "(", ")", "+", "(", "self", ".", "pwm_max_score", "(", ")", "-", "...
Scan sequences with this motif. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nreport to 1, the best match for every sequence will be returned. The score, position and strand for every match is returned...
[ "Scan", "sequences", "with", "this", "motif", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L445-L479
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.pwm_scan_to_gff
def pwm_scan_to_gff(self, fa, gfffile, cutoff=0.9, nreport=50, scan_rc=True, append=False): """Scan sequences with this motif and save to a GFF file. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nrepor...
python
def pwm_scan_to_gff(self, fa, gfffile, cutoff=0.9, nreport=50, scan_rc=True, append=False): """Scan sequences with this motif and save to a GFF file. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nrepor...
[ "def", "pwm_scan_to_gff", "(", "self", ",", "fa", ",", "gfffile", ",", "cutoff", "=", "0.9", ",", "nreport", "=", "50", ",", "scan_rc", "=", "True", ",", "append", "=", "False", ")", ":", "if", "append", ":", "out", "=", "open", "(", "gfffile", ","...
Scan sequences with this motif and save to a GFF file. Scan sequences from a FASTA object with this motif. Less efficient than using a Scanner object. By setting the cutoff to 0.0 and nreport to 1, the best match for every sequence will be returned. The output is save to a file in GFF...
[ "Scan", "sequences", "with", "this", "motif", "and", "save", "to", "a", "GFF", "file", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L517-L564
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.average_motifs
def average_motifs(self, other, pos, orientation, include_bg=False): """Return the average of two motifs. Combine this motif with another motif and return the average as a new Motif object. The position and orientatien need to be supplied. The pos parameter is the position of the second...
python
def average_motifs(self, other, pos, orientation, include_bg=False): """Return the average of two motifs. Combine this motif with another motif and return the average as a new Motif object. The position and orientatien need to be supplied. The pos parameter is the position of the second...
[ "def", "average_motifs", "(", "self", ",", "other", ",", "pos", ",", "orientation", ",", "include_bg", "=", "False", ")", ":", "# xxCATGYT", "# GGCTTGYx", "# pos = -2", "pfm1", "=", "self", ".", "pfm", "[", ":", "]", "pfm2", "=", "other", ".", "pfm", "...
Return the average of two motifs. Combine this motif with another motif and return the average as a new Motif object. The position and orientatien need to be supplied. The pos parameter is the position of the second motif relative to this motif. For example, take the following ...
[ "Return", "the", "average", "of", "two", "motifs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L566-L637
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif._pwm_to_str
def _pwm_to_str(self, precision=4): """Return string representation of pwm. Parameters ---------- precision : int, optional, default 4 Floating-point precision. Returns ------- pwm_string : str """ if not self.pwm: return ...
python
def _pwm_to_str(self, precision=4): """Return string representation of pwm. Parameters ---------- precision : int, optional, default 4 Floating-point precision. Returns ------- pwm_string : str """ if not self.pwm: return ...
[ "def", "_pwm_to_str", "(", "self", ",", "precision", "=", "4", ")", ":", "if", "not", "self", ".", "pwm", ":", "return", "\"\"", "fmt", "=", "\"{{:.{:d}f}}\"", ".", "format", "(", "precision", ")", "return", "\"\\n\"", ".", "join", "(", "[", "\"\\t\"",...
Return string representation of pwm. Parameters ---------- precision : int, optional, default 4 Floating-point precision. Returns ------- pwm_string : str
[ "Return", "string", "representation", "of", "pwm", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L906-L925
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.to_pwm
def to_pwm(self, precision=4, extra_str=""): """Return pwm as string. Parameters ---------- precision : int, optional, default 4 Floating-point precision. extra_str |: str, optional Extra text to include with motif id line. Retur...
python
def to_pwm(self, precision=4, extra_str=""): """Return pwm as string. Parameters ---------- precision : int, optional, default 4 Floating-point precision. extra_str |: str, optional Extra text to include with motif id line. Retur...
[ "def", "to_pwm", "(", "self", ",", "precision", "=", "4", ",", "extra_str", "=", "\"\"", ")", ":", "motif_id", "=", "self", ".", "id", "if", "extra_str", ":", "motif_id", "+=", "\"_%s\"", "%", "extra_str", "if", "not", "self", ".", "pwm", ":", "self"...
Return pwm as string. Parameters ---------- precision : int, optional, default 4 Floating-point precision. extra_str |: str, optional Extra text to include with motif id line. Returns ------- motif_str : str M...
[ "Return", "pwm", "as", "string", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L937-L964
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.to_img
def to_img(self, fname, fmt="PNG", add_left=0, seqlogo=None, height=6): """Create a sequence logo using seqlogo. Create a sequence logo and save it to a file. Valid formats are: PNG, EPS, GIF and PDF. Parameters ---------- fname : str Output filename. ...
python
def to_img(self, fname, fmt="PNG", add_left=0, seqlogo=None, height=6): """Create a sequence logo using seqlogo. Create a sequence logo and save it to a file. Valid formats are: PNG, EPS, GIF and PDF. Parameters ---------- fname : str Output filename. ...
[ "def", "to_img", "(", "self", ",", "fname", ",", "fmt", "=", "\"PNG\"", ",", "add_left", "=", "0", ",", "seqlogo", "=", "None", ",", "height", "=", "6", ")", ":", "if", "not", "seqlogo", ":", "seqlogo", "=", "self", ".", "seqlogo", "if", "not", "...
Create a sequence logo using seqlogo. Create a sequence logo and save it to a file. Valid formats are: PNG, EPS, GIF and PDF. Parameters ---------- fname : str Output filename. fmt : str , optional Output format (case-insensitive). Valid format...
[ "Create", "a", "sequence", "logo", "using", "seqlogo", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L966-L1039
vanheeringen-lab/gimmemotifs
gimmemotifs/motif.py
Motif.randomize
def randomize(self): """Create a new motif with shuffled positions. Shuffle the positions of this motif and return a new Motif instance. Returns ------- m : Motif instance Motif instance with shuffled positions. """ random_pfm = [[c for c in row] for...
python
def randomize(self): """Create a new motif with shuffled positions. Shuffle the positions of this motif and return a new Motif instance. Returns ------- m : Motif instance Motif instance with shuffled positions. """ random_pfm = [[c for c in row] for...
[ "def", "randomize", "(", "self", ")", ":", "random_pfm", "=", "[", "[", "c", "for", "c", "in", "row", "]", "for", "row", "in", "self", ".", "pfm", "]", "random", ".", "shuffle", "(", "random_pfm", ")", "m", "=", "Motif", "(", "pfm", "=", "random_...
Create a new motif with shuffled positions. Shuffle the positions of this motif and return a new Motif instance. Returns ------- m : Motif instance Motif instance with shuffled positions.
[ "Create", "a", "new", "motif", "with", "shuffled", "positions", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/motif.py#L1045-L1059
vanheeringen-lab/gimmemotifs
gimmemotifs/commands/maelstrom.py
maelstrom
def maelstrom(args): """Run the maelstrom method.""" infile = args.inputfile genome = args.genome outdir = args.outdir pwmfile = args.pwmfile methods = args.methods ncpus = args.ncpus if not os.path.exists(infile): raise ValueError("file {} does not exist".format(infile)) ...
python
def maelstrom(args): """Run the maelstrom method.""" infile = args.inputfile genome = args.genome outdir = args.outdir pwmfile = args.pwmfile methods = args.methods ncpus = args.ncpus if not os.path.exists(infile): raise ValueError("file {} does not exist".format(infile)) ...
[ "def", "maelstrom", "(", "args", ")", ":", "infile", "=", "args", ".", "inputfile", "genome", "=", "args", ".", "genome", "outdir", "=", "args", ".", "outdir", "pwmfile", "=", "args", ".", "pwmfile", "methods", "=", "args", ".", "methods", "ncpus", "="...
Run the maelstrom method.
[ "Run", "the", "maelstrom", "method", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/commands/maelstrom.py#L12-L27
pescadores/pescador
pescador/zmq_stream.py
zmq_send_data
def zmq_send_data(socket, data, flags=0, copy=True, track=False): """Send data, e.g. {key: np.ndarray}, with metadata""" header, payload = [], [] for key in sorted(data.keys()): arr = data[key] if not isinstance(arr, np.ndarray): raise DataError('Only ndarray types can be seri...
python
def zmq_send_data(socket, data, flags=0, copy=True, track=False): """Send data, e.g. {key: np.ndarray}, with metadata""" header, payload = [], [] for key in sorted(data.keys()): arr = data[key] if not isinstance(arr, np.ndarray): raise DataError('Only ndarray types can be seri...
[ "def", "zmq_send_data", "(", "socket", ",", "data", ",", "flags", "=", "0", ",", "copy", "=", "True", ",", "track", "=", "False", ")", ":", "header", ",", "payload", "=", "[", "]", ",", "[", "]", "for", "key", "in", "sorted", "(", "data", ".", ...
Send data, e.g. {key: np.ndarray}, with metadata
[ "Send", "data", "e", ".", "g", ".", "{", "key", ":", "np", ".", "ndarray", "}", "with", "metadata" ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/zmq_stream.py#L47-L69
pescadores/pescador
pescador/zmq_stream.py
zmq_recv_data
def zmq_recv_data(socket, flags=0, copy=True, track=False): """Receive data over a socket.""" data = dict() msg = socket.recv_multipart(flags=flags, copy=copy, track=track) headers = json.loads(msg[0].decode('ascii')) if len(headers) == 0: raise StopIteration for header, payload in ...
python
def zmq_recv_data(socket, flags=0, copy=True, track=False): """Receive data over a socket.""" data = dict() msg = socket.recv_multipart(flags=flags, copy=copy, track=track) headers = json.loads(msg[0].decode('ascii')) if len(headers) == 0: raise StopIteration for header, payload in ...
[ "def", "zmq_recv_data", "(", "socket", ",", "flags", "=", "0", ",", "copy", "=", "True", ",", "track", "=", "False", ")", ":", "data", "=", "dict", "(", ")", "msg", "=", "socket", ".", "recv_multipart", "(", "flags", "=", "flags", ",", "copy", "=",...
Receive data over a socket.
[ "Receive", "data", "over", "a", "socket", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/zmq_stream.py#L72-L93
pescadores/pescador
pescador/zmq_stream.py
ZMQStreamer.iterate
def iterate(self, max_iter=None): """ Note: A ZMQStreamer does not activate its stream, but allows the zmq_worker to do that. Yields ------ data : dict Data drawn from `streamer(max_iter)`. """ context = zmq.Context() if six.PY2: ...
python
def iterate(self, max_iter=None): """ Note: A ZMQStreamer does not activate its stream, but allows the zmq_worker to do that. Yields ------ data : dict Data drawn from `streamer(max_iter)`. """ context = zmq.Context() if six.PY2: ...
[ "def", "iterate", "(", "self", ",", "max_iter", "=", "None", ")", ":", "context", "=", "zmq", ".", "Context", "(", ")", "if", "six", ".", "PY2", ":", "warnings", ".", "warn", "(", "'zmq_stream cannot preserve numpy array alignment '", "'in Python 2'", ",", "...
Note: A ZMQStreamer does not activate its stream, but allows the zmq_worker to do that. Yields ------ data : dict Data drawn from `streamer(max_iter)`.
[ "Note", ":", "A", "ZMQStreamer", "does", "not", "activate", "its", "stream", "but", "allows", "the", "zmq_worker", "to", "do", "that", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/zmq_stream.py#L169-L218
vanheeringen-lab/gimmemotifs
gimmemotifs/fasta.py
Fasta.hardmask
def hardmask(self): """ Mask all lowercase nucleotides with N's """ p = re.compile("a|c|g|t|n") for seq_id in self.fasta_dict.keys(): self.fasta_dict[seq_id] = p.sub("N", self.fasta_dict[seq_id]) return self
python
def hardmask(self): """ Mask all lowercase nucleotides with N's """ p = re.compile("a|c|g|t|n") for seq_id in self.fasta_dict.keys(): self.fasta_dict[seq_id] = p.sub("N", self.fasta_dict[seq_id]) return self
[ "def", "hardmask", "(", "self", ")", ":", "p", "=", "re", ".", "compile", "(", "\"a|c|g|t|n\"", ")", "for", "seq_id", "in", "self", ".", "fasta_dict", ".", "keys", "(", ")", ":", "self", ".", "fasta_dict", "[", "seq_id", "]", "=", "p", ".", "sub", ...
Mask all lowercase nucleotides with N's
[ "Mask", "all", "lowercase", "nucleotides", "with", "N", "s" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/fasta.py#L39-L44
vanheeringen-lab/gimmemotifs
gimmemotifs/fasta.py
Fasta.get_random
def get_random(self, n, l=None): """ Return n random sequences from this Fasta object """ random_f = Fasta() if l: ids = self.ids[:] random.shuffle(ids) i = 0 while (i < n) and (len(ids) > 0): seq_id = ids.pop() if (...
python
def get_random(self, n, l=None): """ Return n random sequences from this Fasta object """ random_f = Fasta() if l: ids = self.ids[:] random.shuffle(ids) i = 0 while (i < n) and (len(ids) > 0): seq_id = ids.pop() if (...
[ "def", "get_random", "(", "self", ",", "n", ",", "l", "=", "None", ")", ":", "random_f", "=", "Fasta", "(", ")", "if", "l", ":", "ids", "=", "self", ".", "ids", "[", ":", "]", "random", ".", "shuffle", "(", "ids", ")", "i", "=", "0", "while",...
Return n random sequences from this Fasta object
[ "Return", "n", "random", "sequences", "from", "this", "Fasta", "object" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/fasta.py#L46-L69
vanheeringen-lab/gimmemotifs
gimmemotifs/fasta.py
Fasta.writefasta
def writefasta(self, fname): """ Write sequences to FASTA formatted file""" f = open(fname, "w") fa_str = "\n".join([">%s\n%s" % (id, self._format_seq(seq)) for id, seq in self.items()]) f.write(fa_str) f.close()
python
def writefasta(self, fname): """ Write sequences to FASTA formatted file""" f = open(fname, "w") fa_str = "\n".join([">%s\n%s" % (id, self._format_seq(seq)) for id, seq in self.items()]) f.write(fa_str) f.close()
[ "def", "writefasta", "(", "self", ",", "fname", ")", ":", "f", "=", "open", "(", "fname", ",", "\"w\"", ")", "fa_str", "=", "\"\\n\"", ".", "join", "(", "[", "\">%s\\n%s\"", "%", "(", "id", ",", "self", ".", "_format_seq", "(", "seq", ")", ")", "...
Write sequences to FASTA formatted file
[ "Write", "sequences", "to", "FASTA", "formatted", "file" ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/fasta.py#L117-L122
vanheeringen-lab/gimmemotifs
gimmemotifs/cluster.py
cluster_motifs
def cluster_motifs(motifs, match="total", metric="wic", combine="mean", pval=True, threshold=0.95, trim_edges=False, edge_ic_cutoff=0.2, include_bg=True, progress=True, ncpus=None): """ Clusters a set of sequence motifs. Required arg 'motifs' is a file containing positional frequency matrices or an array w...
python
def cluster_motifs(motifs, match="total", metric="wic", combine="mean", pval=True, threshold=0.95, trim_edges=False, edge_ic_cutoff=0.2, include_bg=True, progress=True, ncpus=None): """ Clusters a set of sequence motifs. Required arg 'motifs' is a file containing positional frequency matrices or an array w...
[ "def", "cluster_motifs", "(", "motifs", ",", "match", "=", "\"total\"", ",", "metric", "=", "\"wic\"", ",", "combine", "=", "\"mean\"", ",", "pval", "=", "True", ",", "threshold", "=", "0.95", ",", "trim_edges", "=", "False", ",", "edge_ic_cutoff", "=", ...
Clusters a set of sequence motifs. Required arg 'motifs' is a file containing positional frequency matrices or an array with motifs. Optional args: 'match', 'metric' and 'combine' specify the method used to compare and score the motifs. By default the WIC score is used (metric='wic'), using the the ...
[ "Clusters", "a", "set", "of", "sequence", "motifs", ".", "Required", "arg", "motifs", "is", "a", "file", "containing", "positional", "frequency", "matrices", "or", "an", "array", "with", "motifs", "." ]
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/cluster.py#L83-L225
pescadores/pescador
pescador/util.py
batch_length
def batch_length(batch): '''Determine the number of samples in a batch. Parameters ---------- batch : dict A batch dictionary. Each value must implement `len`. All values must have the same `len`. Returns ------- n : int >= 0 or None The number of samples in this b...
python
def batch_length(batch): '''Determine the number of samples in a batch. Parameters ---------- batch : dict A batch dictionary. Each value must implement `len`. All values must have the same `len`. Returns ------- n : int >= 0 or None The number of samples in this b...
[ "def", "batch_length", "(", "batch", ")", ":", "n", "=", "None", "for", "value", "in", "six", ".", "itervalues", "(", "batch", ")", ":", "if", "n", "is", "None", ":", "n", "=", "len", "(", "value", ")", "elif", "len", "(", "value", ")", "!=", "...
Determine the number of samples in a batch. Parameters ---------- batch : dict A batch dictionary. Each value must implement `len`. All values must have the same `len`. Returns ------- n : int >= 0 or None The number of samples in this batch. If the batch has n...
[ "Determine", "the", "number", "of", "samples", "in", "a", "batch", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/util.py#L121-L150
pescadores/pescador
pescador/mux.py
Mux._activate
def _activate(self): """Activates a number of streams""" self.distribution_ = 1. / self.n_streams * np.ones(self.n_streams) self.valid_streams_ = np.ones(self.n_streams, dtype=bool) self.streams_ = [None] * self.k self.stream_weights_ = np.zeros(self.k) self.stream_coun...
python
def _activate(self): """Activates a number of streams""" self.distribution_ = 1. / self.n_streams * np.ones(self.n_streams) self.valid_streams_ = np.ones(self.n_streams, dtype=bool) self.streams_ = [None] * self.k self.stream_weights_ = np.zeros(self.k) self.stream_coun...
[ "def", "_activate", "(", "self", ")", ":", "self", ".", "distribution_", "=", "1.", "/", "self", ".", "n_streams", "*", "np", ".", "ones", "(", "self", ".", "n_streams", ")", "self", ".", "valid_streams_", "=", "np", ".", "ones", "(", "self", ".", ...
Activates a number of streams
[ "Activates", "a", "number", "of", "streams" ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L237-L259
pescadores/pescador
pescador/mux.py
Mux._new_stream
def _new_stream(self, idx): '''Randomly select and create a stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace ''' # instantiate if self.rate is not None: n_stream = 1 + self.rng.poisson(lam=self.rate) ...
python
def _new_stream(self, idx): '''Randomly select and create a stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace ''' # instantiate if self.rate is not None: n_stream = 1 + self.rng.poisson(lam=self.rate) ...
[ "def", "_new_stream", "(", "self", ",", "idx", ")", ":", "# instantiate", "if", "self", ".", "rate", "is", "not", "None", ":", "n_stream", "=", "1", "+", "self", ".", "rng", ".", "poisson", "(", "lam", "=", "self", ".", "rate", ")", "else", ":", ...
Randomly select and create a stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace
[ "Randomly", "select", "and", "create", "a", "stream", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L341-L366
pescadores/pescador
pescador/mux.py
BaseMux.iterate
def iterate(self, max_iter=None): """Yields items from the mux, and handles stream exhaustion and replacement. """ if max_iter is None: max_iter = np.inf # Calls Streamer's __enter__, which calls activate() with self as active_mux: # Main sampling...
python
def iterate(self, max_iter=None): """Yields items from the mux, and handles stream exhaustion and replacement. """ if max_iter is None: max_iter = np.inf # Calls Streamer's __enter__, which calls activate() with self as active_mux: # Main sampling...
[ "def", "iterate", "(", "self", ",", "max_iter", "=", "None", ")", ":", "if", "max_iter", "is", "None", ":", "max_iter", "=", "np", ".", "inf", "# Calls Streamer's __enter__, which calls activate()", "with", "self", "as", "active_mux", ":", "# Main sampling loop", ...
Yields items from the mux, and handles stream exhaustion and replacement.
[ "Yields", "items", "from", "the", "mux", "and", "handles", "stream", "exhaustion", "and", "replacement", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L479-L511
pescadores/pescador
pescador/mux.py
StochasticMux._next_sample_index
def _next_sample_index(self): """StochasticMux chooses its next sample stream randomly""" return self.rng.choice(self.n_active, p=(self.stream_weights_ / self.weight_norm_))
python
def _next_sample_index(self): """StochasticMux chooses its next sample stream randomly""" return self.rng.choice(self.n_active, p=(self.stream_weights_ / self.weight_norm_))
[ "def", "_next_sample_index", "(", "self", ")", ":", "return", "self", ".", "rng", ".", "choice", "(", "self", ".", "n_active", ",", "p", "=", "(", "self", ".", "stream_weights_", "/", "self", ".", "weight_norm_", ")", ")" ]
StochasticMux chooses its next sample stream randomly
[ "StochasticMux", "chooses", "its", "next", "sample", "stream", "randomly" ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L713-L717
pescadores/pescador
pescador/mux.py
StochasticMux._activate_stream
def _activate_stream(self, idx): '''Randomly select and create a stream. StochasticMux adds mode handling to _activate_stream, making it so that if we're not sampling "with_replacement", the distribution for this chosen streamer is set to 0, causing the streamer not to be available ...
python
def _activate_stream(self, idx): '''Randomly select and create a stream. StochasticMux adds mode handling to _activate_stream, making it so that if we're not sampling "with_replacement", the distribution for this chosen streamer is set to 0, causing the streamer not to be available ...
[ "def", "_activate_stream", "(", "self", ",", "idx", ")", ":", "# Get the number of samples for this streamer.", "n_samples_to_stream", "=", "None", "if", "self", ".", "rate", "is", "not", "None", ":", "n_samples_to_stream", "=", "1", "+", "self", ".", "rng", "."...
Randomly select and create a stream. StochasticMux adds mode handling to _activate_stream, making it so that if we're not sampling "with_replacement", the distribution for this chosen streamer is set to 0, causing the streamer not to be available until it is exhausted. Paramete...
[ "Randomly", "select", "and", "create", "a", "stream", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L738-L771
pescadores/pescador
pescador/mux.py
StochasticMux._new_stream
def _new_stream(self, idx): '''Randomly select and create a new stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace ''' # Choose the stream index from the candidate pool self.stream_idxs_[idx] = self.rng.choice( ...
python
def _new_stream(self, idx): '''Randomly select and create a new stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace ''' # Choose the stream index from the candidate pool self.stream_idxs_[idx] = self.rng.choice( ...
[ "def", "_new_stream", "(", "self", ",", "idx", ")", ":", "# Choose the stream index from the candidate pool", "self", ".", "stream_idxs_", "[", "idx", "]", "=", "self", ".", "rng", ".", "choice", "(", "self", ".", "n_streams", ",", "p", "=", "self", ".", "...
Randomly select and create a new stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace
[ "Randomly", "select", "and", "create", "a", "new", "stream", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L773-L790
pescadores/pescador
pescador/mux.py
ShuffledMux._activate
def _activate(self): """ShuffledMux's activate is similar to StochasticMux, but there is no 'n_active', since all the streams are always available. """ self.streams_ = [None] * self.n_streams # Weights of the active streams. # Once a stream is exhausted, it is set to 0. ...
python
def _activate(self): """ShuffledMux's activate is similar to StochasticMux, but there is no 'n_active', since all the streams are always available. """ self.streams_ = [None] * self.n_streams # Weights of the active streams. # Once a stream is exhausted, it is set to 0. ...
[ "def", "_activate", "(", "self", ")", ":", "self", ".", "streams_", "=", "[", "None", "]", "*", "self", ".", "n_streams", "# Weights of the active streams.", "# Once a stream is exhausted, it is set to 0.", "# Upon activation, this is just a copy of self.weights.", "self", ...
ShuffledMux's activate is similar to StochasticMux, but there is no 'n_active', since all the streams are always available.
[ "ShuffledMux", "s", "activate", "is", "similar", "to", "StochasticMux", "but", "there", "is", "no", "n_active", "since", "all", "the", "streams", "are", "always", "available", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L888-L906
pescadores/pescador
pescador/mux.py
ShuffledMux._next_sample_index
def _next_sample_index(self): """ShuffledMux chooses its next sample stream randomly, conditioned on the stream weights. """ return self.rng.choice(self.n_streams, p=(self.stream_weights_ / self.weight_norm_))
python
def _next_sample_index(self): """ShuffledMux chooses its next sample stream randomly, conditioned on the stream weights. """ return self.rng.choice(self.n_streams, p=(self.stream_weights_ / self.weight_norm_))
[ "def", "_next_sample_index", "(", "self", ")", ":", "return", "self", ".", "rng", ".", "choice", "(", "self", ".", "n_streams", ",", "p", "=", "(", "self", ".", "stream_weights_", "/", "self", ".", "weight_norm_", ")", ")" ]
ShuffledMux chooses its next sample stream randomly, conditioned on the stream weights.
[ "ShuffledMux", "chooses", "its", "next", "sample", "stream", "randomly", "conditioned", "on", "the", "stream", "weights", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L917-L923
pescadores/pescador
pescador/mux.py
ShuffledMux._new_stream
def _new_stream(self, idx): '''Randomly select and create a new stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace ''' # Don't activate the stream if the weight is 0 or None if self.stream_weights_[idx]: ...
python
def _new_stream(self, idx): '''Randomly select and create a new stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace ''' # Don't activate the stream if the weight is 0 or None if self.stream_weights_[idx]: ...
[ "def", "_new_stream", "(", "self", ",", "idx", ")", ":", "# Don't activate the stream if the weight is 0 or None", "if", "self", ".", "stream_weights_", "[", "idx", "]", ":", "self", ".", "streams_", "[", "idx", "]", "=", "self", ".", "streamers", "[", "idx", ...
Randomly select and create a new stream. Parameters ---------- idx : int, [0:n_streams - 1] The stream index to replace
[ "Randomly", "select", "and", "create", "a", "new", "stream", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L932-L947
pescadores/pescador
pescador/mux.py
RoundRobinMux._next_sample_index
def _next_sample_index(self): """Rotates through each active sampler by incrementing the index""" # Return the next streamer index where the streamer is not None, # wrapping around. idx = self.active_index_ self.active_index_ += 1 if self.active_index_ >= len(self.stream...
python
def _next_sample_index(self): """Rotates through each active sampler by incrementing the index""" # Return the next streamer index where the streamer is not None, # wrapping around. idx = self.active_index_ self.active_index_ += 1 if self.active_index_ >= len(self.stream...
[ "def", "_next_sample_index", "(", "self", ")", ":", "# Return the next streamer index where the streamer is not None,", "# wrapping around.", "idx", "=", "self", ".", "active_index_", "self", ".", "active_index_", "+=", "1", "if", "self", ".", "active_index_", ">=", "le...
Rotates through each active sampler by incrementing the index
[ "Rotates", "through", "each", "active", "sampler", "by", "incrementing", "the", "index" ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L1058-L1080
pescadores/pescador
pescador/mux.py
RoundRobinMux._new_stream
def _new_stream(self, idx): """Activate a new stream, given the index into the stream pool. BaseMux's _new_stream simply chooses a new stream and activates it. For special behavior (ie Weighted streams), you must override this in a child class. Parameters ---------- ...
python
def _new_stream(self, idx): """Activate a new stream, given the index into the stream pool. BaseMux's _new_stream simply chooses a new stream and activates it. For special behavior (ie Weighted streams), you must override this in a child class. Parameters ---------- ...
[ "def", "_new_stream", "(", "self", ",", "idx", ")", ":", "# Get the stream index from the candidate pool", "stream_index", "=", "self", ".", "stream_idxs_", "[", "idx", "]", "# Activate the Streamer, and get the weights", "self", ".", "streams_", "[", "idx", "]", "=",...
Activate a new stream, given the index into the stream pool. BaseMux's _new_stream simply chooses a new stream and activates it. For special behavior (ie Weighted streams), you must override this in a child class. Parameters ---------- idx : int, [0:n_streams - 1] ...
[ "Activate", "a", "new", "stream", "given", "the", "index", "into", "the", "stream", "pool", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L1082-L1101
pescadores/pescador
pescador/mux.py
RoundRobinMux._replace_stream
def _replace_stream(self, idx=None): """Called by `BaseMux`'s iterate() when a stream is exhausted. Set the stream to None so it is ignored once exhausted. Parameters ---------- idx : int or None Raises ------ StopIteration If all streams are...
python
def _replace_stream(self, idx=None): """Called by `BaseMux`'s iterate() when a stream is exhausted. Set the stream to None so it is ignored once exhausted. Parameters ---------- idx : int or None Raises ------ StopIteration If all streams are...
[ "def", "_replace_stream", "(", "self", ",", "idx", "=", "None", ")", ":", "self", ".", "streams_", "[", "idx", "]", "=", "None", "# Check if we've now exhausted all the streams.", "if", "not", "self", ".", "_streamers_available", "(", ")", ":", "if", "self", ...
Called by `BaseMux`'s iterate() when a stream is exhausted. Set the stream to None so it is ignored once exhausted. Parameters ---------- idx : int or None Raises ------ StopIteration If all streams are consumed, and `mode`=="exahustive"
[ "Called", "by", "BaseMux", "s", "iterate", "()", "when", "a", "stream", "is", "exhausted", ".", "Set", "the", "stream", "to", "None", "so", "it", "is", "ignored", "once", "exhausted", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L1103-L1127
pescadores/pescador
pescador/mux.py
ChainMux._new_stream
def _new_stream(self): '''Grab the next stream from the input streamers, and start it. Raises ------ StopIteration When the input list or generator of streamers is complete, will raise a StopIteration. If `mode == cycle`, it will instead restart itera...
python
def _new_stream(self): '''Grab the next stream from the input streamers, and start it. Raises ------ StopIteration When the input list or generator of streamers is complete, will raise a StopIteration. If `mode == cycle`, it will instead restart itera...
[ "def", "_new_stream", "(", "self", ")", ":", "try", ":", "# Advance the stream_generator_ to get the next available stream.", "# If successful, this will make self.chain_streamer_.active True", "next_stream", "=", "six", ".", "advance_iterator", "(", "self", ".", "stream_generato...
Grab the next stream from the input streamers, and start it. Raises ------ StopIteration When the input list or generator of streamers is complete, will raise a StopIteration. If `mode == cycle`, it will instead restart iterating from the beginning of the seq...
[ "Grab", "the", "next", "stream", "from", "the", "input", "streamers", "and", "start", "it", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L1247-L1287
pescadores/pescador
examples/mux/mux_files_example.py
split_and_save_datasets
def split_and_save_datasets(X, Y, paths): """Shuffle X and Y into n / len(paths) datasets, and save them to disk at the locations provided in paths. """ shuffled_idxs = np.random.permutation(np.arange(len(X))) for i in range(len(paths)): # Take every len(paths) item, starting at i. ...
python
def split_and_save_datasets(X, Y, paths): """Shuffle X and Y into n / len(paths) datasets, and save them to disk at the locations provided in paths. """ shuffled_idxs = np.random.permutation(np.arange(len(X))) for i in range(len(paths)): # Take every len(paths) item, starting at i. ...
[ "def", "split_and_save_datasets", "(", "X", ",", "Y", ",", "paths", ")", ":", "shuffled_idxs", "=", "np", ".", "random", ".", "permutation", "(", "np", ".", "arange", "(", "len", "(", "X", ")", ")", ")", "for", "i", "in", "range", "(", "len", "(", ...
Shuffle X and Y into n / len(paths) datasets, and save them to disk at the locations provided in paths.
[ "Shuffle", "X", "and", "Y", "into", "n", "/", "len", "(", "paths", ")", "datasets", "and", "save", "them", "to", "disk", "at", "the", "locations", "provided", "in", "paths", "." ]
train
https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/examples/mux/mux_files_example.py#L38-L49