Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EU-28-add-more-attachment-props #46

Merged
merged 3 commits into from
Jan 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 80 additions & 8 deletions encode_utils/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,12 @@ def set_attachment(self, document):
`dict`: The 'attachment' propery value.
"""
download_filename = os.path.basename(document)
mime_type = mimetypes.guess_type(download_filename)[0]
(mime_type, extension) = mimetypes.guess_type(download_filename)
# Because the portal treats all gzipped files as application/gzip,
# force the type to be application/gzip for any files with .gz
# extension, even if the content is another type.
if extension == 'gzip':
mime_type = 'application/gzip'
data = None
if euu.is_jpg_or_tiff(document):
orientation_stats = euu.orient_jpg(document)
Expand Down Expand Up @@ -775,15 +780,82 @@ def before_submit_attachment(self, payload):
Returns:
`dict`: The potentially modified payload.
"""
attachment_prop = "attachment"
attachment_props = [
"attachment",
# atac_alignment_enrichment_quality_metric, chip_alignment_enrichment_quality_metric, complexity_xcorr_quality_metric
"cross_correlation_plot",
"gc_bias_plot",
"jsd_plot",
"tss_enrichment_plot",
# atac_peak_enrichment_quality_metric
"peak_width_distribution_plot",
# atac_replication_quality_metric and chip_replication_quality_metric
"idr_dispersion_plot",
"idr_parameters",
# dnase_alignment_quality_metric
"insert_size_histogram",
"insert_size_metric",
"nuclear_preseq",
"nuclear_preseq_targets",
# dnase_footprinting_quality_metric
"dispersion_model",
# gembs_alignment_quality_metric
"insert_size_plot",
"mapq_plot",
# idr_quality_metric
"IDR_plot_true",
"IDR_plot_rep1_pr",
"IDR_plot_rep2_pr",
"IDR_plot_pool_pr",
"IDR_parameters_true",
"IDR_parameters_rep1_pr",
"IDR_parameters_rep2_pr",
"IDR_parameters_pool_pr",
# sc_atac_alignment_quality_metric
"mito_stats",
"samstats",
# sc_atac_analysis_quality_metric
"archr_doublet_summary_figure",
"archr_fragment_size_distribution",
"archr_tss_by_unique_frags",
"archr_doublet_summary_text",
"archr_pre_filter_metadata",
# sc_atac_library_complexity_quality_metric
"pbc_stats",
"picard_markdup_stats",
# sc_atac_multiplet_quality_metric
"barcodes_status",
"barcode_pairs_multiplets",
"barcode_pairs_expanded",
"multiplet_stats",
"multiplet_threshold_plot",
# sc_atac_read_quality_metric
"adapter_trimming_stats",
"barcode_matching_stats",
"barcode_revcomp_stats",
# scrna_seq_counts_summary_quality_metric
"total_counts_vs_pct_mitochondria",
"total_counts_vs_genes_by_count",
"counts_violin_plot",
# segway_quality_metric
"feature_aggregation_tab",
"length_distribution_tab",
"segment_sizes_tab",
"signal_distribution_tab",
"trackname_assay",
# star_solo_quality_metric
"barcode_rank_plot",
"sequencing_saturation_plot",
]
path = "path"

if attachment_prop in payload:
val = payload[attachment_prop] # dict
if path in val:
# Then set the actual attachment object:
attachment = self.set_attachment(document=val[path])
payload[attachment_prop] = attachment
for prop in attachment_props:
if prop in payload:
val = payload[prop] # dict
if path in val:
# Then set the actual attachment object:
attachment = self.set_attachment(document=val[path])
payload[prop] = attachment
return payload

def before_post_file(self, payload):
Expand Down