Skip to content

Commit

Permalink
Merge pull request #23 from martinghunt/expose_mincluster
Browse files Browse the repository at this point in the history
Expose mincluster
  • Loading branch information
martinghunt authored Oct 17, 2016
2 parents e25a59e + b352fa6 commit 3c1dee6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
17 changes: 11 additions & 6 deletions pymummer/nucmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(
coords_header=True,
diagdiff=None,
maxmatch=False,
mincluster=None,
simplify=True,
show_snps=False,
snps_header=True,
Expand All @@ -35,12 +36,13 @@ def __init__(
self.diagdiff = diagdiff
self.coords_header = coords_header
self.maxmatch = maxmatch
self.mincluster = mincluster
self.simplify = simplify
self.show_snps = show_snps
self.snps_header = snps_header
self.verbose = verbose
self.use_promer = promer



def _nucmer_command(self, ref, qry, outprefix):
Expand All @@ -49,7 +51,7 @@ def _nucmer_command(self, ref, qry, outprefix):
command = 'promer'
else:
command = 'nucmer'

command += ' -p ' + outprefix

if self.breaklen is not None:
Expand All @@ -60,7 +62,10 @@ def _nucmer_command(self, ref, qry, outprefix):

if self.maxmatch:
command += ' --maxmatch'


if self.mincluster is not None:
command += ' -c ' + str(self.mincluster)

if not self.simplify and not self.use_promer:
command += ' --nosimplify'

Expand All @@ -79,7 +84,7 @@ def _delta_filter_command(self, infile, outfile):
command += ' -l ' + str(self.min_length)

return command + ' ' + infile + ' > ' + outfile


def _show_coords_command(self, infile, outfile):
'''Construct show-coords command'''
Expand Down Expand Up @@ -109,7 +114,7 @@ def _write_script(self, script_name, ref, qry, outfile):
if self.show_snps:
print(self._show_snps_command('p.delta.filter', outfile + '.snps'), file=f)
pyfastaq.utils.close(f)


def run(self):
'''
Expand All @@ -125,7 +130,7 @@ def run(self):
original_dir = os.getcwd()
os.chdir(tmpdir)
script = 'run_nucmer.sh'
self._write_script(script, ref, qry, outfile)
self._write_script(script, ref, qry, outfile)
syscall.run('bash ' + script, verbose=self.verbose)
os.chdir(original_dir)
shutil.rmtree(tmpdir)
Expand Down
5 changes: 3 additions & 2 deletions pymummer/tests/nucmer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_nucmer_command(self):
[nucmer.Runner('ref', 'qry', 'outfile', diagdiff=11), 'nucmer -p pre -D 11 ref qry'],
[nucmer.Runner('ref', 'qry', 'outfile', diagdiff=11, promer=True), 'promer -p pre ref qry'],
[nucmer.Runner('ref', 'qry', 'outfile', maxmatch=True), 'nucmer -p pre --maxmatch ref qry'],
[nucmer.Runner('ref', 'qry', 'outfile', mincluster=42), 'nucmer -p pre -c 42 ref qry'],
[nucmer.Runner('ref', 'qry', 'outfile', simplify=False), 'nucmer -p pre --nosimplify ref qry'],
[nucmer.Runner('ref', 'qry', 'outfile', promer=True), 'promer -p pre ref qry'],
[nucmer.Runner('ref', 'qry', 'outfile', promer=True, breaklen=42), 'promer -p pre -b 42 ref qry'],
Expand All @@ -37,7 +38,7 @@ def test_delta_filter_command(self):

for l in tests:
self.assertEqual(l[0]._delta_filter_command('infile', 'outfile'), l[1])


def test_show_coords_command(self):
'''test _show_coords_command'''
Expand Down Expand Up @@ -93,5 +94,5 @@ def test_run_nucmer(self):
self.assertTrue(filecmp.cmp(tmp_out + '.snps', expected + '.snps', shallow=False))
os.unlink(tmp_out)
os.unlink(tmp_out + '.snps')


2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='pymummer',
version='0.8.1',
version='0.9.0',
description='Wrapper for MUMmer',
packages = find_packages(),
author='Martin Hunt, Nishadi De Silva',
Expand Down

0 comments on commit 3c1dee6

Please sign in to comment.