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 |
|---|---|---|---|---|---|---|---|
databio/pypiper | pypiper/ngstk.py | NGSTk.count_unique_reads | def count_unique_reads(self, file_name, paired_end):
"""
Sometimes alignment software puts multiple locations for a single read; if you just count
those reads, you will get an inaccurate count. This is _not_ the same as multimapping reads,
which may or may not be actually duplicated in t... | python | def count_unique_reads(self, file_name, paired_end):
"""
Sometimes alignment software puts multiple locations for a single read; if you just count
those reads, you will get an inaccurate count. This is _not_ the same as multimapping reads,
which may or may not be actually duplicated in t... | Sometimes alignment software puts multiple locations for a single read; if you just count
those reads, you will get an inaccurate count. This is _not_ the same as multimapping reads,
which may or may not be actually duplicated in the bam file (depending on the alignment
software).
This f... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L681-L701 |
databio/pypiper | pypiper/ngstk.py | NGSTk.count_unique_mapped_reads | def count_unique_mapped_reads(self, file_name, paired_end):
"""
For a bam or sam file with paired or or single-end reads, returns the
number of mapped reads, counting each read only once, even if it appears
mapped at multiple locations.
:param str file_name: name of reads file
... | python | def count_unique_mapped_reads(self, file_name, paired_end):
"""
For a bam or sam file with paired or or single-end reads, returns the
number of mapped reads, counting each read only once, even if it appears
mapped at multiple locations.
:param str file_name: name of reads file
... | For a bam or sam file with paired or or single-end reads, returns the
number of mapped reads, counting each read only once, even if it appears
mapped at multiple locations.
:param str file_name: name of reads file
:param bool paired_end: True/False paired end data
:return int: N... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L704-L732 |
databio/pypiper | pypiper/ngstk.py | NGSTk.count_flag_reads | def count_flag_reads(self, file_name, flag, paired_end):
"""
Counts the number of reads with the specified flag.
:param str file_name: name of reads file
:param str flag: sam flag value to be read
:param bool paired_end: This parameter is ignored; samtools automatically correctl... | python | def count_flag_reads(self, file_name, flag, paired_end):
"""
Counts the number of reads with the specified flag.
:param str file_name: name of reads file
:param str flag: sam flag value to be read
:param bool paired_end: This parameter is ignored; samtools automatically correctl... | Counts the number of reads with the specified flag.
:param str file_name: name of reads file
:param str flag: sam flag value to be read
:param bool paired_end: This parameter is ignored; samtools automatically correctly responds depending
on the data in the bamfile. We leave the opt... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L735-L750 |
databio/pypiper | pypiper/ngstk.py | NGSTk.count_uniquelymapping_reads | def count_uniquelymapping_reads(self, file_name, paired_end):
"""
Counts the number of reads that mapped to a unique position.
:param str file_name: name of reads file
:param bool paired_end: This parameter is ignored.
"""
param = " -c -F256"
if file_name.endswit... | python | def count_uniquelymapping_reads(self, file_name, paired_end):
"""
Counts the number of reads that mapped to a unique position.
:param str file_name: name of reads file
:param bool paired_end: This parameter is ignored.
"""
param = " -c -F256"
if file_name.endswit... | Counts the number of reads that mapped to a unique position.
:param str file_name: name of reads file
:param bool paired_end: This parameter is ignored. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L769-L779 |
databio/pypiper | pypiper/ngstk.py | NGSTk.samtools_view | def samtools_view(self, file_name, param, postpend=""):
"""
Run samtools view, with flexible parameters and post-processing.
This is used internally to implement the various count_reads functions.
:param str file_name: file_name
:param str param: String of parameters to pass to... | python | def samtools_view(self, file_name, param, postpend=""):
"""
Run samtools view, with flexible parameters and post-processing.
This is used internally to implement the various count_reads functions.
:param str file_name: file_name
:param str param: String of parameters to pass to... | Run samtools view, with flexible parameters and post-processing.
This is used internally to implement the various count_reads functions.
:param str file_name: file_name
:param str param: String of parameters to pass to samtools view
:param str postpend: String to append to the samtools... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L793-L806 |
databio/pypiper | pypiper/ngstk.py | NGSTk.count_reads | def count_reads(self, file_name, paired_end):
"""
Count reads in a file.
Paired-end reads count as 2 in this function.
For paired-end reads, this function assumes that the reads are split
into 2 files, so it divides line count by 2 instead of 4.
This will thus give an in... | python | def count_reads(self, file_name, paired_end):
"""
Count reads in a file.
Paired-end reads count as 2 in this function.
For paired-end reads, this function assumes that the reads are split
into 2 files, so it divides line count by 2 instead of 4.
This will thus give an in... | Count reads in a file.
Paired-end reads count as 2 in this function.
For paired-end reads, this function assumes that the reads are split
into 2 files, so it divides line count by 2 instead of 4.
This will thus give an incorrect result if your paired-end fastq files
are in only ... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L809-L837 |
databio/pypiper | pypiper/ngstk.py | NGSTk.count_concordant | def count_concordant(self, aligned_bam):
"""
Count only reads that "aligned concordantly exactly 1 time."
:param str aligned_bam: File for which to count mapped reads.
"""
cmd = self.tools.samtools + " view " + aligned_bam + " | "
cmd += "grep 'YT:Z:CP'" + " | uniq -u | ... | python | def count_concordant(self, aligned_bam):
"""
Count only reads that "aligned concordantly exactly 1 time."
:param str aligned_bam: File for which to count mapped reads.
"""
cmd = self.tools.samtools + " view " + aligned_bam + " | "
cmd += "grep 'YT:Z:CP'" + " | uniq -u | ... | Count only reads that "aligned concordantly exactly 1 time."
:param str aligned_bam: File for which to count mapped reads. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L840-L849 |
databio/pypiper | pypiper/ngstk.py | NGSTk.count_mapped_reads | def count_mapped_reads(self, file_name, paired_end):
"""
Mapped_reads are not in fastq format, so this one doesn't need to accommodate fastq,
and therefore, doesn't require a paired-end parameter because it only uses samtools view.
Therefore, it's ok that it has a default parameter, sinc... | python | def count_mapped_reads(self, file_name, paired_end):
"""
Mapped_reads are not in fastq format, so this one doesn't need to accommodate fastq,
and therefore, doesn't require a paired-end parameter because it only uses samtools view.
Therefore, it's ok that it has a default parameter, sinc... | Mapped_reads are not in fastq format, so this one doesn't need to accommodate fastq,
and therefore, doesn't require a paired-end parameter because it only uses samtools view.
Therefore, it's ok that it has a default parameter, since this is discarded.
:param str file_name: File for which to cou... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L852-L869 |
databio/pypiper | pypiper/ngstk.py | NGSTk.sam_conversions | def sam_conversions(self, sam_file, depth=True):
"""
Convert sam files to bam files, then sort and index them for later use.
:param bool depth: also calculate coverage over each position
"""
cmd = self.tools.samtools + " view -bS " + sam_file + " > " + sam_file.replace(".sam", "... | python | def sam_conversions(self, sam_file, depth=True):
"""
Convert sam files to bam files, then sort and index them for later use.
:param bool depth: also calculate coverage over each position
"""
cmd = self.tools.samtools + " view -bS " + sam_file + " > " + sam_file.replace(".sam", "... | Convert sam files to bam files, then sort and index them for later use.
:param bool depth: also calculate coverage over each position | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L872-L883 |
databio/pypiper | pypiper/ngstk.py | NGSTk.bam_conversions | def bam_conversions(self, bam_file, depth=True):
"""
Sort and index bam files for later use.
:param bool depth: also calculate coverage over each position
"""
cmd = self.tools.samtools + " view -h " + bam_file + " > " + bam_file.replace(".bam", ".sam") + "\n"
cmd += self... | python | def bam_conversions(self, bam_file, depth=True):
"""
Sort and index bam files for later use.
:param bool depth: also calculate coverage over each position
"""
cmd = self.tools.samtools + " view -h " + bam_file + " > " + bam_file.replace(".bam", ".sam") + "\n"
cmd += self... | Sort and index bam files for later use.
:param bool depth: also calculate coverage over each position | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L886-L897 |
databio/pypiper | pypiper/ngstk.py | NGSTk.fastqc | def fastqc(self, file, output_dir):
"""
Create command to run fastqc on a FASTQ file
:param str file: Path to file with sequencing reads
:param str output_dir: Path to folder in which to place output
:return str: Command with which to run fastqc
"""
# You can fin... | python | def fastqc(self, file, output_dir):
"""
Create command to run fastqc on a FASTQ file
:param str file: Path to file with sequencing reads
:param str output_dir: Path to folder in which to place output
:return str: Command with which to run fastqc
"""
# You can fin... | Create command to run fastqc on a FASTQ file
:param str file: Path to file with sequencing reads
:param str output_dir: Path to folder in which to place output
:return str: Command with which to run fastqc | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L900-L919 |
databio/pypiper | pypiper/ngstk.py | NGSTk.fastqc_rename | def fastqc_rename(self, input_bam, output_dir, sample_name):
"""
Create pair of commands to run fastqc and organize files.
The first command returned is the one that actually runs fastqc when
it's executed; the second moves the output files to the output
folder for the sample in... | python | def fastqc_rename(self, input_bam, output_dir, sample_name):
"""
Create pair of commands to run fastqc and organize files.
The first command returned is the one that actually runs fastqc when
it's executed; the second moves the output files to the output
folder for the sample in... | Create pair of commands to run fastqc and organize files.
The first command returned is the one that actually runs fastqc when
it's executed; the second moves the output files to the output
folder for the sample indicated.
:param str input_bam: Path to file for which to run fastqc.
... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L922-L945 |
databio/pypiper | pypiper/ngstk.py | NGSTk.samtools_index | def samtools_index(self, bam_file):
"""Index a bam file."""
cmd = self.tools.samtools + " index {0}".format(bam_file)
return cmd | python | def samtools_index(self, bam_file):
"""Index a bam file."""
cmd = self.tools.samtools + " index {0}".format(bam_file)
return cmd | Index a bam file. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L948-L951 |
databio/pypiper | pypiper/ngstk.py | NGSTk.skewer | def skewer(
self, input_fastq1, output_prefix, output_fastq1,
log, cpus, adapters, input_fastq2=None, output_fastq2=None):
"""
Create commands with which to run skewer.
:param str input_fastq1: Path to input (read 1) FASTQ file
:param str output_prefix: Prefix fo... | python | def skewer(
self, input_fastq1, output_prefix, output_fastq1,
log, cpus, adapters, input_fastq2=None, output_fastq2=None):
"""
Create commands with which to run skewer.
:param str input_fastq1: Path to input (read 1) FASTQ file
:param str output_prefix: Prefix fo... | Create commands with which to run skewer.
:param str input_fastq1: Path to input (read 1) FASTQ file
:param str output_prefix: Prefix for output FASTQ file names
:param str output_fastq1: Path to (read 1) output FASTQ file
:param str log: Path to file to which to write logging informati... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1039-L1082 |
databio/pypiper | pypiper/ngstk.py | NGSTk.filter_reads | def filter_reads(self, input_bam, output_bam, metrics_file, paired=False, cpus=16, Q=30):
"""
Remove duplicates, filter for >Q, remove multiple mapping reads.
For paired-end reads, keep only proper pairs.
"""
nodups = re.sub("\.bam$", "", output_bam) + ".nodups.nofilter.bam"
... | python | def filter_reads(self, input_bam, output_bam, metrics_file, paired=False, cpus=16, Q=30):
"""
Remove duplicates, filter for >Q, remove multiple mapping reads.
For paired-end reads, keep only proper pairs.
"""
nodups = re.sub("\.bam$", "", output_bam) + ".nodups.nofilter.bam"
... | Remove duplicates, filter for >Q, remove multiple mapping reads.
For paired-end reads, keep only proper pairs. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1135-L1152 |
databio/pypiper | pypiper/ngstk.py | NGSTk.run_spp | def run_spp(self, input_bam, output, plot, cpus):
"""
Run the SPP read peak analysis tool.
:param str input_bam: Path to reads file
:param str output: Path to output file
:param str plot: Path to plot file
:param int cpus: Number of processors to use
:return str:... | python | def run_spp(self, input_bam, output, plot, cpus):
"""
Run the SPP read peak analysis tool.
:param str input_bam: Path to reads file
:param str output: Path to output file
:param str plot: Path to plot file
:param int cpus: Number of processors to use
:return str:... | Run the SPP read peak analysis tool.
:param str input_bam: Path to reads file
:param str output: Path to output file
:param str plot: Path to plot file
:param int cpus: Number of processors to use
:return str: Command with which to run SPP | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1176-L1189 |
databio/pypiper | pypiper/ngstk.py | NGSTk.plot_atacseq_insert_sizes | def plot_atacseq_insert_sizes(self, bam, plot, output_csv, max_insert=1500, smallest_insert=30):
"""
Heavy inspiration from here:
https://github.com/dbrg77/ATAC/blob/master/ATAC_seq_read_length_curve_fitting.ipynb
"""
try:
import pysam
import numpy as np
... | python | def plot_atacseq_insert_sizes(self, bam, plot, output_csv, max_insert=1500, smallest_insert=30):
"""
Heavy inspiration from here:
https://github.com/dbrg77/ATAC/blob/master/ATAC_seq_read_length_curve_fitting.ipynb
"""
try:
import pysam
import numpy as np
... | Heavy inspiration from here:
https://github.com/dbrg77/ATAC/blob/master/ATAC_seq_read_length_curve_fitting.ipynb | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1207-L1335 |
databio/pypiper | pypiper/ngstk.py | NGSTk.bam_to_bigwig | def bam_to_bigwig(
self, input_bam, output_bigwig, genome_sizes, genome,
tagmented=False, normalize=False, norm_factor=1000):
"""
Convert a BAM file to a bigWig file.
:param str input_bam: path to BAM file to convert
:param str output_bigwig: path to which to wri... | python | def bam_to_bigwig(
self, input_bam, output_bigwig, genome_sizes, genome,
tagmented=False, normalize=False, norm_factor=1000):
"""
Convert a BAM file to a bigWig file.
:param str input_bam: path to BAM file to convert
:param str output_bigwig: path to which to wri... | Convert a BAM file to a bigWig file.
:param str input_bam: path to BAM file to convert
:param str output_bigwig: path to which to write file in bigwig format
:param str genome_sizes: path to file with chromosome size information
:param str genome: name of genomic assembly
:param... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1338-L1376 |
databio/pypiper | pypiper/ngstk.py | NGSTk.calc_frip | def calc_frip(self, input_bam, input_bed, threads=4):
"""
Calculate fraction of reads in peaks.
A file of with a pool of sequencing reads and a file with peak call
regions define the operation that will be performed. Thread count
for samtools can be specified as well.
:... | python | def calc_frip(self, input_bam, input_bed, threads=4):
"""
Calculate fraction of reads in peaks.
A file of with a pool of sequencing reads and a file with peak call
regions define the operation that will be performed. Thread count
for samtools can be specified as well.
:... | Calculate fraction of reads in peaks.
A file of with a pool of sequencing reads and a file with peak call
regions define the operation that will be performed. Thread count
for samtools can be specified as well.
:param str input_bam: sequencing reads file
:param str input_bed: f... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1426-L1440 |
databio/pypiper | pypiper/ngstk.py | NGSTk.macs2_call_peaks | def macs2_call_peaks(
self, treatment_bams, output_dir, sample_name, genome,
control_bams=None, broad=False, paired=False,
pvalue=None, qvalue=None, include_significance=None):
"""
Use MACS2 to call peaks.
:param str | Iterable[str] treatment_bams... | python | def macs2_call_peaks(
self, treatment_bams, output_dir, sample_name, genome,
control_bams=None, broad=False, paired=False,
pvalue=None, qvalue=None, include_significance=None):
"""
Use MACS2 to call peaks.
:param str | Iterable[str] treatment_bams... | Use MACS2 to call peaks.
:param str | Iterable[str] treatment_bams: Paths to files with data to
regard as treatment.
:param str output_dir: Path to output folder.
:param str sample_name: Name for the sample involved.
:param str genome: Name of the genome assembly to use.
... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1458-L1522 |
databio/pypiper | pypiper/ngstk.py | NGSTk.spp_call_peaks | def spp_call_peaks(
self, treatment_bam, control_bam, treatment_name, control_name,
output_dir, broad, cpus, qvalue=None):
"""
Build command for R script to call peaks with SPP.
:param str treatment_bam: Path to file with data for treatment sample.
:param... | python | def spp_call_peaks(
self, treatment_bam, control_bam, treatment_name, control_name,
output_dir, broad, cpus, qvalue=None):
"""
Build command for R script to call peaks with SPP.
:param str treatment_bam: Path to file with data for treatment sample.
:param... | Build command for R script to call peaks with SPP.
:param str treatment_bam: Path to file with data for treatment sample.
:param str control_bam: Path to file with data for control sample.
:param str treatment_name: Name for the treatment sample.
:param str control_name: Name for the co... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1537-L1559 |
databio/pypiper | pypiper/ngstk.py | NGSTk.get_read_type | def get_read_type(self, bam_file, n=10):
"""
Gets the read type (single, paired) and length of bam file.
:param str bam_file: Bam file to determine read attributes.
:param int n: Number of lines to read from bam file.
:return str, int: tuple of read type and read length
"... | python | def get_read_type(self, bam_file, n=10):
"""
Gets the read type (single, paired) and length of bam file.
:param str bam_file: Bam file to determine read attributes.
:param int n: Number of lines to read from bam file.
:return str, int: tuple of read type and read length
"... | Gets the read type (single, paired) and length of bam file.
:param str bam_file: Bam file to determine read attributes.
:param int n: Number of lines to read from bam file.
:return str, int: tuple of read type and read length | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1593-L1623 |
databio/pypiper | pypiper/ngstk.py | NGSTk.parse_bowtie_stats | def parse_bowtie_stats(self, stats_file):
"""
Parses Bowtie2 stats file, returns series with values.
:param str stats_file: Bowtie2 output file with alignment statistics.
"""
import pandas as pd
stats = pd.Series(index=["readCount", "unpaired", "unaligned", "unique", "mu... | python | def parse_bowtie_stats(self, stats_file):
"""
Parses Bowtie2 stats file, returns series with values.
:param str stats_file: Bowtie2 output file with alignment statistics.
"""
import pandas as pd
stats = pd.Series(index=["readCount", "unpaired", "unaligned", "unique", "mu... | Parses Bowtie2 stats file, returns series with values.
:param str stats_file: Bowtie2 output file with alignment statistics. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1626-L1658 |
databio/pypiper | pypiper/ngstk.py | NGSTk.parse_duplicate_stats | def parse_duplicate_stats(self, stats_file):
"""
Parses sambamba markdup output, returns series with values.
:param str stats_file: sambamba output file with duplicate statistics.
"""
import pandas as pd
series = pd.Series()
try:
with open(stats_file)... | python | def parse_duplicate_stats(self, stats_file):
"""
Parses sambamba markdup output, returns series with values.
:param str stats_file: sambamba output file with duplicate statistics.
"""
import pandas as pd
series = pd.Series()
try:
with open(stats_file)... | Parses sambamba markdup output, returns series with values.
:param str stats_file: sambamba output file with duplicate statistics. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1661-L1683 |
databio/pypiper | pypiper/ngstk.py | NGSTk.parse_qc | def parse_qc(self, qc_file):
"""
Parse phantompeakqualtools (spp) QC table and return quality metrics.
:param str qc_file: Path to phantompeakqualtools output file, which
contains sample quality measurements.
"""
import pandas as pd
series = pd.Series()
... | python | def parse_qc(self, qc_file):
"""
Parse phantompeakqualtools (spp) QC table and return quality metrics.
:param str qc_file: Path to phantompeakqualtools output file, which
contains sample quality measurements.
"""
import pandas as pd
series = pd.Series()
... | Parse phantompeakqualtools (spp) QC table and return quality metrics.
:param str qc_file: Path to phantompeakqualtools output file, which
contains sample quality measurements. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1686-L1703 |
databio/pypiper | pypiper/ngstk.py | NGSTk.get_peak_number | def get_peak_number(self, sample):
"""
Counts number of peaks from a sample's peak file.
:param pipelines.Sample sample: Sample object with "peaks" attribute.
"""
proc = subprocess.Popen(["wc", "-l", sample.peaks], stdout=subprocess.PIPE)
out, err = proc.communicate()
... | python | def get_peak_number(self, sample):
"""
Counts number of peaks from a sample's peak file.
:param pipelines.Sample sample: Sample object with "peaks" attribute.
"""
proc = subprocess.Popen(["wc", "-l", sample.peaks], stdout=subprocess.PIPE)
out, err = proc.communicate()
... | Counts number of peaks from a sample's peak file.
:param pipelines.Sample sample: Sample object with "peaks" attribute. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1706-L1715 |
databio/pypiper | pypiper/ngstk.py | NGSTk.get_frip | def get_frip(self, sample):
"""
Calculates the fraction of reads in peaks for a given sample.
:param pipelines.Sample sample: Sample object with "peaks" attribute.
"""
import pandas as pd
with open(sample.frip, "r") as handle:
content = handle.readlines()
... | python | def get_frip(self, sample):
"""
Calculates the fraction of reads in peaks for a given sample.
:param pipelines.Sample sample: Sample object with "peaks" attribute.
"""
import pandas as pd
with open(sample.frip, "r") as handle:
content = handle.readlines()
... | Calculates the fraction of reads in peaks for a given sample.
:param pipelines.Sample sample: Sample object with "peaks" attribute. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1718-L1729 |
databio/pypiper | pypiper/manager.py | PipelineManager._ignore_interrupts | def _ignore_interrupts(self):
"""
Ignore interrupt and termination signals. Used as a pre-execution
function (preexec_fn) for subprocess.Popen calls that pypiper will
control over (i.e., manually clean up).
"""
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.s... | python | def _ignore_interrupts(self):
"""
Ignore interrupt and termination signals. Used as a pre-execution
function (preexec_fn) for subprocess.Popen calls that pypiper will
control over (i.e., manually clean up).
"""
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.s... | Ignore interrupt and termination signals. Used as a pre-execution
function (preexec_fn) for subprocess.Popen calls that pypiper will
control over (i.e., manually clean up). | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L366-L373 |
databio/pypiper | pypiper/manager.py | PipelineManager.start_pipeline | def start_pipeline(self, args=None, multi=False):
"""
Initialize setup. Do some setup, like tee output, print some diagnostics, create temp files.
You provide only the output directory (used for pipeline stats, log, and status flag files).
"""
# Perhaps this could all just be put... | python | def start_pipeline(self, args=None, multi=False):
"""
Initialize setup. Do some setup, like tee output, print some diagnostics, create temp files.
You provide only the output directory (used for pipeline stats, log, and status flag files).
"""
# Perhaps this could all just be put... | Initialize setup. Do some setup, like tee output, print some diagnostics, create temp files.
You provide only the output directory (used for pipeline stats, log, and status flag files). | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L376-L514 |
databio/pypiper | pypiper/manager.py | PipelineManager._set_status_flag | def _set_status_flag(self, status):
"""
Configure state and files on disk to match current processing status.
:param str status: Name of new status designation for pipeline.
"""
# Remove previous status flag file.
flag_file_path = self._flag_file_path()
try:
... | python | def _set_status_flag(self, status):
"""
Configure state and files on disk to match current processing status.
:param str status: Name of new status designation for pipeline.
"""
# Remove previous status flag file.
flag_file_path = self._flag_file_path()
try:
... | Configure state and files on disk to match current processing status.
:param str status: Name of new status designation for pipeline. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L517-L541 |
databio/pypiper | pypiper/manager.py | PipelineManager._flag_file_path | def _flag_file_path(self, status=None):
"""
Create path to flag file based on indicated or current status.
Internal variables used are the pipeline name and the designated
pipeline output folder path.
:param str status: flag file type to create, default to current status
... | python | def _flag_file_path(self, status=None):
"""
Create path to flag file based on indicated or current status.
Internal variables used are the pipeline name and the designated
pipeline output folder path.
:param str status: flag file type to create, default to current status
... | Create path to flag file based on indicated or current status.
Internal variables used are the pipeline name and the designated
pipeline output folder path.
:param str status: flag file type to create, default to current status
:return str: path to flag file of indicated or current sta... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L544-L556 |
databio/pypiper | pypiper/manager.py | PipelineManager.run | def run(self, cmd, target=None, lock_name=None, shell=None, nofail=False, clean=False, follow=None, container=None):
"""
The primary workhorse function of PipelineManager, this runs a command.
This is the command execution function, which enforces
race-free file-locking, enables restar... | python | def run(self, cmd, target=None, lock_name=None, shell=None, nofail=False, clean=False, follow=None, container=None):
"""
The primary workhorse function of PipelineManager, this runs a command.
This is the command execution function, which enforces
race-free file-locking, enables restar... | The primary workhorse function of PipelineManager, this runs a command.
This is the command execution function, which enforces
race-free file-locking, enables restartability, and multiple pipelines
can produce/use the same files. The function will wait for the file
lock if it exists, a... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L562-L774 |
databio/pypiper | pypiper/manager.py | PipelineManager.checkprint | def checkprint(self, cmd, shell=None, nofail=False):
"""
Just like callprint, but checks output -- so you can get a variable
in python corresponding to the return value of the command you call.
This is equivalent to running subprocess.check_output()
instead of subprocess.call().... | python | def checkprint(self, cmd, shell=None, nofail=False):
"""
Just like callprint, but checks output -- so you can get a variable
in python corresponding to the return value of the command you call.
This is equivalent to running subprocess.check_output()
instead of subprocess.call().... | Just like callprint, but checks output -- so you can get a variable
in python corresponding to the return value of the command you call.
This is equivalent to running subprocess.check_output()
instead of subprocess.call().
:param str | Iterable[str] cmd: Bash command(s) to be run.
... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L776-L807 |
databio/pypiper | pypiper/manager.py | PipelineManager._attend_process | def _attend_process(self, proc, sleeptime):
"""
Waits on a process for a given time to see if it finishes, returns True
if it's still running after the given time or False as soon as it
returns.
:param psutil.Popen proc: Process object opened by psutil.Popen()
:param fl... | python | def _attend_process(self, proc, sleeptime):
"""
Waits on a process for a given time to see if it finishes, returns True
if it's still running after the given time or False as soon as it
returns.
:param psutil.Popen proc: Process object opened by psutil.Popen()
:param fl... | Waits on a process for a given time to see if it finishes, returns True
if it's still running after the given time or False as soon as it
returns.
:param psutil.Popen proc: Process object opened by psutil.Popen()
:param float sleeptime: Time to wait
:return bool: True if proces... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L810-L825 |
databio/pypiper | pypiper/manager.py | PipelineManager.callprint | def callprint(self, cmd, shell=None, lock_file=None, nofail=False, container=None):
"""
Prints the command, and then executes it, then prints the memory use and
return code of the command.
Uses python's subprocess.Popen() to execute the given command. The shell argument is simply
... | python | def callprint(self, cmd, shell=None, lock_file=None, nofail=False, container=None):
"""
Prints the command, and then executes it, then prints the memory use and
return code of the command.
Uses python's subprocess.Popen() to execute the given command. The shell argument is simply
... | Prints the command, and then executes it, then prints the memory use and
return code of the command.
Uses python's subprocess.Popen() to execute the given command. The shell argument is simply
passed along to Popen(). You should use shell=False (default) where possible, because this enables mem... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L828-L971 |
databio/pypiper | pypiper/manager.py | PipelineManager._wait_for_process | def _wait_for_process(self, p, shell=False):
"""
Debug function used in unit tests.
:param p: A subprocess.Popen process.
:param bool shell: If command requires should be run in its own shell. Optional. Default: False.
"""
local_maxmem = -1
sleeptime = .5
... | python | def _wait_for_process(self, p, shell=False):
"""
Debug function used in unit tests.
:param p: A subprocess.Popen process.
:param bool shell: If command requires should be run in its own shell. Optional. Default: False.
"""
local_maxmem = -1
sleeptime = .5
... | Debug function used in unit tests.
:param p: A subprocess.Popen process.
:param bool shell: If command requires should be run in its own shell. Optional. Default: False. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L978-L1006 |
databio/pypiper | pypiper/manager.py | PipelineManager._wait_for_lock | def _wait_for_lock(self, lock_file):
"""
Just sleep until the lock_file does not exist or a lock_file-related dynamic recovery flag is spotted
:param str lock_file: Lock file to wait upon.
"""
sleeptime = .5
first_message_flag = False
dot_count = 0
recove... | python | def _wait_for_lock(self, lock_file):
"""
Just sleep until the lock_file does not exist or a lock_file-related dynamic recovery flag is spotted
:param str lock_file: Lock file to wait upon.
"""
sleeptime = .5
first_message_flag = False
dot_count = 0
recove... | Just sleep until the lock_file does not exist or a lock_file-related dynamic recovery flag is spotted
:param str lock_file: Lock file to wait upon. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1009-L1039 |
databio/pypiper | pypiper/manager.py | PipelineManager.timestamp | def timestamp(self, message="", checkpoint=None,
finished=False, raise_error=True):
"""
Print message, time, and time elapsed, perhaps creating checkpoint.
This prints your given message, along with the current time, and time
elapsed since the previous timestamp() call... | python | def timestamp(self, message="", checkpoint=None,
finished=False, raise_error=True):
"""
Print message, time, and time elapsed, perhaps creating checkpoint.
This prints your given message, along with the current time, and time
elapsed since the previous timestamp() call... | Print message, time, and time elapsed, perhaps creating checkpoint.
This prints your given message, along with the current time, and time
elapsed since the previous timestamp() call. If you specify a
HEADING by beginning the message with "###", it surrounds the message
with newlines fo... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1046-L1114 |
databio/pypiper | pypiper/manager.py | PipelineManager._report_profile | def _report_profile(self, command, lock_name, elapsed_time, memory):
"""
Writes a string to self.pipeline_profile_file.
"""
message_raw = str(command) + "\t " + \
str(lock_name) + "\t" + \
str(datetime.timedelta(seconds = round(elapsed_time, 2))) + "\t " + \
... | python | def _report_profile(self, command, lock_name, elapsed_time, memory):
"""
Writes a string to self.pipeline_profile_file.
"""
message_raw = str(command) + "\t " + \
str(lock_name) + "\t" + \
str(datetime.timedelta(seconds = round(elapsed_time, 2))) + "\t " + \
... | Writes a string to self.pipeline_profile_file. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1126-L1136 |
databio/pypiper | pypiper/manager.py | PipelineManager.report_result | def report_result(self, key, value, annotation=None):
"""
Writes a string to self.pipeline_stats_file.
:param str key: name (key) of the stat
:param str annotation: By default, the stats will be annotated with the pipeline
name, so you can tell which pipeline records... | python | def report_result(self, key, value, annotation=None):
"""
Writes a string to self.pipeline_stats_file.
:param str key: name (key) of the stat
:param str annotation: By default, the stats will be annotated with the pipeline
name, so you can tell which pipeline records... | Writes a string to self.pipeline_stats_file.
:param str key: name (key) of the stat
:param str annotation: By default, the stats will be annotated with the pipeline
name, so you can tell which pipeline records which stats. If you want, you can
change this; use annotation... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1139-L1167 |
databio/pypiper | pypiper/manager.py | PipelineManager.report_object | def report_object(self, key, filename, anchor_text=None, anchor_image=None,
annotation=None):
"""
Writes a string to self.pipeline_objects_file. Used to report figures and others.
:param str key: name (key) of the object
:param str filename: relative path to the file (relative to... | python | def report_object(self, key, filename, anchor_text=None, anchor_image=None,
annotation=None):
"""
Writes a string to self.pipeline_objects_file. Used to report figures and others.
:param str key: name (key) of the object
:param str filename: relative path to the file (relative to... | Writes a string to self.pipeline_objects_file. Used to report figures and others.
:param str key: name (key) of the object
:param str filename: relative path to the file (relative to parent output dir)
:param str anchor_text: text used as the link anchor test or caption to
refer to ... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1171-L1219 |
databio/pypiper | pypiper/manager.py | PipelineManager._safe_write_to_file | def _safe_write_to_file(self, file, message):
"""
Writes a string to a file safely (with file locks).
"""
target = file
lock_name = make_lock_name(target, self.outfolder)
lock_file = self._make_lock_path(lock_name)
while True:
if os.path.isfile(lock_f... | python | def _safe_write_to_file(self, file, message):
"""
Writes a string to a file safely (with file locks).
"""
target = file
lock_name = make_lock_name(target, self.outfolder)
lock_file = self._make_lock_path(lock_name)
while True:
if os.path.isfile(lock_f... | Writes a string to a file safely (with file locks). | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1222-L1250 |
databio/pypiper | pypiper/manager.py | PipelineManager._report_command | def _report_command(self, cmd, procs=None):
"""
Writes a command to both stdout and to the commands log file
(self.pipeline_commands_file).
:param str cmd: command to report
:param str | list[str] procs: process numbers for processes in the command
"""
if isinst... | python | def _report_command(self, cmd, procs=None):
"""
Writes a command to both stdout and to the commands log file
(self.pipeline_commands_file).
:param str cmd: command to report
:param str | list[str] procs: process numbers for processes in the command
"""
if isinst... | Writes a command to both stdout and to the commands log file
(self.pipeline_commands_file).
:param str cmd: command to report
:param str | list[str] procs: process numbers for processes in the command | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1253-L1270 |
databio/pypiper | pypiper/manager.py | PipelineManager._create_file_racefree | def _create_file_racefree(self, file):
"""
Creates a file, but fails if the file already exists.
This function will thus only succeed if this process actually creates
the file; if the file already exists, it will cause an OSError,
solving race conditions.
:par... | python | def _create_file_racefree(self, file):
"""
Creates a file, but fails if the file already exists.
This function will thus only succeed if this process actually creates
the file; if the file already exists, it will cause an OSError,
solving race conditions.
:par... | Creates a file, but fails if the file already exists.
This function will thus only succeed if this process actually creates
the file; if the file already exists, it will cause an OSError,
solving race conditions.
:param str file: File to create. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1289-L1300 |
databio/pypiper | pypiper/manager.py | PipelineManager._make_lock_path | def _make_lock_path(self, lock_name_base):
"""
Create path to lock file with given name as base.
:param str lock_name_base: Lock file name, designed to not be prefixed
with the lock file designation, but that's permitted.
:return str: Path to the lock file.
... | python | def _make_lock_path(self, lock_name_base):
"""
Create path to lock file with given name as base.
:param str lock_name_base: Lock file name, designed to not be prefixed
with the lock file designation, but that's permitted.
:return str: Path to the lock file.
... | Create path to lock file with given name as base.
:param str lock_name_base: Lock file name, designed to not be prefixed
with the lock file designation, but that's permitted.
:return str: Path to the lock file. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1310-L1326 |
databio/pypiper | pypiper/manager.py | PipelineManager._recoverfile_from_lockfile | def _recoverfile_from_lockfile(self, lockfile):
"""
Create path to recovery file with given name as base.
:param str lockfile: Name of file on which to base this path,
perhaps already prefixed with the designation of a lock file.
:return str: Path to recovery file.
... | python | def _recoverfile_from_lockfile(self, lockfile):
"""
Create path to recovery file with given name as base.
:param str lockfile: Name of file on which to base this path,
perhaps already prefixed with the designation of a lock file.
:return str: Path to recovery file.
... | Create path to recovery file with given name as base.
:param str lockfile: Name of file on which to base this path,
perhaps already prefixed with the designation of a lock file.
:return str: Path to recovery file. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1329-L1341 |
databio/pypiper | pypiper/manager.py | PipelineManager.make_sure_path_exists | def make_sure_path_exists(self, path):
"""
Creates all directories in a path if it does not exist.
:param str path: Path to create.
:raises Exception: if the path creation attempt hits an error with
a code indicating a cause other than pre-existence.
"""
try... | python | def make_sure_path_exists(self, path):
"""
Creates all directories in a path if it does not exist.
:param str path: Path to create.
:raises Exception: if the path creation attempt hits an error with
a code indicating a cause other than pre-existence.
"""
try... | Creates all directories in a path if it does not exist.
:param str path: Path to create.
:raises Exception: if the path creation attempt hits an error with
a code indicating a cause other than pre-existence. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1344-L1356 |
databio/pypiper | pypiper/manager.py | PipelineManager._refresh_stats | def _refresh_stats(self):
"""
Loads up the stats sheet created for this pipeline run and reads
those stats into memory
"""
# regex identifies all possible stats files.
#regex = self.outfolder + "*_stats.tsv"
#stats_files = glob.glob(regex)
#stats_... | python | def _refresh_stats(self):
"""
Loads up the stats sheet created for this pipeline run and reads
those stats into memory
"""
# regex identifies all possible stats files.
#regex = self.outfolder + "*_stats.tsv"
#stats_files = glob.glob(regex)
#stats_... | Loads up the stats sheet created for this pipeline run and reads
those stats into memory | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1363-L1387 |
databio/pypiper | pypiper/manager.py | PipelineManager.get_stat | def get_stat(self, key):
"""
Returns a stat that was previously reported. This is necessary for reporting new stats that are
derived from two stats, one of which may have been reported by an earlier run. For example,
if you first use report_result to report (number of trimmed reads), an... | python | def get_stat(self, key):
"""
Returns a stat that was previously reported. This is necessary for reporting new stats that are
derived from two stats, one of which may have been reported by an earlier run. For example,
if you first use report_result to report (number of trimmed reads), an... | Returns a stat that was previously reported. This is necessary for reporting new stats that are
derived from two stats, one of which may have been reported by an earlier run. For example,
if you first use report_result to report (number of trimmed reads), and then in a later stage
want to repor... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1392-L1412 |
databio/pypiper | pypiper/manager.py | PipelineManager._checkpoint | def _checkpoint(self, stage):
"""
Decide whether to stop processing of a pipeline. This is the hook
A pipeline can report various "checkpoints" as sort of status markers
that designate the logical processing phase that's just been completed.
The initiation of a pipeline can preo... | python | def _checkpoint(self, stage):
"""
Decide whether to stop processing of a pipeline. This is the hook
A pipeline can report various "checkpoints" as sort of status markers
that designate the logical processing phase that's just been completed.
The initiation of a pipeline can preo... | Decide whether to stop processing of a pipeline. This is the hook
A pipeline can report various "checkpoints" as sort of status markers
that designate the logical processing phase that's just been completed.
The initiation of a pipeline can preordain one of those as a "stopping
point" t... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1421-L1476 |
databio/pypiper | pypiper/manager.py | PipelineManager._touch_checkpoint | def _touch_checkpoint(self, check_file):
"""
Alternative way for a pipeline to designate a checkpoint.
:param str check_file: Name or path of file to use as checkpoint.
:return bool: Whether a file was written (equivalent to whether the
checkpoint file already existed).
... | python | def _touch_checkpoint(self, check_file):
"""
Alternative way for a pipeline to designate a checkpoint.
:param str check_file: Name or path of file to use as checkpoint.
:return bool: Whether a file was written (equivalent to whether the
checkpoint file already existed).
... | Alternative way for a pipeline to designate a checkpoint.
:param str check_file: Name or path of file to use as checkpoint.
:return bool: Whether a file was written (equivalent to whether the
checkpoint file already existed).
:raise ValueError: Raise a ValueError if the argument pro... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1479-L1512 |
databio/pypiper | pypiper/manager.py | PipelineManager.fail_pipeline | def fail_pipeline(self, e, dynamic_recover=False):
"""
If the pipeline does not complete, this function will stop the pipeline gracefully.
It sets the status flag to failed and skips the normal success completion procedure.
:param Exception e: Exception to raise.
:param bool dyn... | python | def fail_pipeline(self, e, dynamic_recover=False):
"""
If the pipeline does not complete, this function will stop the pipeline gracefully.
It sets the status flag to failed and skips the normal success completion procedure.
:param Exception e: Exception to raise.
:param bool dyn... | If the pipeline does not complete, this function will stop the pipeline gracefully.
It sets the status flag to failed and skips the normal success completion procedure.
:param Exception e: Exception to raise.
:param bool dynamic_recover: Whether to recover e.g. for job termination. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1520-L1556 |
databio/pypiper | pypiper/manager.py | PipelineManager.halt | def halt(self, checkpoint=None, finished=False, raise_error=True):
"""
Stop the pipeline before completion point.
:param str checkpoint: Name of stage just reached or just completed.
:param bool finished: Whether the indicated stage was just finished
(True), or just reached ... | python | def halt(self, checkpoint=None, finished=False, raise_error=True):
"""
Stop the pipeline before completion point.
:param str checkpoint: Name of stage just reached or just completed.
:param bool finished: Whether the indicated stage was just finished
(True), or just reached ... | Stop the pipeline before completion point.
:param str checkpoint: Name of stage just reached or just completed.
:param bool finished: Whether the indicated stage was just finished
(True), or just reached (False)
:param bool raise_error: Whether to raise an exception to truly
... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1559-L1572 |
databio/pypiper | pypiper/manager.py | PipelineManager.stop_pipeline | def stop_pipeline(self, status=COMPLETE_FLAG):
"""
Terminate the pipeline.
This is the "healthy" pipeline completion function.
The normal pipeline completion function, to be run by the pipeline
at the end of the script. It sets status flag to completed and records
some ... | python | def stop_pipeline(self, status=COMPLETE_FLAG):
"""
Terminate the pipeline.
This is the "healthy" pipeline completion function.
The normal pipeline completion function, to be run by the pipeline
at the end of the script. It sets status flag to completed and records
some ... | Terminate the pipeline.
This is the "healthy" pipeline completion function.
The normal pipeline completion function, to be run by the pipeline
at the end of the script. It sets status flag to completed and records
some time and memory statistics to the log file. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1575-L1594 |
databio/pypiper | pypiper/manager.py | PipelineManager._generic_signal_handler | def _generic_signal_handler(self, signal_type):
"""
Function for handling both SIGTERM and SIGINT
"""
print("</pre>")
message = "Got " + signal_type + ". Failing gracefully..."
self.timestamp(message)
self.fail_pipeline(KeyboardInterrupt(signal_type), dynamic_reco... | python | def _generic_signal_handler(self, signal_type):
"""
Function for handling both SIGTERM and SIGINT
"""
print("</pre>")
message = "Got " + signal_type + ". Failing gracefully..."
self.timestamp(message)
self.fail_pipeline(KeyboardInterrupt(signal_type), dynamic_reco... | Function for handling both SIGTERM and SIGINT | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1609-L1617 |
databio/pypiper | pypiper/manager.py | PipelineManager._exit_handler | def _exit_handler(self):
"""
This function I register with atexit to run whenever the script is completing.
A catch-all for uncaught exceptions, setting status flag file to failed.
"""
# TODO: consider handling sys.stderr/sys.stdout exceptions related to
# TODO (cont.): ... | python | def _exit_handler(self):
"""
This function I register with atexit to run whenever the script is completing.
A catch-all for uncaught exceptions, setting status flag file to failed.
"""
# TODO: consider handling sys.stderr/sys.stdout exceptions related to
# TODO (cont.): ... | This function I register with atexit to run whenever the script is completing.
A catch-all for uncaught exceptions, setting status flag file to failed. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1638-L1664 |
databio/pypiper | pypiper/manager.py | PipelineManager._kill_child_process | def _kill_child_process(self, child_pid, proc_name=None):
"""
Pypiper spawns subprocesses. We need to kill them to exit gracefully,
in the event of a pipeline termination or interrupt signal.
By default, child processes are not automatically killed when python
terminates, so Pypi... | python | def _kill_child_process(self, child_pid, proc_name=None):
"""
Pypiper spawns subprocesses. We need to kill them to exit gracefully,
in the event of a pipeline termination or interrupt signal.
By default, child processes are not automatically killed when python
terminates, so Pypi... | Pypiper spawns subprocesses. We need to kill them to exit gracefully,
in the event of a pipeline termination or interrupt signal.
By default, child processes are not automatically killed when python
terminates, so Pypiper must clean these up manually.
Given a process ID, this function ju... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1681-L1751 |
databio/pypiper | pypiper/manager.py | PipelineManager.clean_add | def clean_add(self, regex, conditional=False, manual=False):
"""
Add files (or regexs) to a cleanup list, to delete when this pipeline completes successfully.
When making a call with run that produces intermediate files that should be
deleted after the pipeline completes, you flag these ... | python | def clean_add(self, regex, conditional=False, manual=False):
"""
Add files (or regexs) to a cleanup list, to delete when this pipeline completes successfully.
When making a call with run that produces intermediate files that should be
deleted after the pipeline completes, you flag these ... | Add files (or regexs) to a cleanup list, to delete when this pipeline completes successfully.
When making a call with run that produces intermediate files that should be
deleted after the pipeline completes, you flag these files for deletion with this command.
Files added with clean_add will onl... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1780-L1829 |
databio/pypiper | pypiper/manager.py | PipelineManager._cleanup | def _cleanup(self, dry_run=False):
"""
Cleans up (removes) intermediate files.
You can register intermediate files, which will be deleted automatically
when the pipeline completes. This function deletes them,
either absolutely or conditionally. It is run automatically when the
... | python | def _cleanup(self, dry_run=False):
"""
Cleans up (removes) intermediate files.
You can register intermediate files, which will be deleted automatically
when the pipeline completes. This function deletes them,
either absolutely or conditionally. It is run automatically when the
... | Cleans up (removes) intermediate files.
You can register intermediate files, which will be deleted automatically
when the pipeline completes. This function deletes them,
either absolutely or conditionally. It is run automatically when the
pipeline succeeds, so you shouldn't need to call... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1832-L1912 |
databio/pypiper | pypiper/manager.py | PipelineManager._memory_usage | def _memory_usage(self, pid='self', category="hwm", container=None):
"""
Memory usage of the process in kilobytes.
:param str pid: Process ID of process to check
:param str category: Memory type to check. 'hwm' for high water mark.
"""
if container:
# TODO: P... | python | def _memory_usage(self, pid='self', category="hwm", container=None):
"""
Memory usage of the process in kilobytes.
:param str pid: Process ID of process to check
:param str category: Memory type to check. 'hwm' for high water mark.
"""
if container:
# TODO: P... | Memory usage of the process in kilobytes.
:param str pid: Process ID of process to check
:param str category: Memory type to check. 'hwm' for high water mark. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1914-L1965 |
databio/pypiper | pypiper/manager.py | PipelineManager._triage_error | def _triage_error(self, e, nofail):
""" Print a message and decide what to do about an error. """
if not nofail:
self.fail_pipeline(e)
elif self._failed:
print("This is a nofail process, but the pipeline was terminated for other reasons, so we fail.")
raise e... | python | def _triage_error(self, e, nofail):
""" Print a message and decide what to do about an error. """
if not nofail:
self.fail_pipeline(e)
elif self._failed:
print("This is a nofail process, but the pipeline was terminated for other reasons, so we fail.")
raise e... | Print a message and decide what to do about an error. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/manager.py#L1967-L1976 |
databio/pypiper | setup.py | read_reqs_file | def read_reqs_file(reqs_name):
""" Read requirements file for given requirements group. """
path_reqs_file = os.path.join(
"requirements", "reqs-{}.txt".format(reqs_name))
with open(path_reqs_file, 'r') as reqs_file:
return [pkg.rstrip() for pkg in reqs_file.readlines()
i... | python | def read_reqs_file(reqs_name):
""" Read requirements file for given requirements group. """
path_reqs_file = os.path.join(
"requirements", "reqs-{}.txt".format(reqs_name))
with open(path_reqs_file, 'r') as reqs_file:
return [pkg.rstrip() for pkg in reqs_file.readlines()
i... | Read requirements file for given requirements group. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/setup.py#L20-L26 |
databio/pypiper | pypiper/pipeline.py | _is_unordered | def _is_unordered(collection):
"""
Determine whether a collection appears to be unordered.
This is a conservative implementation, allowing for the possibility that
someone's implemented Mapping or Set, for example, and provided an
__iter__ implementation that defines a consistent ordering of the
... | python | def _is_unordered(collection):
"""
Determine whether a collection appears to be unordered.
This is a conservative implementation, allowing for the possibility that
someone's implemented Mapping or Set, for example, and provided an
__iter__ implementation that defines a consistent ordering of the
... | Determine whether a collection appears to be unordered.
This is a conservative implementation, allowing for the possibility that
someone's implemented Mapping or Set, for example, and provided an
__iter__ implementation that defines a consistent ordering of the
collection's elements.
:param object... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L382-L401 |
databio/pypiper | pypiper/pipeline.py | _parse_stage_spec | def _parse_stage_spec(stage_spec):
"""
Handle alternate Stage specifications, returning name and Stage.
Isolate this parsing logic from any iteration. TypeError as single
exception type funnel also provides a more uniform way for callers to
handle specification errors (e.g., skip a stage, warn, re-... | python | def _parse_stage_spec(stage_spec):
"""
Handle alternate Stage specifications, returning name and Stage.
Isolate this parsing logic from any iteration. TypeError as single
exception type funnel also provides a more uniform way for callers to
handle specification errors (e.g., skip a stage, warn, re-... | Handle alternate Stage specifications, returning name and Stage.
Isolate this parsing logic from any iteration. TypeError as single
exception type funnel also provides a more uniform way for callers to
handle specification errors (e.g., skip a stage, warn, re-raise, etc.)
:param (str, pypiper.Stage) |... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L405-L452 |
databio/pypiper | pypiper/pipeline.py | Pipeline.checkpoint | def checkpoint(self, stage, msg=""):
"""
Touch checkpoint file for given stage and provide timestamp message.
:param pypiper.Stage stage: Stage for which to mark checkpoint
:param str msg: Message to embed in timestamp.
:return bool: Whether a checkpoint file was written.
... | python | def checkpoint(self, stage, msg=""):
"""
Touch checkpoint file for given stage and provide timestamp message.
:param pypiper.Stage stage: Stage for which to mark checkpoint
:param str msg: Message to embed in timestamp.
:return bool: Whether a checkpoint file was written.
... | Touch checkpoint file for given stage and provide timestamp message.
:param pypiper.Stage stage: Stage for which to mark checkpoint
:param str msg: Message to embed in timestamp.
:return bool: Whether a checkpoint file was written. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L181-L195 |
databio/pypiper | pypiper/pipeline.py | Pipeline.completed_stage | def completed_stage(self, stage):
"""
Determine whether the pipeline's completed the stage indicated.
:param pypiper.Stage stage: Stage to check for completion status.
:return bool: Whether this pipeline's completed the indicated stage.
:raises UnknownStageException: If the stag... | python | def completed_stage(self, stage):
"""
Determine whether the pipeline's completed the stage indicated.
:param pypiper.Stage stage: Stage to check for completion status.
:return bool: Whether this pipeline's completed the indicated stage.
:raises UnknownStageException: If the stag... | Determine whether the pipeline's completed the stage indicated.
:param pypiper.Stage stage: Stage to check for completion status.
:return bool: Whether this pipeline's completed the indicated stage.
:raises UnknownStageException: If the stage name given is undefined
for the pipeline... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L198-L208 |
databio/pypiper | pypiper/pipeline.py | Pipeline.list_flags | def list_flags(self, only_name=False):
"""
Determine the flag files associated with this pipeline.
:param bool only_name: Whether to return only flag file name(s) (True),
or full flag file paths (False); default False (paths)
:return list[str]: flag files associated with thi... | python | def list_flags(self, only_name=False):
"""
Determine the flag files associated with this pipeline.
:param bool only_name: Whether to return only flag file name(s) (True),
or full flag file paths (False); default False (paths)
:return list[str]: flag files associated with thi... | Determine the flag files associated with this pipeline.
:param bool only_name: Whether to return only flag file name(s) (True),
or full flag file paths (False); default False (paths)
:return list[str]: flag files associated with this pipeline. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L216-L228 |
databio/pypiper | pypiper/pipeline.py | Pipeline.run | def run(self, start_point=None, stop_before=None, stop_after=None):
"""
Run the pipeline, optionally specifying start and/or stop points.
:param str start_point: Name of stage at which to begin execution.
:param str stop_before: Name of stage at which to cease execution;
exc... | python | def run(self, start_point=None, stop_before=None, stop_after=None):
"""
Run the pipeline, optionally specifying start and/or stop points.
:param str start_point: Name of stage at which to begin execution.
:param str stop_before: Name of stage at which to cease execution;
exc... | Run the pipeline, optionally specifying start and/or stop points.
:param str start_point: Name of stage at which to begin execution.
:param str stop_before: Name of stage at which to cease execution;
exclusive, i.e. this stage is not run
:param str stop_after: Name of stage at which... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L231-L334 |
databio/pypiper | pypiper/pipeline.py | Pipeline._start_index | def _start_index(self, start=None):
""" Seek to the first stage to run. """
if start is None:
return 0
start_stage = translate_stage_name(start)
internal_names = [translate_stage_name(s.name) for s in self._stages]
try:
return internal_names.index(start_st... | python | def _start_index(self, start=None):
""" Seek to the first stage to run. """
if start is None:
return 0
start_stage = translate_stage_name(start)
internal_names = [translate_stage_name(s.name) for s in self._stages]
try:
return internal_names.index(start_st... | Seek to the first stage to run. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L344-L353 |
databio/pypiper | pypiper/pipeline.py | Pipeline._stop_index | def _stop_index(self, stop_point, inclusive):
"""
Determine index of stage of stopping point for run().
:param str | pypiper.Stage | function stop_point: Stopping point itself
or name of it.
:param bool inclusive: Whether the stopping point is to be regarded as
i... | python | def _stop_index(self, stop_point, inclusive):
"""
Determine index of stage of stopping point for run().
:param str | pypiper.Stage | function stop_point: Stopping point itself
or name of it.
:param bool inclusive: Whether the stopping point is to be regarded as
i... | Determine index of stage of stopping point for run().
:param str | pypiper.Stage | function stop_point: Stopping point itself
or name of it.
:param bool inclusive: Whether the stopping point is to be regarded as
inclusive (i.e., whether it's the final stage to run, or the one
... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L355-L378 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/font.py | to_ufo_font_attributes | def to_ufo_font_attributes(self, family_name):
"""Generate a list of UFOs with metadata loaded from .glyphs data.
Modifies the list of UFOs in the UFOBuilder (self) in-place.
"""
font = self.font
# "date" can be missing; Glyphs.app removes it on saving if it's empty:
# https://github.com/goog... | python | def to_ufo_font_attributes(self, family_name):
"""Generate a list of UFOs with metadata loaded from .glyphs data.
Modifies the list of UFOs in the UFOBuilder (self) in-place.
"""
font = self.font
# "date" can be missing; Glyphs.app removes it on saving if it's empty:
# https://github.com/goog... | Generate a list of UFOs with metadata loaded from .glyphs data.
Modifies the list of UFOs in the UFOBuilder (self) in-place. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/font.py#L29-L90 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/font.py | to_glyphs_font_attributes | def to_glyphs_font_attributes(self, source, master, is_initial):
"""
Copy font attributes from `ufo` either to `self.font` or to `master`.
Arguments:
self -- The UFOBuilder
ufo -- The current UFO being read
master -- The current master being written
is_initial -- True iff this the first UFO... | python | def to_glyphs_font_attributes(self, source, master, is_initial):
"""
Copy font attributes from `ufo` either to `self.font` or to `master`.
Arguments:
self -- The UFOBuilder
ufo -- The current UFO being read
master -- The current master being written
is_initial -- True iff this the first UFO... | Copy font attributes from `ufo` either to `self.font` or to `master`.
Arguments:
self -- The UFOBuilder
ufo -- The current UFO being read
master -- The current master being written
is_initial -- True iff this the first UFO that we process | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/font.py#L93-L106 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/glyph.py | to_ufo_glyph | def to_ufo_glyph(self, ufo_glyph, layer, glyph):
"""Add .glyphs metadata, paths, components, and anchors to a glyph."""
ufo_glyph.unicodes = [int(uval, 16) for uval in glyph.unicodes]
note = glyph.note
if note is not None:
ufo_glyph.note = note
last_change = glyph.lastChange
if last_ch... | python | def to_ufo_glyph(self, ufo_glyph, layer, glyph):
"""Add .glyphs metadata, paths, components, and anchors to a glyph."""
ufo_glyph.unicodes = [int(uval, 16) for uval in glyph.unicodes]
note = glyph.note
if note is not None:
ufo_glyph.note = note
last_change = glyph.lastChange
if last_ch... | Add .glyphs metadata, paths, components, and anchors to a glyph. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/glyph.py#L32-L129 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/glyph.py | to_glyphs_glyph | def to_glyphs_glyph(self, ufo_glyph, ufo_layer, master):
"""Add UFO glif metadata, paths, components, and anchors to a GSGlyph.
If the matching GSGlyph does not exist, then it is created,
else it is updated with the new data.
In all cases, a matching GSLayer is created in the GSGlyph to hold paths.
... | python | def to_glyphs_glyph(self, ufo_glyph, ufo_layer, master):
"""Add UFO glif metadata, paths, components, and anchors to a GSGlyph.
If the matching GSGlyph does not exist, then it is created,
else it is updated with the new data.
In all cases, a matching GSLayer is created in the GSGlyph to hold paths.
... | Add UFO glif metadata, paths, components, and anchors to a GSGlyph.
If the matching GSGlyph does not exist, then it is created,
else it is updated with the new data.
In all cases, a matching GSLayer is created in the GSGlyph to hold paths. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/glyph.py#L132-L241 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/glyph.py | to_ufo_glyph_background | def to_ufo_glyph_background(self, glyph, layer):
"""Set glyph background."""
if not layer.hasBackground:
return
background = layer.background
ufo_layer = self.to_ufo_background_layer(glyph)
new_glyph = ufo_layer.newGlyph(glyph.name)
width = background.userData[BACKGROUND_WIDTH_KEY]
... | python | def to_ufo_glyph_background(self, glyph, layer):
"""Set glyph background."""
if not layer.hasBackground:
return
background = layer.background
ufo_layer = self.to_ufo_background_layer(glyph)
new_glyph = ufo_layer.newGlyph(glyph.name)
width = background.userData[BACKGROUND_WIDTH_KEY]
... | Set glyph background. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/glyph.py#L244-L262 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/instances.py | to_designspace_instances | def to_designspace_instances(self):
"""Write instance data from self.font to self.designspace."""
for instance in self.font.instances:
if self.minimize_glyphs_diffs or (
is_instance_active(instance)
and _is_instance_included_in_family(self, instance)
):
_to_de... | python | def to_designspace_instances(self):
"""Write instance data from self.font to self.designspace."""
for instance in self.font.instances:
if self.minimize_glyphs_diffs or (
is_instance_active(instance)
and _is_instance_included_in_family(self, instance)
):
_to_de... | Write instance data from self.font to self.designspace. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/instances.py#L49-L56 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/instances.py | apply_instance_data | def apply_instance_data(designspace, include_filenames=None, Font=defcon.Font):
"""Open UFO instances referenced by designspace, apply Glyphs instance
data if present, re-save UFOs and return updated UFO Font objects.
Args:
designspace: DesignSpaceDocument object or path (str or PathLike) to
... | python | def apply_instance_data(designspace, include_filenames=None, Font=defcon.Font):
"""Open UFO instances referenced by designspace, apply Glyphs instance
data if present, re-save UFOs and return updated UFO Font objects.
Args:
designspace: DesignSpaceDocument object or path (str or PathLike) to
... | Open UFO instances referenced by designspace, apply Glyphs instance
data if present, re-save UFOs and return updated UFO Font objects.
Args:
designspace: DesignSpaceDocument object or path (str or PathLike) to
a designspace file.
include_filenames: optional set of instance filenames... | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/instances.py#L334-L384 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/features.py | _to_ufo_features | def _to_ufo_features(self, master, ufo):
"""Write an UFO's OpenType feature file."""
# Recover the original feature code if it was stored in the user data
original = master.userData[ORIGINAL_FEATURE_CODE_KEY]
if original is not None:
ufo.features.text = original
return
prefixes = [... | python | def _to_ufo_features(self, master, ufo):
"""Write an UFO's OpenType feature file."""
# Recover the original feature code if it was stored in the user data
original = master.userData[ORIGINAL_FEATURE_CODE_KEY]
if original is not None:
ufo.features.text = original
return
prefixes = [... | Write an UFO's OpenType feature file. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/features.py#L42-L107 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/features.py | _build_gdef | def _build_gdef(ufo, skipExportGlyphs=None):
"""Build a GDEF table statement (GlyphClassDef and LigatureCaretByPos).
Building GlyphClassDef requires anchor propagation or user care to work as
expected, as Glyphs.app also looks at anchors for classification:
* Base: any glyph that has an attaching anch... | python | def _build_gdef(ufo, skipExportGlyphs=None):
"""Build a GDEF table statement (GlyphClassDef and LigatureCaretByPos).
Building GlyphClassDef requires anchor propagation or user care to work as
expected, as Glyphs.app also looks at anchors for classification:
* Base: any glyph that has an attaching anch... | Build a GDEF table statement (GlyphClassDef and LigatureCaretByPos).
Building GlyphClassDef requires anchor propagation or user care to work as
expected, as Glyphs.app also looks at anchors for classification:
* Base: any glyph that has an attaching anchor (such as "top"; "_top" does
not count) and ... | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/features.py#L110-L188 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/features.py | FeatureFileProcessor._pop_comment | def _pop_comment(self, statements, comment_re):
"""Look for the comment that matches the given regex.
If it matches, return the regex match object and list of statements
without the special one.
"""
res = []
match = None
for st in statements:
if match ... | python | def _pop_comment(self, statements, comment_re):
"""Look for the comment that matches the given regex.
If it matches, return the regex match object and list of statements
without the special one.
"""
res = []
match = None
for st in statements:
if match ... | Look for the comment that matches the given regex.
If it matches, return the regex match object and list of statements
without the special one. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/features.py#L566-L580 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/features.py | FeatureFileProcessor._pop_comment_block | def _pop_comment_block(self, statements, header_re):
"""Look for a series of comments that start with one that matches the
regex. If the first comment is found, all subsequent comments are
popped from statements, concatenated and dedented and returned.
"""
res = []
commen... | python | def _pop_comment_block(self, statements, header_re):
"""Look for a series of comments that start with one that matches the
regex. If the first comment is found, all subsequent comments are
popped from statements, concatenated and dedented and returned.
"""
res = []
commen... | Look for a series of comments that start with one that matches the
regex. If the first comment is found, all subsequent comments are
popped from statements, concatenated and dedented and returned. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/features.py#L582-L613 |
4Catalyzer/flask-resty | flask_resty/spec/declaration.py | ApiViewDeclaration.get_marshmallow_schema_name | def get_marshmallow_schema_name(self, plugin, schema):
"""Get the schema name.
If the schema doesn't exist, create it.
"""
try:
return plugin.openapi.refs[schema]
except KeyError:
plugin.spec.definition(schema.__name__, schema=schema)
return s... | python | def get_marshmallow_schema_name(self, plugin, schema):
"""Get the schema name.
If the schema doesn't exist, create it.
"""
try:
return plugin.openapi.refs[schema]
except KeyError:
plugin.spec.definition(schema.__name__, schema=schema)
return s... | Get the schema name.
If the schema doesn't exist, create it. | https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/declaration.py#L85-L94 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/components.py | to_ufo_components | def to_ufo_components(self, ufo_glyph, layer):
"""Draw .glyphs components onto a pen, adding them to the parent glyph."""
pen = ufo_glyph.getPointPen()
for index, component in enumerate(layer.components):
pen.addComponent(component.name, component.transform)
if component.anchor:
... | python | def to_ufo_components(self, ufo_glyph, layer):
"""Draw .glyphs components onto a pen, adding them to the parent glyph."""
pen = ufo_glyph.getPointPen()
for index, component in enumerate(layer.components):
pen.addComponent(component.name, component.transform)
if component.anchor:
... | Draw .glyphs components onto a pen, adding them to the parent glyph. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/components.py#L26-L45 |
4Catalyzer/flask-resty | flask_resty/view.py | ApiView.request_args | def request_args(self):
"""Use args_schema to parse request query arguments."""
args = flask.request.args
data_raw = {}
for field_name, field in self.args_schema.fields.items():
alternate_field_name = field.load_from if MA2 else field.data_key
if alternate_field... | python | def request_args(self):
"""Use args_schema to parse request query arguments."""
args = flask.request.args
data_raw = {}
for field_name, field in self.args_schema.fields.items():
alternate_field_name = field.load_from if MA2 else field.data_key
if alternate_field... | Use args_schema to parse request query arguments. | https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/view.py#L167-L188 |
4Catalyzer/flask-resty | flask_resty/view.py | ModelView.query | def query(self):
"""The SQLAlchemy query for the view.
Override this to customize the query to fetch items in this view.
By default, this applies the filter from the view's `authorization` and
the query options from `base_query_options` and `query_options`.
"""
query = ... | python | def query(self):
"""The SQLAlchemy query for the view.
Override this to customize the query to fetch items in this view.
By default, this applies the filter from the view's `authorization` and
the query options from `base_query_options` and `query_options`.
"""
query = ... | The SQLAlchemy query for the view.
Override this to customize the query to fetch items in this view.
By default, this applies the filter from the view's `authorization` and
the query options from `base_query_options` and `query_options`. | https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/view.py#L245-L259 |
4Catalyzer/flask-resty | flask_resty/view.py | ModelView.query_options | def query_options(self):
"""Options to apply to the query for the view.
Set this to configure relationship and column loading.
By default, this calls the ``get_query_options`` method on the
serializer with a `Load` object bound to the model, if that serializer
method exists.
... | python | def query_options(self):
"""Options to apply to the query for the view.
Set this to configure relationship and column loading.
By default, this calls the ``get_query_options`` method on the
serializer with a `Load` object bound to the model, if that serializer
method exists.
... | Options to apply to the query for the view.
Set this to configure relationship and column loading.
By default, this calls the ``get_query_options`` method on the
serializer with a `Load` object bound to the model, if that serializer
method exists. | https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/view.py#L273-L285 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/paths.py | to_ufo_paths | def to_ufo_paths(self, ufo_glyph, layer):
"""Draw .glyphs paths onto a pen."""
pen = ufo_glyph.getPointPen()
for path in layer.paths:
# the list is changed below, otherwise you can't draw more than once
# per session.
nodes = list(path.nodes)
for node in nodes:
s... | python | def to_ufo_paths(self, ufo_glyph, layer):
"""Draw .glyphs paths onto a pen."""
pen = ufo_glyph.getPointPen()
for path in layer.paths:
# the list is changed below, otherwise you can't draw more than once
# per session.
nodes = list(path.nodes)
for node in nodes:
s... | Draw .glyphs paths onto a pen. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/paths.py#L21-L49 |
4Catalyzer/flask-resty | flask_resty/decorators.py | request_cached_property | def request_cached_property(func):
"""Make the given method a per-request cached property.
This caches the value on the request context rather than on the object
itself, preventing problems if the object gets reused across multiple
requests.
"""
@property
@functools.wraps(func)
def wrap... | python | def request_cached_property(func):
"""Make the given method a per-request cached property.
This caches the value on the request context rather than on the object
itself, preventing problems if the object gets reused across multiple
requests.
"""
@property
@functools.wraps(func)
def wrap... | Make the given method a per-request cached property.
This caches the value on the request context rather than on the object
itself, preventing problems if the object gets reused across multiple
requests. | https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/decorators.py#L31-L50 |
googlefonts/glyphsLib | Lib/glyphsLib/builder/groups.py | _ufo_logging_ref | def _ufo_logging_ref(ufo):
"""Return a string that can identify this UFO in logs."""
if ufo.path:
return os.path.basename(ufo.path)
return ufo.info.styleName | python | def _ufo_logging_ref(ufo):
"""Return a string that can identify this UFO in logs."""
if ufo.path:
return os.path.basename(ufo.path)
return ufo.info.styleName | Return a string that can identify this UFO in logs. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/groups.py#L180-L184 |
googlefonts/glyphsLib | Lib/glyphsLib/types.py | parse_datetime | def parse_datetime(src=None):
"""Parse a datetime object from a string."""
if src is None:
return None
string = src.replace('"', "")
# parse timezone ourselves, since %z is not always supported
# see: http://bugs.python.org/issue6641
m = UTC_OFFSET_RE.match(string)
if m:
sign... | python | def parse_datetime(src=None):
"""Parse a datetime object from a string."""
if src is None:
return None
string = src.replace('"', "")
# parse timezone ourselves, since %z is not always supported
# see: http://bugs.python.org/issue6641
m = UTC_OFFSET_RE.match(string)
if m:
sign... | Parse a datetime object from a string. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/types.py#L267-L288 |
googlefonts/glyphsLib | Lib/glyphsLib/types.py | parse_color | def parse_color(src=None):
# type: (Optional[str]) -> Optional[Union[Tuple[int, ...], int]]
"""Parse a string representing a color value.
Color is either a fixed color (when coloring something from the UI, see
the GLYPHS_COLORS constant) or a list of the format [u8, u8, u8, u8],
Glyphs does not su... | python | def parse_color(src=None):
# type: (Optional[str]) -> Optional[Union[Tuple[int, ...], int]]
"""Parse a string representing a color value.
Color is either a fixed color (when coloring something from the UI, see
the GLYPHS_COLORS constant) or a list of the format [u8, u8, u8, u8],
Glyphs does not su... | Parse a string representing a color value.
Color is either a fixed color (when coloring something from the UI, see
the GLYPHS_COLORS constant) or a list of the format [u8, u8, u8, u8],
Glyphs does not support an alpha channel as of 2.5.1 (confirmed by Georg
Seifert), and always writes a 1 to it. This ... | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/types.py#L305-L334 |
googlefonts/glyphsLib | Lib/glyphsLib/writer.py | dump | def dump(obj, fp):
"""Write a GSFont object to a .glyphs file.
'fp' should be a (writable) file object.
"""
writer = Writer(fp)
logger.info("Writing .glyphs file")
writer.write(obj) | python | def dump(obj, fp):
"""Write a GSFont object to a .glyphs file.
'fp' should be a (writable) file object.
"""
writer = Writer(fp)
logger.info("Writing .glyphs file")
writer.write(obj) | Write a GSFont object to a .glyphs file.
'fp' should be a (writable) file object. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/writer.py#L156-L162 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | loads | def loads(s):
"""Read a .glyphs file from a (unicode) str object, or from
a UTF-8 encoded bytes object.
Return a GSFont object.
"""
p = Parser(current_type=glyphsLib.classes.GSFont)
logger.info("Parsing .glyphs file")
data = p.parse(s)
return data | python | def loads(s):
"""Read a .glyphs file from a (unicode) str object, or from
a UTF-8 encoded bytes object.
Return a GSFont object.
"""
p = Parser(current_type=glyphsLib.classes.GSFont)
logger.info("Parsing .glyphs file")
data = p.parse(s)
return data | Read a .glyphs file from a (unicode) str object, or from
a UTF-8 encoded bytes object.
Return a GSFont object. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L246-L254 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | main | def main(args=None):
"""Roundtrip the .glyphs file given as an argument."""
for arg in args:
glyphsLib.dump(load(open(arg, "r", encoding="utf-8")), sys.stdout) | python | def main(args=None):
"""Roundtrip the .glyphs file given as an argument."""
for arg in args:
glyphsLib.dump(load(open(arg, "r", encoding="utf-8")), sys.stdout) | Roundtrip the .glyphs file given as an argument. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L257-L260 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | Parser.parse | def parse(self, text):
"""Do the parsing."""
text = tounicode(text, encoding="utf-8")
result, i = self._parse(text, 0)
if text[i:].strip():
self._fail("Unexpected trailing content", text, i)
return result | python | def parse(self, text):
"""Do the parsing."""
text = tounicode(text, encoding="utf-8")
result, i = self._parse(text, 0)
if text[i:].strip():
self._fail("Unexpected trailing content", text, i)
return result | Do the parsing. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L48-L55 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | Parser.parse_into_object | def parse_into_object(self, res, text):
"""Parse data into an existing GSFont instance."""
text = tounicode(text, encoding="utf-8")
m = self.start_dict_re.match(text, 0)
if m:
i = self._parse_dict_into_object(res, text, 1)
else:
self._fail("not correct f... | python | def parse_into_object(self, res, text):
"""Parse data into an existing GSFont instance."""
text = tounicode(text, encoding="utf-8")
m = self.start_dict_re.match(text, 0)
if m:
i = self._parse_dict_into_object(res, text, 1)
else:
self._fail("not correct f... | Parse data into an existing GSFont instance. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L57-L69 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | Parser._parse | def _parse(self, text, i):
"""Recursive function to parse a single dictionary, list, or value."""
m = self.start_dict_re.match(text, i)
if m:
parsed = m.group(0)
i += len(parsed)
return self._parse_dict(text, i)
m = self.start_list_re.match(text, i)
... | python | def _parse(self, text, i):
"""Recursive function to parse a single dictionary, list, or value."""
m = self.start_dict_re.match(text, i)
if m:
parsed = m.group(0)
i += len(parsed)
return self._parse_dict(text, i)
m = self.start_list_re.match(text, i)
... | Recursive function to parse a single dictionary, list, or value. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L91-L139 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | Parser._parse_dict | def _parse_dict(self, text, i):
"""Parse a dictionary from source text starting at i."""
old_current_type = self.current_type
new_type = self.current_type
if new_type is None:
# customparameter.value needs to be set from the found value
new_type = dict
eli... | python | def _parse_dict(self, text, i):
"""Parse a dictionary from source text starting at i."""
old_current_type = self.current_type
new_type = self.current_type
if new_type is None:
# customparameter.value needs to be set from the found value
new_type = dict
eli... | Parse a dictionary from source text starting at i. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L141-L153 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | Parser._parse_list | def _parse_list(self, text, i):
"""Parse a list from source text starting at i."""
res = []
end_match = self.end_list_re.match(text, i)
old_current_type = self.current_type
while not end_match:
list_item, i = self._parse(text, i)
res.append(list_item)
... | python | def _parse_list(self, text, i):
"""Parse a list from source text starting at i."""
res = []
end_match = self.end_list_re.match(text, i)
old_current_type = self.current_type
while not end_match:
list_item, i = self._parse(text, i)
res.append(list_item)
... | Parse a list from source text starting at i. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L187-L209 |
googlefonts/glyphsLib | Lib/glyphsLib/parser.py | Parser._trim_value | def _trim_value(self, value):
"""Trim double quotes off the ends of a value, un-escaping inner
double quotes and literal backslashes. Also convert escapes to unicode.
If the string is not quoted, return it unmodified.
"""
if value[0] == '"':
assert value[-1] == '"'
... | python | def _trim_value(self, value):
"""Trim double quotes off the ends of a value, un-escaping inner
double quotes and literal backslashes. Also convert escapes to unicode.
If the string is not quoted, return it unmodified.
"""
if value[0] == '"':
assert value[-1] == '"'
... | Trim double quotes off the ends of a value, un-escaping inner
double quotes and literal backslashes. Also convert escapes to unicode.
If the string is not quoted, return it unmodified. | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L221-L231 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.