Skip to content

Create analysis from user default #1040

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
90339fd
skeleton for demoing
squirrelo Mar 20, 2015
72267a0
add conformation to removing proc data
squirrelo Mar 25, 2015
10f077d
Merge branch 'master' of https://github.com/biocore/qiita into cart-a…
squirrelo Mar 28, 2015
f1ca570
add patch to create default analyses for all existing users
squirrelo Mar 28, 2015
e362c25
add default analysis on user creation
squirrelo Mar 28, 2015
cfe9ba2
streamline UI for cart
squirrelo Mar 30, 2015
28f8480
further refining IU
squirrelo Mar 30, 2015
f0c3f80
add default analyses using only SQL
squirrelo Mar 31, 2015
6d30936
changes to tests to reflect patch
squirrelo Mar 31, 2015
4f3756f
fix more tests, add analysis_workflow steps for carts
squirrelo Mar 31, 2015
b5bf4ed
update user private_analyses to ignore default cart
squirrelo Mar 31, 2015
68488c7
update test again to reflect change
squirrelo Mar 31, 2015
90b3de2
merge upstream/master
squirrelo Apr 1, 2015
bd3d513
Merge branch 'master' of https://github.com/biocore/qiita into cart-a…
squirrelo Apr 2, 2015
f5026f8
move default analysis pull to user object
squirrelo Apr 2, 2015
874632b
implement the default_analysis in qiita_pet
squirrelo Apr 2, 2015
ddf2ff4
more comments addressed
squirrelo Apr 2, 2015
1dc1440
pep8
squirrelo Apr 2, 2015
cf1123f
remove magic numbers from tests
squirrelo Apr 2, 2015
15c71dc
replace processed_date retriveal
squirrelo Apr 3, 2015
8e129e6
add info modal for proc data
squirrelo Apr 3, 2015
e784006
more UI changes
squirrelo Apr 3, 2015
d7b4778
couple small UI changes
squirrelo Apr 3, 2015
ba42c6a
use info glyph
squirrelo Apr 3, 2015
dc9ff3a
add from_default flag for analysis creation
squirrelo Apr 6, 2015
2274b0d
queue analysis creation
squirrelo Apr 6, 2015
d8f4738
Merge branch 'cart-analysis-changes' into create-analysis-from-cart
squirrelo Apr 6, 2015
bc9321a
fix queues and tests
squirrelo Apr 6, 2015
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
Prev Previous commit
Next Next commit
changes to tests to reflect patch
  • Loading branch information
squirrelo committed Mar 31, 2015
commit 6d309368d2d6edaae286d2f3e6205baa3df9666a
4 changes: 2 additions & 2 deletions qiita_db/support_files/populate_test_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ INSERT INTO qiita.collection_job (collection_id, job_id) VALUES (1, 1);
--share collection with shared user
INSERT INTO qiita.collection_users (email, collection_id) VALUES ('shared@foo.bar', 1);

--add default analysis for test user
INSERT INTO qiita.analysis (email, name, description, dflt, analysis_status_id) VALUES ('test@foo.bar', 'test@foo.bar-dflt', 'dflt', true, 1);
--add default analysis for users
INSERT INTO qiita.analysis (email, name, description, dflt, analysis_status_id) VALUES ('test@foo.bar', 'test@foo.bar-dflt', 'dflt', true, 1), ('admin@foo.bar', 'admin@foo.bar-dflt', 'dflt', true, 1), ('shared@foo.bar', 'shared@foo.bar-dflt', 'dflt', true, 1), ('demo@microbio.me', 'demo@microbio.me-dflt', 'dflt', true, 1);

-- Attach samples to analysis
INSERT INTO qiita.analysis_sample (analysis_id, processed_data_id, sample_id) VALUES (3,1,'1.SKD8.640184'), (3,1,'1.SKB7.640196'), (3,1,'1.SKM9.640192'), (3,1,'1.SKM4.640180')
29 changes: 17 additions & 12 deletions qiita_db/test/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def test_get_by_status(self):
self.analysis.status = "public"
self.assertEqual(Analysis.get_by_status('public'), {1})

def test_get_user_default(self):
obs = Analysis.get_user_default(User('admin@foo.bar'))
exp = Analysis(4)
self.assertEqual(obs.id, exp.id)

def test_has_access_public(self):
self.conn_handler.execute("UPDATE qiita.analysis SET "
"analysis_status_id = 6")
Expand All @@ -95,12 +100,12 @@ def test_create(self):

new = Analysis.create(User("admin@foo.bar"), "newAnalysis",
"A New Analysis")
self.assertEqual(new.id, 3)
self.assertEqual(new.id, 7)
sql = ("SELECT analysis_id, email, name, description, "
"analysis_status_id, pmid, EXTRACT(EPOCH FROM timestamp) "
"FROM qiita.analysis WHERE analysis_id = 3")
"FROM qiita.analysis WHERE analysis_id = 7")
obs = self.conn_handler.execute_fetchall(sql)
self.assertEqual(obs[0][:-1], [3, 'admin@foo.bar', 'newAnalysis',
self.assertEqual(obs[0][:-1], [7, 'admin@foo.bar', 'newAnalysis',
'A New Analysis', 1, None])
self.assertTrue(time1 < float(obs[0][-1]))

Expand All @@ -110,18 +115,18 @@ def test_create_parent(self):

new = Analysis.create(User("admin@foo.bar"), "newAnalysis",
"A New Analysis", Analysis(1))
self.assertEqual(new.id, 3)
self.assertEqual(new.id, 7)
sql = ("SELECT analysis_id, email, name, description, "
"analysis_status_id, pmid, EXTRACT(EPOCH FROM timestamp) "
"FROM qiita.analysis WHERE analysis_id = 3")
"FROM qiita.analysis WHERE analysis_id = 7")
obs = self.conn_handler.execute_fetchall(sql)
self.assertEqual(obs[0][:-1], [3, 'admin@foo.bar', 'newAnalysis',
self.assertEqual(obs[0][:-1], [7, 'admin@foo.bar', 'newAnalysis',
'A New Analysis', 1, None])
self.assertTrue(time1 < float(obs[0][-1]))

sql = "SELECT * FROM qiita.analysis_chain WHERE child_id = 3"
sql = "SELECT * FROM qiita.analysis_chain WHERE child_id = 7"
obs = self.conn_handler.execute_fetchall(sql)
self.assertEqual(obs, [[1, 3]])
self.assertEqual(obs, [[1, 7]])

def test_retrieve_owner(self):
self.assertEqual(self.analysis.owner, "test@foo.bar")
Expand Down Expand Up @@ -245,18 +250,18 @@ def test_set_step(self):
new = Analysis.create(User("admin@foo.bar"), "newAnalysis",
"A New Analysis", Analysis(1))
new.step = 2
sql = "SELECT * FROM qiita.analysis_workflow WHERE analysis_id = 3"
sql = "SELECT * FROM qiita.analysis_workflow WHERE analysis_id = 7"
obs = self.conn_handler.execute_fetchall(sql)
self.assertEqual(obs, [[3, 2]])
self.assertEqual(obs, [[7, 2]])

def test_set_step_twice(self):
new = Analysis.create(User("admin@foo.bar"), "newAnalysis",
"A New Analysis", Analysis(1))
new.step = 2
new.step = 4
sql = "SELECT * FROM qiita.analysis_workflow WHERE analysis_id = 3"
sql = "SELECT * FROM qiita.analysis_workflow WHERE analysis_id = 7"
obs = self.conn_handler.execute_fetchall(sql)
self.assertEqual(obs, [[3, 4]])
self.assertEqual(obs, [[7, 4]])

def test_retrieve_step(self):
new = Analysis.create(User("admin@foo.bar"), "newAnalysis",
Expand Down
6 changes: 3 additions & 3 deletions qiita_db/test/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ def test_create_exists_return_existing(self):
self.conn_handler.execute(
"INSERT INTO qiita.analysis_sample "
"(analysis_id, processed_data_id, sample_id) VALUES "
"(3, 1, '1.SKB8.640193'), (3, 1, '1.SKD8.640184'), "
"(3, 1, '1.SKB7.640196'), (3, 1, '1.SKM9.640192'), "
"(3, 1, '1.SKM4.640180')")
"(7, 1, '1.SKB8.640193'), (7, 1, '1.SKD8.640184'), "
"(7, 1, '1.SKB7.640196'), (7, 1, '1.SKM9.640192'), "
"(7, 1, '1.SKM4.640180')")
new = Job.create("18S", "Beta Diversity",
{"--otu_table_fp": 1, "--mapping_fp": 1},
Analysis(3), return_existing=True)
Expand Down
6 changes: 2 additions & 4 deletions qiita_db/test/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

from unittest import TestCase, main

from qiita_core.util import qiita_test_checker
from qiita_db.util import get_count, check_count


@qiita_test_checker()
class SetupTest(TestCase):
"""Tests that the test database have been successfully populated"""

Expand Down Expand Up @@ -111,7 +109,7 @@ def test_job(self):
self.assertEqual(get_count("qiita.job"), 3)

def test_analysis(self):
self.assertEqual(get_count("qiita.analysis"), 2)
self.assertEqual(get_count("qiita.analysis"), 6)

def test_analysis_job(self):
self.assertEqual(get_count("qiita.analysis_job"), 3)
Expand All @@ -123,7 +121,7 @@ def test_analysis_filepath(self):
self.assertEqual(get_count("qiita.analysis_filepath"), 2)

def test_analysis_sample(self):
self.assertEqual(get_count("qiita.analysis_sample"), 9)
self.assertEqual(get_count("qiita.analysis_sample"), 13)

def test_analysis_users(self):
self.assertEqual(get_count("qiita.analysis_users"), 1)
Expand Down
2 changes: 1 addition & 1 deletion qiita_db/test/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def test_get_shared_studies(self):
self.assertEqual(user.shared_studies, {1})

def test_get_private_analyses(self):
self.assertEqual(self.user.private_analyses, set([]))
self.assertEqual(self.user.private_analyses, set([4]))

def test_get_shared_analyses(self):
self.assertEqual(self.user.shared_analyses, set([]))
Expand Down
6 changes: 3 additions & 3 deletions qiita_pet/templates/analysis_selected.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ <h2><a href="/study/description/{{sid}}">{{study.title}}</a></h2>
</tr>
{% for pid, samples in viewitems(proc_datas) %}
<tr id="proc{{pid}}">
<td><a href="#" onclick = 'remove_proc_data({{pid}}, {{sid}})'>Remove</a></td>
<td><a href="#" onclick="$('#proc{{pid}}-samples').toggle(); return false;">Show/Hide samples</a></td>
<td>{{pid}}</td>
<td>{{proc_info[pid]["data_type"]}}</td>
<td>{{proc_info[pid]["processed_date"]}}</td>
<td>{{proc_info[pid]["algorithm"]}}</td>
<td>{{proc_info[pid]["reference_name"]}} {{proc_info[pid]["reference_version"]}}</td>
<td><a href="#" onclick="$('#proc{{pid}}-samples').toggle(); return false;">Show/Hide samples</a></td>
<td><a href="#" onclick = 'remove_proc_data({{pid}}, {{sid}})'>Remove</a></td>
</tr>
<tr id="proc{{pid}}-samples" hidden><td colspan=7>
<table class="table table-striped sample-table" id="proc{{pid}}-samples-table" style="width:50%">
{% for samp in samples %}
<tr id="{{pid}}@{{samp}}"><td><a href="#" onclick="remove_sample('{{sid}}', '{{pid}}', '{{samp}}')">Remove</a></td><td>{{samp}}</td></tr>
<tr id="{{pid}}@{{samp}}"><td>{{samp}}</td><td><a href="#" onclick="remove_sample('{{sid}}', '{{pid}}', '{{samp}}')">Remove</a></td></tr>
{% end %}
</table>
</td></tr>
Expand Down