Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bcftbx/mock: updates for Python 3 compatibility #121

Merged
merged 2 commits into from Sep 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 11 additions & 10 deletions bcftbx/mock.py
Expand Up @@ -37,6 +37,7 @@
from .TabFile import TabFile
from .utils import OrderedDictionary
from .utils import mkdir
from builtins import range

#######################################################################
# Module data
Expand Down Expand Up @@ -165,7 +166,7 @@ def create(run_name,bases_mask,nlanes,tilecount=None,
# AlignToPhiX
if align_to_phix:
xml += " <AlignToPhiX>\n"
for i in xrange(nlanes):
for i in range(nlanes):
xml += " <Lane>%s</Lane>\n" % (i+1)
xml += " </AlignToPhiX>\n"
# Footer
Expand Down Expand Up @@ -519,7 +520,7 @@ def lanes(self):
"""
List of lane numbers
"""
return [l for l in xrange(1,self._nlanes+1)]
return [l for l in range(1,self._nlanes+1)]

@property
def dirn(self):
Expand Down Expand Up @@ -568,16 +569,16 @@ def create(self):
mkdir(self._path('Data','Intensities'))
mkdir(self._path('Data','Intensities','BaseCalls'))
# Lanes
for i in xrange(1,nlanes+1):
for i in range(1,nlanes+1):
# .locs files
mkdir(self._path('Data','Intensities','L%03d' % i))
for j in xrange(1101,1101+ntiles):
for j in range(1101,1101+ntiles):
io.open(self._path('Data','Intensities','L%03d' % i,
's_%d_%d.locs' % (i,j)),'wb+').close()
# BaseCalls directory
mkdir(self._path('Data','Intensities','BaseCalls',
'L%03d' % i))
for j in xrange(1101,1101+ntiles):
for j in range(1101,1101+ntiles):
if self._include_control:
# Add .control files
io.open(self._path('Data',
Expand All @@ -596,7 +597,7 @@ def create(self):
# No cycle subdirectores (e.g. 'C121.1')
# so put bcl files directory in lane directory
# This is the case for NextSeq
for j in xrange(1,ntiles+1):
for j in range(1,ntiles+1):
io.open(self._path('Data',
'Intensities',
'BaseCalls',
Expand All @@ -611,13 +612,13 @@ def create(self):
'%04d%s.bci' % (j,bcl_ext)),'wb+').close()
# Cycles subdirectories
if self._include_cycles:
for k in xrange(1,ncycles+1):
for k in range(1,ncycles+1):
mkdir(self._path('Data',
'Intensities',
'BaseCalls',
'L%03d' % i,
'C%d.1' % k))
for j in xrange(1101,1101+ntiles):
for j in range(1101,1101+ntiles):
# .bcl files
io.open(self._path('Data',
'Intensities',
Expand Down Expand Up @@ -1167,11 +1168,11 @@ def _touch(self,f):
if f.endswith(".gz"):
# Make empty gzipped file
with gzip.open(f,'wb') as fp:
fp.write("")
fp.write(b"")
else:
# Make regular empty file
with io.open(f,'wb') as fp:
fp.write("")
fp.write(b"")

def remove(self):
"""Delete the directory structure and contents
Expand Down