Skip to content

Commit 515f08f

Browse files
Merge pull request #8 from antgonza/Tell-Seq
Tell-Seq
2 parents 437da57 + 15947d8 commit 515f08f

File tree

7 files changed

+76
-111
lines changed

7 files changed

+76
-111
lines changed

.github/workflows/qiita-plugin-ci.yml

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
on:
44
push:
5-
branches: [ dev ]
5+
branches: [dev]
66
pull_request:
77

88
jobs:
@@ -39,7 +39,7 @@ jobs:
3939
uses: conda-incubator/setup-miniconda@v2
4040
with:
4141
auto-update-conda: true
42-
python-version: 3.6
42+
python-version: 3.9
4343

4444
- name: Basic dependencies install
4545
env:
@@ -62,15 +62,15 @@ jobs:
6262
6363
# Setting up main qiita conda environment
6464
conda config --add channels conda-forge
65-
conda create -q --yes -n qiita python=3.6 pip libgfortran numpy nginx cython redis
65+
conda create --quiet --yes -n qiita python=3.9 pip libgfortran numpy nginx cython redis
6666
conda activate qiita
6767
pip install sphinx sphinx-bootstrap-theme nose-timer codecov Click
6868
6969
- name: Qiita install
7070
shell: bash -l {0}
7171
run: |
7272
conda activate qiita
73-
pip install qiita-dev/ --no-binary redbiom
73+
pip --quiet install qiita-dev/ --no-binary redbiom
7474
mkdir ~/.qiita_plugins
7575
7676
- name: Install plugins
@@ -80,37 +80,34 @@ jobs:
8080
conda config --add channels bioconda
8181
8282
# installing qtp-sequencing
83-
conda create -q --yes -n qtp-sequencing python=3.6 pip pigz quast
83+
conda create -q --yes -n qtp-sequencing python=3.9 pip pigz quast
8484
conda activate qtp-sequencing
8585
pip --quiet install https://github.com/qiita-spots/qtp-sequencing/archive/master.zip
86-
export QIITA_SERVER_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
86+
export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
8787
export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg
88-
configure_qtp_sequencing --env-script "source /home/runner/.profile; conda activate qtp-sequencing" --server-cert $QIITA_SERVER_CERT
89-
88+
configure_qtp_sequencing --env-script "source /home/runner/.profile; conda activate qtp-sequencing" --server-cert $QIITA_ROOTCA_CERT
9089
conda deactivate
9190
9291
# installing this plugin
93-
conda create -q --yes -n qp-spades python=3.6 cmake clang zlib flash spades=3.15.2
92+
conda create -q --yes -n qp-spades python=3.9 cmake clang zlib flash
9493
conda activate qp-spades
9594
9695
# making sure the installed versions haven't changed
9796
flash_version=`flash --version`
98-
spades_version=`spades.py --version`
9997
if [[ $flash_version != *"v1.2.11"* ]]; then echo "wrong flash version", $flash_version; exit 1; fi
100-
if [[ $spades_version != *"v3.15.2"* ]]; then echo "wrong spades version", $spades_version; exit 1; fi
10198
102-
export QIITA_SERVER_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
99+
export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
103100
export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg
104101
export ENVIRONMENT="source /home/runner/.profile; conda activate qp-spades"
105102
pip install -U pip
106103
pip install .
107-
configure_qp_spades --env-script 'source /home/runner/.profile; conda activate qp-spades; export ENVIRONMENT="source /home/runner/.profile; conda activate qp-spades"' --server-cert $QIITA_SERVER_CERT
104+
configure_qp_spades --env-script 'source /home/runner/.profile; conda activate qp-spades; export ENVIRONMENT="source /home/runner/.profile; conda activate qp-spades"' --ca-cert $QIITA_ROOTCA_CERT
108105
109106
- name: Starting services
110107
shell: bash -l {0}
111108
run: |
112109
conda activate qiita
113-
export QIITA_SERVER_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
110+
export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
114111
export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg
115112
sed "s#/home/runner/work/qiita/qiita#${PWD}/qiita-dev/#g" `pwd`/qiita-dev/qiita_core/support_files/config_test.cfg > ${QIITA_CONFIG_FP}
116113
@@ -143,11 +140,11 @@ jobs:
143140
COVER_PACKAGE: ${{ matrix.cover_package }}
144141
run: |
145142
conda activate qp-spades
146-
export QIITA_SERVER_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
143+
export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt
147144
export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg
148145
export ENVIRONMENT="source /home/runner/.profile; conda activate qp-spades"
149146
150-
nosetests $COVER_PACKAGE --with-doctest --with-coverage -vv --cover-package=$COVER_PACKAGE
147+
nosetests --with-doctest --with-coverage -v --cover-package=qp_woltka
151148
152149
# killing the qiita server to run the next commands
153150
QIITA_PID=`cat /tmp/supervisord.pid`
@@ -156,21 +153,21 @@ jobs:
156153
157154
- uses: codecov/codecov-action@v1
158155
with:
159-
token: ${{ secrets.CODECOV_TOKEN }}
160-
file: codecov.yml
156+
token: ${{ secrets.CODECOV_TOKEN }}
157+
file: codecov.yml
161158

162159
lint:
163160
runs-on: ubuntu-latest
164161
steps:
165-
- name: flake8
166-
uses: actions/setup-python@v2
167-
with:
168-
python-version: 3.9
169-
- name: install dependencies
170-
run: python -m pip install --upgrade pip
171-
- name: Check out repository code
172-
uses: actions/checkout@v2
173-
- name: lint
174-
run: |
175-
pip install -q flake8
176-
flake8 qp_spades setup.py scripts/*
162+
- name: flake8
163+
uses: actions/setup-python@v2
164+
with:
165+
python-version: 3.9
166+
- name: install dependencies
167+
run: python -m pip install --upgrade pip
168+
- name: Check out repository code
169+
uses: actions/checkout@v2
170+
- name: lint
171+
run: |
172+
pip install -q flake8
173+
flake8 qp_spades setup.py scripts/*

qp_spades/__init__.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
from .qp_spades import spades
1111

1212

13-
THREADS = "16"
14-
MEMORY = "200"
15-
KMERS = "21,33,55,77,99,127"
13+
THREADS = "12"
1614

1715
plugin_details = {'name': 'qp-spades',
18-
'version': '3.15.2',
19-
'description': 'spades pipeline'}
16+
'version': '2025.02',
17+
'description': 'spades assembler pipeline'}
2018

2119

2220
# Initialize the plugin
@@ -25,30 +23,19 @@
2523
# Define the command
2624
req_params = {'input': ('artifact', ['per_sample_FASTQ'])}
2725
opt_params = {
28-
'type': ['choice:["meta", "isolate"]', "meta"],
29-
'merging': ['choice:["no merge", "flash 65%"]', "flash 65%"],
26+
'type': ['choice:["meta"]', "meta"],
27+
'merging': ['choice:["no merge", "flash 65%"]', "no merge"],
3028
'threads': ['integer', THREADS],
31-
'memory': ['integer', MEMORY],
32-
'k-mers': ['string', KMERS],
3329
}
3430

3531
outputs = {'Preprocessed FASTA': 'FASTA_preprocessed'}
3632
default_params = {
37-
'no merging + meta': {
38-
'type': 'meta', 'merging': 'no merge', 'threads': THREADS,
39-
'memory': MEMORY, 'k-mers': KMERS},
40-
'no merging + isolate': {
41-
'type': 'isolate', 'merging': 'no merge', 'threads': THREADS,
42-
'memory': MEMORY, 'k-mers': KMERS},
43-
'merge flash 65% + meta': {
44-
'type': 'meta', 'merging': 'flash 65%', 'threads': THREADS,
45-
'memory': MEMORY, 'k-mers': KMERS},
46-
'merge flash 65% + isolate': {
47-
'type': 'isolate', 'merging': 'flash 65%', 'threads': THREADS,
48-
'memory': MEMORY, 'k-mers': KMERS}}
33+
'Tell-Seq meta + no merge': {
34+
'type': 'meta', 'merging': 'no merge', 'threads': THREADS}
35+
}
4936

5037
spades_cmd = QiitaCommand(
51-
"spades", "Isolate and Metagenomic processing via spades", spades,
38+
"cloudSPAdes", "Assembly via cloudSPAdes", spades,
5239
req_params, opt_params, outputs, default_params)
5340

5441
plugin.register_command(spades_cmd)

qp_spades/qp_spades.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# resources per job
1717
WALLTIME = '200:00:00'
1818
MAX_RUNNING = 8
19+
MEMORY = '128g'
1920
FINISH_WALLTIME = '10:00:00'
2021
FINISH_MEMORY = '4g'
2122

@@ -24,7 +25,6 @@ def spades_to_array(directory, output_dir, prefix_to_name, url,
2425
job_id, params):
2526
environment = environ["ENVIRONMENT"]
2627
ppn = params["threads"]
27-
memory = params["memory"]
2828

2929
# 1. create file list
3030
num_samples = len(prefix_to_name)
@@ -43,16 +43,16 @@ def spades_to_array(directory, output_dir, prefix_to_name, url,
4343

4444
# 2. format main comand
4545
command = (
46-
f'spades.py --{params["type"]} -t {ppn} -m {memory} '
47-
f'-k {params["k-mers"]} -o $OUTDIR/$SNAME')
46+
f'spades.py --{params["type"]} -m {MEMORY.replace("g", "")} '
47+
f'-t {ppn} -o $OUTDIR/$SNAME')
4848
if params['merging'].startswith('flash '):
4949
# get read length quickly; note that we are going to assume
5050
# that (1) the forward and reverse are the same length and (2)
5151
# all file pairs have the same length so only calculate once
5252
fp = glob(join(directory, list(prefix_to_name)[0] + '*'))[0]
5353
std_out, std_err, return_value = system_call(
5454
f'zcat -c {fp} | head -n 2')
55-
if return_value != 0:
55+
if return_value != 0 or std_err:
5656
error_msg = (f"Error uncompressing: {fp}\n"
5757
f"Std out: {std_out}\nStd err: {std_err}\n")
5858
raise ValueError(error_msg)
@@ -70,10 +70,10 @@ def spades_to_array(directory, output_dir, prefix_to_name, url,
7070
# spades
7171
f'{command} '
7272
'--merge $OUTDIR/${SNAME}.extendedFrags.fastq '
73-
'-1 $OUTDIR/${SNAME}.notCombined_1.fastq '
74-
'-2 $OUTDIR/${SNAME}.notCombined_2.fastq')
73+
'--gemcode1-1 $OUTDIR/${SNAME}.notCombined_1.fastq '
74+
'--gemcode1-2 $OUTDIR/${SNAME}.notCombined_2.fastq')
7575
else:
76-
command = '%s -1 ${FWD} -2 ${REV}' % command
76+
command = '%s --gemcode1-1 ${FWD} --gemcode1-2 ${REV}' % command
7777

7878
# 3. create command for array submission
7979
marray = [
@@ -84,7 +84,7 @@ def spades_to_array(directory, output_dir, prefix_to_name, url,
8484
'#SBATCH -N 1',
8585
f'#SBATCH -n {ppn}',
8686
f'#SBATCH --time {WALLTIME}',
87-
f'#SBATCH --mem {memory}g',
87+
f'#SBATCH --mem {MEMORY}',
8888
f'#SBATCH --output {output_dir}/{job_id}_%a.log',
8989
f'#SBATCH --error {output_dir}/{job_id}_%a.err',
9090
f'#SBATCH --array 1-{num_samples}%{MAX_RUNNING}',
@@ -107,7 +107,7 @@ def spades_to_array(directory, output_dir, prefix_to_name, url,
107107
'#!/bin/bash',
108108
'#SBATCH -p qiita',
109109
'#SBATCH --mail-user [email protected]',
110-
f'#SBATCH --job-name merge-{job_id}',
110+
f'#SBATCH --job-name finish-{job_id}',
111111
'#SBATCH -N 1',
112112
'#SBATCH -n 1',
113113
f'#SBATCH --time {FINISH_WALLTIME}',
@@ -164,23 +164,15 @@ def spades(qclient, job_id, parameters, out_dir):
164164
files, prep = qclient.artifact_and_preparation_files(artifact_id)
165165
prep_info = prep.set_index('run_prefix')['sample_name'].to_dict()
166166

167-
missing = []
168167
outfiles = []
169168
for run_prefix, sname in prep_info.items():
170169
scaffold = join(out_dir, run_prefix, 'scaffolds.fasta')
170+
new_scaffold = join(out_dir, run_prefix, f'{run_prefix}.fasta')
171171
if exists(scaffold):
172-
new_scaffold = join(out_dir, run_prefix, f'{run_prefix}.fasta')
173172
run(['mv', scaffold, new_scaffold], stdout=PIPE)
174-
outfiles.append((new_scaffold, 'preprocessed_fasta'))
175173
else:
176-
missing.append(f'{sname} [{run_prefix}]')
177-
178-
if missing:
179-
error_msg = (
180-
'There was no scaffolds.fasta for samples: %s. Contact: '
181-
'[email protected] and add this job id: %s' % (
182-
', '.join(missing), job_id))
183-
return False, None, error_msg
174+
run(['touch', new_scaffold], stdout=PIPE)
175+
outfiles.append((new_scaffold, 'preprocessed_fasta'))
184176

185177
# Step 4 generating artifacts
186178
msg = "Step 4 of 4: Generating new artifact"

qp_spades/tests/test_spades.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_spades_to_array(self):
8989
# testing isolate/no-merge
9090
params = {
9191
'type': 'isolate', 'merging': 'no merge', 'input': self.aid,
92-
'threads': 5, 'memory': 200, 'k-mers': '21,33,55,77,99,127'}
92+
'threads': 5}
9393
out_dir = mkdtemp()
9494
self._clean_up_files.append(out_dir)
9595
files, prep = self.qclient.artifact_and_preparation_files(self.aid)
@@ -121,7 +121,7 @@ def test_spades_to_array(self):
121121
# can reuse
122122
params = {
123123
'type': 'meta', 'merging': 'flash 65%', 'input': self.aid,
124-
'threads': 5, 'memory': 200, 'k-mers': '21,33,55,77,99,127'}
124+
'threads': 5}
125125
prefix_to_name = prep.set_index('run_prefix')['sample_name'].to_dict()
126126

127127
main_fp, finish_fp = spades_to_array(
@@ -159,24 +159,15 @@ def test_spades(self):
159159
# testing error
160160
params = {
161161
'type': 'meta', 'merging': 'flash 65%', 'input': self.aid,
162-
'threads': 5, 'memory': 200, 'k-mers': '21,33,55,77,99,127'}
162+
'threads': 5}
163163
self.data['command'] = dumps(
164-
[plugin_details['name'], plugin_details['version'], 'spades'])
164+
[plugin_details['name'], plugin_details['version'], 'cloudSPAdes'])
165165
self.data['parameters'] = dumps(params)
166166
jid = self.qclient.post(
167167
'/apitest/processing_job/', data=self.data)['job']
168168

169169
out_dir = mkdtemp()
170170
self._clean_up_files.append(out_dir)
171-
success, artifact, msg = spades(self.qclient, jid, params, out_dir)
172-
self.assertIsNone(artifact)
173-
self.assertFalse(success)
174-
self.assertEqual(msg, f'There was no scaffolds.fasta for samples: '
175-
'1.SKB8.640193 [S22205_S104], 1.SKD8.640184 '
176-
'[S22282_S102]. Contact: [email protected] and '
177-
f'add this job id: {jid}')
178-
179-
# testing success
180171
mkdir(f'{out_dir}/S22205_S104')
181172
mkdir(f'{out_dir}/S22282_S102')
182173
Path(f'{out_dir}/S22205_S104/scaffolds.fasta').touch()
@@ -196,9 +187,9 @@ def test_spades(self):
196187
#SBATCH --mail-user [email protected]
197188
#SBATCH --job-name qiita_job_id
198189
#SBATCH -N 1
199-
#SBATCH -n 5
190+
#SBATCH -n {threads}
200191
#SBATCH --time 200:00:00
201-
#SBATCH --mem 200g
192+
#SBATCH --mem 128g
202193
#SBATCH --output {out_dir}/qiita_job_id_%a.log
203194
#SBATCH --error {out_dir}/qiita_job_id_%a.err
204195
#SBATCH --array 1-2%8
@@ -213,15 +204,15 @@ def test_spades(self):
213204
FWD=$(echo -e $args | awk '{{ print $1 }}')
214205
REV=$(echo -e $args | awk '{{ print $2 }}')
215206
SNAME=$(echo -e $args | awk '{{ print $3 }}')
216-
spades.py --{type} -t {threads} -m {memory} -k {k-mers} -o $OUTDIR/$SNAME \
217-
-1 ${{FWD}} -2 ${{REV}}
207+
spades.py --{type} -m 128 -t {threads} -o $OUTDIR/$SNAME \
208+
--gemcode1-1 ${{FWD}} --gemcode1-2 ${{REV}}
218209
date
219210
"""
220211

221212
EXP_FINISH = """#!/bin/bash
222213
#SBATCH -p qiita
223214
#SBATCH --mail-user [email protected]
224-
#SBATCH --job-name merge-qiita_job_id
215+
#SBATCH --job-name finish-qiita_job_id
225216
#SBATCH -N 1
226217
#SBATCH -n 1
227218
#SBATCH --time 10:00:00
@@ -248,9 +239,9 @@ def test_spades(self):
248239
#SBATCH --mail-user [email protected]
249240
#SBATCH --job-name qiita_job_id
250241
#SBATCH -N 1
251-
#SBATCH -n 5
242+
#SBATCH -n {threads}
252243
#SBATCH --time 200:00:00
253-
#SBATCH --mem 200g
244+
#SBATCH --mem 128g
254245
#SBATCH --output {out_dir}/qiita_job_id_%a.log
255246
#SBATCH --error {out_dir}/qiita_job_id_%a.err
256247
#SBATCH --array 1-2%8
@@ -267,11 +258,10 @@ def test_spades(self):
267258
SNAME=$(echo -e $args | awk '{{ print $3 }}')
268259
flash --threads {threads} --max-overlap=97 --output-directory $OUTDIR \
269260
--output-prefix="$SNAME" ${{FWD}} ${{REV}} --max-mismatch-density=0.1 \
270-
> $OUTDIR/${{SNAME}}.flash.log 2>&1 && spades.py --{type} -t {threads} \
271-
-m {memory} -k {k-mers} -o $OUTDIR/$SNAME \
272-
--merge $OUTDIR/${{SNAME}}.extendedFrags.fastq \
273-
-1 $OUTDIR/${{SNAME}}.notCombined_1.fastq \
274-
-2 $OUTDIR/${{SNAME}}.notCombined_2.fastq
261+
> $OUTDIR/${{SNAME}}.flash.log 2>&1 && spades.py --{type} -m 128 -t \
262+
{threads} -o $OUTDIR/$SNAME --merge $OUTDIR/${{SNAME}}.extendedFrags.fastq \
263+
--gemcode1-1 $OUTDIR/${{SNAME}}.notCombined_1.fastq \
264+
--gemcode1-2 $OUTDIR/${{SNAME}}.notCombined_2.fastq
275265
date
276266
"""
277267

0 commit comments

Comments
 (0)