Skip to content

Commit

Permalink
Merge pull request #1979 from antgonza/study-listing-no-ref
Browse files Browse the repository at this point in the history
Thanks @antgonza ! Study listing brakes when no ref
  • Loading branch information
josenavas committed Oct 31, 2016
2 parents 764f074 + 43899fb commit 071bef2
Show file tree
Hide file tree
Showing 14 changed files with 1,683 additions and 1,455 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
- TEST_ADD_STUDIES=True
before_install:
- redis-server --version
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/miniconda3/bin:$PATH
Expand Down
21 changes: 12 additions & 9 deletions qiita_db/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,20 +857,23 @@ def build_files(self,

# figuring out if we are going to have duplicated samples, again
# doing it here cause it's computational cheaper
# 1. merge samples per data_type, reference used and the command id
# if not one of the tables is not 'Pick closed-reference OTUs'
# it's safer to always rename. Note that grouped_samples is
# basically how many biom tables we are going to create
# 1. merge samples per: data_type, reference used and
# the command id
# Note that grouped_samples is basically how many biom tables we
# are going to create
rename_dup_samples = False
grouped_samples = {}
for k, v in viewitems(samples):
a = qdb.artifact.Artifact(k)
p = a.processing_parameters
c = p.command
if c.name != 'Pick closed-reference OTUs':
rename_dup_samples = True
break
l = "%s.%d.%d" % (a.data_type, p.values['reference'], c.id)
if p is not None and p.command is not None:
ref = (str(p.values['reference'])
if 'reference' in p.values else 'na')
cid = str(p.command.id)
else:
ref = 'na'
cid = 'na'
l = "%s.%s.%s" % (a.data_type, ref, cid)
if l not in grouped_samples:
grouped_samples[l] = []
grouped_samples[l].append((k, v))
Expand Down
20 changes: 12 additions & 8 deletions qiita_db/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ def exists(cls, datatype, command, options, analysis,
AND input_file_reference_id = %s
AND input_file_software_command_id = %s
""".format(cls._table)
rid = (input_file_reference.id
if input_file_reference is not None else None)
cid = (input_file_software_command.id
if input_file_software_command is not None else None)
qdb.sql_connection.TRN.add(
sql, [datatype_id, command_id, opts_json,
input_file_reference.id,
input_file_software_command.id])
sql, [datatype_id, command_id, opts_json, rid, cid])
analyses = qdb.sql_connection.TRN.execute_fetchindex()

if not analyses and return_existing:
Expand Down Expand Up @@ -289,10 +291,12 @@ def create(cls, datatype, command, options, analysis,
input_file_software_command_id)
VALUES (%s, %s, %s, %s, %s, %s)
RETURNING job_id""".format(cls._table)
rid = (input_file_reference.id
if input_file_reference is not None else None)
cid = (input_file_software_command.id
if input_file_software_command is not None else None)
qdb.sql_connection.TRN.add(
sql, [datatype_id, 1, command_id, opts_json,
input_file_reference.id,
input_file_software_command.id])
sql, [datatype_id, 1, command_id, opts_json, rid, cid])
job_id = qdb.sql_connection.TRN.execute_fetchlast()

# add job to analysis
Expand Down Expand Up @@ -359,8 +363,8 @@ def options(self):
db_comm = qdb.sql_connection.TRN.execute_fetchindex()[0]

out_opt = loads(db_comm[1])
basedir = qdb.util.get_db_files_base_dir()
join_f = partial(join, join(basedir, "job"))
_, mp, _ = qdb.util.get_mountpoint('job', retrieve_subdir=True)[0]
join_f = partial(join, mp)
for k in out_opt:
opts[k] = join_f("%s_%s_%s" % (self._id, db_comm[0],
k.strip("-")))
Expand Down
6 changes: 6 additions & 0 deletions qiita_db/support_files/patches/41.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Oct 29, 2016
-- Dropping command and reference NULL constraints from jobs so bioms
-- without them can be analyzed

ALTER TABLE qiita.job ALTER COLUMN input_file_reference_id DROP NOT NULL;
ALTER TABLE qiita.job ALTER COLUMN input_file_software_command_id DROP NOT NULL;
6 changes: 3 additions & 3 deletions qiita_db/support_files/qiita-db.dbs
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,8 @@
<column name="log_id" type="bigint" jt="-5" >
<comment><![CDATA[Reference to error if status is error]]></comment>
</column>
<column name="input_file_reference_id" type="bigint" jt="-5" mandatory="y" />
<column name="input_file_software_command_id" type="bigint" jt="-5" mandatory="y" />
<column name="input_file_reference_id" type="bigint" jt="-5" />
<column name="input_file_software_command_id" type="bigint" jt="-5" />
<index name="pk_job" unique="PRIMARY_KEY" >
<column name="job_id" />
</index>
Expand Down Expand Up @@ -1916,12 +1916,12 @@ Controlled Vocabulary]]></comment>
<entity schema="qiita" name="processing_job_workflow" color="b2cdf7" x="2265" y="1710" />
<entity schema="qiita" name="processing_job_workflow_root" color="b2cdf7" x="2250" y="1590" />
<entity schema="qiita" name="processing_job" color="b2cdf7" x="1995" y="1350" />
<entity schema="qiita" name="job" color="d0def5" x="405" y="1155" />
<entity schema="qiita" name="prep_template_processing_job" color="b2cdf7" x="1740" y="960" />
<entity schema="qiita" name="software_artifact_type" color="b2cdf7" x="2040" y="945" />
<entity schema="qiita" name="software_type" color="b2cdf7" x="2625" y="930" />
<entity schema="qiita" name="software" color="b2cdf7" x="2400" y="930" />
<entity schema="qiita" name="software_command" color="b2cdf7" x="2175" y="1215" />
<entity schema="qiita" name="job" color="d0def5" x="405" y="1155" />
<group name="Group_analyses" color="c4e0f9" >
<comment>analysis tables</comment>
<entity schema="qiita" name="analysis" />
Expand Down
Loading

0 comments on commit 071bef2

Please sign in to comment.