Skip to content

Commit

Permalink
Merge pull request #49 from gedankenstuecke/master
Browse files Browse the repository at this point in the history
support for samtools > 1.2
  • Loading branch information
martinghunt committed Mar 8, 2016
2 parents 204bd0d + 14b284b commit b29ec01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion circlator/external_progs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ def check_all_progs(verbose=False, raise_error=False, filehandle=None):

for prog in sorted(prog_name_to_default):
make_and_check_prog(prog, verbose=verbose, raise_error=raise_error, filehandle=filehandle)

22 changes: 17 additions & 5 deletions circlator/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Error (Exception): pass


def bwa_index(infile, outprefix=None, bwa='bwa', verbose=False):
if outprefix is None:
if outprefix is None:
outprefix = infile

missing = [not os.path.exists(outprefix + '.' + x) for x in index_extensions]
Expand Down Expand Up @@ -60,7 +60,7 @@ def bwa_mem(
bwa_options,
'-t', str(threads),
tmp_index,
reads,
reads,
'|',
samtools.exe(), 'view',
'-F 0x0800',
Expand All @@ -74,15 +74,27 @@ def bwa_mem(
bwa_index_clean(tmp_index)
threads = min(4, threads)
thread_mem = int(500 / threads)


# here we have to check for the version of samtools, starting from 1.3 the
# -o flag is used for specifying the samtools sort output-file
# Starting from 1.2 you can use the -o flag

outparam = ''

if samtools.version_at_least('1.2'):
outparam = '-o'
samout = outfile
else:
samout = outfile[:-4]

cmd = ' '.join([
samtools.exe(), 'sort',
'-@', str(threads),
'-m', str(thread_mem) + 'M',
unsorted_bam,
outfile[:-4]
outparam,samout
])

common.syscall(cmd, verbose=verbose)
os.unlink(unsorted_bam)

Expand Down

0 comments on commit b29ec01

Please sign in to comment.