repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
widdowquinn/pyani
pyani/pyani_jobs.py
JobGroup.generate_script
def generate_script(self): """Create the SGE script that will run the jobs in the JobGroup, with the passed arguments. """ self.script = "" # Holds the script string total = 1 # total number of jobs in this group # for now, SGE_TASK_ID becomes TASK_I...
python
def generate_script(self): """Create the SGE script that will run the jobs in the JobGroup, with the passed arguments. """ self.script = "" # Holds the script string total = 1 # total number of jobs in this group # for now, SGE_TASK_ID becomes TASK_I...
Create the SGE script that will run the jobs in the JobGroup, with the passed arguments.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_jobs.py#L119-L154
widdowquinn/pyani
pyani/anim.py
generate_nucmer_jobs
def generate_nucmer_jobs( filenames, outdir=".", nucmer_exe=pyani_config.NUCMER_DEFAULT, filter_exe=pyani_config.FILTER_DEFAULT, maxmatch=False, jobprefix="ANINUCmer", ): """Return a list of Jobs describing NUCmer command-lines for ANIm - filenames - a list of paths to input FASTA files...
python
def generate_nucmer_jobs( filenames, outdir=".", nucmer_exe=pyani_config.NUCMER_DEFAULT, filter_exe=pyani_config.FILTER_DEFAULT, maxmatch=False, jobprefix="ANINUCmer", ): """Return a list of Jobs describing NUCmer command-lines for ANIm - filenames - a list of paths to input FASTA files...
Return a list of Jobs describing NUCmer command-lines for ANIm - filenames - a list of paths to input FASTA files - outdir - path to output directory - nucmer_exe - location of the nucmer binary - maxmatch - Boolean flag indicating to use NUCmer's -maxmatch option Loop over all FASTA files, genera...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L33-L61
widdowquinn/pyani
pyani/anim.py
generate_nucmer_commands
def generate_nucmer_commands( filenames, outdir=".", nucmer_exe=pyani_config.NUCMER_DEFAULT, filter_exe=pyani_config.FILTER_DEFAULT, maxmatch=False, ): """Return a tuple of lists of NUCmer command-lines for ANIm The first element is a list of NUCmer commands, the second a list of delta_...
python
def generate_nucmer_commands( filenames, outdir=".", nucmer_exe=pyani_config.NUCMER_DEFAULT, filter_exe=pyani_config.FILTER_DEFAULT, maxmatch=False, ): """Return a tuple of lists of NUCmer command-lines for ANIm The first element is a list of NUCmer commands, the second a list of delta_...
Return a tuple of lists of NUCmer command-lines for ANIm The first element is a list of NUCmer commands, the second a list of delta_filter_wrapper.py commands. These are ordered such that commands are paired. The NUCmer commands should be run before the delta-filter commands. - filenames - a list ...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L66-L96
widdowquinn/pyani
pyani/anim.py
construct_nucmer_cmdline
def construct_nucmer_cmdline( fname1, fname2, outdir=".", nucmer_exe=pyani_config.NUCMER_DEFAULT, filter_exe=pyani_config.FILTER_DEFAULT, maxmatch=False, ): """Returns a tuple of NUCmer and delta-filter commands The split into a tuple was made necessary by changes to SGE/OGE. The de...
python
def construct_nucmer_cmdline( fname1, fname2, outdir=".", nucmer_exe=pyani_config.NUCMER_DEFAULT, filter_exe=pyani_config.FILTER_DEFAULT, maxmatch=False, ): """Returns a tuple of NUCmer and delta-filter commands The split into a tuple was made necessary by changes to SGE/OGE. The de...
Returns a tuple of NUCmer and delta-filter commands The split into a tuple was made necessary by changes to SGE/OGE. The delta-filter command must now be run as a dependency of the NUCmer command, and be wrapped in a Python script to capture STDOUT. NOTE: This command-line writes output data to a subd...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L101-L143
widdowquinn/pyani
pyani/anim.py
parse_delta
def parse_delta(filename): """Returns (alignment length, similarity errors) tuple from passed .delta. - filename - path to the input .delta file Extracts the aligned length and number of similarity errors for each aligned uniquely-matched region, and returns the cumulative total for each as a tupl...
python
def parse_delta(filename): """Returns (alignment length, similarity errors) tuple from passed .delta. - filename - path to the input .delta file Extracts the aligned length and number of similarity errors for each aligned uniquely-matched region, and returns the cumulative total for each as a tupl...
Returns (alignment length, similarity errors) tuple from passed .delta. - filename - path to the input .delta file Extracts the aligned length and number of similarity errors for each aligned uniquely-matched region, and returns the cumulative total for each as a tuple.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L148-L165
widdowquinn/pyani
pyani/anim.py
process_deltadir
def process_deltadir(delta_dir, org_lengths, logger=None): """Returns a tuple of ANIm results for .deltas in passed directory. - delta_dir - path to the directory containing .delta files - org_lengths - dictionary of total sequence lengths, keyed by sequence Returns the following pandas dataframes in ...
python
def process_deltadir(delta_dir, org_lengths, logger=None): """Returns a tuple of ANIm results for .deltas in passed directory. - delta_dir - path to the directory containing .delta files - org_lengths - dictionary of total sequence lengths, keyed by sequence Returns the following pandas dataframes in ...
Returns a tuple of ANIm results for .deltas in passed directory. - delta_dir - path to the directory containing .delta files - org_lengths - dictionary of total sequence lengths, keyed by sequence Returns the following pandas dataframes in an ANIResults object; query sequences are rows, subject sequen...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L169-L244
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
parse_cmdline
def parse_cmdline(): """Parse command-line arguments""" parser = ArgumentParser(prog="genbank_get_genomes_by_taxon.py") parser.add_argument( "-o", "--outdir", dest="outdirname", required=True, action="store", default=None, help="Output directory (requi...
python
def parse_cmdline(): """Parse command-line arguments""" parser = ArgumentParser(prog="genbank_get_genomes_by_taxon.py") parser.add_argument( "-o", "--outdir", dest="outdirname", required=True, action="store", default=None, help="Output directory (requi...
Parse command-line arguments
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L46-L125
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
set_ncbi_email
def set_ncbi_email(): """Set contact email for NCBI.""" Entrez.email = args.email logger.info("Set NCBI contact email to %s", args.email) Entrez.tool = "genbank_get_genomes_by_taxon.py"
python
def set_ncbi_email(): """Set contact email for NCBI.""" Entrez.email = args.email logger.info("Set NCBI contact email to %s", args.email) Entrez.tool = "genbank_get_genomes_by_taxon.py"
Set contact email for NCBI.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L139-L143
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
entrez_retry
def entrez_retry(func, *fnargs, **fnkwargs): """Retries the passed function up to the number of times specified by args.retries """ tries, success = 0, False while not success and tries < args.retries: try: output = func(*fnargs, **fnkwargs) success = True exc...
python
def entrez_retry(func, *fnargs, **fnkwargs): """Retries the passed function up to the number of times specified by args.retries """ tries, success = 0, False while not success and tries < args.retries: try: output = func(*fnargs, **fnkwargs) success = True exc...
Retries the passed function up to the number of times specified by args.retries
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L187-L204
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
entrez_batch_webhistory
def entrez_batch_webhistory(record, expected, batchsize, *fnargs, **fnkwargs): """Recovers the Entrez data from a prior NCBI webhistory search, in batches of defined size, using Efetch. Returns all results as a list. - record: Entrez webhistory record - expected: number of expected search returns -...
python
def entrez_batch_webhistory(record, expected, batchsize, *fnargs, **fnkwargs): """Recovers the Entrez data from a prior NCBI webhistory search, in batches of defined size, using Efetch. Returns all results as a list. - record: Entrez webhistory record - expected: number of expected search returns -...
Recovers the Entrez data from a prior NCBI webhistory search, in batches of defined size, using Efetch. Returns all results as a list. - record: Entrez webhistory record - expected: number of expected search returns - batchsize: how many search returns to retrieve in a batch - *fnargs: arguments to...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L208-L230
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
get_asm_uids
def get_asm_uids(taxon_uid): """Returns a set of NCBI UIDs associated with the passed taxon. This query at NCBI returns all assemblies for the taxon subtree rooted at the passed taxon_uid. """ query = "txid%s[Organism:exp]" % taxon_uid logger.info("Entrez ESearch with query: %s", query) # ...
python
def get_asm_uids(taxon_uid): """Returns a set of NCBI UIDs associated with the passed taxon. This query at NCBI returns all assemblies for the taxon subtree rooted at the passed taxon_uid. """ query = "txid%s[Organism:exp]" % taxon_uid logger.info("Entrez ESearch with query: %s", query) # ...
Returns a set of NCBI UIDs associated with the passed taxon. This query at NCBI returns all assemblies for the taxon subtree rooted at the passed taxon_uid.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L234-L259
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
extract_filestem
def extract_filestem(data): """Extract filestem from Entrez eSummary data. Function expects esummary['DocumentSummarySet']['DocumentSummary'][0] Some illegal characters may occur in AssemblyName - for these, a more robust regex replace/escape may be required. Sadly, NCBI don't just use standard pe...
python
def extract_filestem(data): """Extract filestem from Entrez eSummary data. Function expects esummary['DocumentSummarySet']['DocumentSummary'][0] Some illegal characters may occur in AssemblyName - for these, a more robust regex replace/escape may be required. Sadly, NCBI don't just use standard pe...
Extract filestem from Entrez eSummary data. Function expects esummary['DocumentSummarySet']['DocumentSummary'][0] Some illegal characters may occur in AssemblyName - for these, a more robust regex replace/escape may be required. Sadly, NCBI don't just use standard percent escapes, but instead replace ...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L263-L275
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
get_ncbi_asm
def get_ncbi_asm(asm_uid, fmt='fasta'): """Returns the NCBI AssemblyAccession and AssemblyName for the assembly with passed UID, and organism data for class/label files also, as well as accession, so we can track whether downloads fail because only the most recent version is available.. AssemblyAcc...
python
def get_ncbi_asm(asm_uid, fmt='fasta'): """Returns the NCBI AssemblyAccession and AssemblyName for the assembly with passed UID, and organism data for class/label files also, as well as accession, so we can track whether downloads fail because only the most recent version is available.. AssemblyAcc...
Returns the NCBI AssemblyAccession and AssemblyName for the assembly with passed UID, and organism data for class/label files also, as well as accession, so we can track whether downloads fail because only the most recent version is available.. AssemblyAccession and AssemblyName are data fields in the ...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L279-L344
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
retrieve_asm_contigs
def retrieve_asm_contigs(filestem, ftpstem="ftp://ftp.ncbi.nlm.nih.gov/genomes/all", fmt='fasta'): """Downloads an assembly sequence to a local directory. The filestem corresponds to <AA>_<AN>, where <AA> and <AN> are AssemblyAccession and AssemblyName: dat...
python
def retrieve_asm_contigs(filestem, ftpstem="ftp://ftp.ncbi.nlm.nih.gov/genomes/all", fmt='fasta'): """Downloads an assembly sequence to a local directory. The filestem corresponds to <AA>_<AN>, where <AA> and <AN> are AssemblyAccession and AssemblyName: dat...
Downloads an assembly sequence to a local directory. The filestem corresponds to <AA>_<AN>, where <AA> and <AN> are AssemblyAccession and AssemblyName: data fields in the eSummary record. These correspond to downloadable files for each assembly at ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GC[AF]/nnn/nnn/n...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L348-L477
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
write_contigs
def write_contigs(asm_uid, contig_uids, batchsize=10000): """Writes assembly contigs out to a single FASTA file in the script's designated output directory. FASTA records are returned, as GenBank and even GenBankWithParts format records don't reliably give correct sequence in all cases. The script...
python
def write_contigs(asm_uid, contig_uids, batchsize=10000): """Writes assembly contigs out to a single FASTA file in the script's designated output directory. FASTA records are returned, as GenBank and even GenBankWithParts format records don't reliably give correct sequence in all cases. The script...
Writes assembly contigs out to a single FASTA file in the script's designated output directory. FASTA records are returned, as GenBank and even GenBankWithParts format records don't reliably give correct sequence in all cases. The script returns two strings for each assembly, a 'class' and a 'label' ...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L481-L560
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
logreport_downloaded
def logreport_downloaded(accession, skippedlist, accessiondict, uidaccdict): """Reports to logger whether alternative assemblies for an accession that was missing have been downloaded """ for vid in accessiondict[accession.split('.')[0]]: if vid in skippedlist: status = "NOT DOWNLOAD...
python
def logreport_downloaded(accession, skippedlist, accessiondict, uidaccdict): """Reports to logger whether alternative assemblies for an accession that was missing have been downloaded """ for vid in accessiondict[accession.split('.')[0]]: if vid in skippedlist: status = "NOT DOWNLOAD...
Reports to logger whether alternative assemblies for an accession that was missing have been downloaded
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L564-L573
widdowquinn/pyani
pyani/tetra.py
calculate_tetra_zscores
def calculate_tetra_zscores(infilenames): """Returns dictionary of TETRA Z-scores for each input file. - infilenames - collection of paths to sequence files """ org_tetraz = {} for filename in infilenames: org = os.path.splitext(os.path.split(filename)[-1])[0] org_tetraz[org] = calc...
python
def calculate_tetra_zscores(infilenames): """Returns dictionary of TETRA Z-scores for each input file. - infilenames - collection of paths to sequence files """ org_tetraz = {} for filename in infilenames: org = os.path.splitext(os.path.split(filename)[-1])[0] org_tetraz[org] = calc...
Returns dictionary of TETRA Z-scores for each input file. - infilenames - collection of paths to sequence files
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/tetra.py#L33-L42
widdowquinn/pyani
pyani/tetra.py
calculate_tetra_zscore
def calculate_tetra_zscore(filename): """Returns TETRA Z-score for the sequence in the passed file. - filename - path to sequence file Calculates mono-, di-, tri- and tetranucleotide frequencies for each sequence, on each strand, and follows Teeling et al. (2004) in calculating a corresponding Z-s...
python
def calculate_tetra_zscore(filename): """Returns TETRA Z-score for the sequence in the passed file. - filename - path to sequence file Calculates mono-, di-, tri- and tetranucleotide frequencies for each sequence, on each strand, and follows Teeling et al. (2004) in calculating a corresponding Z-s...
Returns TETRA Z-score for the sequence in the passed file. - filename - path to sequence file Calculates mono-, di-, tri- and tetranucleotide frequencies for each sequence, on each strand, and follows Teeling et al. (2004) in calculating a corresponding Z-score for each observed tetranucleotide fr...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/tetra.py#L46-L102
widdowquinn/pyani
pyani/tetra.py
calculate_correlations
def calculate_correlations(tetra_z): """Returns dataframe of Pearson correlation coefficients. - tetra_z - dictionary of Z-scores, keyed by sequence ID Calculates Pearson correlation coefficient from Z scores for each tetranucleotide. This is done longhand here, which is fast enough, but for robus...
python
def calculate_correlations(tetra_z): """Returns dataframe of Pearson correlation coefficients. - tetra_z - dictionary of Z-scores, keyed by sequence ID Calculates Pearson correlation coefficient from Z scores for each tetranucleotide. This is done longhand here, which is fast enough, but for robus...
Returns dataframe of Pearson correlation coefficients. - tetra_z - dictionary of Z-scores, keyed by sequence ID Calculates Pearson correlation coefficient from Z scores for each tetranucleotide. This is done longhand here, which is fast enough, but for robustness we might want to do something else... ...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/tetra.py#L118-L149
widdowquinn/pyani
pyani/pyani_tools.py
get_labels
def get_labels(filename, logger=None): """Returns a dictionary of alternative sequence labels, or None - filename - path to file containing tab-separated table of labels Input files should be formatted as <key>\t<label>, one pair per line. """ labeldict = {} if filename is not None: if...
python
def get_labels(filename, logger=None): """Returns a dictionary of alternative sequence labels, or None - filename - path to file containing tab-separated table of labels Input files should be formatted as <key>\t<label>, one pair per line. """ labeldict = {} if filename is not None: if...
Returns a dictionary of alternative sequence labels, or None - filename - path to file containing tab-separated table of labels Input files should be formatted as <key>\t<label>, one pair per line.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L131-L156
widdowquinn/pyani
pyani/pyani_tools.py
ANIResults.add_tot_length
def add_tot_length(self, qname, sname, value, sym=True): """Add a total length value to self.alignment_lengths.""" self.alignment_lengths.loc[qname, sname] = value if sym: self.alignment_lengths.loc[sname, qname] = value
python
def add_tot_length(self, qname, sname, value, sym=True): """Add a total length value to self.alignment_lengths.""" self.alignment_lengths.loc[qname, sname] = value if sym: self.alignment_lengths.loc[sname, qname] = value
Add a total length value to self.alignment_lengths.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L33-L37
widdowquinn/pyani
pyani/pyani_tools.py
ANIResults.add_sim_errors
def add_sim_errors(self, qname, sname, value, sym=True): """Add a similarity error value to self.similarity_errors.""" self.similarity_errors.loc[qname, sname] = value if sym: self.similarity_errors.loc[sname, qname] = value
python
def add_sim_errors(self, qname, sname, value, sym=True): """Add a similarity error value to self.similarity_errors.""" self.similarity_errors.loc[qname, sname] = value if sym: self.similarity_errors.loc[sname, qname] = value
Add a similarity error value to self.similarity_errors.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L39-L43
widdowquinn/pyani
pyani/pyani_tools.py
ANIResults.add_pid
def add_pid(self, qname, sname, value, sym=True): """Add a percentage identity value to self.percentage_identity.""" self.percentage_identity.loc[qname, sname] = value if sym: self.percentage_identity.loc[sname, qname] = value
python
def add_pid(self, qname, sname, value, sym=True): """Add a percentage identity value to self.percentage_identity.""" self.percentage_identity.loc[qname, sname] = value if sym: self.percentage_identity.loc[sname, qname] = value
Add a percentage identity value to self.percentage_identity.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L45-L49
widdowquinn/pyani
pyani/pyani_tools.py
ANIResults.add_coverage
def add_coverage(self, qname, sname, qcover, scover=None): """Add percentage coverage values to self.alignment_coverage.""" self.alignment_coverage.loc[qname, sname] = qcover if scover: self.alignment_coverage.loc[sname, qname] = scover
python
def add_coverage(self, qname, sname, qcover, scover=None): """Add percentage coverage values to self.alignment_coverage.""" self.alignment_coverage.loc[qname, sname] = qcover if scover: self.alignment_coverage.loc[sname, qname] = scover
Add percentage coverage values to self.alignment_coverage.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L51-L55
widdowquinn/pyani
pyani/pyani_tools.py
ANIResults.data
def data(self): """Return list of (dataframe, filestem) tuples.""" stemdict = { "ANIm": pyani_config.ANIM_FILESTEMS, "ANIb": pyani_config.ANIB_FILESTEMS, "ANIblastall": pyani_config.ANIBLASTALL_FILESTEMS, } return zip( ( sel...
python
def data(self): """Return list of (dataframe, filestem) tuples.""" stemdict = { "ANIm": pyani_config.ANIM_FILESTEMS, "ANIb": pyani_config.ANIB_FILESTEMS, "ANIblastall": pyani_config.ANIBLASTALL_FILESTEMS, } return zip( ( sel...
Return list of (dataframe, filestem) tuples.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L63-L79
widdowquinn/pyani
pyani/pyani_tools.py
BLASTcmds.build_db_cmd
def build_db_cmd(self, fname): """Return database format/build command""" return self.funcs.db_func(fname, self.outdir, self.exes.format_exe)[0]
python
def build_db_cmd(self, fname): """Return database format/build command""" return self.funcs.db_func(fname, self.outdir, self.exes.format_exe)[0]
Return database format/build command
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L117-L119
widdowquinn/pyani
pyani/pyani_tools.py
BLASTcmds.get_db_name
def get_db_name(self, fname): """Return database filename""" return self.funcs.db_func(fname, self.outdir, self.exes.format_exe)[1]
python
def get_db_name(self, fname): """Return database filename""" return self.funcs.db_func(fname, self.outdir, self.exes.format_exe)[1]
Return database filename
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L121-L123
widdowquinn/pyani
pyani/pyani_tools.py
BLASTcmds.build_blast_cmd
def build_blast_cmd(self, fname, dbname): """Return BLASTN command""" return self.funcs.blastn_func(fname, dbname, self.outdir, self.exes.blast_exe)
python
def build_blast_cmd(self, fname, dbname): """Return BLASTN command""" return self.funcs.blastn_func(fname, dbname, self.outdir, self.exes.blast_exe)
Return BLASTN command
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L125-L127
widdowquinn/pyani
pyani/anib.py
fragment_fasta_files
def fragment_fasta_files(infiles, outdirname, fragsize): """Chops sequences of the passed files into fragments, returns filenames. - infiles - paths to each input sequence file - outdirname - path to output directory - fragsize - the size of sequence fragments Takes every sequence from every file ...
python
def fragment_fasta_files(infiles, outdirname, fragsize): """Chops sequences of the passed files into fragments, returns filenames. - infiles - paths to each input sequence file - outdirname - path to output directory - fragsize - the size of sequence fragments Takes every sequence from every file ...
Chops sequences of the passed files into fragments, returns filenames. - infiles - paths to each input sequence file - outdirname - path to output directory - fragsize - the size of sequence fragments Takes every sequence from every file in infiles, and splits them into consecutive fragments of le...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L100-L130
widdowquinn/pyani
pyani/anib.py
get_fraglength_dict
def get_fraglength_dict(fastafiles): """Returns dictionary of sequence fragment lengths, keyed by query name. - fastafiles - list of FASTA input whole sequence files Loops over input files and, for each, produces a dictionary with fragment lengths, keyed by sequence ID. These are returned as a diction...
python
def get_fraglength_dict(fastafiles): """Returns dictionary of sequence fragment lengths, keyed by query name. - fastafiles - list of FASTA input whole sequence files Loops over input files and, for each, produces a dictionary with fragment lengths, keyed by sequence ID. These are returned as a diction...
Returns dictionary of sequence fragment lengths, keyed by query name. - fastafiles - list of FASTA input whole sequence files Loops over input files and, for each, produces a dictionary with fragment lengths, keyed by sequence ID. These are returned as a dictionary with the keys being query IDs derive...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L134-L147
widdowquinn/pyani
pyani/anib.py
get_fragment_lengths
def get_fragment_lengths(fastafile): """Returns dictionary of sequence fragment lengths, keyed by fragment ID. Biopython's SeqIO module is used to parse all sequences in the FASTA file. NOTE: ambiguity symbols are not discounted. """ fraglengths = {} for seq in SeqIO.parse(fastafile, "fast...
python
def get_fragment_lengths(fastafile): """Returns dictionary of sequence fragment lengths, keyed by fragment ID. Biopython's SeqIO module is used to parse all sequences in the FASTA file. NOTE: ambiguity symbols are not discounted. """ fraglengths = {} for seq in SeqIO.parse(fastafile, "fast...
Returns dictionary of sequence fragment lengths, keyed by fragment ID. Biopython's SeqIO module is used to parse all sequences in the FASTA file. NOTE: ambiguity symbols are not discounted.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L151-L162
widdowquinn/pyani
pyani/anib.py
build_db_jobs
def build_db_jobs(infiles, blastcmds): """Returns dictionary of db-building commands, keyed by dbname.""" dbjobdict = {} # Dict of database construction jobs, keyed by filename # Create dictionary of database building jobs, keyed by db name # defining jobnum for later use as last job index used for...
python
def build_db_jobs(infiles, blastcmds): """Returns dictionary of db-building commands, keyed by dbname.""" dbjobdict = {} # Dict of database construction jobs, keyed by filename # Create dictionary of database building jobs, keyed by db name # defining jobnum for later use as last job index used for...
Returns dictionary of db-building commands, keyed by dbname.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L166-L175
widdowquinn/pyani
pyani/anib.py
make_blastcmd_builder
def make_blastcmd_builder( mode, outdir, format_exe=None, blast_exe=None, prefix="ANIBLAST" ): """Returns BLASTcmds object for construction of BLAST commands.""" if mode == "ANIb": # BLAST/formatting executable depends on mode blastcmds = BLASTcmds( BLASTfunctions(construct_makeblastdb_...
python
def make_blastcmd_builder( mode, outdir, format_exe=None, blast_exe=None, prefix="ANIBLAST" ): """Returns BLASTcmds object for construction of BLAST commands.""" if mode == "ANIb": # BLAST/formatting executable depends on mode blastcmds = BLASTcmds( BLASTfunctions(construct_makeblastdb_...
Returns BLASTcmds object for construction of BLAST commands.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L178-L202
widdowquinn/pyani
pyani/anib.py
make_job_graph
def make_job_graph(infiles, fragfiles, blastcmds): """Return a job dependency graph, based on the passed input sequence files. - infiles - a list of paths to input FASTA files - fragfiles - a list of paths to fragmented input FASTA files By default, will run ANIb - it *is* possible to make a mess of p...
python
def make_job_graph(infiles, fragfiles, blastcmds): """Return a job dependency graph, based on the passed input sequence files. - infiles - a list of paths to input FASTA files - fragfiles - a list of paths to fragmented input FASTA files By default, will run ANIb - it *is* possible to make a mess of p...
Return a job dependency graph, based on the passed input sequence files. - infiles - a list of paths to input FASTA files - fragfiles - a list of paths to fragmented input FASTA files By default, will run ANIb - it *is* possible to make a mess of passing the wrong executable for the mode you're using....
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L206-L246
widdowquinn/pyani
pyani/anib.py
generate_blastdb_commands
def generate_blastdb_commands(filenames, outdir, blastdb_exe=None, mode="ANIb"): """Return a list of makeblastdb command-lines for ANIb/ANIblastall - filenames - a list of paths to input FASTA files - outdir - path to output directory - blastdb_exe - path to the makeblastdb executable """ if mo...
python
def generate_blastdb_commands(filenames, outdir, blastdb_exe=None, mode="ANIb"): """Return a list of makeblastdb command-lines for ANIb/ANIblastall - filenames - a list of paths to input FASTA files - outdir - path to output directory - blastdb_exe - path to the makeblastdb executable """ if mo...
Return a list of makeblastdb command-lines for ANIb/ANIblastall - filenames - a list of paths to input FASTA files - outdir - path to output directory - blastdb_exe - path to the makeblastdb executable
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L250-L267
widdowquinn/pyani
pyani/anib.py
construct_makeblastdb_cmd
def construct_makeblastdb_cmd( filename, outdir, blastdb_exe=pyani_config.MAKEBLASTDB_DEFAULT ): """Returns a single makeblastdb command. - filename - input filename - blastdb_exe - path to the makeblastdb executable """ title = os.path.splitext(os.path.split(filename)[-1])[0] outfilename =...
python
def construct_makeblastdb_cmd( filename, outdir, blastdb_exe=pyani_config.MAKEBLASTDB_DEFAULT ): """Returns a single makeblastdb command. - filename - input filename - blastdb_exe - path to the makeblastdb executable """ title = os.path.splitext(os.path.split(filename)[-1])[0] outfilename =...
Returns a single makeblastdb command. - filename - input filename - blastdb_exe - path to the makeblastdb executable
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L271-L286
widdowquinn/pyani
pyani/anib.py
construct_formatdb_cmd
def construct_formatdb_cmd(filename, outdir, blastdb_exe=pyani_config.FORMATDB_DEFAULT): """Returns a single formatdb command. - filename - input filename - blastdb_exe - path to the formatdb executable """ title = os.path.splitext(os.path.split(filename)[-1])[0] newfilename = os.path.join(outd...
python
def construct_formatdb_cmd(filename, outdir, blastdb_exe=pyani_config.FORMATDB_DEFAULT): """Returns a single formatdb command. - filename - input filename - blastdb_exe - path to the formatdb executable """ title = os.path.splitext(os.path.split(filename)[-1])[0] newfilename = os.path.join(outd...
Returns a single formatdb command. - filename - input filename - blastdb_exe - path to the formatdb executable
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L290-L302
widdowquinn/pyani
pyani/anib.py
generate_blastn_commands
def generate_blastn_commands(filenames, outdir, blast_exe=None, mode="ANIb"): """Return a list of blastn command-lines for ANIm - filenames - a list of paths to fragmented input FASTA files - outdir - path to output directory - blastn_exe - path to BLASTN executable Assumes that the fragment seque...
python
def generate_blastn_commands(filenames, outdir, blast_exe=None, mode="ANIb"): """Return a list of blastn command-lines for ANIm - filenames - a list of paths to fragmented input FASTA files - outdir - path to output directory - blastn_exe - path to BLASTN executable Assumes that the fragment seque...
Return a list of blastn command-lines for ANIm - filenames - a list of paths to fragmented input FASTA files - outdir - path to output directory - blastn_exe - path to BLASTN executable Assumes that the fragment sequence input filenames have the form ACCESSION-fragments.ext, where the correspondin...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L306-L337
widdowquinn/pyani
pyani/anib.py
construct_blastn_cmdline
def construct_blastn_cmdline( fname1, fname2, outdir, blastn_exe=pyani_config.BLASTN_DEFAULT ): """Returns a single blastn command. - filename - input filename - blastn_exe - path to BLASTN executable """ fstem1 = os.path.splitext(os.path.split(fname1)[-1])[0] fstem2 = os.path.splitext(os.p...
python
def construct_blastn_cmdline( fname1, fname2, outdir, blastn_exe=pyani_config.BLASTN_DEFAULT ): """Returns a single blastn command. - filename - input filename - blastn_exe - path to BLASTN executable """ fstem1 = os.path.splitext(os.path.split(fname1)[-1])[0] fstem2 = os.path.splitext(os.p...
Returns a single blastn command. - filename - input filename - blastn_exe - path to BLASTN executable
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L341-L360
widdowquinn/pyani
pyani/anib.py
construct_blastall_cmdline
def construct_blastall_cmdline( fname1, fname2, outdir, blastall_exe=pyani_config.BLASTALL_DEFAULT ): """Returns a single blastall command. - blastall_exe - path to BLASTALL executable """ fstem1 = os.path.splitext(os.path.split(fname1)[-1])[0] fstem2 = os.path.splitext(os.path.split(fname2)[-1...
python
def construct_blastall_cmdline( fname1, fname2, outdir, blastall_exe=pyani_config.BLASTALL_DEFAULT ): """Returns a single blastall command. - blastall_exe - path to BLASTALL executable """ fstem1 = os.path.splitext(os.path.split(fname1)[-1])[0] fstem2 = os.path.splitext(os.path.split(fname2)[-1...
Returns a single blastall command. - blastall_exe - path to BLASTALL executable
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L364-L380
widdowquinn/pyani
pyani/anib.py
process_blast
def process_blast( blast_dir, org_lengths, fraglengths=None, mode="ANIb", identity=0.3, coverage=0.7, logger=None, ): """Returns a tuple of ANIb results for .blast_tab files in the output dir. - blast_dir - path to the directory containing .blast_tab files - org_lengths - the ba...
python
def process_blast( blast_dir, org_lengths, fraglengths=None, mode="ANIb", identity=0.3, coverage=0.7, logger=None, ): """Returns a tuple of ANIb results for .blast_tab files in the output dir. - blast_dir - path to the directory containing .blast_tab files - org_lengths - the ba...
Returns a tuple of ANIb results for .blast_tab files in the output dir. - blast_dir - path to the directory containing .blast_tab files - org_lengths - the base count for each input sequence - fraglengths - dictionary of query sequence fragment lengths, only needed for BLASTALL output - mode - pars...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L384-L453
widdowquinn/pyani
pyani/anib.py
parse_blast_tab
def parse_blast_tab(filename, fraglengths, identity, coverage, mode="ANIb"): """Returns (alignment length, similarity errors, mean_pid) tuple from .blast_tab - filename - path to .blast_tab file Calculate the alignment length and total number of similarity errors (as we would with ANIm), as well a...
python
def parse_blast_tab(filename, fraglengths, identity, coverage, mode="ANIb"): """Returns (alignment length, similarity errors, mean_pid) tuple from .blast_tab - filename - path to .blast_tab file Calculate the alignment length and total number of similarity errors (as we would with ANIm), as well a...
Returns (alignment length, similarity errors, mean_pid) tuple from .blast_tab - filename - path to .blast_tab file Calculate the alignment length and total number of similarity errors (as we would with ANIm), as well as the Goris et al.-defined mean identity of all valid BLAST matches for the pass...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L457-L551
widdowquinn/pyani
pyani/run_sge.py
split_seq
def split_seq(iterable, size): """Splits a passed iterable into chunks of a given size.""" elm = iter(iterable) item = list(itertools.islice(elm, size)) while item: yield item item = list(itertools.islice(elm, size))
python
def split_seq(iterable, size): """Splits a passed iterable into chunks of a given size.""" elm = iter(iterable) item = list(itertools.islice(elm, size)) while item: yield item item = list(itertools.islice(elm, size))
Splits a passed iterable into chunks of a given size.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L23-L29
widdowquinn/pyani
pyani/run_sge.py
build_joblist
def build_joblist(jobgraph): """Returns a list of jobs, from a passed jobgraph.""" jobset = set() for job in jobgraph: jobset = populate_jobset(job, jobset, depth=1) return list(jobset)
python
def build_joblist(jobgraph): """Returns a list of jobs, from a passed jobgraph.""" jobset = set() for job in jobgraph: jobset = populate_jobset(job, jobset, depth=1) return list(jobset)
Returns a list of jobs, from a passed jobgraph.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L33-L38
widdowquinn/pyani
pyani/run_sge.py
compile_jobgroups_from_joblist
def compile_jobgroups_from_joblist(joblist, jgprefix, sgegroupsize): """Return list of jobgroups, rather than list of jobs.""" jobcmds = defaultdict(list) for job in joblist: jobcmds[job.command.split(' ', 1)[0]].append(job.command) jobgroups = [] for cmds in list(jobcmds.items()): #...
python
def compile_jobgroups_from_joblist(joblist, jgprefix, sgegroupsize): """Return list of jobgroups, rather than list of jobs.""" jobcmds = defaultdict(list) for job in joblist: jobcmds[job.command.split(' ', 1)[0]].append(job.command) jobgroups = [] for cmds in list(jobcmds.items()): #...
Return list of jobgroups, rather than list of jobs.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L42-L58
widdowquinn/pyani
pyani/run_sge.py
run_dependency_graph
def run_dependency_graph(jobgraph, logger=None, jgprefix="ANIm_SGE_JG", sgegroupsize=10000, sgeargs=None): """Creates and runs GridEngine scripts for jobs based on the passed jobgraph. - jobgraph - list of jobs, which may have dependencies. - verbose - flag for multiprocessing ...
python
def run_dependency_graph(jobgraph, logger=None, jgprefix="ANIm_SGE_JG", sgegroupsize=10000, sgeargs=None): """Creates and runs GridEngine scripts for jobs based on the passed jobgraph. - jobgraph - list of jobs, which may have dependencies. - verbose - flag for multiprocessing ...
Creates and runs GridEngine scripts for jobs based on the passed jobgraph. - jobgraph - list of jobs, which may have dependencies. - verbose - flag for multiprocessing verbosity - logger - a logger module logger (optional) - jgprefix - a prefix for the submitted jobs, in the scheduler - sgegrou...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L62-L112
widdowquinn/pyani
pyani/run_sge.py
populate_jobset
def populate_jobset(job, jobset, depth): """ Creates a set of jobs, containing jobs at difference depths of the dependency tree, retaining dependencies as strings, not Jobs. """ jobset.add(job) if len(job.dependencies) == 0: return jobset for j in job.dependencies: jobset = popul...
python
def populate_jobset(job, jobset, depth): """ Creates a set of jobs, containing jobs at difference depths of the dependency tree, retaining dependencies as strings, not Jobs. """ jobset.add(job) if len(job.dependencies) == 0: return jobset for j in job.dependencies: jobset = popul...
Creates a set of jobs, containing jobs at difference depths of the dependency tree, retaining dependencies as strings, not Jobs.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L115-L124
widdowquinn/pyani
pyani/run_sge.py
build_directories
def build_directories(root_dir): """Constructs the subdirectories output, stderr, stdout, and jobs in the passed root directory. These subdirectories have the following roles: jobs Stores the scripts for each job stderr Stores the stderr output from SGE stdout ...
python
def build_directories(root_dir): """Constructs the subdirectories output, stderr, stdout, and jobs in the passed root directory. These subdirectories have the following roles: jobs Stores the scripts for each job stderr Stores the stderr output from SGE stdout ...
Constructs the subdirectories output, stderr, stdout, and jobs in the passed root directory. These subdirectories have the following roles: jobs Stores the scripts for each job stderr Stores the stderr output from SGE stdout Stores the stdout output from SGE ...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L127-L146
widdowquinn/pyani
pyani/run_sge.py
build_job_scripts
def build_job_scripts(root_dir, jobs): """Constructs the script for each passed Job in the jobs iterable - root_dir Path to output directory """ # Loop over the job list, creating each job script in turn, and then adding # scriptPath to the Job object for job in jobs: scriptpath = ...
python
def build_job_scripts(root_dir, jobs): """Constructs the script for each passed Job in the jobs iterable - root_dir Path to output directory """ # Loop over the job list, creating each job script in turn, and then adding # scriptPath to the Job object for job in jobs: scriptpath = ...
Constructs the script for each passed Job in the jobs iterable - root_dir Path to output directory
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L149-L160
widdowquinn/pyani
pyani/run_sge.py
extract_submittable_jobs
def extract_submittable_jobs(waiting): """Obtain a list of jobs that are able to be submitted from the passed list of pending jobs - waiting List of Job objects """ submittable = set() # Holds jobs that are able to be submitted # Loop over each job, and check all the subjob...
python
def extract_submittable_jobs(waiting): """Obtain a list of jobs that are able to be submitted from the passed list of pending jobs - waiting List of Job objects """ submittable = set() # Holds jobs that are able to be submitted # Loop over each job, and check all the subjob...
Obtain a list of jobs that are able to be submitted from the passed list of pending jobs - waiting List of Job objects
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L163-L178
widdowquinn/pyani
pyani/run_sge.py
submit_safe_jobs
def submit_safe_jobs(root_dir, jobs, sgeargs=None): """Submit the passed list of jobs to the Grid Engine server, using the passed directory as the root for scheduler output. - root_dir Path to output directory - jobs Iterable of Job objects """ # Loop over each job, constructing S...
python
def submit_safe_jobs(root_dir, jobs, sgeargs=None): """Submit the passed list of jobs to the Grid Engine server, using the passed directory as the root for scheduler output. - root_dir Path to output directory - jobs Iterable of Job objects """ # Loop over each job, constructing S...
Submit the passed list of jobs to the Grid Engine server, using the passed directory as the root for scheduler output. - root_dir Path to output directory - jobs Iterable of Job objects
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L181-L222
widdowquinn/pyani
pyani/run_sge.py
submit_jobs
def submit_jobs(root_dir, jobs, sgeargs=None): """ Submit each of the passed jobs to the SGE server, using the passed directory as root for SGE output. - root_dir Path to output directory - jobs List of Job objects """ waiting = list(jobs) # List of jobs still to...
python
def submit_jobs(root_dir, jobs, sgeargs=None): """ Submit each of the passed jobs to the SGE server, using the passed directory as root for SGE output. - root_dir Path to output directory - jobs List of Job objects """ waiting = list(jobs) # List of jobs still to...
Submit each of the passed jobs to the SGE server, using the passed directory as root for SGE output. - root_dir Path to output directory - jobs List of Job objects
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L225-L241
widdowquinn/pyani
pyani/run_sge.py
build_and_submit_jobs
def build_and_submit_jobs(root_dir, jobs, sgeargs=None): """Submits the passed iterable of Job objects to SGE, placing SGE's output in the passed root directory - root_dir Root directory for SGE and job output - jobs List of Job objects, describing each job to be submitted - sgeargs Addi...
python
def build_and_submit_jobs(root_dir, jobs, sgeargs=None): """Submits the passed iterable of Job objects to SGE, placing SGE's output in the passed root directory - root_dir Root directory for SGE and job output - jobs List of Job objects, describing each job to be submitted - sgeargs Addi...
Submits the passed iterable of Job objects to SGE, placing SGE's output in the passed root directory - root_dir Root directory for SGE and job output - jobs List of Job objects, describing each job to be submitted - sgeargs Additional arguments to qsub
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_sge.py#L244-L260
widdowquinn/pyani
pyani/pyani_config.py
params_mpl
def params_mpl(df): """Returns dict of matplotlib parameters, dependent on dataframe.""" return {'ANIb_alignment_lengths': ('afmhot', df.values.min(), df.values.max()), 'ANIb_percentage_identity': ('spbnd_BuRd', 0, 1), 'ANIb_alignment_coverage': ('B...
python
def params_mpl(df): """Returns dict of matplotlib parameters, dependent on dataframe.""" return {'ANIb_alignment_lengths': ('afmhot', df.values.min(), df.values.max()), 'ANIb_percentage_identity': ('spbnd_BuRd', 0, 1), 'ANIb_alignment_coverage': ('B...
Returns dict of matplotlib parameters, dependent on dataframe.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_config.py#L107-L130
datapythonista/mnist
mnist/__init__.py
download_file
def download_file(fname, target_dir=None, force=False): """Download fname from the datasets_url, and save it to target_dir, unless the file already exists, and force is False. Parameters ---------- fname : str Name of the file to download target_dir : str Directory where to sto...
python
def download_file(fname, target_dir=None, force=False): """Download fname from the datasets_url, and save it to target_dir, unless the file already exists, and force is False. Parameters ---------- fname : str Name of the file to download target_dir : str Directory where to sto...
Download fname from the datasets_url, and save it to target_dir, unless the file already exists, and force is False. Parameters ---------- fname : str Name of the file to download target_dir : str Directory where to store the file force : bool Force downloading the fil...
https://github.com/datapythonista/mnist/blob/d91df2b27ee62d07396b5b64c7cfead59833b563/mnist/__init__.py#L34-L61
datapythonista/mnist
mnist/__init__.py
parse_idx
def parse_idx(fd): """Parse an IDX file, and return it as a numpy array. Parameters ---------- fd : file File descriptor of the IDX file to parse endian : str Byte order of the IDX file. See [1] for available options Returns ------- data : numpy.ndarray Numpy a...
python
def parse_idx(fd): """Parse an IDX file, and return it as a numpy array. Parameters ---------- fd : file File descriptor of the IDX file to parse endian : str Byte order of the IDX file. See [1] for available options Returns ------- data : numpy.ndarray Numpy a...
Parse an IDX file, and return it as a numpy array. Parameters ---------- fd : file File descriptor of the IDX file to parse endian : str Byte order of the IDX file. See [1] for available options Returns ------- data : numpy.ndarray Numpy array with the dimensions a...
https://github.com/datapythonista/mnist/blob/d91df2b27ee62d07396b5b64c7cfead59833b563/mnist/__init__.py#L64-L120
datapythonista/mnist
mnist/__init__.py
download_and_parse_mnist_file
def download_and_parse_mnist_file(fname, target_dir=None, force=False): """Download the IDX file named fname from the URL specified in dataset_url and return it as a numpy array. Parameters ---------- fname : str File name to download and parse target_dir : str Directory where ...
python
def download_and_parse_mnist_file(fname, target_dir=None, force=False): """Download the IDX file named fname from the URL specified in dataset_url and return it as a numpy array. Parameters ---------- fname : str File name to download and parse target_dir : str Directory where ...
Download the IDX file named fname from the URL specified in dataset_url and return it as a numpy array. Parameters ---------- fname : str File name to download and parse target_dir : str Directory where to store the file force : bool Force downloading the file, if it a...
https://github.com/datapythonista/mnist/blob/d91df2b27ee62d07396b5b64c7cfead59833b563/mnist/__init__.py#L123-L146
Bogdanp/anom-py
anom/adapters/memcache_adapter.py
MemcacheAdapter._transactions
def _transactions(self): "list[Transaction]: The current stack of Transactions." transactions = getattr(self._state, "transactions", None) if transactions is None: transactions = self._state.transactions = [] return transactions
python
def _transactions(self): "list[Transaction]: The current stack of Transactions." transactions = getattr(self._state, "transactions", None) if transactions is None: transactions = self._state.transactions = [] return transactions
list[Transaction]: The current stack of Transactions.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/adapters/memcache_adapter.py#L76-L81
Bogdanp/anom-py
anom/transaction.py
transactional
def transactional(*, adapter=None, retries=3, propagation=Transaction.Propagation.Nested): """Decorates functions so that all of their operations (except for queries) run inside a Datastore transaction. Parameters: adapter(Adapter, optional): The Adapter to use when running the transaction. ...
python
def transactional(*, adapter=None, retries=3, propagation=Transaction.Propagation.Nested): """Decorates functions so that all of their operations (except for queries) run inside a Datastore transaction. Parameters: adapter(Adapter, optional): The Adapter to use when running the transaction. ...
Decorates functions so that all of their operations (except for queries) run inside a Datastore transaction. Parameters: adapter(Adapter, optional): The Adapter to use when running the transaction. Defaults to the current adapter. retries(int, optional): The number of times to retry the ...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/transaction.py#L82-L131
Bogdanp/anom-py
anom/query.py
QueryOptions.batch_size
def batch_size(self): """int: The number of results to fetch per batch. Clamped to limit if limit is set and is smaller than the given batch size. """ batch_size = self.get("batch_size", DEFAULT_BATCH_SIZE) if self.limit is not None: return min(self.limit, ba...
python
def batch_size(self): """int: The number of results to fetch per batch. Clamped to limit if limit is set and is smaller than the given batch size. """ batch_size = self.get("batch_size", DEFAULT_BATCH_SIZE) if self.limit is not None: return min(self.limit, ba...
int: The number of results to fetch per batch. Clamped to limit if limit is set and is smaller than the given batch size.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/query.py#L46-L54
Bogdanp/anom-py
anom/query.py
Pages.fetch_next_page
def fetch_next_page(self): """Fetch the next Page of results. Returns: Page: The next page of results. """ for page in self: return page else: return Page(self._resultset.cursor, iter(()))
python
def fetch_next_page(self): """Fetch the next Page of results. Returns: Page: The next page of results. """ for page in self: return page else: return Page(self._resultset.cursor, iter(()))
Fetch the next Page of results. Returns: Page: The next page of results.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/query.py#L204-L213
Bogdanp/anom-py
anom/query.py
Query.count
def count(self, *, page_size=DEFAULT_BATCH_SIZE, **options): """Counts the number of entities that match this query. Note: Since Datastore doesn't provide a native way to count entities by query, this method paginates through all the entities' keys and counts them. ...
python
def count(self, *, page_size=DEFAULT_BATCH_SIZE, **options): """Counts the number of entities that match this query. Note: Since Datastore doesn't provide a native way to count entities by query, this method paginates through all the entities' keys and counts them. ...
Counts the number of entities that match this query. Note: Since Datastore doesn't provide a native way to count entities by query, this method paginates through all the entities' keys and counts them. Parameters: \**options(QueryOptions, optional) Retu...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/query.py#L383-L401
Bogdanp/anom-py
anom/query.py
Query.delete
def delete(self, *, page_size=DEFAULT_BATCH_SIZE, **options): """Deletes all the entities that match this query. Note: Since Datasotre doesn't provide a native way to delete entities by query, this method paginates through all the entities' keys and issues a single delete_...
python
def delete(self, *, page_size=DEFAULT_BATCH_SIZE, **options): """Deletes all the entities that match this query. Note: Since Datasotre doesn't provide a native way to delete entities by query, this method paginates through all the entities' keys and issues a single delete_...
Deletes all the entities that match this query. Note: Since Datasotre doesn't provide a native way to delete entities by query, this method paginates through all the entities' keys and issues a single delete_multi call per page. Parameters: \**options(...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/query.py#L403-L427
Bogdanp/anom-py
anom/query.py
Query.get
def get(self, **options): """Run this query and get the first result. Parameters: \**options(QueryOptions, optional) Returns: Model: An entity or None if there were no results. """ sub_query = self.with_limit(1) options = QueryOptions(sub_query).repl...
python
def get(self, **options): """Run this query and get the first result. Parameters: \**options(QueryOptions, optional) Returns: Model: An entity or None if there were no results. """ sub_query = self.with_limit(1) options = QueryOptions(sub_query).repl...
Run this query and get the first result. Parameters: \**options(QueryOptions, optional) Returns: Model: An entity or None if there were no results.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/query.py#L429-L442
Bogdanp/anom-py
anom/query.py
Query.paginate
def paginate(self, *, page_size, **options): """Run this query and return a page iterator. Parameters: page_size(int): The number of entities to fetch per page. \**options(QueryOptions, optional) Returns: Pages: An iterator for this query's pages of results. ...
python
def paginate(self, *, page_size, **options): """Run this query and return a page iterator. Parameters: page_size(int): The number of entities to fetch per page. \**options(QueryOptions, optional) Returns: Pages: An iterator for this query's pages of results. ...
Run this query and return a page iterator. Parameters: page_size(int): The number of entities to fetch per page. \**options(QueryOptions, optional) Returns: Pages: An iterator for this query's pages of results.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/query.py#L455-L465
Bogdanp/anom-py
anom/conditions.py
is_none
def is_none(entity, prop, name): "bool: True if the value of a property is None." return is_not_empty(entity, prop, name) and getattr(entity, name) is None
python
def is_none(entity, prop, name): "bool: True if the value of a property is None." return is_not_empty(entity, prop, name) and getattr(entity, name) is None
bool: True if the value of a property is None.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/conditions.py#L21-L23
Bogdanp/anom-py
anom/conditions.py
is_not_none
def is_not_none(entity, prop, name): "bool: True if the value of a property is not None." return is_not_empty(entity, prop, name) and name in entity._data and getattr(entity, name) is not None
python
def is_not_none(entity, prop, name): "bool: True if the value of a property is not None." return is_not_empty(entity, prop, name) and name in entity._data and getattr(entity, name) is not None
bool: True if the value of a property is not None.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/conditions.py#L26-L28
Bogdanp/anom-py
anom/conditions.py
is_true
def is_true(entity, prop, name): "bool: True if the value of a property is True." return is_not_empty(entity, prop, name) and name in entity._data and bool(getattr(entity, name))
python
def is_true(entity, prop, name): "bool: True if the value of a property is True." return is_not_empty(entity, prop, name) and name in entity._data and bool(getattr(entity, name))
bool: True if the value of a property is True.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/conditions.py#L31-L33
Bogdanp/anom-py
anom/conditions.py
is_false
def is_false(entity, prop, name): "bool: True if the value of a property is False." return is_not_empty(entity, prop, name) and name in entity._data and not bool(getattr(entity, name))
python
def is_false(entity, prop, name): "bool: True if the value of a property is False." return is_not_empty(entity, prop, name) and name in entity._data and not bool(getattr(entity, name))
bool: True if the value of a property is False.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/conditions.py#L36-L38
Bogdanp/anom-py
anom/namespaces.py
namespace
def namespace(namespace): """Context manager for stacking the current thread-local default namespace. Exiting the context sets the thread-local default namespace back to the previously-set namespace. If there is no previous namespace, then the thread-local namespace is cleared. Example: >>>...
python
def namespace(namespace): """Context manager for stacking the current thread-local default namespace. Exiting the context sets the thread-local default namespace back to the previously-set namespace. If there is no previous namespace, then the thread-local namespace is cleared. Example: >>>...
Context manager for stacking the current thread-local default namespace. Exiting the context sets the thread-local default namespace back to the previously-set namespace. If there is no previous namespace, then the thread-local namespace is cleared. Example: >>> with namespace("foo"): ......
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/namespaces.py#L55-L85
Bogdanp/anom-py
anom/model.py
lookup_model_by_kind
def lookup_model_by_kind(kind): """Look up the model instance for a given Datastore kind. Parameters: kind(str) Raises: RuntimeError: If a model for the given kind has not been defined. Returns: model: The model class. """ model = _known_models.get(kind) if model...
python
def lookup_model_by_kind(kind): """Look up the model instance for a given Datastore kind. Parameters: kind(str) Raises: RuntimeError: If a model for the given kind has not been defined. Returns: model: The model class. """ model = _known_models.get(kind) if model...
Look up the model instance for a given Datastore kind. Parameters: kind(str) Raises: RuntimeError: If a model for the given kind has not been defined. Returns: model: The model class.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L612-L628
Bogdanp/anom-py
anom/model.py
delete_multi
def delete_multi(keys): """Delete a set of entitites from Datastore by their respective keys. Note: This uses the adapter that is tied to the first model in the list. If the keys have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **lis...
python
def delete_multi(keys): """Delete a set of entitites from Datastore by their respective keys. Note: This uses the adapter that is tied to the first model in the list. If the keys have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **lis...
Delete a set of entitites from Datastore by their respective keys. Note: This uses the adapter that is tied to the first model in the list. If the keys have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **list** and not a generator or some...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L631-L673
Bogdanp/anom-py
anom/model.py
get_multi
def get_multi(keys): """Get a set of entities from Datastore by their respective keys. Note: This uses the adapter that is tied to the first model in the list. If the keys have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **list** and no...
python
def get_multi(keys): """Get a set of entities from Datastore by their respective keys. Note: This uses the adapter that is tied to the first model in the list. If the keys have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **list** and no...
Get a set of entities from Datastore by their respective keys. Note: This uses the adapter that is tied to the first model in the list. If the keys have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **list** and not a generator or some other ...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L676-L730
Bogdanp/anom-py
anom/model.py
put_multi
def put_multi(entities): """Persist a set of entities to Datastore. Note: This uses the adapter that is tied to the first Entity in the list. If the entities have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **list** and not a generator ...
python
def put_multi(entities): """Persist a set of entities to Datastore. Note: This uses the adapter that is tied to the first Entity in the list. If the entities have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **list** and not a generator ...
Persist a set of entities to Datastore. Note: This uses the adapter that is tied to the first Entity in the list. If the entities have disparate adapters this function may behave in unexpected ways. Warning: You must pass a **list** and not a generator or some other kind of iter...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L733-L772
Bogdanp/anom-py
anom/model.py
Key.from_path
def from_path(cls, *path, namespace=None): """Build up a Datastore key from a path. Parameters: \*path(tuple[str or int]): The path segments. namespace(str): An optional namespace for the key. This is applied to each key in the tree. Returns: anom.Key:...
python
def from_path(cls, *path, namespace=None): """Build up a Datastore key from a path. Parameters: \*path(tuple[str or int]): The path segments. namespace(str): An optional namespace for the key. This is applied to each key in the tree. Returns: anom.Key:...
Build up a Datastore key from a path. Parameters: \*path(tuple[str or int]): The path segments. namespace(str): An optional namespace for the key. This is applied to each key in the tree. Returns: anom.Key: The Datastore represented by the given path.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L70-L85
Bogdanp/anom-py
anom/model.py
Key.path
def path(self): "tuple: The full Datastore path represented by this key." prefix = () if self.parent: prefix = self.parent.path if self.id_or_name: return prefix + (self.kind, self.id_or_name) return prefix + (self.kind,)
python
def path(self): "tuple: The full Datastore path represented by this key." prefix = () if self.parent: prefix = self.parent.path if self.id_or_name: return prefix + (self.kind, self.id_or_name) return prefix + (self.kind,)
tuple: The full Datastore path represented by this key.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L88-L97
Bogdanp/anom-py
anom/model.py
Key.int_id
def int_id(self): "int: This key's numeric id." id_or_name = self.id_or_name if id_or_name is not None and isinstance(id_or_name, int): return id_or_name return None
python
def int_id(self): "int: This key's numeric id." id_or_name = self.id_or_name if id_or_name is not None and isinstance(id_or_name, int): return id_or_name return None
int: This key's numeric id.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L105-L110
Bogdanp/anom-py
anom/model.py
Key.str_id
def str_id(self): "str: This key's string id." id_or_name = self.id_or_name if id_or_name is not None and isinstance(id_or_name, str): return id_or_name return None
python
def str_id(self): "str: This key's string id." id_or_name = self.id_or_name if id_or_name is not None and isinstance(id_or_name, str): return id_or_name return None
str: This key's string id.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L113-L118
Bogdanp/anom-py
anom/model.py
Property.validate
def validate(self, value): """Validates that `value` can be assigned to this Property. Parameters: value: The value to validate. Raises: TypeError: If the type of the assigned value is invalid. Returns: The value that should be assigned to the entity. ...
python
def validate(self, value): """Validates that `value` can be assigned to this Property. Parameters: value: The value to validate. Raises: TypeError: If the type of the assigned value is invalid. Returns: The value that should be assigned to the entity. ...
Validates that `value` can be assigned to this Property. Parameters: value: The value to validate. Raises: TypeError: If the type of the assigned value is invalid. Returns: The value that should be assigned to the entity.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L230-L252
Bogdanp/anom-py
anom/model.py
Property.prepare_to_store
def prepare_to_store(self, entity, value): """Prepare `value` for storage. Called by the Model for each Property, value pair it contains before handing the data off to an adapter. Parameters: entity(Model): The entity to which the value belongs. value: The value bei...
python
def prepare_to_store(self, entity, value): """Prepare `value` for storage. Called by the Model for each Property, value pair it contains before handing the data off to an adapter. Parameters: entity(Model): The entity to which the value belongs. value: The value bei...
Prepare `value` for storage. Called by the Model for each Property, value pair it contains before handing the data off to an adapter. Parameters: entity(Model): The entity to which the value belongs. value: The value being stored. Raises: RuntimeError: If...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L268-L286
Bogdanp/anom-py
anom/model.py
Model.unindexed_properties
def unindexed_properties(self): "tuple[str]: The names of all the unindexed properties on this entity." properties = () for name, prop in self._properties.items(): if isinstance(prop, EmbedLike): embedded_entity = getattr(self, name, None) if embedded_...
python
def unindexed_properties(self): "tuple[str]: The names of all the unindexed properties on this entity." properties = () for name, prop in self._properties.items(): if isinstance(prop, EmbedLike): embedded_entity = getattr(self, name, None) if embedded_...
tuple[str]: The names of all the unindexed properties on this entity.
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L489-L501
Bogdanp/anom-py
anom/model.py
Model.get
def get(cls, id_or_name, *, parent=None, namespace=None): """Get an entity by id. Parameters: id_or_name(int or str): The entity's id. parent(anom.Key, optional): The entity's parent Key. namespace(str, optional): The entity's namespace. Returns: Model: ...
python
def get(cls, id_or_name, *, parent=None, namespace=None): """Get an entity by id. Parameters: id_or_name(int or str): The entity's id. parent(anom.Key, optional): The entity's parent Key. namespace(str, optional): The entity's namespace. Returns: Model: ...
Get an entity by id. Parameters: id_or_name(int or str): The entity's id. parent(anom.Key, optional): The entity's parent Key. namespace(str, optional): The entity's namespace. Returns: Model: An entity or ``None`` if the entity doesn't exist in Datast...
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/model.py#L519-L531
grauwoelfchen/flask-dotenv
flask_dotenv.py
DotEnv.init_app
def init_app(self, app, env_file=None, verbose_mode=False): """Imports .env file.""" if self.app is None: self.app = app self.verbose_mode = verbose_mode if env_file is None: env_file = os.path.join(os.getcwd(), ".env") if not os.path.exists(env_file): ...
python
def init_app(self, app, env_file=None, verbose_mode=False): """Imports .env file.""" if self.app is None: self.app = app self.verbose_mode = verbose_mode if env_file is None: env_file = os.path.join(os.getcwd(), ".env") if not os.path.exists(env_file): ...
Imports .env file.
https://github.com/grauwoelfchen/flask-dotenv/blob/7dc811fff18570c4b6803ce48c3ecca7eebabe51/flask_dotenv.py#L24-L35
grauwoelfchen/flask-dotenv
flask_dotenv.py
DotEnv.__import_vars
def __import_vars(self, env_file): """Actual importing function.""" with open(env_file, "r") as f: # pylint: disable=invalid-name for line in f: try: line = line.lstrip() if line.startswith('export'): line = lin...
python
def __import_vars(self, env_file): """Actual importing function.""" with open(env_file, "r") as f: # pylint: disable=invalid-name for line in f: try: line = line.lstrip() if line.startswith('export'): line = lin...
Actual importing function.
https://github.com/grauwoelfchen/flask-dotenv/blob/7dc811fff18570c4b6803ce48c3ecca7eebabe51/flask_dotenv.py#L37-L60
grauwoelfchen/flask-dotenv
flask_dotenv.py
DotEnv.eval
def eval(self, keys): """ Examples: Specify type literal for key. >>> env.eval({MAIL_PORT: int}) """ for k, v in keys.items(): # pylint: disable=invalid-name if k in self.app.config: try: val = ast.literal_eval(sel...
python
def eval(self, keys): """ Examples: Specify type literal for key. >>> env.eval({MAIL_PORT: int}) """ for k, v in keys.items(): # pylint: disable=invalid-name if k in self.app.config: try: val = ast.literal_eval(sel...
Examples: Specify type literal for key. >>> env.eval({MAIL_PORT: int})
https://github.com/grauwoelfchen/flask-dotenv/blob/7dc811fff18570c4b6803ce48c3ecca7eebabe51/flask_dotenv.py#L62-L86
grauwoelfchen/flask-dotenv
flask_dotenv.py
DotEnv.alias
def alias(self, maps): """ Examples: Make alias var -> as. >>> env.alias(maps={ 'TEST_DATABASE_URL': 'SQLALCHEMY_DATABASE_URI', 'TEST_HOST': 'HOST' }) """ for k, v in maps.items(): # pylint: disable=invalid-name ...
python
def alias(self, maps): """ Examples: Make alias var -> as. >>> env.alias(maps={ 'TEST_DATABASE_URL': 'SQLALCHEMY_DATABASE_URI', 'TEST_HOST': 'HOST' }) """ for k, v in maps.items(): # pylint: disable=invalid-name ...
Examples: Make alias var -> as. >>> env.alias(maps={ 'TEST_DATABASE_URL': 'SQLALCHEMY_DATABASE_URI', 'TEST_HOST': 'HOST' })
https://github.com/grauwoelfchen/flask-dotenv/blob/7dc811fff18570c4b6803ce48c3ecca7eebabe51/flask_dotenv.py#L88-L103
jazzband/django-embed-video
docs/ext/djangodocs.py
parse_django_adminopt_node
def parse_django_adminopt_node(env, sig, signode): """A copy of sphinx.directives.CmdoptionDesc.parse_signature()""" from sphinx.domains.std import option_desc_re count = 0 firstname = '' for m in option_desc_re.finditer(sig): optname, args = m.groups() if count: signode ...
python
def parse_django_adminopt_node(env, sig, signode): """A copy of sphinx.directives.CmdoptionDesc.parse_signature()""" from sphinx.domains.std import option_desc_re count = 0 firstname = '' for m in option_desc_re.finditer(sig): optname, args = m.groups() if count: signode ...
A copy of sphinx.directives.CmdoptionDesc.parse_signature()
https://github.com/jazzband/django-embed-video/blob/6811664c65560840e98ea1db9ff410a359e70681/docs/ext/djangodocs.py#L168-L194
Alir3z4/python-stop-words
stop_words/__init__.py
get_stop_words
def get_stop_words(language, cache=True): """ :type language: basestring :rtype: list """ try: language = LANGUAGE_MAPPING[language] except KeyError: if language not in AVAILABLE_LANGUAGES: raise StopWordError('{0}" language is unavailable.'.format( l...
python
def get_stop_words(language, cache=True): """ :type language: basestring :rtype: list """ try: language = LANGUAGE_MAPPING[language] except KeyError: if language not in AVAILABLE_LANGUAGES: raise StopWordError('{0}" language is unavailable.'.format( l...
:type language: basestring :rtype: list
https://github.com/Alir3z4/python-stop-words/blob/7b30f5b953ef02b62dfb4b8a158ea5f1218d11e7/stop_words/__init__.py#L28-L61
Alir3z4/python-stop-words
stop_words/__init__.py
apply_filters
def apply_filters(stopwords, language): """ Apply registered filters to stopwords :param stopwords: list :param language: string :return: filtered stopwords """ if language in _filters: for func in _filters[language]: stopwords = func(stopwords) for func in _filters[...
python
def apply_filters(stopwords, language): """ Apply registered filters to stopwords :param stopwords: list :param language: string :return: filtered stopwords """ if language in _filters: for func in _filters[language]: stopwords = func(stopwords) for func in _filters[...
Apply registered filters to stopwords :param stopwords: list :param language: string :return: filtered stopwords
https://github.com/Alir3z4/python-stop-words/blob/7b30f5b953ef02b62dfb4b8a158ea5f1218d11e7/stop_words/__init__.py#L66-L80
Alir3z4/python-stop-words
stop_words/__init__.py
add_filter
def add_filter(func, language=None): """ Register filters for specific language. If language == None the filter applies for all languages. Filter will not apply for stop words in cache. :param func: callable :param language: string|None :return: """ if language not in _filters: ...
python
def add_filter(func, language=None): """ Register filters for specific language. If language == None the filter applies for all languages. Filter will not apply for stop words in cache. :param func: callable :param language: string|None :return: """ if language not in _filters: ...
Register filters for specific language. If language == None the filter applies for all languages. Filter will not apply for stop words in cache. :param func: callable :param language: string|None :return:
https://github.com/Alir3z4/python-stop-words/blob/7b30f5b953ef02b62dfb4b8a158ea5f1218d11e7/stop_words/__init__.py#L83-L94
Alir3z4/python-stop-words
stop_words/__init__.py
remove_filter
def remove_filter(func, language=None): """ :param func: :param language: :return: """ if not (language in _filters and func in _filters[language]): return False _filters[language].remove(func) return True
python
def remove_filter(func, language=None): """ :param func: :param language: :return: """ if not (language in _filters and func in _filters[language]): return False _filters[language].remove(func) return True
:param func: :param language: :return:
https://github.com/Alir3z4/python-stop-words/blob/7b30f5b953ef02b62dfb4b8a158ea5f1218d11e7/stop_words/__init__.py#L97-L106
uktrade/directory-components
directory_components/middleware.py
CountryMiddleware.process_response
def process_response(self, request, response): """ Shares config with the language cookie as they serve a similar purpose """ if hasattr(request, 'COUNTRY_CODE'): response.set_cookie( key=constants.COUNTRY_COOKIE_NAME, value=request.COUNTRY_CO...
python
def process_response(self, request, response): """ Shares config with the language cookie as they serve a similar purpose """ if hasattr(request, 'COUNTRY_CODE'): response.set_cookie( key=constants.COUNTRY_COOKIE_NAME, value=request.COUNTRY_CO...
Shares config with the language cookie as they serve a similar purpose
https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/directory_components/middleware.py#L91-L104
uktrade/directory-components
directory_components/widgets.py
PrettyIDsMixin.create_option
def create_option( self, name, value, label, selected, index, subindex=None, attrs=None): """Patch to use nicer ids.""" index = str(index) if subindex is None else "%s%s%s" % ( index, self.id_separator, subindex) if attrs is None: attrs = {} ...
python
def create_option( self, name, value, label, selected, index, subindex=None, attrs=None): """Patch to use nicer ids.""" index = str(index) if subindex is None else "%s%s%s" % ( index, self.id_separator, subindex) if attrs is None: attrs = {} ...
Patch to use nicer ids.
https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/directory_components/widgets.py#L15-L47
uktrade/directory-components
scripts/upgrade_header_footer.py
current_version
def current_version(): """Get current version of directory-components.""" filepath = os.path.abspath( project_root / "directory_components" / "version.py") version_py = get_file_string(filepath) regex = re.compile(Utils.get_version) if regex.search(version_py) is not None: current_ve...
python
def current_version(): """Get current version of directory-components.""" filepath = os.path.abspath( project_root / "directory_components" / "version.py") version_py = get_file_string(filepath) regex = re.compile(Utils.get_version) if regex.search(version_py) is not None: current_ve...
Get current version of directory-components.
https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/scripts/upgrade_header_footer.py#L27-L42
uktrade/directory-components
scripts/upgrade_header_footer.py
get_file_string
def get_file_string(filepath): """Get string from file.""" with open(os.path.abspath(filepath)) as f: return f.read()
python
def get_file_string(filepath): """Get string from file.""" with open(os.path.abspath(filepath)) as f: return f.read()
Get string from file.
https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/scripts/upgrade_header_footer.py#L45-L48
uktrade/directory-components
scripts/upgrade_header_footer.py
replace_in_dirs
def replace_in_dirs(version): """Look through dirs and run replace_in_files in each.""" print(color( "Upgrading directory-components dependency in all repos...", fg='blue', style='bold')) for dirname in Utils.dirs: replace = "directory-components=={}".format(version) replace_...
python
def replace_in_dirs(version): """Look through dirs and run replace_in_files in each.""" print(color( "Upgrading directory-components dependency in all repos...", fg='blue', style='bold')) for dirname in Utils.dirs: replace = "directory-components=={}".format(version) replace_...
Look through dirs and run replace_in_files in each.
https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/scripts/upgrade_header_footer.py#L59-L67
uktrade/directory-components
scripts/upgrade_header_footer.py
replace_in_files
def replace_in_files(dirname, replace): """Replace current version with new version in requirements files.""" filepath = os.path.abspath(dirname / "requirements.in") if os.path.isfile(filepath) and header_footer_exists(filepath): replaced = re.sub(Utils.exp, replace, get_file_string(filepath)) ...
python
def replace_in_files(dirname, replace): """Replace current version with new version in requirements files.""" filepath = os.path.abspath(dirname / "requirements.in") if os.path.isfile(filepath) and header_footer_exists(filepath): replaced = re.sub(Utils.exp, replace, get_file_string(filepath)) ...
Replace current version with new version in requirements files.
https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/scripts/upgrade_header_footer.py#L70-L79
uktrade/directory-components
scripts/upgrade_header_footer.py
header_footer_exists
def header_footer_exists(filepath): """Check if directory-components is listed in requirements files.""" with open(filepath) as f: return re.search(Utils.exp, f.read())
python
def header_footer_exists(filepath): """Check if directory-components is listed in requirements files.""" with open(filepath) as f: return re.search(Utils.exp, f.read())
Check if directory-components is listed in requirements files.
https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/scripts/upgrade_header_footer.py#L82-L85
bxlab/bx-python
lib/bx_extras/pstat.py
abut
def abut (source,*args): """ Like the |Stat abut command. It concatenates two lists side-by-side and returns the result. '2D' lists are also accomodated for either argument (source or addon). CAUTION: If one list is shorter, it will be repeated until it is as long as the longest list. If this behavior is not d...
python
def abut (source,*args): """ Like the |Stat abut command. It concatenates two lists side-by-side and returns the result. '2D' lists are also accomodated for either argument (source or addon). CAUTION: If one list is shorter, it will be repeated until it is as long as the longest list. If this behavior is not d...
Like the |Stat abut command. It concatenates two lists side-by-side and returns the result. '2D' lists are also accomodated for either argument (source or addon). CAUTION: If one list is shorter, it will be repeated until it is as long as the longest list. If this behavior is not desired, use pstat.simpleabut(). ...
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pstat.py#L122-L166
bxlab/bx-python
lib/bx_extras/pstat.py
simpleabut
def simpleabut (source, addon): """ Concatenates two lists as columns and returns the result. '2D' lists are also accomodated for either argument (source or addon). This DOES NOT repeat either list to make the 2 lists of equal length. Beware of list pairs with different lengths ... the resulting list will be the...
python
def simpleabut (source, addon): """ Concatenates two lists as columns and returns the result. '2D' lists are also accomodated for either argument (source or addon). This DOES NOT repeat either list to make the 2 lists of equal length. Beware of list pairs with different lengths ... the resulting list will be the...
Concatenates two lists as columns and returns the result. '2D' lists are also accomodated for either argument (source or addon). This DOES NOT repeat either list to make the 2 lists of equal length. Beware of list pairs with different lengths ... the resulting list will be the length of the FIRST list passed. Usage...
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pstat.py#L169-L202