63c73fb7fa9838b6797aaf932654758d6f8c0fb2 wong Mon Jan 9 15:25:30 2012 -0800 had drop vs new backwards diff --git python/lib/ucscgenomics/ra.py python/lib/ucscgenomics/ra.py index 9b675f3..ebf8663 100644 --- python/lib/ucscgenomics/ra.py +++ python/lib/ucscgenomics/ra.py @@ -276,52 +276,52 @@ if stanza.name not in other.keys(): RetThis[stanza.name] = stanza else: if stanza.difference(other[stanza.name]): RetThis[stanza.name] = stanza.difference(other[stanza.name]) return RetThis def changeSummary(self, otherRa): ''' Input: Two RaFile objects Output: Dictionary showing differences between stanzas, list of added and dropeed stanzas ''' retDict = collections.defaultdict(list) - dropList = set(self.iterkeys()) - set(otherRa.iterkeys()) - addList = set(otherRa.iterkeys()) - set(self.iterkeys()) + addList = set(self.iterkeys()) - set(otherRa.iterkeys()) + dropList = set(otherRa.iterkeys()) - set(self.iterkeys()) common = set(self.iterkeys()) & set(otherRa.iterkeys()) p = re.compile('^\s*#') for stanza in common: if p.match(stanza): continue for key in self[stanza]: if p.match(key): continue if key in otherRa[stanza]: if self[stanza][key] != otherRa[stanza][key]: retDict[stanza].append("Changed %s from %s -> %s" %(key, otherRa[stanza][key], self[stanza][key])) else: retDict[stanza].append("Added %s -> %s" %(key, self[stanza][key])) for key in otherRa[stanza]: if p.match(key): continue if key not in self[stanza]: retDict[stanza].append("Dropped %s -> %s" %(key, otherRa[stanza][key])) - return retDict, dropList, addList + return retDict, addList, dropList def diffFilter(self, select, other): ''' Input: Lambda function of desired comparison term RaFile object being compared. Output: RaFile with differences. Filter returns ***full*** stanzas of a ***select function*** from the self dictionary compared to the other dictionary. For versatility, it only returns stanzas from the self Ra file. In other words, it only returns self dictionary stanzas with the function term that are either not found in or different from the other dictionary.