allpy
changeset 653:2125782780c6
50% speed up for blocks_finder due to local application of remove_contained_preblocks.
For every preblock that is going to be extended by all the groups,
I first check that the resulting preblocks don't overlap. Due to
this local check we get slight advantage in speed.
| author | Boris Burkov <BurkovBA@gmail.com> |
|---|---|
| date | Sun, 12 Jun 2011 15:36:07 +0400 |
| parents | 7c27a4174954 |
| children | c32e728b98d7 |
| files | sequence_based_blocks_search/blocks_finder.py |
| diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/sequence_based_blocks_search/blocks_finder.py Fri Jun 10 16:15:35 2011 +0400 1.2 +++ b/sequence_based_blocks_search/blocks_finder.py Sun Jun 12 15:36:07 2011 +0400 1.3 @@ -88,10 +88,13 @@ 1.4 print "Found non-canonical aminoacid: %s"%(ke) 1.5 #create new preblocks as combinations of the old ones 1.6 try: 1.7 - for group_name in functional_groups: 1.8 - for preblock in candidate_preblocks: 1.9 + for preblock in candidate_preblocks: 1.10 + preblock_extensions = [] 1.11 + for group_name in functional_groups: 1.12 if len([sequence_in_block for sequence_in_block in groups_content[column][group_name] if sequence_in_block in preblock.sequences]) > 1: 1.13 - addition_to_candidate_preblocks.append(Preblock(preblock.first_column_index, index_of_column, [sequence_in_block for sequence_in_block in groups_content[column][group_name] if sequence_in_block in preblock.sequences], preblock.term1+functional_groups[group_name]["70%"], preblock.term2+functional_groups[group_name]["100%"], preblock.term3, alignment)) 1.14 + preblock_extensions.append(Preblock(preblock.first_column_index, index_of_column, [sequence_in_block for sequence_in_block in groups_content[column][group_name] if sequence_in_block in preblock.sequences], preblock.term1+functional_groups[group_name]["70%"], preblock.term2+functional_groups[group_name]["100%"], preblock.term3, alignment)) 1.15 + remove_contained_preblocks(preblock_extensions) 1.16 + addition_to_candidate_preblocks+=preblock_extensions 1.17 except KeyError as ke: 1.18 print "Found non-canonical aminoacid: %s"%(ke) 1.19 #add one inconserved column to the old ones, merge all together
