Skip to content

Commit aff1548

Browse files
committed
merge with current master
2 parents 9361f9f + 434be98 commit aff1548

File tree

6 files changed

+71
-27
lines changed

6 files changed

+71
-27
lines changed

qiita_pet/handlers/study_handlers/base.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def get(self, study_id):
2323
study = to_int(study_id)
2424
level = self.get_argument('level', '')
2525
message = self.get_argument('message', '')
26+
prep_id = self.get_argument('prep_id', default=None)
2627

2728
study_info = study_get_req(study, self.current_user.id)
2829
if study_info['status'] != 'success':
@@ -32,6 +33,25 @@ def get(self, study_id):
3233
study_info['level'] = level
3334
study_info['message'] = message
3435

36+
if prep_id:
37+
msg = f"'{prep_id}' is not a valid preparation for this study"
38+
study_info['study_info']['prep_id'] = to_int(prep_id, msg)
39+
40+
# prep_id is an integer - confirm that it's a valid prep_id.
41+
prep_info = study_prep_get_req(study, self.current_user.id)
42+
if prep_info['status'] != 'success':
43+
raise HTTPError(404, reason=prep_info['message'])
44+
45+
prep_ids = []
46+
for prep_type in prep_info['info']:
47+
# prep_type will be either '18S', '16S', or similarly named.
48+
# generate a list of prep-ids from the preps in each list.
49+
prep_ids += [x['id'] for x in prep_info['info'][prep_type]]
50+
51+
if study_info['study_info']['prep_id'] not in prep_ids:
52+
raise HTTPError(400, reason=(f"'{prep_id}' is not a valid "
53+
"preparation for this study"))
54+
3555
self.render("study_base.html", **study_info)
3656

3757

qiita_pet/handlers/study_handlers/tests/test_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ class StudyIndexHandlerTests(TestHandlerBase):
1717
def test_get_exists(self):
1818
response = self.get('/study/description/1')
1919
self.assertEqual(response.code, 200)
20+
self.assertTrue('study/description/baseinfo' in str(response.body))
2021

2122
def test_get_no_exists(self):
2223
response = self.get('/study/description/245')
2324
self.assertEqual(response.code, 404)
2425

26+
def test_get_prep_page(self):
27+
response = self.get('/study/description/1?prep_id=1')
28+
self.assertEqual(response.code, 200)
29+
self.assertTrue('study/description/prep_template' in
30+
str(response.body))
31+
2532

2633
class StudyBaseInfoAJAX(TestHandlerBase):
2734
# TODO: Missing tests

qiita_pet/handlers/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def download_link_or_path(is_local_request, filepath, fp_id, label):
8181
linkify, "<a target=\"_blank\" href=\"http://dx.doi.org/{0}\">{0}</a>")
8282

8383

84-
def to_int(value):
84+
def to_int(value, reason=None):
8585
"""Transforms `value` to an integer
8686
8787
Parameters
@@ -102,8 +102,9 @@ def to_int(value):
102102
try:
103103
res = int(value)
104104
except ValueError:
105-
raise HTTPError(400, reason="%s cannot be converted to an "
106-
"integer" % value)
105+
msg = f"{value} cannot be converted to an integer" if reason is None \
106+
else reason
107+
raise HTTPError(400, reason=msg)
107108
return res
108109

109110

qiita_pet/support_files/doc/source/processingdata/processing-recommendations.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Currently, Qiita supports the processing of raw data from:
66
#. Target gene barcoded sequencing
77
#. Shotgun sequencing
88
#. Metatranscriptome sequencing
9-
#. Genome Isolate sequencing
9+
#. Genome isolate sequencing
1010

1111
Note that the selected processing recommendations are mainly guided towards performing meta-analyses,
1212
this is combine different studies, even from different wet lab techniques or
@@ -63,19 +63,19 @@ The current workflow is as follows:
6363

6464
Note that we recommend only uploading sequences that have already been through QC and human sequence removal. However, we
6565
recommend that all sequence files go through adapter and host filtering within the system to ensure they are ready for
66-
subsequent meta-analyses. Currently, the `fastp` command is set to autodetect adaptors so this command is available for all different
67-
wetlab processing and we provide the following host references for your convenience:
68-
69-
- auto-detect adapters and artifacts + phix filtering: This is a `deblur artifacts <https://github.com/biocore/deblur/blob/master/deblur/support_files/artifacts.fa>`_ reference, mainly for debugging and testing
70-
- auto-detect adapters and `cheetah <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/003/709/585/GCF_003709585.1_Aci_jub_2/GCF_003709585.1_Aci_jub_2_genomic.fna.gz>`_ + phix filtering
71-
- auto-detect adapters and `cow <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/003/205/GCA_000003205.6_Btau_5.0.1/GCA_000003205.6_Btau_5.0.1_genomic.fna.gz>`_ + phix filtering
72-
- auto-detect adapters and `hamster <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/017/639/785/GCF_017639785.1_BCM_Maur_2.0/GCF_017639785.1_BCM_Maur_2.0_genomic.fna.gz>`_ + phix filtering
73-
- auto-detect adapters and `horse <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/002/305/GCA_000002305.1_EquCab2.0/GCA_000002305.1_EquCab2.0_genomic.fna.gz>`_ + phix filtering
74-
- auto-detect adapters and `mouse <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/635/GCF_000001635.27_GRCm39/GCF_000001635.27_GRCm39_genomic.fna.gz>`_ + phix filtering
75-
- auto-detect adapters and `pig <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/003/025/GCF_000003025.6_Sscrofa11.1/GCF_000003025.6_Sscrofa11.1_genomic.fna.gz>`_ + phix filtering
76-
- auto-detect adapters and `rabbit <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/003/625/GCF_000003625.3_OryCun2.0/GCF_000003625.3_OryCun2.0_genomic.fna.gz>`_ + phix filtering
77-
- auto-detect adapters and `rat <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/001/895/GCA_000001895.4_Rnor_6.0/GCA_000001895.4_Rnor_6.0_genomic.fna.gz>`_ + phix filtering
78-
- auto-detect adapters only filtering
66+
subsequent meta-analyses. We currently provide the several options for your convenience. For each the `fastp` command is set to autodetect and remove universal adapter sequences (i.e., 'GATCGGAAGAGCACACGTCTGAACTCCAGTCAC' for R1 reads and 'GATCGGAAGAGCGTCGTGTAGGGAAAGGAGTGT' for R2 reads). We also provide the following host reference genomes for filtering against; each also filters against three phi x sequences (i.e., `HM753704.1 <https://www.ncbi.nlm.nih.gov/nuccore/HM753704.1/>`_, `JF719728.1 <https://www.ncbi.nlm.nih.gov/nuccore/JF719728.1>`_, `J02482.1 <https://www.ncbi.nlm.nih.gov/nuccore/J02482.1>`_):
67+
68+
- auto-detect adapters and artifacts + phix filtering: This is a `deblur artifacts <https://github.com/biocore/deblur/blob/master/deblur/support_files/artifacts.fa>`_ reference, mainly for debugging and testing. Includes another adapter sequence (i.e., 'ATCTCGTATGCCGTCTTCTGC').
69+
- auto-detect adapters and **cheetah** + phix filtering. Includes cheetah (*Acinonyx jubatus*) reference `GCF_003709585.1 (Aci_jub_2) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_003709585.1/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/003/709/585/GCF_003709585.1_Aci_jub_2/GCF_003709585.1_Aci_jub_2_genomic.fna.gz>`_
70+
- auto-detect adapters and **cow** + phix filtering. Includes cow (*Bos taurus*) reference `GCF_000003205.7 (Btau_5.0.1) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000003205.7/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/003/205/GCA_000003205.6_Btau_5.0.1/GCA_000003205.6_Btau_5.0.1_genomic.fna.gz>`_
71+
- auto-detect adapters and **hamster** + phix filtering. Includes golden hamster (*Mesocricetus auratus*) reference `GCF_017639785.1 (BCM_Maur_2.0) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_017639785.1/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/017/639/785/GCF_017639785.1_BCM_Maur_2.0/GCF_017639785.1_BCM_Maur_2.0_genomic.fna.gz>`_
72+
- auto-detect adapters and **horse** + phix filtering. Includes horse (*Equus caballus*) reference `GCF_000002305.2 (EquCab2.0) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000002305.2/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/002/305/GCA_000002305.1_EquCab2.0/GCA_000002305.1_EquCab2.0_genomic.fna.gz>`_
73+
- auto-detect adapters and **merge_genomes** + phix filtering. Includes the genomes of cheetah, cow, hamster, horse, mouse, pig, rabbit, and rat described here.
74+
- auto-detect adapters and **mouse** + phix filtering. Includes house mouse (*Mus musculus*) reference `GCF_000001635.27 (GRCm39) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000001635.27/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/635/GCF_000001635.27_GRCm39/GCF_000001635.27_GRCm39_genomic.fna.gz>`_
75+
- auto-detect adapters and **pig** + phix filtering. Includes pig (*Sus scrofa*) reference `GCF_000003025.6 (Sscrofa11.1) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000003025.6/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/003/025/GCF_000003025.6_Sscrofa11.1/GCF_000003025.6_Sscrofa11.1_genomic.fna.gz>`_
76+
- auto-detect adapters and **rabbit** + phix filtering. Includes rabbit (*Oryctolagus cuniculus*) reference `GCF_000003625.3 (OryCun2.0) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000003625.3/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/003/625/GCF_000003625.3_OryCun2.0/GCF_000003625.3_OryCun2.0_genomic.fna.gz>`_
77+
- auto-detect adapters and **rat** + phix filtering. Includes Norway rat (*Rattus norvegicus*) reference `GCF_000001895.5 (Rnor_6.0) <https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000001895.5/>`_. `Download link <https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/001/895/GCA_000001895.4_Rnor_6.0/GCA_000001895.4_Rnor_6.0_genomic.fna.gz>`_
78+
- auto-detect adapters only filtering. Only includes the two adapter sequences noted above.
7979

8080
Note that the command produces up to 6 output artifacts based on the aligner and database selected:
8181

qiita_pet/templates/study_ajax/sample_prep_summary.html

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
var column_width_factor = 10;
77
var rows = {% raw list(rows.values()) %};
88
// setting up checkboxes
9-
var prep_colums = jQuery.map(
9+
var prep_columns = jQuery.map(
1010
Object.keys(rows[0]), function(e) { if (e.startsWith("prep")) return e });
1111
for(var i=0;i<rows.length;i++) {
1212
rows[i]['sample-delete'] = '';
@@ -19,13 +19,19 @@
1919
});
2020
}
2121
function toggleCheckbox(element){
22-
var checked = element.checked ? 'checked' : '';
23-
var row = $(element).prop('value');
24-
rows[row]["sample-delete"] = checked;
25-
}
22+
if(element['sample-delete'] == 'checked') {
23+
element['sample-delete'] = '';
24+
// if user clicks inside row and column, but not in checkbox, this will force checkbox to change.
25+
$('.sample-delete[name="' + element['sample'] + '"]').prop('checked', '');
26+
} else {
27+
element['sample-delete'] = 'checked';
28+
// if user clicks inside row and column, but not in checkbox, this will force checkbox to change.
29+
$('.sample-delete[name="' + element['sample'] + '"]').prop('checked', 'checked');
30+
};
31+
}
2632
function linkFormatter(row, cell, value, columnDef, dataContext) {
2733
{% if user_can_edit %}
28-
return "<input type='checkbox' class='sample-delete' value='" + row + "' name='" + rows[row]['sample'] + "' onchange='toggleCheckbox(this)' " + rows[row]['sample-delete'] + ">";
34+
return "<input type='checkbox' class='sample-delete' value='" + row + "' name='" + rows[row]['sample'] + "'>";
2935
{% else %}
3036
return ""
3137
{% end %}
@@ -44,7 +50,7 @@
4450
var to_delete = [];
4551
$.each(rows, function(i, row){
4652
var sample_delete = jQuery.map(
47-
prep_colums, function(pc) { if (row[pc] === 'X') return pc });
53+
prep_columns, function(pc) { if (row[pc] === 'X') return pc });
4854
if (sample_delete.length === 0){
4955
to_delete.push(row['sample'])
5056
}
@@ -64,15 +70,15 @@
6470

6571
// adding header
6672
var header = ['sample_name']
67-
$.each(prep_colums, function(i, prep){
73+
$.each(prep_columns, function(i, prep){
6874
header.push(prep_names[prep]);
6975
});
7076
information.push(header.join('\t'))
7177

7278
// adding data
7379
$.each(rows, function (i, row){
7480
var line = [row['sample']]
75-
$.each(prep_colums, function(i, prep){
81+
$.each(prep_columns, function(i, prep){
7682
line.push(row[prep]);
7783
});
7884
information.push(line.join('\t'));
@@ -116,6 +122,12 @@
116122
grid.invalidate();
117123
grid.render();
118124
});
125+
grid.onClick.subscribe(function(e, args){
126+
let cell = grid.getCellFromEvent(e);
127+
if(grid.getColumns()[cell.cell].id == "sample-delete") {
128+
toggleCheckbox(grid.getDataItem(cell.row))
129+
}
130+
});
119131

120132
function add_meta() {
121133
var metadata_category = $("#metadata_category").val();

qiita_pet/templates/study_base.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
// Populate the different sections of the page
6565
populate_data_type_menu_div();
6666
// The initial page to be shown is the base information of the study
67-
populate_main_div("{% raw qiita_config.portal_dir %}/study/description/baseinfo/", { study_id: {{study_info['study_id']}}});
67+
{% if 'prep_id' in study_info %}
68+
populate_main_div("{% raw qiita_config.portal_dir %}/study/description/prep_template/", { prep_id: {{study_info['prep_id']}}, study_id: {{study_info['study_id']}}});
69+
{% else %}
70+
populate_main_div("{% raw qiita_config.portal_dir %}/study/description/baseinfo/", { study_id: {{study_info['study_id']}}});
71+
{% end %}
6872

6973
{% if study_info['num_samples'] > 0 %}
7074
$("#sample-summary-btn").show();

0 commit comments

Comments
 (0)