Skip to content

Commit

Permalink
Tweak verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Hunt committed Feb 20, 2015
1 parent 5c2177a commit ad46956
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions ariba/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ def _bam_to_clusters_reads(self):
self.cluster_to_dir[ref] = new_dir
filehandles_1[ref] = pyfastaq.utils.open_file_write(os.path.join(new_dir, 'reads_1.fq'))
filehandles_2[ref] = pyfastaq.utils.open_file_write(os.path.join(new_dir, 'reads_2.fq'))
if self.verbose:
print('New cluster with reads that hit:', ref, flush=True)

print(read1, file=filehandles_1[ref])
print(read2, file=filehandles_2[ref])
Expand All @@ -234,6 +236,8 @@ def _bam_to_clusters_reads(self):
pyfastaq.utils.close(filehandles_1[ref])
pyfastaq.utils.close(filehandles_2[ref])

if self.verbose:
print('Total clusters to perform local assemblies:', len(self.cluster_to_dir), flush=True)

def _set_insert_size_data(self):
assert len(self.insert_hist) > 0
Expand Down Expand Up @@ -365,27 +369,27 @@ def run(self):
os.chdir(self.outdir)

if self.verbose:
print('{:_^79}'.format(' Running cd-hit '))
print('{:_^79}'.format(' Running cd-hit '), flush=True)
self._run_cdhit()
self._write_clusters_info_file()
if self.verbose:
print('Finished cd-hit\n')
print('{:_^79}'.format(' Mapping reads to clustered genes '))
print('{:_^79}'.format(' Mapping reads to clustered genes '), flush=True)
self._map_reads_to_clustered_genes()
if self.verbose:
print('Finished mapping\n')
print('{:_^79}'.format(' Generating clusters '))
print('{:_^79}'.format(' Generating clusters '), flush=True)
self._bam_to_clusters_reads()
self._set_insert_size_data()
if self.verbose:
print('{:_^79}'.format(' Assembling each cluster '))
print('{:_^79}'.format(' Assembling each cluster '), flush=True)
self._init_and_run_clusters()
if self.verbose:
print('Finished assembling clusters\n')
print('{:_^79}'.format(' Writing report files '))
print('{:_^79}'.format(' Writing report files '), flush=True)
self._write_reports()
if self.verbose:
print('Finished writing report files. Cleaning files')
print('Finished writing report files. Cleaning files', flush=True)
self._clean()
if self.verbose:
print('\nAll done!\n')
Expand Down
2 changes: 1 addition & 1 deletion ariba/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def syscall(cmd, allow_fail=False, verbose=False):
print('The following command failed with exit code', error.returncode, file=sys.stderr)
print(cmd, file=sys.stderr)
print('\nThe output was:\n', file=sys.stderr)
print(errors, file=sys.stderr)
print(errors, file=sys.stderr, flush=True)

if allow_fail:
return False, errors
Expand Down

0 comments on commit ad46956

Please sign in to comment.