Skip to content

Commit

Permalink
Don't allow too-new versions of SPAdes
Browse files Browse the repository at this point in the history
  • Loading branch information
rrwick committed Jul 20, 2020
1 parent 6ed4d61 commit 372307c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Reasons to __not__ use Unicycler:
* [ICC](https://software.intel.com/en-us/c-compilers) also works (though I don't know the minimum required version number)
* [setuptools](https://packaging.python.org/installing/#install-pip-setuptools-and-wheel) (only required for installation of Unicycler)
* For short-read or hybrid assembly:
* [SPAdes](http://bioinf.spbau.ru/spades) v3.6.2 or later (`spades.py`)
* [SPAdes](http://bioinf.spbau.ru/spades) v3.6.2 – v3.13.0 (`spades.py`)
* For long-read or hybrid assembly:
* [Racon](https://github.com/isovic/racon) (`racon`)
* For polishing
Expand Down
33 changes: 33 additions & 0 deletions test/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,36 @@ def test_spades_version_parsing_4(self):
'-o <output_dir>\n\nBasic options:'
version = unicycler.misc.spades_version_from_spades_output(spades_version_output)
self.assertEqual(version, '2.4.0')

def test_spades_version_status_1(self):
self.assertEqual(unicycler.misc.spades_status_from_version('2.4.0'), 'too old')

def test_spades_version_status_2(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.4.0'), 'too old')

def test_spades_version_status_3(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.6.0'), 'too old')

def test_spades_version_status_4(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.6.1'), 'too old')

def test_spades_version_status_5(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.6.2'), 'good')

def test_spades_version_status_6(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.7.0'), 'good')

def test_spades_version_status_7(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.9.9'), 'good')

def test_spades_version_status_8(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.13.0'), 'good')

def test_spades_version_status_9(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.13.1'), 'too new')

def test_spades_version_status_10(self):
self.assertEqual(unicycler.misc.spades_status_from_version('3.14.1'), 'too new')

def test_spades_version_status_11(self):
self.assertEqual(unicycler.misc.spades_status_from_version('4.0.0'), 'too new')
50 changes: 33 additions & 17 deletions unicycler/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,23 +891,9 @@ def spades_path_and_version(spades_path):
if 'python version' in out and 'is not supported' in out:
return found_spades_path, '', 'Python problem'

# Make sure SPAdes is 3.6.2+
# Make sure SPAdes is 3.6.2 - 3.13.0
try:
major_version = int(version.split('.')[0])
if major_version < 3:
status = 'too old'
else:
minor_version = int(version.split('.')[1])
if minor_version < 6:
status = 'too old'
elif minor_version > 6:
status = 'good'
else: # minor_version == 6
patch_version = int(version.split('.')[2])
if patch_version < 2:
status = 'too old'
else:
status = 'good'
status = spades_status_from_version(version)
except (ValueError, IndexError):
version, status = '?', 'too old'

Expand All @@ -933,6 +919,36 @@ def spades_version_from_spades_output(spades_output):
return ''


def spades_status_from_version(version):
major_version = int(version.split('.')[0])
if major_version < 3:
return 'too old'
if major_version >= 4:
return 'too new'

minor_version = int(version.split('.')[1])
if minor_version < 6:
return 'too old'
if minor_version > 13:
return 'too new'
assert 6 <= minor_version <= 13

patch_version = int(version.split('.')[2])
if 6 < minor_version < 13:
return 'good'
assert minor_version == 6 or minor_version == 13
if minor_version == 6:
if patch_version < 2:
return 'too old'
else:
return 'good'
if minor_version == 13:
if patch_version > 0:
return 'too new'
else:
return 'good'


def racon_path_and_version(racon_path):
found_racon_path = shutil.which(racon_path)
if found_racon_path is None:
Expand All @@ -941,7 +957,7 @@ def racon_path_and_version(racon_path):
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = process.communicate()
out = out.decode().lower()
if 'racon' not in out or 'options' not in out:
if 'racon' not in out or 'options' not in out:
return found_racon_path, '-', 'bad'

return found_racon_path, racon_version(found_racon_path), 'good'
Expand Down
7 changes: 4 additions & 3 deletions unicycler/unicycler.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,8 @@ def check_dependencies(args, short_reads_available, long_reads_available):
for i, row in enumerate(program_table):
if 'not used' in row:
row_colours[i] = 'dim'
elif 'too old' in row or 'not found' in row or 'bad' in row or 'Python problem' in row:
elif ('too old' in row or 'too new' in row or 'not found' in row or 'bad' in row or
'Python problem' in row):
row_colours[i] = 'red'

print_table(program_table, alignments='LLLL', row_colour=row_colours, max_col_width=60,
Expand All @@ -866,8 +867,8 @@ def quit_if_dependency_problem(spades_status, racon_status, makeblastdb_status,
log.log('')
if spades_status == 'not found':
quit_with_error('could not find SPAdes at ' + args.spades_path)
if spades_status == 'too old':
quit_with_error('Unicycler requires SPAdes v3.6.2 or higher')
if spades_status == 'too old' or spades_status == 'too new':
quit_with_error('Unicycler requires SPAdes v3.6.2 - v3.13.0')
if spades_status == 'Python problem':
quit_with_error('SPAdes cannot run due to an incompatible Python version')
if spades_status == 'bad':
Expand Down

0 comments on commit 372307c

Please sign in to comment.