Skip to content

Commit

Permalink
replaced last_read with offset variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvark committed Jul 7, 2017
1 parent 8b3e492 commit 0cfdfbf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/galaxy/datatypes/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ def get_chunk( self, trans, dataset, offset=0, ck_size=None ):
with pysam.AlignmentFile( dataset.file_name, "rb", index_filename=index_file.file_name ) as bamfile:
ck_size = 300 # 300 lines
ck_data = ""
last_read = 0
header_line_count = 0
if offset == 0:
ck_data = bamfile.text
Expand All @@ -482,17 +481,17 @@ def get_chunk( self, trans, dataset, offset=0, ck_size=None ):
for line_number, alignment in enumerate( bamfile ) :
# return only Header lines if 'header_line_count' exceeds 'ck_size'
# FIXME: Can be problematic if bam has million lines of header
last_read = bamfile.tell()
offset = bamfile.tell()
if ( line_number + header_line_count ) > ck_size:
break
else:
bamline = alignment.tostring( bamfile )
# Galaxy display each tag as separate column because 'tostring()' funcition put spaces in between each tag of tags column.
# Below code will remove spaces between each tag.
bamline_modified = ('\t').join( bamline.split()[:11] + [ ('').join(bamline.split()[11:]) ] )
ck_data = ck_data + "\n" + bamline_modified
ck_data = "%s\n%s" % ( ck_data, bamline_modified )
return dumps( { 'ck_data': util.unicodify( ck_data ),
'offset': last_read } )
'offset': offset } )

def display_data( self, trans, dataset, preview=False, filename=None, to_ext=None, offset=None, ck_size=None, **kwd):
preview = util.string_as_bool( preview )
Expand Down

0 comments on commit 0cfdfbf

Please sign in to comment.