Skip to content

Commit

Permalink
Sync-ing with master (again) (#2073)
Browse files Browse the repository at this point in the history
* fix #1505

* improving some GUI stuff

* improving some GUI stuff - missing lines

* addressing all comments

* ready for review

* fix #1987

* initial commit

* requested changes

* fix filter job list

* Fixing server cert (#2051)

* fix get_studies

* flake8

* fix #503

* fix #2010

* fix #1913

* fix errors

* addressing @josenavas comment

* flake8

* fix #1010

* fix #1066 (#2058)

* addressing @josenavas comments

* fix #1961

* fix #1837

* Automatic jobs & new stats (#2057)

* fix #814, fix #1636

* fixing error in test-env

* fixing stats.html call

* adding img

* addressing @josenavas comments

* rm for loops

* addresssing @ElDeveloper comments

* generalizing this functionality

* fix #1816

* fix #1959

* addressing @josenavas comments

* addressing @josenavas comments

* fixing error

* fixed?

* addressing @josenavas comments

* addressing @wasade comments

* fix flake8

* generate biom and metadata release (#2066)

* initial commit

* adding portal

* addressing @josenavas comments

* pid -> qiita_artifact_id

* addressing @josenavas comments

* addressing @ElDeveloper comments

* rm 50.sql

* database changes to fix 969

* adding delete

* addressing @josenavas comments

* addressing @ElDeveloper comments

* duh!

* fix generate_biom_and_metadata_release (#2072)

* fix generate_biom_and_metadata_release

* addressing @ElDeveloper comment
  • Loading branch information
josenavas authored and antgonza committed Feb 8, 2017
1 parent 3fdb802 commit 1377640
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
1 change: 1 addition & 0 deletions qiita_db/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ def _associate_with_analysis(instance, analysis_id):
instance.visibility = 'private'
else:
instance.visibility = 'public'

elif prep_template:
# This artifact is uploaded by the user in the
# processing pipeline
Expand Down
1 change: 1 addition & 0 deletions qiita_db/test/test_meta_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_validate_filepath_access_by_user(self):
for i in [1, 2, 3, 4, 5, 9, 12, 17, 18, 19, 20, 21]:
self.assertFalse(qdb.meta_util.validate_filepath_access_by_user(
user, i))

for i in [15, 16]:
self.assertTrue(qdb.meta_util.validate_filepath_access_by_user(
user, i))
Expand Down
56 changes: 56 additions & 0 deletions qiita_db/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,62 @@ def test_generate_biom_and_metadata_release(self):
'FASTQ\n']
self.assertEqual(txt_obs, txt_exp)

# whatever the configuration was, we will change to settings so we can
# test the other option when dealing with the end '/'
with qdb.sql_connection.TRN:
qdb.sql_connection.TRN.add(
"SELECT base_data_dir FROM settings")
obdr = qdb.sql_connection.TRN.execute_fetchlast()
if obdr[-1] == '/':
bdr = obdr[:-1]
else:
bdr = obdr + '/'

qdb.sql_connection.TRN.add(
"UPDATE settings SET base_data_dir = '%s'" % bdr)
bdr = qdb.sql_connection.TRN.execute()

tgz, txt = qdb.util.generate_biom_and_metadata_release('private')
self.files_to_remove.extend([tgz, txt])

tmp = topen(tgz, "r:gz")
tgz_obs = [ti.name for ti in tmp]
tmp.close()
tgz_exp = [
'processed_data/1_study_1001_closed_reference_otu_table.biom',
'templates/1_19700101-000000.txt',
'templates/1_prep_1_19700101-000000.txt',
'processed_data/1_study_1001_closed_reference_otu_table.biom',
'templates/1_19700101-000000.txt',
'templates/1_prep_1_19700101-000000.txt',
'processed_data/1_study_1001_closed_reference_otu_table_'
'Silva.biom', 'templates/1_19700101-000000.txt',
'templates/1_prep_1_19700101-000000.txt']
self.assertEqual(tgz_obs, tgz_exp)

tmp = open(txt)
txt_obs = tmp.readlines()
tmp.close()
txt_exp = [
'biom_fp\tsample_fp\tprep_fp\tqiita_artifact_id\tcommand\n',
'processed_data/1_study_1001_closed_reference_otu_table.biom\ttem'
'plates/1_19700101-000000.txt\ttemplates/1_prep_1_19700101-000000'
'.txt\t4\tPick closed-reference OTUs, Split libraries FASTQ\n',
'processed_data/1_study_1001_closed_reference_otu_table.biom\ttem'
'plates/1_19700101-000000.txt\ttemplates/1_prep_1_19700101-000000'
'.txt\t5\tPick closed-reference OTUs, Split libraries FASTQ\n',
'processed_data/1_study_1001_closed_reference_otu_table_Silva.bio'
'm\ttemplates/1_19700101-000000.txt\ttemplates/1_prep_1_19700101-'
'000000.txt\t6\tPick closed-reference OTUs, Split libraries '
'FASTQ\n']
self.assertEqual(txt_obs, txt_exp)

# returning configuration
with qdb.sql_connection.TRN:
qdb.sql_connection.TRN.add(
"UPDATE settings SET base_data_dir = '%s'" % obdr)
bdr = qdb.sql_connection.TRN.execute()


@qiita_test_checker()
class UtilTests(TestCase):
Expand Down
11 changes: 3 additions & 8 deletions qiita_db/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,14 +1531,11 @@ def generate_biom_and_metadata_release(study_status='public'):
working_dir = qiita_config.working_dir
portal = qiita_config.portal
bdir = qdb.util.get_db_files_base_dir()
bdir_len = len(bdir) + 1

data = []
for s in studies:
# [0] latest is first, [1] only getting the filepath
sample_fp = s.sample_template.get_filepaths()[0][1]
if sample_fp.startswith(bdir):
sample_fp = sample_fp[bdir_len:]
sample_fp = relpath(s.sample_template.get_filepaths()[0][1], bdir)

for a in s.artifacts(artifact_type='BIOM'):
if a.processing_parameters is None:
Expand All @@ -1562,16 +1559,14 @@ def generate_biom_and_metadata_release(study_status='public'):
for _, fp, fp_type in a.filepaths:
if fp_type != 'biom' or 'only-16s' in fp:
continue
if fp.startswith(bdir):
fp = fp[bdir_len:]
fp = relpath(fp, bdir)
# format: (biom_fp, sample_fp, prep_fp, qiita_artifact_id,
# human readable name)
for pt in a.prep_templates:
for _, prep_fp in pt.get_filepaths():
if 'qiime' not in prep_fp:
break
if prep_fp.startswith(bdir):
prep_fp = prep_fp[bdir_len:]
prep_fp = relpath(prep_fp, bdir)
data.append((fp, sample_fp, prep_fp, a.id, human_cmd))

# writing text and tgz file
Expand Down

0 comments on commit 1377640

Please sign in to comment.