Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/6070ac379ec8
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:31:07 2012
Кодировка:
allpy: 6070ac379ec8

allpy

changeset 447:6070ac379ec8

repeats: use hash instead of tuple to distinguish intervals Interval.__hash__ returns hash(tuple(...)) tuple contains significant properties of interval Previously method .tuple() was used
author boris <bnagaev@gmail.com>
date Tue, 15 Feb 2011 23:25:36 +0300
parents b8371cf32aed
children 63e3ae08de77 919b2eeaec89
files repeats/repeat_joiner.py repeats/test.py
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/repeats/repeat_joiner.py	Tue Feb 15 22:51:10 2011 +0300
     1.2 +++ b/repeats/repeat_joiner.py	Tue Feb 15 23:25:36 2011 +0300
     1.3 @@ -68,8 +68,8 @@
     1.4      def __ne__(self, other):
     1.5          return not (self == other)
     1.6  
     1.7 -    def tuple(self):
     1.8 -        return (self.start, self.end, self.ori, self.chromosome)
     1.9 +    def __hash__(self):
    1.10 +        return hash((self.start, self.end, self.ori, self.chromosome))
    1.11  
    1.12      def thin_edges(self, min_intersection=config.min_intersection):
    1.13          """ return all thin edges (intersected intervals) """
     2.1 --- a/repeats/test.py	Tue Feb 15 22:51:10 2011 +0300
     2.2 +++ b/repeats/test.py	Tue Feb 15 23:25:36 2011 +0300
     2.3 @@ -29,10 +29,10 @@
     2.4  print "group\tchr\tchr_from\tchr_to\tgroup_from\tgroup_to\tori\tgroup_ori"
     2.5  for i, interval_group in enumerate(rj.interval_groups):
     2.6      interval_group.sort(key=lambda i: i.group_start)
     2.7 -    prev = set()
     2.8 +    used = set()
     2.9      for interval in interval_group:
    2.10 -        if interval.tuple() in prev:
    2.11 +        if interval in used:
    2.12              continue
    2.13 -        prev.add(interval.tuple())
    2.14 +        used.add(interval)
    2.15          print "%i\t%s" % (i, str(interval).replace(' ', '\t'))
    2.16