Mercurial > repos > peterjc > seq_filter_by_mapping
changeset 12:fb21ab9bdb98 draft
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/seq_filter_by_mapping commit 8ac4eac1507e91426b883d440c89d3f654c51a26-dirty
author | peterjc |
---|---|
date | Wed, 17 May 2017 12:42:03 -0400 |
parents | 0f7cc6ccc95d |
children | 37de286fc844 |
files | tools/seq_filter_by_mapping/README.rst tools/seq_filter_by_mapping/seq_filter_by_mapping.py tools/seq_filter_by_mapping/seq_filter_by_mapping.xml |
diffstat | 3 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/seq_filter_by_mapping/README.rst Wed May 17 09:22:19 2017 -0400 +++ b/tools/seq_filter_by_mapping/README.rst Wed May 17 12:42:03 2017 -0400 @@ -71,6 +71,7 @@ - Use ``<command detect_errors="aggressive">`` (internal change only). - Single quote command line arguments (internal change only). v0.0.6 - Python 3 compatible print function. +v0.0.7 - Script works on Python 2 and 3 (fixed input file mode) ======= ======================================================================
--- a/tools/seq_filter_by_mapping/seq_filter_by_mapping.py Wed May 17 09:22:19 2017 -0400 +++ b/tools/seq_filter_by_mapping/seq_filter_by_mapping.py Wed May 17 12:42:03 2017 -0400 @@ -64,7 +64,7 @@ options, args = parser.parse_args() if options.version: - print("v0.0.6") + print("v0.0.7") sys.exit(0) in_file = options.input @@ -149,11 +149,11 @@ Parses BAM files via call out to samtools view command. """ - handle = open(filename, "rb") - magic = handle.read(4) + with open(filename, "rb") as handle: + magic = handle.read(4) + if magic == b"\x1f\x8b\x08\x04": # Presumably a BAM file then... - handle.close() # Call samtools view, don't need header so no -h added: child = subprocess.Popen(["samtools", "view", filename], stdin=None, @@ -163,7 +163,8 @@ else: # Presumably a SAM file... child = None - handle.seek(0) + # Open in text mode + handle = open(filename) # Handle should now contain SAM records for line in handle: # Ignore header lines
--- a/tools/seq_filter_by_mapping/seq_filter_by_mapping.xml Wed May 17 09:22:19 2017 -0400 +++ b/tools/seq_filter_by_mapping/seq_filter_by_mapping.xml Wed May 17 12:42:03 2017 -0400 @@ -1,4 +1,4 @@ -<tool id="seq_filter_by_mapping" name="Filter sequences by mapping" version="0.0.6"> +<tool id="seq_filter_by_mapping" name="Filter sequences by mapping" version="0.0.7"> <description>from SAM/BAM file</description> <requirements> <requirement type="package" version="1.67">biopython</requirement>