1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
%global _empty_manifest_terminate_build 0
Name: python-submit4dn
Version: 3.3.0
Release: 1
Summary: Utility package for submitting data to the 4DN Data Portal
License: MIT
URL: https://github.com/4dn-dcic/Submit4DN
Source0: https://mirrors.aliyun.com/pypi/web/packages/3c/1e/454eb59853ca4bb1440066f5cfea34886e2f0374bd4ba148390a6bfff350/submit4dn-3.3.0.tar.gz
BuildArch: noarch
Requires: python3-magic
Requires: python3-attrs
Requires: python3-openpyxl
Requires: python3-dcicutils
Requires: python3-awscli
%description
# Submit 4DN - Data Submitter Tools
[](https://travis-ci.org/4dn-dcic/Submit4DN)
[](https://coveralls.io/github/4dn-dcic/Submit4DN?branch=master)
[](https://www.codacy.com/app/jeremy_7/Submit4DN)
[](https://badge.fury.io/py/Submit4DN)
The Submit4DN package is written by the [4DN Data Coordination and Integration Center](http://dcic.4dnucleome.org/) for data submitters from the 4DN Network. Please [contact us](mailto:support@4dnucleome.org) to get access to the system, or if you have any questions or suggestions. Detailed documentation on data submission can be found [at this link](https://data.4dnucleome.org/help/submitter-guide/getting-started-with-submissions)
## Installing the package
```
pip install submit4dn
```
To upgrade to the latest version
```
pip install submit4dn --upgrade
```
### Troubleshooting
This package is not supported on older Python versions and is supported and tested for versions 3.7 - 3.9. It may work with other python versions but your mileage may vary.
It is recommended to install this package in a virtual environment to avoid dependency clashes.
Problems have been reported on recent MacOS X and Windows versions having to do with the inablity to find `libmagic`,
a C library to check file types that is used by the `python-magic` library.
eg. `ImportError: failed to find libmagic. Check your installation`
First thing to try is:
```
pip uninstall python-magic
pip install python-magic
```
If that doesn't work one solution that has worked for some from [here](https://github.com/Yelp/elastalert/issues/1927):
```
pip uninstall python-magic
pip install python-magic-bin==0.4.14
```
Others have had success using homebrew to install `libmagic`:
```
brew install libmagic
brew link libmagic (if the link is already created is going to fail, don't worry about that)
```
Additionally, problems have been reported on Windows when installing Submit4DN
inside a virtual environment, due to `aws` trying to use the global python instead
of the python inside the virtual environment.
The workaround, then, because it’s actually OK if `aws` doesn’t use the python
inside the virtual environment, is to just install `awscli` in the global
environment before entering the virtual environment. Or if you discover the
problem after you’re in, then go outside, install `awscli`, and re-enter the
virtual environment.
```
deactivate
pip install awscli
VENV\scripts\activate # replace VENV with your virtual environment name
aws --version # this is to test that awscli is now installed correctly
```
## Connecting to the Data Portal
To be able to use the provided tools, you need to generate an AccessKey on the [data portal](https://data.4dnucleome.org/).
If you do not yet have access, please contact [4DN Data Wranglers](mailto:support@4dnucleome.org)
to get an account and [learn how to generate and save a key](https://data.4dnucleome.org/help/submitter-guide/getting-started-with-submissions#getting-connection-keys-for-the-4dn-dcic-servers).
## Generating data submission forms
To create the data submission excel workbook, you can use `get_field_info`.
It will accept the following parameters:
~~~~
--keyfile the path to the file where you have stored your access key info (default ~/keypairs.json)
--key the name of the key identifier for the access key and secret in your keys file (default=default)
--type use for each sheet that you want to add to the excel workbook
--nodesc do not add the descriptions in the second line (by default they are added)
--noenums do not add the list of options for a field if they are specified (by default they are added)
--comments adds any (usually internal) comments together with enums (by default False)
--outfile change the default file name "fields.xlsx" to a specified one
--debug to add more debugging output
--noadmin if you have admin access to 4DN this option lets you generate the sheet as a non-admin user
~~~~
Examples generating a single sheet:
~~~~
get_field_info --type Biosample
get_field_info --type Biosample --comments
get_field_info --type Biosample --comments --outfile biosample.xlsx
~~~~
Example Workbook with all sheets:
~~~~
get_field_info --outfile MetadataSheets.xlsx
~~~~
Examples for Workbooks using a preset option:
~~~~
get_field_info --type HiC --comments --outfile exp_hic_generic.xlsx
get_field_info --type ChIP-seq --comments --outfile exp_chipseq_generic.xlsx
get_field_info --type FISH --comments --outfile exp_fish_generic.xlsx
~~~~
Current presets include: `Hi-C, ChIP-seq, Repli-seq, ATAC-seq, DamID, ChIA-PET, Capture-C, FISH, SPT`
## Data submission
Please refer to the [submission guidelines](https://data.4dnucleome.org/help/submitter-guide) and become familiar with the metadata structure prior to submission.
After you fill out the data submission forms, you can use `import_data` to submit the metadata. The method can be used both to create new metadata items and to patch fields of existing items.
~~~~
import_data filename.xlsx
~~~~
#### Uploading vs Patching
Runnning `import_data` without one of the flags described below will perform a dry run submission that will include several validation checks.
It is strongly recommended to do a dry run prior to actual submission and if necessary work with a Data Wrangler to correct any errors.
If there are uuid, alias, @id, or accession fields in the excel form that match existing entries in the database, you will be asked if you want to PATCH each object.
You can use the `--patchall` flag, if you want to patch ALL objects in your document and ignore that message.
If no object identifiers are found in the document, you need to use `--update` for POSTing to occur.
**Other Helpful Advanced parameters**
Normally you are asked to verify the **Lab** and **Award** that you are submitting for. In some cases it may be desirable to skip this prompt so a submission
can be run by a scheduler or in the background:
`--remote` is an option that will skip any prompt before submission
**However** if you submit for more than one Lab or there is more than one Award associated with your lab you will need to specify these values
as parameters using `--lab` and/or `--award` followed by the uuids for the appropriate items.
<img src="https://media.giphy.com/media/l0HlN5Y28D9MzzcRy/giphy.gif" width="200" height="200" />
# Development
Note if you are attempting to run the scripts in the wranglertools directory without installing the package then in order to get the correct sys.path you need to run the scripts from the parent directory using the following command format:
```
python -m wranglertools.get_field_info —-type Biosource
python -m wranglertools.import_data filename.xlsx
```
pypi page is - https://pypi.python.org/pypi/Submit4DN
Submit4DN is packaged with poetry. New versions can be released and submitted to pypi using `poetry publish`
# Pytest
Every function is tested by pytest implementation. It can be run in terminal in submit4dn folder by:
py.test
Some tests need internet access, and labeled with "webtest" mark.
Some tests have file operations, and labeled with "file_operation" mark.
To run the mark tests, or exclude them from the tests you can use the following commands:
# Run all tests
py.test
# Run only webtest
py.test -m webtest
# Run only tests with file_operation
py.test -m file_operation
# skip tests that use ftp (do this when testing locally)
py.test -m "not ftp"
%package -n python3-submit4dn
Summary: Utility package for submitting data to the 4DN Data Portal
Provides: python-submit4dn
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-submit4dn
# Submit 4DN - Data Submitter Tools
[](https://travis-ci.org/4dn-dcic/Submit4DN)
[](https://coveralls.io/github/4dn-dcic/Submit4DN?branch=master)
[](https://www.codacy.com/app/jeremy_7/Submit4DN)
[](https://badge.fury.io/py/Submit4DN)
The Submit4DN package is written by the [4DN Data Coordination and Integration Center](http://dcic.4dnucleome.org/) for data submitters from the 4DN Network. Please [contact us](mailto:support@4dnucleome.org) to get access to the system, or if you have any questions or suggestions. Detailed documentation on data submission can be found [at this link](https://data.4dnucleome.org/help/submitter-guide/getting-started-with-submissions)
## Installing the package
```
pip install submit4dn
```
To upgrade to the latest version
```
pip install submit4dn --upgrade
```
### Troubleshooting
This package is not supported on older Python versions and is supported and tested for versions 3.7 - 3.9. It may work with other python versions but your mileage may vary.
It is recommended to install this package in a virtual environment to avoid dependency clashes.
Problems have been reported on recent MacOS X and Windows versions having to do with the inablity to find `libmagic`,
a C library to check file types that is used by the `python-magic` library.
eg. `ImportError: failed to find libmagic. Check your installation`
First thing to try is:
```
pip uninstall python-magic
pip install python-magic
```
If that doesn't work one solution that has worked for some from [here](https://github.com/Yelp/elastalert/issues/1927):
```
pip uninstall python-magic
pip install python-magic-bin==0.4.14
```
Others have had success using homebrew to install `libmagic`:
```
brew install libmagic
brew link libmagic (if the link is already created is going to fail, don't worry about that)
```
Additionally, problems have been reported on Windows when installing Submit4DN
inside a virtual environment, due to `aws` trying to use the global python instead
of the python inside the virtual environment.
The workaround, then, because it’s actually OK if `aws` doesn’t use the python
inside the virtual environment, is to just install `awscli` in the global
environment before entering the virtual environment. Or if you discover the
problem after you’re in, then go outside, install `awscli`, and re-enter the
virtual environment.
```
deactivate
pip install awscli
VENV\scripts\activate # replace VENV with your virtual environment name
aws --version # this is to test that awscli is now installed correctly
```
## Connecting to the Data Portal
To be able to use the provided tools, you need to generate an AccessKey on the [data portal](https://data.4dnucleome.org/).
If you do not yet have access, please contact [4DN Data Wranglers](mailto:support@4dnucleome.org)
to get an account and [learn how to generate and save a key](https://data.4dnucleome.org/help/submitter-guide/getting-started-with-submissions#getting-connection-keys-for-the-4dn-dcic-servers).
## Generating data submission forms
To create the data submission excel workbook, you can use `get_field_info`.
It will accept the following parameters:
~~~~
--keyfile the path to the file where you have stored your access key info (default ~/keypairs.json)
--key the name of the key identifier for the access key and secret in your keys file (default=default)
--type use for each sheet that you want to add to the excel workbook
--nodesc do not add the descriptions in the second line (by default they are added)
--noenums do not add the list of options for a field if they are specified (by default they are added)
--comments adds any (usually internal) comments together with enums (by default False)
--outfile change the default file name "fields.xlsx" to a specified one
--debug to add more debugging output
--noadmin if you have admin access to 4DN this option lets you generate the sheet as a non-admin user
~~~~
Examples generating a single sheet:
~~~~
get_field_info --type Biosample
get_field_info --type Biosample --comments
get_field_info --type Biosample --comments --outfile biosample.xlsx
~~~~
Example Workbook with all sheets:
~~~~
get_field_info --outfile MetadataSheets.xlsx
~~~~
Examples for Workbooks using a preset option:
~~~~
get_field_info --type HiC --comments --outfile exp_hic_generic.xlsx
get_field_info --type ChIP-seq --comments --outfile exp_chipseq_generic.xlsx
get_field_info --type FISH --comments --outfile exp_fish_generic.xlsx
~~~~
Current presets include: `Hi-C, ChIP-seq, Repli-seq, ATAC-seq, DamID, ChIA-PET, Capture-C, FISH, SPT`
## Data submission
Please refer to the [submission guidelines](https://data.4dnucleome.org/help/submitter-guide) and become familiar with the metadata structure prior to submission.
After you fill out the data submission forms, you can use `import_data` to submit the metadata. The method can be used both to create new metadata items and to patch fields of existing items.
~~~~
import_data filename.xlsx
~~~~
#### Uploading vs Patching
Runnning `import_data` without one of the flags described below will perform a dry run submission that will include several validation checks.
It is strongly recommended to do a dry run prior to actual submission and if necessary work with a Data Wrangler to correct any errors.
If there are uuid, alias, @id, or accession fields in the excel form that match existing entries in the database, you will be asked if you want to PATCH each object.
You can use the `--patchall` flag, if you want to patch ALL objects in your document and ignore that message.
If no object identifiers are found in the document, you need to use `--update` for POSTing to occur.
**Other Helpful Advanced parameters**
Normally you are asked to verify the **Lab** and **Award** that you are submitting for. In some cases it may be desirable to skip this prompt so a submission
can be run by a scheduler or in the background:
`--remote` is an option that will skip any prompt before submission
**However** if you submit for more than one Lab or there is more than one Award associated with your lab you will need to specify these values
as parameters using `--lab` and/or `--award` followed by the uuids for the appropriate items.
<img src="https://media.giphy.com/media/l0HlN5Y28D9MzzcRy/giphy.gif" width="200" height="200" />
# Development
Note if you are attempting to run the scripts in the wranglertools directory without installing the package then in order to get the correct sys.path you need to run the scripts from the parent directory using the following command format:
```
python -m wranglertools.get_field_info —-type Biosource
python -m wranglertools.import_data filename.xlsx
```
pypi page is - https://pypi.python.org/pypi/Submit4DN
Submit4DN is packaged with poetry. New versions can be released and submitted to pypi using `poetry publish`
# Pytest
Every function is tested by pytest implementation. It can be run in terminal in submit4dn folder by:
py.test
Some tests need internet access, and labeled with "webtest" mark.
Some tests have file operations, and labeled with "file_operation" mark.
To run the mark tests, or exclude them from the tests you can use the following commands:
# Run all tests
py.test
# Run only webtest
py.test -m webtest
# Run only tests with file_operation
py.test -m file_operation
# skip tests that use ftp (do this when testing locally)
py.test -m "not ftp"
%package help
Summary: Development documents and examples for submit4dn
Provides: python3-submit4dn-doc
%description help
# Submit 4DN - Data Submitter Tools
[](https://travis-ci.org/4dn-dcic/Submit4DN)
[](https://coveralls.io/github/4dn-dcic/Submit4DN?branch=master)
[](https://www.codacy.com/app/jeremy_7/Submit4DN)
[](https://badge.fury.io/py/Submit4DN)
The Submit4DN package is written by the [4DN Data Coordination and Integration Center](http://dcic.4dnucleome.org/) for data submitters from the 4DN Network. Please [contact us](mailto:support@4dnucleome.org) to get access to the system, or if you have any questions or suggestions. Detailed documentation on data submission can be found [at this link](https://data.4dnucleome.org/help/submitter-guide/getting-started-with-submissions)
## Installing the package
```
pip install submit4dn
```
To upgrade to the latest version
```
pip install submit4dn --upgrade
```
### Troubleshooting
This package is not supported on older Python versions and is supported and tested for versions 3.7 - 3.9. It may work with other python versions but your mileage may vary.
It is recommended to install this package in a virtual environment to avoid dependency clashes.
Problems have been reported on recent MacOS X and Windows versions having to do with the inablity to find `libmagic`,
a C library to check file types that is used by the `python-magic` library.
eg. `ImportError: failed to find libmagic. Check your installation`
First thing to try is:
```
pip uninstall python-magic
pip install python-magic
```
If that doesn't work one solution that has worked for some from [here](https://github.com/Yelp/elastalert/issues/1927):
```
pip uninstall python-magic
pip install python-magic-bin==0.4.14
```
Others have had success using homebrew to install `libmagic`:
```
brew install libmagic
brew link libmagic (if the link is already created is going to fail, don't worry about that)
```
Additionally, problems have been reported on Windows when installing Submit4DN
inside a virtual environment, due to `aws` trying to use the global python instead
of the python inside the virtual environment.
The workaround, then, because it’s actually OK if `aws` doesn’t use the python
inside the virtual environment, is to just install `awscli` in the global
environment before entering the virtual environment. Or if you discover the
problem after you’re in, then go outside, install `awscli`, and re-enter the
virtual environment.
```
deactivate
pip install awscli
VENV\scripts\activate # replace VENV with your virtual environment name
aws --version # this is to test that awscli is now installed correctly
```
## Connecting to the Data Portal
To be able to use the provided tools, you need to generate an AccessKey on the [data portal](https://data.4dnucleome.org/).
If you do not yet have access, please contact [4DN Data Wranglers](mailto:support@4dnucleome.org)
to get an account and [learn how to generate and save a key](https://data.4dnucleome.org/help/submitter-guide/getting-started-with-submissions#getting-connection-keys-for-the-4dn-dcic-servers).
## Generating data submission forms
To create the data submission excel workbook, you can use `get_field_info`.
It will accept the following parameters:
~~~~
--keyfile the path to the file where you have stored your access key info (default ~/keypairs.json)
--key the name of the key identifier for the access key and secret in your keys file (default=default)
--type use for each sheet that you want to add to the excel workbook
--nodesc do not add the descriptions in the second line (by default they are added)
--noenums do not add the list of options for a field if they are specified (by default they are added)
--comments adds any (usually internal) comments together with enums (by default False)
--outfile change the default file name "fields.xlsx" to a specified one
--debug to add more debugging output
--noadmin if you have admin access to 4DN this option lets you generate the sheet as a non-admin user
~~~~
Examples generating a single sheet:
~~~~
get_field_info --type Biosample
get_field_info --type Biosample --comments
get_field_info --type Biosample --comments --outfile biosample.xlsx
~~~~
Example Workbook with all sheets:
~~~~
get_field_info --outfile MetadataSheets.xlsx
~~~~
Examples for Workbooks using a preset option:
~~~~
get_field_info --type HiC --comments --outfile exp_hic_generic.xlsx
get_field_info --type ChIP-seq --comments --outfile exp_chipseq_generic.xlsx
get_field_info --type FISH --comments --outfile exp_fish_generic.xlsx
~~~~
Current presets include: `Hi-C, ChIP-seq, Repli-seq, ATAC-seq, DamID, ChIA-PET, Capture-C, FISH, SPT`
## Data submission
Please refer to the [submission guidelines](https://data.4dnucleome.org/help/submitter-guide) and become familiar with the metadata structure prior to submission.
After you fill out the data submission forms, you can use `import_data` to submit the metadata. The method can be used both to create new metadata items and to patch fields of existing items.
~~~~
import_data filename.xlsx
~~~~
#### Uploading vs Patching
Runnning `import_data` without one of the flags described below will perform a dry run submission that will include several validation checks.
It is strongly recommended to do a dry run prior to actual submission and if necessary work with a Data Wrangler to correct any errors.
If there are uuid, alias, @id, or accession fields in the excel form that match existing entries in the database, you will be asked if you want to PATCH each object.
You can use the `--patchall` flag, if you want to patch ALL objects in your document and ignore that message.
If no object identifiers are found in the document, you need to use `--update` for POSTing to occur.
**Other Helpful Advanced parameters**
Normally you are asked to verify the **Lab** and **Award** that you are submitting for. In some cases it may be desirable to skip this prompt so a submission
can be run by a scheduler or in the background:
`--remote` is an option that will skip any prompt before submission
**However** if you submit for more than one Lab or there is more than one Award associated with your lab you will need to specify these values
as parameters using `--lab` and/or `--award` followed by the uuids for the appropriate items.
<img src="https://media.giphy.com/media/l0HlN5Y28D9MzzcRy/giphy.gif" width="200" height="200" />
# Development
Note if you are attempting to run the scripts in the wranglertools directory without installing the package then in order to get the correct sys.path you need to run the scripts from the parent directory using the following command format:
```
python -m wranglertools.get_field_info —-type Biosource
python -m wranglertools.import_data filename.xlsx
```
pypi page is - https://pypi.python.org/pypi/Submit4DN
Submit4DN is packaged with poetry. New versions can be released and submitted to pypi using `poetry publish`
# Pytest
Every function is tested by pytest implementation. It can be run in terminal in submit4dn folder by:
py.test
Some tests need internet access, and labeled with "webtest" mark.
Some tests have file operations, and labeled with "file_operation" mark.
To run the mark tests, or exclude them from the tests you can use the following commands:
# Run all tests
py.test
# Run only webtest
py.test -m webtest
# Run only tests with file_operation
py.test -m file_operation
# skip tests that use ftp (do this when testing locally)
py.test -m "not ftp"
%prep
%autosetup -n submit4dn-3.3.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-submit4dn -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Thu Jun 08 2023 Python_Bot <Python_Bot@openeuler.org> - 3.3.0-1
- Package Spec generated
|