_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q28300
TagDirReportMixin.parse_tagLength_dist
train
def parse_tagLength_dist(self): """parses and plots tag length distribution files""" # Find and parse homer tag length distribution reports for f in self.find_log_files('homer/LengthDistribution', filehandles=True): s_name = os.path.basename(f['root']) s_name = self.clean...
python
{ "resource": "" }
q28301
TagDirReportMixin.homer_stats_table_tagInfo
train
def homer_stats_table_tagInfo(self): """ Add core HOMER stats to the general stats table from tagInfo file""" if len(self.tagdir_data['header']) == 0: return None headers = OrderedDict() headers['UniqPositions'] = { 'title': 'Uniq Pos', 'description'...
python
{ "resource": "" }
q28302
TagDirReportMixin.homer_stats_table_interChr
train
def homer_stats_table_interChr(self): """ Add core HOMER stats to the general stats table from FrequencyDistribution file""" headers = OrderedDict() headers['InterChr'] = { 'title': 'InterChr', 'description': 'Fraction of Reads forming inter chromosomal interactions',
python
{ "resource": "" }
q28303
TagDirReportMixin.parse_restriction_dist
train
def parse_restriction_dist(self, f): """ Parse HOMER tagdirectory petagRestrictionDistribution file. """ parsed_data = dict() firstline = True for l in f['f']: if firstline: #skip first line firstline = False continue s = l.split...
python
{ "resource": "" }
q28304
TagDirReportMixin.parse_length_dist
train
def parse_length_dist(self, f): """ Parse HOMER tagdirectory tagLengthDistribution file. """ parsed_data = dict() firstline = True for l in f['f']: if firstline: #skip first line firstline = False continue s = l.split("\t") ...
python
{ "resource": "" }
q28305
TagDirReportMixin.parse_tag_info
train
def parse_tag_info(self, f): """ Parse HOMER tagdirectory taginfo.txt file to extract statistics in the first 11 lines. """ # General Stats Table tag_info = dict() for l in f['f']: s = l.split("=") if len(s) > 1: if s[0].strip() == 'genome': ...
python
{ "resource": "" }
q28306
TagDirReportMixin.parse_tag_info_chrs
train
def parse_tag_info_chrs(self, f, convChr=True): """ Parse HOMER tagdirectory taginfo.txt file to extract chromosome coverage. """ parsed_data_total = OrderedDict() parsed_data_uniq = OrderedDict() remove = ["hap", "random", "chrUn", "cmd", "EBV", "GL", "NT_"] for l in f['f']: ...
python
{ "resource": "" }
q28307
TagDirReportMixin.parse_FreqDist
train
def parse_FreqDist(self, f): """ Parse HOMER tagdirectory petag.FreqDistribution_1000 file. """ parsed_data = dict() firstline = True for l in f['f']: if firstline: firstline = False continue else: s = l.split("\t") ...
python
{ "resource": "" }
q28308
TagDirReportMixin.parse_FreqDist_interChr
train
def parse_FreqDist_interChr(self, f): """ Parse HOMER tagdirectory petag.FreqDistribution_1000 file to get inter-chromosomal interactions. """ parsed_data = dict() firstline = True
python
{ "resource": "" }
q28309
TagDirReportMixin.restriction_dist_chart
train
def restriction_dist_chart (self): """ Make the petagRestrictionDistribution plot """ pconfig = { 'id': 'petagRestrictionDistribution', 'title': 'Restriction Distribution', 'ylab': 'Reads', 'xlab': 'Distance from cut site (bp)', 'data_labels'...
python
{ "resource": "" }
q28310
TagDirReportMixin.GCcontent_plot
train
def GCcontent_plot (self): """ Create the HTML for the Homer GC content plot """ pconfig = { 'id': 'homer-tag-directory-gc-content', 'title': 'Homer: Tag Directory Per Sequence GC Content', 'smooth_points': 200, 'smooth_points_sumcounts': False, ...
python
{ "resource": "" }
q28311
TagDirReportMixin.tag_info_chart
train
def tag_info_chart (self): """ Make the taginfo.txt plot """ ## TODO: human chrs on hg19. How will this work with GRCh genome or other, non human, genomes? # nice if they are ordered by size ucsc = ["chr" + str(i) for i in range(1,23)].append([ "chrX", "chrY", "chrM"]) ensembl ...
python
{ "resource": "" }
q28312
TagDirReportMixin.FreqDist_chart
train
def FreqDist_chart (self): """ Make the petag.FreqDistribution_1000 plot """ # Take a log of the data before plotting so that we can # reduce the number of points to plot evenly pdata = {} for idx, s_name in enumerate(self.tagdir_data['FreqDistribution']): pdata[s_nam...
python
{ "resource": "" }
q28313
MultiqcModule.parse_bismark_report
train
def parse_bismark_report(self, report, regexes): """ Search a bismark report with a set of regexes """ parsed_data = {} for k, r in regexes.items(): r_search = re.search(r, report, re.MULTILINE)
python
{ "resource": "" }
q28314
MultiqcModule.parse_bismark_mbias
train
def parse_bismark_mbias(self, f): """ Parse the Bismark M-Bias plot data """ s = f['s_name'] self.bismark_mbias_data['meth']['CpG_R1'][s] = {} self.bismark_mbias_data['meth']['CHG_R1'][s] = {} self.bismark_mbias_data['meth']['CHH_R1'][s] = {} self.bismark_mbias_data['cov'...
python
{ "resource": "" }
q28315
MultiqcModule.parse_bismark_bam2nuc
train
def parse_bismark_bam2nuc(self, f): """ Parse reports generated by Bismark bam2nuc """ if f['s_name'] in self.bismark_data['bam2nuc']: log.debug("Duplicate deduplication sample log found! Overwriting: {}".format(f['s_name'])) self.add_data_source(f, section='bam2nuc') self.bi...
python
{ "resource": "" }
q28316
MultiqcModule.bismark_stats_table
train
def bismark_stats_table(self): """ Take the parsed stats from the Bismark reports and add them to the basic stats table at the top of the report """ headers = { 'alignment': OrderedDict(), 'dedup': OrderedDict(), 'methextract': OrderedDict(), 'bam...
python
{ "resource": "" }
q28317
MultiqcModule.bismark_alignment_chart
train
def bismark_alignment_chart (self): """ Make the alignment plot """ # Specify the order of the different possible categories keys = OrderedDict() keys['aligned_reads'] = { 'color': '#2f7ed8', 'name': 'Aligned Uniquely' } keys['ambig_reads'] = { 'color': '#492970', 'name': ...
python
{ "resource": "" }
q28318
MultiqcModule.bismark_strand_chart
train
def bismark_strand_chart (self): """ Make the strand alignment plot """ # Specify the order of the different possible categories keys = OrderedDict() keys['strand_ob'] = { 'name': 'Original bottom strand' } keys['strand_ctob'] = { 'name': 'Complementary to original bottom stra...
python
{ "resource": "" }
q28319
MultiqcModule.bismark_dedup_chart
train
def bismark_dedup_chart (self): """ Make the deduplication plot """ # Specify the order of the different possible categories keys = OrderedDict() keys['dedup_reads'] = { 'name': 'Deduplicated reads (remaining)' } keys['dup_reads'] = { 'name': 'Duplicate reads (removed)' } ...
python
{ "resource": "" }
q28320
MultiqcModule.bismark_methlyation_chart
train
def bismark_methlyation_chart (self): """ Make the methylation plot """ # Config for the plot keys = OrderedDict() defaults = { 'max': 100, 'min': 0, 'suffix': '%', 'decimalPlaces': 1 } keys['percent_cpg_meth'] = dict(defau...
python
{ "resource": "" }
q28321
MultiqcModule.bismark_mbias_plot
train
def bismark_mbias_plot (self): """ Make the M-Bias plot """ description = '<p>This plot shows the average percentage methylation and coverage across reads. See the \n\ <a href="https://rawgit.com/FelixKrueger/Bismark/master/Docs/Bismark_User_Guide.html#m-bias-plot" target="_blank">bismark user ...
python
{ "resource": "" }
q28322
MultiqcModule.parse_afterqc_log
train
def parse_afterqc_log(self, f): """ Parse the JSON output from AfterQC and save the summary statistics """ try: parsed_json = json.load(f['f']) except: log.warn("Could not parse AfterQC JSON: '{}'".format(f['fn'])) return None # AfterQC changed the na...
python
{ "resource": "" }
q28323
MultiqcModule.afterqc_general_stats_table
train
def afterqc_general_stats_table(self): """ Take the parsed stats from the Afterqc report and add it to the General Statistics table at the top of the report """ headers = OrderedDict() headers['pct_good_bases'] = { 'title': '% Good Bases', 'description': 'Percent...
python
{ "resource": "" }
q28324
MultiqcModule.after_qc_bad_reads_chart
train
def after_qc_bad_reads_chart(self): """ Function to generate the AfterQC bad reads bar plot """ # Specify the order of the different possible categories keys = OrderedDict() keys['good_reads'] = { 'name': 'Good Reads' } keys['bad_reads_with_bad_barcode'] = ...
python
{ "resource": "" }
q28325
MultiqcModule.plot
train
def plot(self, file_type): """ Call file_type plotting function. """ samples = self.mod_data[file_type] plot_title = file_types[file_type]['title']
python
{ "resource": "" }
q28326
MultiqcModule.make_basic_table
train
def make_basic_table(self, file_type): """ Create table of key-value items in 'file_type'. """ table_data = {sample: items['kv'] for sample, items in self.mod_data[file_type].items() } table_headers = {} for column_header, (description, h...
python
{ "resource": "" }
q28327
TsTvByCountMixin.parse_tstv_by_count
train
def parse_tstv_by_count(self): """ Create the HTML for the TsTv by alternative allele count linegraph plot. """ self.vcftools_tstv_by_count = dict() for f in self.find_log_files('vcftools/tstv_by_count', filehandles=True): d = {} for line in f['f'].readlines()[1:]: # don...
python
{ "resource": "" }
q28328
plotEnrichmentMixin.parse_plotEnrichment
train
def parse_plotEnrichment(self): """Find plotEnrichment output.""" self.deeptools_plotEnrichment = dict() for f in self.find_log_files('deeptools/plotEnrichment'): parsed_data = self.parsePlotEnrichment(f) for k, v in parsed_data.items(): if k in self.deept...
python
{ "resource": "" }
q28329
MultiqcModule.slamdunkGeneralStatsTable
train
def slamdunkGeneralStatsTable(self): """ Take the parsed summary stats from Slamdunk and add it to the basic stats table at the top of the report """ headers = OrderedDict() headers['counted'] = { 'title': '{} Counted'.format(config.read_count_prefix), 'descript...
python
{ "resource": "" }
q28330
MultiqcModule.slamdunkFilterStatsTable
train
def slamdunkFilterStatsTable(self): """ Take the parsed filter stats from Slamdunk and add it to a separate table """ headers = OrderedDict() headers['mapped'] = { 'namespace': 'Slamdunk', 'title': '{} Mapped'.format(config.read_count_prefix), 'description': ...
python
{ "resource": "" }
q28331
MultiqcModule.bowtie_general_stats_table
train
def bowtie_general_stats_table(self): """ Take the parsed stats from the Bowtie report and add it to the basic stats table at the top of the report """ headers = OrderedDict() headers['reads_aligned_percentage'] = { 'title': '% Aligned', 'description': '% reads w...
python
{ "resource": "" }
q28332
search_file
train
def search_file (pattern, f): """ Function to searach a single file for a single search pattern. """ fn_matched = False contents_matched = False # Use mimetypes to exclude binary files where possible if not re.match(r'.+_mqc\.(png|jpg|jpeg)', f['fn']): (ftype, encoding) = mimetypes...
python
{ "resource": "" }
q28333
exclude_file
train
def exclude_file(sp, f): """ Exclude discovered files if they match the special exclude_ search pattern keys """ # Make everything a list if it isn't already for k in sp: if k in ['exclude_fn', 'exclude_fn_re' 'exclude_contents', 'exclude_contents_re']: if not isinstance(sp[k...
python
{ "resource": "" }
q28334
save_htmlid
train
def save_htmlid(html_id, skiplint=False): """ Take a HTML ID, sanitise for HTML, check for duplicates and save. Returns sanitised, unique ID """ global html_ids global lint_errors # Trailing whitespace html_id_clean = html_id.strip() # Trailing underscores html_id_clean = html_id_clean...
python
{ "resource": "" }
q28335
compress_json
train
def compress_json(data): """ Take a Python data object. Convert to JSON and compress using lzstring """ json_string = json.dumps(data).encode('utf-8', 'ignore').decode('utf-8') # JSON.parse() doesn't handle `NaN`, but it does handle `null`.
python
{ "resource": "" }
q28336
MultiqcModule.methylqa_general_stats_table
train
def methylqa_general_stats_table(self): """ Take the parsed stats from the methylQA report and add it to the basic stats table at the top of the report """ headers = OrderedDict() headers['coverage'] = { 'title':
python
{ "resource": "" }
q28337
MultiqcModule.rsem_stats_table
train
def rsem_stats_table(self): """ Take the parsed stats from the rsem report and add them to the basic stats table at the top of the report """ headers = OrderedDict() headers['alignable_percent'] = { 'title': '% Alignable'.format(config.read_count_prefix), 'descrip...
python
{ "resource": "" }
q28338
MultiqcModule.rsem_mapped_reads_plot
train
def rsem_mapped_reads_plot(self): """ Make the rsem assignment rates plot """ # Plot categories keys = OrderedDict() keys['Unique'] = { 'color': '#437bb1', 'name': 'Aligned uniquely to a gene' } keys['Multi'] = { 'color': '#e63491', 'name': 'Aligned to multiple genes'...
python
{ "resource": "" }
q28339
TsTvByQualMixin.parse_tstv_by_qual
train
def parse_tstv_by_qual(self): """ Create the HTML for the TsTv by quality linegraph plot. """ self.vcftools_tstv_by_qual = dict() for f in self.find_log_files('vcftools/tstv_by_qual', filehandles=True): d = {} for line in f['f'].readlines()[1:]: # don't add the header li...
python
{ "resource": "" }
q28340
MultiqcModule.general_stats
train
def general_stats(self): """ Add key SnpEff stats to the general stats table """ headers = OrderedDict() headers['Change_rate'] = { 'title': 'Change rate', 'scale': 'RdYlBu-rev', 'min': 0, 'format': '{:,.0f}' } headers['Ts_Tv_ratio...
python
{ "resource": "" }
q28341
MultiqcModule.count_genomic_region_plot
train
def count_genomic_region_plot(self): """ Generate the SnpEff Counts by Genomic Region plot """ # Sort the keys based on the total counts keys = self.snpeff_section_totals['# Count by genomic region'] sorted_keys = sorted(keys, reverse=True, key=keys.get) # Make nicer label name...
python
{ "resource": "" }
q28342
MultiqcModule.effects_impact_plot
train
def effects_impact_plot(self): """ Generate the SnpEff Counts by Effects Impact plot """ # Put keys in a more logical order keys = [ 'MODIFIER', 'LOW', 'MODERATE', 'HIGH' ] # Make nicer label names pkeys = OrderedDict() for k in keys: pkeys[k] = {'name': k.t...
python
{ "resource": "" }
q28343
MultiqcModule.parse_prokka
train
def parse_prokka(self, f): """ Parse prokka txt summary files. Prokka summary files are difficult to identify as there are practically no distinct prokka identifiers in the filenames or file contents. This parser makes an attempt using the first three lines, expected to contain ...
python
{ "resource": "" }
q28344
MultiqcModule.prokka_table
train
def prokka_table(self): """ Make basic table of the annotation stats """ # Specify the order of the different possible categories headers = OrderedDict() headers['organism'] = { 'title': 'Organism', 'description': 'Organism name', } header...
python
{ "resource": "" }
q28345
MultiqcModule.prokka_barplot
train
def prokka_barplot(self): """ Make a basic plot of the annotation stats """ # Specify the order of the different categories keys = OrderedDict() keys['CDS'] = { 'name': 'CDS' } keys['rRNA'] = { 'name': 'rRNA' } keys['tRNA'] = { 'name': 'tRNA' ...
python
{ "resource": "" }
q28346
plot_bhist
train
def plot_bhist(samples, file_type, **plot_args): """ Create line graph plot of histogram data for BBMap 'bhist' output. The 'samples' parameter could be from the bbmap mod_data dictionary: samples = bbmap.MultiqcModule.mod_data[file_type] """ all_x = set() for item in sorted(chain(*[samples[sa...
python
{ "resource": "" }
q28347
MultiqcModule.add_readlen_dist_plot
train
def add_readlen_dist_plot(self): """ Generate plot HTML for read length distribution plot. """ pconfig = { 'id': 'skewer_read_length_histogram', 'title': 'Skewer: Read Length Distribution after trimming', 'xDecimals': False, 'ylab': '% of Reads', ...
python
{ "resource": "" }
q28348
MultiqcModule.parse_skewer_log
train
def parse_skewer_log(self, f): """ Go through log file looking for skewer output """ fh = f['f'] regexes = { 'fq1': "Input file:\s+(.+)", 'fq2': "Paired file:\s+(.+)", 'r_processed': "(\d+) read|reads pairs? processed", 'r_short_filtered': "(\d+) \...
python
{ "resource": "" }
q28349
parse_reports
train
def parse_reports(self): """ Find RSeQC read_duplication reports and parse their data """ # Set up vars self.read_dups = dict() # Go through files and parse data for f in self.find_log_files('rseqc/read_duplication_pos'): if f['f'].startswith('Occurrence UniqReadNumber'): if f[...
python
{ "resource": "" }
q28350
read_sample_name
train
def read_sample_name(line_iter, clean_fn): """ Consumes lines from the provided line_iter and parses those lines as a header for the picard base distribution file. The header file is assumed to contain a line with both 'INPUT' and 'BaseDistributionByCycle'. If the header parses correctly, the ...
python
{ "resource": "" }
q28351
MultiqcModule.fastp_general_stats_table
train
def fastp_general_stats_table(self): """ Take the parsed stats from the fastp report and add it to the General Statistics table at the top of the report """ headers = OrderedDict() headers['pct_duplication'] = { 'title': '% Duplication', 'description': 'Duplicati...
python
{ "resource": "" }
q28352
MultiqcModule.fastp_filtered_reads_chart
train
def fastp_filtered_reads_chart(self): """ Function to generate the fastp filtered reads bar plot """ # Specify the order of the different possible categories keys = OrderedDict() keys['filtering_result_passed_filter_reads'] = { 'name': 'Passed Filter' } keys['filtering_result_lo...
python
{ "resource": "" }
q28353
MultiqcModule.fastp_read_qual_plot
train
def fastp_read_qual_plot(self): """ Make the read quality plot for Fastp """ data_labels, pdata = self.filter_pconfig_pdata_subplots(self.fastp_qual_plotdata, 'Sequence Quality') pconfig = { 'id': 'fastp-seq-quality-plot', 'title': 'Fastp: Sequence Quality', '...
python
{ "resource": "" }
q28354
MultiqcModule.fastp_read_gc_plot
train
def fastp_read_gc_plot(self): """ Make the read GC plot for Fastp """ data_labels, pdata = self.filter_pconfig_pdata_subplots(self.fastp_gc_content_data, 'Base Content Percent') pconfig = { 'id': 'fastp-seq-content-gc-plot', 'title': 'Fastp: Read GC Content', ...
python
{ "resource": "" }
q28355
MultiqcModule.fastp_read_n_plot
train
def fastp_read_n_plot(self): """ Make the read N content plot for Fastp """ data_labels, pdata = self.filter_pconfig_pdata_subplots(self.fastp_n_content_data, 'Base Content Percent') pconfig = { 'id': 'fastp-seq-content-n-plot', 'title': 'Fastp: Read N Content', ...
python
{ "resource": "" }
q28356
plotProfileMixin.parse_plotProfile
train
def parse_plotProfile(self): """Find plotProfile output""" self.deeptools_plotProfile = dict() for f in self.find_log_files('deeptools/plotProfile', filehandles=False): parsed_data, bin_labels, converted_bin_labels = self.parsePlotProfileData(f) for k, v in parsed_data.it...
python
{ "resource": "" }
q28357
MultiqcModule.qorts_general_stats
train
def qorts_general_stats (self): """ Add columns to the General Statistics table """ headers = OrderedDict() headers['Genes_PercentWithNonzeroCounts'] = { 'title': '% Genes with Counts', 'description': 'Percent of Genes with Non-Zero Counts', 'max': 100, ...
python
{ "resource": "" }
q28358
MultiqcModule.parse_metrics
train
def parse_metrics(self, f): """ Parse the metrics.tsv file from RNA-SeQC """ headers = None for l in f['f'].splitlines(): s = l.strip().split("\t") if headers is None: headers = s else: s_name = s[ headers.index(...
python
{ "resource": "" }
q28359
MultiqcModule.rnaseqc_general_stats
train
def rnaseqc_general_stats (self): """ Add alignment rate to the general stats table """ headers = OrderedDict() headers['Expression Profiling Efficiency'] = { 'title': '% Expression Efficiency', 'description': 'Expression Profiling Efficiency: Ratio of exo...
python
{ "resource": "" }
q28360
MultiqcModule.transcript_associated_plot
train
def transcript_associated_plot (self): """ Plot a bargraph showing the Transcript-associated reads """ # Plot bar graph of groups keys = OrderedDict() keys['Exonic Rate'] = { 'name': 'Exonic', 'color': '#2f7ed8' } keys['Intronic Rate'] = { 'name': 'Intronic', 'color': '#8bbc21'...
python
{ "resource": "" }
q28361
MultiqcModule.strand_barplot
train
def strand_barplot(self): """ Plot a bargraph showing the strandedness of alignments """ # Plot bar graph of groups keys = [ 'End 1 Sense', 'End 1 Antisense', 'End 2 Sense', 'End 2 Antisense' ] # Config for the plot pconfig = { 'id': 'rna_seqc_strandedness_plot', ...
python
{ "resource": "" }
q28362
MultiqcModule.parse_coverage
train
def parse_coverage (self, f): """ Parse the RNA-SeQC Normalised Coverage Files """ data = dict() s_names = None j = 1 for l in f['f'].splitlines(): s = l.strip().split("\t") if s_names is None: s_names = s for s_name in s_na...
python
{ "resource": "" }
q28363
MultiqcModule.coverage_lineplot
train
def coverage_lineplot (self): """ Make HTML for coverage line plots """ # Add line graph to section data = list() data_labels = list() if len(self.rna_seqc_norm_high_cov) > 0: data.append(self.rna_seqc_norm_high_cov) data_labels.append({'name': 'High Expre...
python
{ "resource": "" }
q28364
MultiqcModule.parse_correlation
train
def parse_correlation(self, f): """ Parse RNA-SeQC correlation matrices """ s_names = None data = list() for l in f['f'].splitlines(): s = l.strip().split("\t") if s_names is None: s_names = [ x for x in s if x != '' ] else: ...
python
{ "resource": "" }
q28365
MultiqcModule.plot_correlation_heatmap
train
def plot_correlation_heatmap(self): """ Return HTML for correlation heatmap """ data = None corr_type = None correlation_type = getattr(config, 'rna_seqc' ,{}).get('default_correlation', 'spearman') if self.rna_seqc_spearman is not None and correlation_type != 'pearson': ...
python
{ "resource": "" }
q28366
MultiqcModule.parse_theta2_report
train
def parse_theta2_report (self, fh): """ Parse the final THetA2 log file. """ parsed_data = {} for l in fh: if l.startswith('#'): continue else: s = l.split("\t") purities = s[1].split(',') parsed_data['propor...
python
{ "resource": "" }
q28367
parse_single_report
train
def parse_single_report(f): """ Parse a gatk varianteval varianteval """ # Fixme: Separate GATKReport parsing and data subsetting. A GATKReport parser now available from the GATK MultiqcModel. data = dict() in_CompOverlap = False in_CountVariants = False in_TiTv = False for l in f: ...
python
{ "resource": "" }
q28368
comp_overlap_table
train
def comp_overlap_table(data): """Build a table from the comp overlaps output.""" headers = OrderedDict() headers['comp_rate'] = { 'title': 'Compare rate', 'description': 'Ratio of known variants found in the reference set.', 'namespace': 'GATK', 'min': 0, 'max': 100, ...
python
{ "resource": "" }
q28369
VariantEvalMixin.parse_gatk_varianteval
train
def parse_gatk_varianteval(self): """ Find GATK varianteval logs and parse their data """ self.gatk_varianteval = dict() for f in self.find_log_files('gatk/varianteval', filehandles=True): parsed_data = parse_single_report(f['f']) if len(parsed_data) > 0: ...
python
{ "resource": "" }
q28370
MultiqcModule.parse_sargasso_logs
train
def parse_sargasso_logs(self, f): """ Parse the sargasso log file. """ species_name = list() items = list() header = list() is_first_line = True for l in f['f'].splitlines(): s = l.split(",") # Check that this actually is a Sargasso file ...
python
{ "resource": "" }
q28371
MultiqcModule.sargasso_stats_table
train
def sargasso_stats_table(self): """ Take the parsed stats from the sargasso report and add them to the basic stats table at the top of the report """ headers = OrderedDict() headers['sargasso_percent_assigned'] = { 'title': '% Assigned', 'description': 'Sargasso ...
python
{ "resource": "" }
q28372
MultiqcModule.sargasso_chart
train
def sargasso_chart (self): """ Make the sargasso plot """ # Config for the plot config = { 'id': 'sargasso_assignment_plot', 'title': 'Sargasso: Assigned Reads', 'ylab': '# Reads', 'cpswitch_counts_label': 'Number of Reads'
python
{ "resource": "" }
q28373
plot_aqhist
train
def plot_aqhist(samples, file_type, **plot_args): """ Create line graph plot of histogram data for BBMap 'aqhist' output. The 'samples' parameter could be from the bbmap mod_data dictionary: samples = bbmap.MultiqcModule.mod_data[file_type] """ sumy = sum([int(samples[sample]['data'][x][0]) ...
python
{ "resource": "" }
q28374
TsTvSummaryMixin.parse_tstv_summary
train
def parse_tstv_summary(self): """ Create the HTML for the TsTv summary plot. """ self.vcftools_tstv_summary = dict() for f in self.find_log_files('vcftools/tstv_summary', filehandles=True): d = {} for line in f['f'].readlines()[1:]: # don't add the header line (first row...
python
{ "resource": "" }
q28375
FindPeaksReportMixin.parse_homer_findpeaks
train
def parse_homer_findpeaks(self): """ Find HOMER findpeaks logs and parse their data """ self.homer_findpeaks = dict() for f in self.find_log_files('homer/findpeaks', filehandles=True): self.parse_findPeaks(f) # Filter to strip out ignored sample names self.homer_fin...
python
{ "resource": "" }
q28376
FindPeaksReportMixin.parse_findPeaks
train
def parse_findPeaks(self, f): """ Parse HOMER findPeaks file headers. """ parsed_data = dict() s_name = f['s_name'] for l in f['f']: # Start of data if l.strip() and not l.strip().startswith('#'): break # Automatically parse header line...
python
{ "resource": "" }
q28377
move_tmp_log
train
def move_tmp_log(logger): """ Move the temporary log file to the MultiQC data directory if it exists. """ try: # https://stackoverflow.com/questions/15435652/python-does-not-release-filehandles-to-logfile logging.shutdown() shutil.move(log_tmp_fn,
python
{ "resource": "" }
q28378
get_log_stream
train
def get_log_stream(logger): """ Returns a stream to the root log file. If there is no logfile return the stderr log stream Returns: A stream to the root log file or stderr stream. """ file_stream = None log_stream = None for handler in logger.handlers: if
python
{ "resource": "" }
q28379
MultiqcModule.parse_jellyfish_data
train
def parse_jellyfish_data(self, f): """ Go through the hist file and memorise it """ histogram = {} occurence = 0 for line in f['f']: line = line.rstrip('\n') occurence = int(line.split(" ")[0]) count = int(line.split(" ")[1]) histogram[occu...
python
{ "resource": "" }
q28380
MultiqcModule.frequencies_plot
train
def frequencies_plot(self, xmin=0, xmax=200): """ Generate the qualities plot """ helptext = ''' A possible way to assess the complexity of a library even in absence of a reference sequence is to look at the kmer profile of the reads. The idea is to count all the kme...
python
{ "resource": "" }
q28381
parse_reports
train
def parse_reports(self): """ Find RSeQC infer_experiment reports and parse their data """ # Set up vars self.infer_exp = dict() regexes = { 'pe_sense': r"\"1\+\+,1--,2\+-,2-\+\": (\d\.\d+)", 'pe_antisense': r"\"1\+-,1-\+,2\+\+,2--\": (\d\.\d+)", 'se_sense': r"\"\+\+,--\": (\d\.\...
python
{ "resource": "" }
q28382
MultiqcModule.parse_leehom_logs
train
def parse_leehom_logs(self, f): """ Go through log file looking for leehom output """ regexes = { 'total': r"Total reads[\s\:]+(\d+)", 'merged_trimming': r"Merged \(trimming\)\s+(\d+)", 'merged_overlap': r"Merged \(overlap\)\s+(\d+)", 'kept': r"Kept PE/SR\...
python
{ "resource": "" }
q28383
MultiqcModule.leehom_general_stats_table
train
def leehom_general_stats_table(self): """ Take the parsed stats from the leeHom report and add it to the basic stats table at the top of the report """ headers = {} headers['merged_trimming'] = { 'title': '{} Merged (Trimming)'.format(config.read_count_prefix), '...
python
{ "resource": "" }
q28384
MultiqcModule.dedup_general_stats_table
train
def dedup_general_stats_table(self): """ Take the parsed stats from the DeDup report and add it to the basic stats table at the top of the report """ headers = OrderedDict() headers['duplication_rate'] = {
python
{ "resource": "" }
q28385
MultiqcModule.macs_filtered_reads_plot
train
def macs_filtered_reads_plot(self): """ Plot of filtered reads for control and treatment samples """ data = dict() req_cats = ['control_fragments_total', 'control_fragments_after_filtering', 'treatment_fragments_total', 'treatment_fragments_after_filtering'] for s_name, d in self.macs_da...
python
{ "resource": "" }
q28386
MultiqcModule.split_log
train
def split_log(logf): """split concat log into individual samples""" flashpatt = re.compile( r'\[FLASH\] Fast Length Adjustment of SHort
python
{ "resource": "" }
q28387
MultiqcModule.get_field
train
def get_field(field, slog, fl=False): """parse sample log for field set fl=True to return a float otherwise, returns int """ field += r'\:\s+([\d\.]+)' match = re.search(field, slog)
python
{ "resource": "" }
q28388
MultiqcModule.clean_pe_name
train
def clean_pe_name(self, nlog, root): """additional name cleaning for paired end data""" use_output_name = getattr(config, 'flash', {}).get('use_output_name', False) if use_output_name: name = re.search(r'Output files\:\n\[FLASH\]\s+(.+?)\n', nlog) else:
python
{ "resource": "" }
q28389
MultiqcModule.parse_flash_log
train
def parse_flash_log(self, logf): """parse flash logs""" data = OrderedDict() samplelogs = self.split_log(logf['f']) for slog in samplelogs: try: sample = dict() ## Sample name ## s_name = self.clean_pe_name(slog, logf['root']) ...
python
{ "resource": "" }
q28390
MultiqcModule.stats_table
train
def stats_table(self, data): """Add percent combined to general stats table""" headers = OrderedDict() headers['combopairs'] = { 'title': 'Combined pairs', 'description': 'Num read pairs combined', 'shared_key': 'read_count', 'hidden': True, ...
python
{ "resource": "" }
q28391
MultiqcModule.summary_plot
train
def summary_plot(data): """Barplot of combined pairs""" cats = OrderedDict() cats = { 'inniepairs': { 'name': 'Combined innie pairs', 'color': '#191970' }, 'outiepairs': { 'name': 'Combined outie pairs', ...
python
{ "resource": "" }
q28392
MultiqcModule.parse_hist_files
train
def parse_hist_files(histf): """parse histogram files""" nameddata = dict() data = dict() try: for l in histf['f'].splitlines(): s = l.split() if s: if len(s) != 2: raise RuntimeError("invalid format:...
python
{ "resource": "" }
q28393
MultiqcModule.get_colors
train
def get_colors(n): """get colors for freqpoly graph""" cb_palette = ["#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7","#001F3F", "#0074D9", "#7FDBFF", "#39CCCC", "#3D9970", "#2ECC40", "#01FF70", "#FFDC00", "#FF851B", "#FF4136", "#F0...
python
{ "resource": "" }
q28394
MultiqcModule.freqpoly_plot
train
def freqpoly_plot(data): """make freqpoly plot of merged read lengths""" rel_data = OrderedDict() for key, val in data.items(): tot = sum(val.values(), 0) rel_data[key] = {k: v / tot for k, v in val.items()} fplotconfig = { 'data_labels': [ ...
python
{ "resource": "" }
q28395
MultiqcModule.hist_results
train
def hist_results(self): """process flash numeric histograms""" self.hist_data = OrderedDict() for histfile in self.find_log_files('flash/hist'): self.hist_data.update(self.parse_hist_files(histfile)) # ignore sample names self.hist_data = self.ignore_samples(self.his...
python
{ "resource": "" }
q28396
generate_dummy_graph
train
def generate_dummy_graph(network): """Generate a dummy graph to feed to the FIAS libraries. It adds the "pos" attribute and removes the 380 kV duplicate buses when the buses have been split, so that all load and generation is attached to the 220kV bus.""" graph = pypsa.descriptors.OrderedGraph(...
python
{ "resource": "" }
q28397
voronoi_partition
train
def voronoi_partition(G, outline): """ For 2D-embedded graph `G`, within the boundary given by the shapely polygon ...
python
{ "resource": "" }
q28398
area_from_lon_lat_poly
train
def area_from_lon_lat_poly(geometry): """ Compute the area in km^2 of a shapely geometry, whose points are in longitude and latitude. Parameters ---------- geometry: shapely geometry Points must be in longitude and latitude. Returns ------- area: float Area in
python
{ "resource": "" }
q28399
define_sub_network_cycle_constraints
train
def define_sub_network_cycle_constraints( subnetwork, snapshots, passive_branch_p, attribute): """ Constructs cycle_constraints for a particular subnetwork """ sub_network_cycle_constraints = {} sub_network_cycle_index = [] matrix = subnetwork.C.tocsc() branches = subnetwork.branches() fo...
python
{ "resource": "" }