geoseeq 0.6.14.dev2__py3-none-any.whl → 0.6.14.dev4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
geoseeq/cli/download.py CHANGED
@@ -378,6 +378,71 @@ def cli_download_ids(state, cores, target_dir, file_name, yes, download, head, i
378
378
  download_manager.download_files()
379
379
 
380
380
 
381
+ def _get_sample_result_files_with_names(sample, module_name=None, first=False):
382
+ for read_type, folder in sample.get_all_fastqs().items():
383
+ if module_name and module_name != read_type:
384
+ continue
385
+ result_files_with_names = []
386
+ for folder_name, result_files in folder.items():
387
+ for lane_num, result_file in enumerate(result_files):
388
+ lane_num = lane_num + 1 # 1 indexed
389
+ if read_type in ["short_read::paired_end"]:
390
+ key = (sample, read_type, 1, lane_num) # sample name, read type, read number, lane number
391
+ result_files_with_names.append(
392
+ (result_file[0], result_file[0].get_referenced_filename(), key)
393
+ )
394
+ key = (sample, read_type, 2, lane_num)
395
+ result_files_with_names.append(
396
+ (result_file[1], result_file[1].get_referenced_filename(), key)
397
+ )
398
+ else:
399
+ key = (sample, read_type, 1, lane_num)
400
+ result_files_with_names.append(
401
+ (result_file, result_file.get_referenced_filename(), key)
402
+ )
403
+ if first:
404
+ break
405
+
406
+ return result_files_with_names
407
+
408
+
409
+ def _make_read_configs(download_results, config_dir="."):
410
+ """Make JSON config files that look like this.
411
+
412
+ {
413
+ "sample_name": "small",
414
+ "reads_1": ["small.fq.gz"],
415
+ "reads_2": [],
416
+ "fastq_checksum": "",
417
+ "data_type": "short-read",
418
+ "bdx_result_dir": "results",
419
+ "geoseeq_uuid": "05bf22e9-9d25-42db-af25-31bc538a7006"
420
+ }
421
+ """
422
+ config_blobs = {} # sample ids -> config_blobs
423
+ download_results = sorted(download_results, key=lambda x: x[1][3]) # sort by lane number
424
+ for local_path, (sample, read_type, read_num, lane_num), _ in download_results:
425
+ if sample.name not in config_blobs:
426
+ config_blobs[sample.name] = {
427
+ "sample_name": sample.name,
428
+ "reads_1": [],
429
+ "reads_2": [],
430
+ "fastq_checksum": "",
431
+ "data_type": "short-read",
432
+ "bdx_result_dir": "results",
433
+ "geoseeq_uuid": sample.uuid,
434
+ }
435
+ if read_num == 1:
436
+ config_blobs[sample.name]["reads_1"].append(local_path) # sorted by lane number
437
+ else:
438
+ config_blobs[sample.name]["reads_2"].append(local_path)
439
+
440
+ for sample_name, config_blob in config_blobs.items():
441
+ config_path = join(config_dir, f"{sample_name}.config.json")
442
+ with open(config_path, "w") as f:
443
+ json.dump(config_blob, f, indent=4)
444
+
445
+
381
446
  @cli_download.command("fastqs")
382
447
  @use_common_state
383
448
  @cores_option
@@ -385,6 +450,7 @@ def cli_download_ids(state, cores, target_dir, file_name, yes, download, head, i
385
450
  @yes_option
386
451
  @click.option("--first/--all", default=False, help="Download only the first folder of fastq files for each sample.")
387
452
  @click.option("--download/--urls-only", default=True, help="Download files or just print urls")
453
+ @click.option("--config-dir", default=None, help="Directory to write read config files. If unset do not write config files.")
388
454
  @module_option(FASTQ_MODULE_NAMES, use_default=False)
389
455
  @ignore_errors_option
390
456
  @alt_id_option
@@ -396,6 +462,7 @@ def cli_download_fastqs(state,
396
462
  yes,
397
463
  first,
398
464
  download,
465
+ config_dir,
399
466
  module_name,
400
467
  ignore_errors,
401
468
  alt_sample_id,
@@ -455,24 +522,12 @@ def cli_download_fastqs(state,
455
522
 
456
523
  result_files_with_names = []
457
524
  for sample in samples:
458
- for read_type, folder in sample.get_all_fastqs().items():
459
- if module_name and module_name != read_type:
460
- continue
461
- for folder_name, result_files in folder.items():
462
- for result_file in result_files:
463
- if read_type in ["short_read::paired_end"]:
464
- result_files_with_names.append(
465
- (result_file[0], result_file[0].get_referenced_filename())
466
- )
467
- result_files_with_names.append(
468
- (result_file[1], result_file[1].get_referenced_filename())
469
- )
470
- else:
471
- result_files_with_names.append(
472
- (result_file, result_file.get_referenced_filename())
473
- )
474
- if first:
475
- break
525
+ try:
526
+ result_files_with_names += _get_sample_result_files_with_names(sample, module_name, first)
527
+ except Exception as e:
528
+ logger.error(f"Error fetching fastq files for sample {sample.name}: {e}")
529
+ if not ignore_errors:
530
+ raise e
476
531
 
477
532
  if len(result_files_with_names) == 0:
478
533
  click.echo("No suitable fastq files found.")
@@ -484,8 +539,8 @@ def cli_download_fastqs(state,
484
539
  log_level=state.log_level,
485
540
  progress_tracker_factory=PBarManager().get_new_bar,
486
541
  )
487
- for result_file, filename in result_files_with_names:
488
- download_manager.add_download(result_file, join(target_dir, filename))
542
+ for result_file, filename, key in result_files_with_names:
543
+ download_manager.add_download(result_file, join(target_dir, filename), key=key)
489
544
  if not download:
490
545
  print(download_manager.get_url_string(), file=state.outfile)
491
546
  else:
@@ -493,5 +548,6 @@ def cli_download_fastqs(state,
493
548
  if not yes:
494
549
  click.confirm('Continue?', abort=True)
495
550
  logger.info(f'Downloading {len(download_manager)} files to {target_dir}')
496
- download_manager.download_files()
497
-
551
+ download_results = download_manager.download_files()
552
+ if config_dir:
553
+ _make_read_configs(download_results, config_dir)
geoseeq/cli/main.py CHANGED
@@ -55,7 +55,7 @@ def version():
55
55
  Use of this tool implies acceptance of the GeoSeeq End User License Agreement.
56
56
  Run `geoseeq eula show` to view the EULA.
57
57
  """
58
- click.echo('0.6.14dev2') # remember to update pyproject.toml
58
+ click.echo('0.6.14dev4') # remember to update pyproject.toml
59
59
 
60
60
 
61
61
  @main.group('advanced')
geoseeq/sample.py CHANGED
@@ -200,7 +200,6 @@ class Sample(RemoteObject):
200
200
  """
201
201
  url = f"data/samples/{self.uuid}/all-fastqs"
202
202
  blob = self.knex.get(url)
203
- print(blob)
204
203
  files = {}
205
204
  for read_type, folders in blob.items():
206
205
  files[read_type] = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: geoseeq
3
- Version: 0.6.14.dev2
3
+ Version: 0.6.14.dev4
4
4
  Summary: GeoSeeq command line tools and python API
5
5
  Author: David C. Danko
6
6
  Author-email: "David C. Danko" <dcdanko@biotia.io>
@@ -9,7 +9,7 @@ geoseeq/organization.py,sha256=bJkYL8_D-k6IYAaii2ZbxjwYnXy6lvu6iLXscxKlA3w,2542
9
9
  geoseeq/pipeline.py,sha256=89mhWaecsKnm6tyRkdkaVp4dmZh62_v42Ze0oXf8OTY,9873
10
10
  geoseeq/project.py,sha256=kN6m1N4Tlud7saU03Sbir-oIBnXet_Cwi2OVVdaeag0,13929
11
11
  geoseeq/remote_object.py,sha256=GYN6PKU7Zz3htIdpFjfZiFejzGqqJHbJyKlefM1Eixk,7151
12
- geoseeq/sample.py,sha256=nlvmSy2WmiOMamkulNRloFPX7E9jVs34m1vO1PSOrHU,8336
12
+ geoseeq/sample.py,sha256=HAfMiDPHp1UJgIA2lI6oGnNit4YKyj7nx9X07CCN98U,8316
13
13
  geoseeq/search.py,sha256=gawad6Cx5FxJBPlYkXWb-UKAO-UC0_yhvyU9Ca1kaNI,3388
14
14
  geoseeq/smart_table.py,sha256=X1y9nBr8BkMNcBqdaiXtlqLCTfgc7lvdjSlAGxppvLo,6098
15
15
  geoseeq/upload_download_manager.py,sha256=eNR_Lw6JJstZ2X1Si43MM-0JZGv9GT-4fDjykaoH38A,9368
@@ -20,11 +20,11 @@ geoseeq/cli/__init__.py,sha256=4WnK87K5seRK3SGJAxNWnQTqyg5uBhdhrOrzB1D4b3M,24
20
20
  geoseeq/cli/constants.py,sha256=Do5AUf9lMO9_P8KpFJ3XwwFBAWsxSjZ6sx9_QEGyC_c,176
21
21
  geoseeq/cli/copy.py,sha256=02U9kdrAIbbM8MlRMLL6p-LMYFSuRObE3h5jyvcL__M,2275
22
22
  geoseeq/cli/detail.py,sha256=q8Suu-j2k18knfSVFG-SWWGNsKM-n8y9RMA3LcIIi9Y,4132
23
- geoseeq/cli/download.py,sha256=W3OswqpHg1thzW6CJ7IcSS0Te2LA2WfgYISQMSl4GQg,18921
23
+ geoseeq/cli/download.py,sha256=Aul4Gk49e0Y0R4kH7sD1iJ9SgJDJsrRfXjfRo88-SJE,21309
24
24
  geoseeq/cli/fastq_utils.py,sha256=-bmeQLaiMBm57zWOF0R5OlWTU0_3sh1JBC1RYw2BOFM,3083
25
25
  geoseeq/cli/find_grn.py,sha256=oMDxkzGQBQb2_cCuvmwoeHOsFHqyO9RLeJzrB6bAe5M,439
26
26
  geoseeq/cli/get_eula.py,sha256=79mbUwyiF7O1r0g6UTxG9kJGQEqKuH805E6eLkPC6Y4,997
27
- geoseeq/cli/main.py,sha256=Y0PDf-9GvAhgiKT_tF-PVC6l7yRkiQkQJZpe6geJ8M4,3987
27
+ geoseeq/cli/main.py,sha256=olfB8IkiY7bO2XbppkWrTdm-PMG0u_jccZk-2Aj0GMM,3987
28
28
  geoseeq/cli/manage.py,sha256=wGXAcVaXqE5JQEU8Jh6OlHr02nB396bpS_SFcOZdrEo,5929
29
29
  geoseeq/cli/progress_bar.py,sha256=p1Xl01nkYxSBZCB30ue2verIIi22W93m3ZAMAxipD0g,738
30
30
  geoseeq/cli/project.py,sha256=V5SdXm2Hwo2lxrkpwRDedw-mAE4XnM2uwT-Gj1D90VQ,3030
@@ -87,9 +87,9 @@ geoseeq/vc/vc_stub.py,sha256=IQr8dI0zsWKVAeY_5ybDD6n49_3othcgfHS3P0O9tuY,3110
87
87
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
88
  tests/test_api_client.py,sha256=TS5njc5pcPP_Ycy-ljcfPVT1hQRBsFVdQ0lCqBmoesU,12810
89
89
  tests/test_plotting.py,sha256=TcTu-2ARr8sxZJ7wPQxmbs3-gHw7uRvsgrhhhg0qKik,784
90
- geoseeq-0.6.14.dev2.dist-info/LICENSE,sha256=IuhIl1XCxXLPLJT_coN1CNqQU4Khlq7x4IdW7ioOJD8,1067
91
- geoseeq-0.6.14.dev2.dist-info/METADATA,sha256=w2CuV665M1mXLobfwQnDGABgjBodlY1mk8X8pzVLi-s,4937
92
- geoseeq-0.6.14.dev2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
93
- geoseeq-0.6.14.dev2.dist-info/entry_points.txt,sha256=yF-6KDM8zXib4Al0qn49TX-qM7PUkWUIcYtsgt36rjM,45
94
- geoseeq-0.6.14.dev2.dist-info/top_level.txt,sha256=zZk7mmeaqAYqFJG8nq2DTgSQPbflRjJwkDIhNURPDEU,14
95
- geoseeq-0.6.14.dev2.dist-info/RECORD,,
90
+ geoseeq-0.6.14.dev4.dist-info/LICENSE,sha256=IuhIl1XCxXLPLJT_coN1CNqQU4Khlq7x4IdW7ioOJD8,1067
91
+ geoseeq-0.6.14.dev4.dist-info/METADATA,sha256=5d01roEOeHuNDH3Jgh2ScJyhc7mdn3JbB2rq32vV90k,4937
92
+ geoseeq-0.6.14.dev4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
93
+ geoseeq-0.6.14.dev4.dist-info/entry_points.txt,sha256=yF-6KDM8zXib4Al0qn49TX-qM7PUkWUIcYtsgt36rjM,45
94
+ geoseeq-0.6.14.dev4.dist-info/top_level.txt,sha256=zZk7mmeaqAYqFJG8nq2DTgSQPbflRjJwkDIhNURPDEU,14
95
+ geoseeq-0.6.14.dev4.dist-info/RECORD,,