From 078d860877019a85958dc2b5709f2b2da96d00b3 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 12 Nov 2013 22:02:58 -0600 Subject: [PATCH] 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. --- lib/galaxy_utils/sequence/fastq.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/galaxy_utils/sequence/fastq.py b/lib/galaxy_utils/sequence/fastq.py index 7f7e0489da6..eb1a2f6a8c3 100644 --- a/lib/galaxy_utils/sequence/fastq.py +++ b/lib/galaxy_utils/sequence/fastq.py @@ -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