Skip to content

Commit a550330

Browse files
authored
Merge pull request #2222 from broadinstitute/jb-bed-file-upload
Correctly identify bundled files in upload wizard (SCP-5941)
2 parents 8939e53 + b06b7ef commit a550330

3 files changed

Lines changed: 85 additions & 5 deletions

File tree

app/javascript/components/upload/upload-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function findBundleChildren(file, files) {
111111
f.study_file_bundle_id
112112
]
113113
return parentFields.includes(file._id) ||
114-
file.study_file_bundle_id && parentFields.includes(file.study_file_bundle_id)
114+
file.study_file_bundle_id && parentFields.includes(file.study_file_bundle_id) && f._id !== file._id
115115
})
116116
}
117117

test/js/upload-wizard/file-info-responses.js

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export const RAW_COUNTS_MTX_FILE = {
323323
''
324324
],
325325
'status': 'uploaded',
326-
'study_file_bundle_id': 'null',
326+
'study_file_bundle_id': '618bd61acc7ba038ac7cb091',
327327
'study_id': {
328328
'$oid': '60a2b9f4cc7ba082358b5448'
329329
},
@@ -368,7 +368,7 @@ export const BARCODES_FILE = {
368368
remote_location: '',
369369
spatial_cluster_associations: [''],
370370
status: 'uploaded',
371-
study_file_bundle_id: { $oid: '618bd61acc7ba038ac7cb091' },
371+
study_file_bundle_id: '618bd61acc7ba038ac7cb091',
372372
study_id: { $oid: '618aacbfcc7ba038ac7cb00f' },
373373
taxon_id: null,
374374
updated_at: '2021-11-10T09:24:57.640-05:00',
@@ -408,7 +408,7 @@ export const FEATURES_FILE = {
408408
remote_location: '',
409409
spatial_cluster_associations: [''],
410410
status: 'uploaded',
411-
study_file_bundle_id: { $oid: '618bd61acc7ba038ac7cb091' },
411+
study_file_bundle_id: '618bd61acc7ba038ac7cb091',
412412
study_id: { $oid: '618aacbfcc7ba038ac7cb00f' },
413413
taxon_id: null,
414414
updated_at: '2021-11-10T09:24:57.640-05:00',
@@ -430,6 +430,70 @@ export const FEATURES_FILE = {
430430
_id: { $oid: '618bd61acc7ba038ac22334' }
431431
}
432432

433+
export const BED_FILE = {
434+
_id: { $oid: "668360b1fb648e9c7c7d3380" },
435+
parse_status: "unparsed",
436+
x_axis_label: "",
437+
y_axis_label: "",
438+
z_axis_label: "",
439+
spatial_cluster_associations: [""],
440+
remote_location: "pbmc_3k_atac_fragments.possorted.bed.gz",
441+
options: { upload_trigger: "bucket" },
442+
study_id: { $oid: "66835832771a5b0202fcfeae" },
443+
human_data: false,
444+
use_metadata_convention: false,
445+
is_spatial: false,
446+
queued_for_deletion: false,
447+
taxon_id: { $oid: '604009b7cc7ba03e1b277a38' },
448+
genome_assembly_id: { $oid: '604009b7cc7ba03e1b277a39' },
449+
name: "pbmc_3k_atac_fragments.possorted.bed.gz",
450+
description: "",
451+
file_type: "BED",
452+
human_fastq_url: "",
453+
data_dir: "b2695100728ad64155d462d59e57bfd7c2200e979114dbc534c17866b935067f",
454+
status: "uploaded",
455+
upload_file_name: "pbmc_3k_atac_fragments.possorted.bed.gz",
456+
upload_content_type: "application/x-gzip",
457+
upload_file_size: 539109524,
458+
generation: "1719884843494138",
459+
updated_at: "2024-07-02T02:07:19.309Z",
460+
created_at: "2024-07-02T02:07:07.182Z",
461+
version: 2,
462+
study_file_bundle_id: "668360d7771a5b0202fcff56",
463+
is_complete: true
464+
}
465+
466+
export const BED_INDEX_FILE = {
467+
_id: { $oid: "668360bdb51a86c2885fd5e6" },
468+
parse_status: "unparsed",
469+
x_axis_label: "",
470+
y_axis_label: "",
471+
z_axis_label: "",
472+
spatial_cluster_associations: [""],
473+
remote_location: "pbmc_3k_atac_fragments.possorted.bed.gz.tbi",
474+
options: { upload_trigger: "bucket", bed_id: "668360b1fb648e9c7c7d3380" },
475+
study_id: { $oid: "66835832771a5b0202fcfeae" },
476+
human_data: false,
477+
use_metadata_convention: false,
478+
is_spatial: false,
479+
queued_for_deletion: false,
480+
name: "pbmc_3k_atac_fragments.possorted.bed.gz",
481+
description: "",
482+
file_type: "Tab Index",
483+
human_fastq_url: "",
484+
data_dir: "b2695100728ad64155d462d59e57bfd7c2200e979114dbc534c17866b935067f",
485+
status: "uploaded",
486+
upload_file_name: "pbmc_3k_atac_fragments.possorted.bed.gz.tbi",
487+
upload_content_type: null,
488+
upload_file_size: 645077,
489+
generation: "1719884679213326",
490+
updated_at: "2024-07-02T02:07:19.316Z",
491+
created_at: "2024-07-02T02:07:19.287Z",
492+
version: 2,
493+
study_file_bundle_id: "668360d7771a5b0202fcff56",
494+
is_complete: true
495+
}
496+
433497
export const IMAGE_FILE = {
434498
created_at: '2021-11-15T18:31:41.598Z',
435499
data_dir: '71e1a89e5c5d9300aabd0e757d1b569eb66644872b40bcbb720e2b39bc7e3822',

test/js/upload-wizard/validations.test.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { validateFile } from 'components/upload/upload-utils'
1+
import { validateFile, findBundleChildren } from 'components/upload/upload-utils'
2+
import { BED_FILE, BED_INDEX_FILE, RAW_COUNTS_MTX_FILE, FEATURES_FILE, BARCODES_FILE } from './file-info-responses'
23

34
describe('upload file validation name checks', () => {
45
it('allows files with unique names and valid extensions', async () => {
@@ -162,3 +163,18 @@ describe('it checks presence of required fields', () => {
162163
expect(msgs['expression_file_info.biosample_input_type']).toEqual('You must specify: biosample input type')
163164
})
164165
})
166+
167+
describe('it finds bundled files', () => {
168+
it('find sequence index files', () => {
169+
const serverFiles = [BED_FILE, BED_INDEX_FILE]
170+
const bundledIndex = findBundleChildren(BED_FILE, serverFiles)[0]
171+
expect(bundledIndex.upload_file_name).toEqual(BED_INDEX_FILE.upload_file_name)
172+
})
173+
174+
it('finds features/barcodes files for MTX', () => {
175+
const serverFiles = [RAW_COUNTS_MTX_FILE, FEATURES_FILE, BARCODES_FILE]
176+
const bundledFiles = findBundleChildren(RAW_COUNTS_MTX_FILE, serverFiles)
177+
const fileNames = bundledFiles.map(f => { return f.upload_file_name })
178+
expect(fileNames).toEqual([FEATURES_FILE.upload_file_name, BARCODES_FILE.upload_file_name])
179+
})
180+
})

0 commit comments

Comments
 (0)