Skip to content

Commit

Permalink
Merge pull request #12 from genomematt/issue11
Browse files Browse the repository at this point in the history
fixes #11 unresolved forward read state assignment error and fixes #13 PEP479 compliance
  • Loading branch information
genomematt committed Jul 5, 2019
2 parents f73e9f1 + 4996bfe commit 6187282
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 33 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@
**/.DS_store

#ignore egg info files
XenoMapper.egg-info
XenoMapper.egg-info
\.eggs/

\.pytest_cache/v/cache/

\.vscode/

dist/
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
matrix:
include:
- python: "3.3"
- python: "3.4"
- python: "3.5"
- python: "3.6"
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='XenoMapper',
version='1.0.1',
version='1.0.2',
author='Matthew Wakefield',
author_email='matthew.wakefield@unimelb.edu.au',
packages=['xenomapper'],
Expand All @@ -36,6 +36,8 @@
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Intended Audience :: Science/Research',
Expand Down
4 changes: 2 additions & 2 deletions xenomapper/mappability.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
from xenomapper.xenomapper import get_sam_header

__author__ = "Matthew Wakefield"
__copyright__ = "Copyright 2011-2016 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__copyright__ = "Copyright 2011-2019 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__credits__ = ["Matthew Wakefield",]
__license__ = "GPLv3"
__version__ = "1.0.1"
__version__ = "1.0.2"
__maintainer__ = "Matthew Wakefield"
__email__ = "wakefield@wehi.edu.au"
__status__ = "Development"
Expand Down
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions xenomapper/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
test_xenomapper.py
Created by Matthew Wakefield on 2012-08-16.
Copyright (c) 2011-2016 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne. All rights reserved.
Copyright (c) 2011-2019 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne. All rights reserved.
"""

import unittest
from xenomapper.tests.test_xenomapper import *
from xenomapper.tests.test_mappability import *

__author__ = "Matthew Wakefield"
__copyright__ = "Copyright 2011-2016 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__copyright__ = "Copyright 2011-2019 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__credits__ = ["Matthew Wakefield",]
__license__ = "GPLv3"
__version__ = "1.0.1"
__version__ = "1.0.2"
__maintainer__ = "Matthew Wakefield"
__email__ = "wakefield@wehi.edu.au"
__status__ = "Release/Stable"
Expand Down
4 changes: 2 additions & 2 deletions xenomapper/tests/test_mappability.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@


__author__ = "Matthew Wakefield"
__copyright__ = "Copyright 2011-2016 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__copyright__ = "Copyright 2011-2019 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__credits__ = ["Matthew Wakefield",]
__license__ = "GPLv3"
__version__ = "1.0.1"
__version__ = "1.0.2"
__maintainer__ = "Matthew Wakefield"
__email__ = "wakefield@wehi.edu.au"
__status__ = "Development/Beta"
Expand Down
10 changes: 5 additions & 5 deletions xenomapper/tests/test_xenomapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from pkg_resources import resource_stream

__author__ = "Matthew Wakefield"
__copyright__ = "Copyright 2011-2016 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__copyright__ = "Copyright 2011-2019 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__credits__ = ["Matthew Wakefield",]
__license__ = "GPLv3"
__version__ = "1.0.1"
__version__ = "1.0.2"
__maintainer__ = "Matthew Wakefield"
__email__ = "wakefield@wehi.edu.au"
__status__ = "Production/Stable"
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_consistent_output_SE(self):
len(test_unassigned_outfile.getvalue().split('\n'))-4) #26 lines of header in this file
self.assertEqual(cat_counts['unassigned'],
len(test_unassigned_outfile.getvalue().split('\n'))-4) #26 lines of header in this file
self.assertEqual(hashlib.sha224(test_primary_specific_outfile.getvalue().encode('latin-1')).hexdigest(),'24107f7addcbfde7180e57965734e0e99481286f3b99e97d815613fb')
self.assertEqual(hashlib.sha224(test_primary_specific_outfile.getvalue().encode('latin-1')).hexdigest(),'381325b12dd9a9cd3afdd72eeb16b23cc92ddd16f675bb21bb21e08e')
sam1.close()
sam2.close()
pass
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_consistent_output_PE(self):
self.assertEqual(sum([cat_counts[x] for x in cat_counts if 'secondary_multi' in x \
and not 'primary_multi' in x and not 'primary_specific' in x and not 'secondary_specific' in x])*2,
len(test_secondary_multi_outfile.getvalue().split('\n'))-1)
self.assertEqual(hashlib.sha224(test_primary_specific_outfile.getvalue().encode('latin-1')).hexdigest(),'85b2499215d91e8ef8115e81bbe745c6095772340bdd548a2bbc7d09')
self.assertEqual(hashlib.sha224(test_primary_specific_outfile.getvalue().encode('latin-1')).hexdigest(),'64c0e24bf141c5aa3bb0993c73b34cdfe630a504ac424843f746918d')
sam1.close()
sam2.close()
pass
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_consistent_output_conservative_PE(self):
len(test_secondary_specific_outfile.getvalue().split('\n'))-27) #26 lines of header in this file
self.assertEqual(cat_counts[('unassigned', 'unassigned')]*2, len(test_unassigned_outfile.getvalue().split('\n'))-1)

self.assertEqual(hashlib.sha224(test_primary_specific_outfile.getvalue().encode('latin-1')).hexdigest(),'5c201ba8ef87f20a11d14fbdbf091c2d7c45267707227122c77ffd26')
self.assertEqual(hashlib.sha224(test_primary_specific_outfile.getvalue().encode('latin-1')).hexdigest(),'c4de3de755092c8f9ff1eb2cd360a502d74ebd4c1e65ed282515ed3e')
sam1.close()
sam2.close()
pass
Expand Down
38 changes: 20 additions & 18 deletions xenomapper/xenomapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from copy import copy

__author__ = "Matthew Wakefield"
__copyright__ = "Copyright 2011-2016 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__copyright__ = "Copyright 2011-2019 Matthew Wakefield, The Walter and Eliza Hall Institute and The University of Melbourne"
__credits__ = ["Matthew Wakefield",]
__license__ = "GPL"
__version__ = "1.0.1"
__version__ = "1.0.2"
__maintainer__ = "Matthew Wakefield"
__email__ = "wakefield@wehi.edu.au"
__status__ = "Production/Stable"
Expand Down Expand Up @@ -73,22 +73,24 @@ def getBamReadPairs(bamfile1,bamfile2, skip_repeated_reads=False): #pragma: no c
"""
bam1 = bam_lines(bamfile1)
bam2 = bam_lines(bamfile2)
line1= next(bam1).strip('\n').split() #split on white space. Results in 11 fields of mandatory SAM + variable number of additional tags.
line2= next(bam2).strip('\n').split()
while line1 and line2 and line1 !=[''] and line2 !=['']:
assert line1[0] == line2[0]
yield line1,line2
previous_read1 = line1[0]
previous_read2 = line2[0]
if skip_repeated_reads:
while line1 and line2 and line1 !=[''] and line2 !=[''] and line1[0] == previous_read1:
try:
line1= next(bam1).strip('\n').split() #split on white space. Results in 11 fields of mandatory SAM + variable number of additional tags.
line2= next(bam2).strip('\n').split()
while line1 and line2 and line1 !=[''] and line2 !=['']:
assert line1[0] == line2[0]
yield line1,line2
previous_read1 = line1[0]
previous_read2 = line2[0]
if skip_repeated_reads:
while line1 and line2 and line1 !=[''] and line2 !=[''] and line1[0] == previous_read1:
line1= next(bam1).strip('\n').split()
while line1 and line2 and line1 !=[''] and line2 !=[''] and line2[0] == previous_read2:
line2= next(bam2).strip('\n').split()
else:
line1= next(bam1).strip('\n').split()
while line1 and line2 and line1 !=[''] and line2 !=[''] and line2[0] == previous_read2:
line2= next(bam2).strip('\n').split()
else:
line1= next(bam1).strip('\n').split()
line2= next(bam2).strip('\n').split()
pass
except StopIteration:
return

def getReadPairs(sam1,sam2, skip_repeated_reads=False):
"""Process two sam files to yield the equivalent line from each file
Expand Down Expand Up @@ -434,7 +436,7 @@ def main_paired_end(readpairs,
if secondary_multi:
print('\t'.join(previous_line2),file=secondary_multi)
print('\t'.join(line2),file=secondary_multi)
elif forward_state == 'unresloved' or reverse_state == 'unresolved':
elif forward_state == 'unresolved' or reverse_state == 'unresolved':
if unresolved:
print('\t'.join(previous_line1),file=unresolved)
print('\t'.join(line1),file=unresolved)
Expand Down Expand Up @@ -520,7 +522,7 @@ def conservative_main_paired_end(readpairs,
if unassigned:
print('\t'.join(previous_line1),file=unassigned)
print('\t'.join(line1),file=unassigned)
elif forward_state == 'unresloved' or reverse_state == 'unresolved' \
elif forward_state == 'unresolved' or reverse_state == 'unresolved' \
or (forward_state in ['primary_specific','primary_multi'] and \
reverse_state in ['secondary_specific','secondary_multi']) \
or (forward_state in ['secondary_specific','secondary_multi'] and \
Expand Down

0 comments on commit 6187282

Please sign in to comment.