FASTQ Opt: No need to map(str) over chr and join, can just join chr's.

Prevent an extra array creation and chr-> str map per base. Shaves 10% off remaining run time of filter on SSD.

Kept 135848 of 250000 reads (54.34%).
         117012863 function calls (116762863 primitive calls) in 46.897 seconds

Down from 48.272 seconds on previous changset. Main Difference:

(ncalls|tottime|percall|cumtime|percall|filename:lineno(function))

   135848    0.502    0.000   22.979    0.000 fastq.py:99(convert_read_to_format)

 -became-

   135848    0.448    0.000   21.159    0.000 fastq.py:99(convert_read_to_format)

Not huge, but a consistent improvement.
This commit is contained in:
John Chilton
2013-11-12 22:02:58 -06:00
parent 99e59c3701
commit 078d860877
+3 -5
View File
@@ -1,4 +1,4 @@
#Dan Blankenberg
##Dan Blankenberg
import math
import string
import transform
@@ -126,12 +126,10 @@ class fastqSequencingRead( SequencingRead ):
new_encoding = force_quality_encoding
if new_encoding == 'ascii':
new_class.transform_scores_to_valid_range_ascii( score_list )
restricted_scores = map( str, score_list )
new_read.quality = "".join( restricted_scores )
new_read.quality = "".join( score_list )
else: # decimal
new_class.transform_scores_to_valid_range( score_list )
restricted_scores = map( str, score_list )
new_read.quality = "%s " % " ".join( restricted_scores ) #need trailing space to be valid decimal fastq
new_read.quality = "%s " % " ".join( score_list ) #need trailing space to be valid decimal fastq
return new_read
def get_sequence( self ):
return self.sequence