X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=htsworkflow%2Fpipelines%2Fsummary.py;h=c3c5919977d3f3847a981f0ed826ea6bb9d1f301;hp=8f47670d99521f37fc8afe75ab8edf292b4c5396;hb=refs%2Fheads%2Fpython3-django1.5;hpb=4262586d10cc0cc227390873b301b55244204c11 diff --git a/htsworkflow/pipelines/summary.py b/htsworkflow/pipelines/summary.py index 8f47670..c3c5919 100644 --- a/htsworkflow/pipelines/summary.py +++ b/htsworkflow/pipelines/summary.py @@ -40,9 +40,9 @@ class Summary(object): def get_elements(self): summary = etree.Element(Summary.SUMMARY, - {'version': unicode(Summary.XML_VERSION)}) + {'version': str(Summary.XML_VERSION)}) for end in self.lane_results: - for lane in end.values(): + for lane in list(end.values()): summary.append(lane.get_elements()) return summary @@ -67,7 +67,7 @@ class Summary(object): Debugging function, report current object """ tree = self.get_elements() - print etree.tostring(tree) + print(etree.tostring(tree)) class SummaryGA(Summary): def __init__(self, filename=None, xml=None): @@ -130,7 +130,7 @@ class SummaryGA(Summary): ('Lane Results Summary : Read 1', 0), ('Lane Results Summary : Read 2', 1),] for name, end in table_names: - if tables.has_key(name): + if name in tables: self._extract_lane_results_for_end(tables, name, end) if len(self.lane_results[0]) == 0: @@ -280,13 +280,13 @@ class LaneResultSummary(object): def get_elements(self): lane_result = etree.Element( LaneResultSummary.LANE_RESULT_SUMMARY, - {'lane': unicode(self.lane), 'end': unicode(self.end)}) - for tag, variable_name in LaneResultSummary.TAGS.items(): + {'lane': str(self.lane), 'end': str(self.end)}) + for tag, variable_name in list(LaneResultSummary.TAGS.items()): value = getattr(self, variable_name) if value is None: continue # it looks like a sequence - elif type(value) in (types.TupleType, types.ListType): + elif type(value) in (tuple, list): element = make_mean_range_element( lane_result, tag, @@ -294,7 +294,7 @@ class LaneResultSummary(object): ) else: element = etree.SubElement(lane_result, tag) - element.text = unicode(value) + element.text = str(value) return lane_result def set_elements(self, tree): @@ -311,7 +311,7 @@ class LaneResultSummary(object): variable_name = tags[element.tag] setattr(self, variable_name, parse_summary_element(element)) - except KeyError, e: + except KeyError as e: LOGGER.warn('Unrecognized tag %s' % (element.tag,)) @@ -333,7 +333,7 @@ class LaneResultSummaryGA(LaneResultSummary): else: self.lane_yield = None - for GeraldName, LRSName in LaneResultSummary.GERALD_TAGS.items(): + for GeraldName, LRSName in list(LaneResultSummary.GERALD_TAGS.items()): node = element.find(GeraldName) if node is None: LOGGER.info("Couldn't find %s" % (GeraldName)) @@ -414,7 +414,7 @@ def tonumber(v): """ try: v = int(v) - except ValueError, e: + except ValueError as e: v = float(v) return v @@ -442,8 +442,8 @@ def make_mean_range_element(parent, name, mean, deviation): Make an etree subelement """ element = etree.SubElement(parent, name, - { 'mean': unicode(mean), - 'deviation': unicode(deviation)}) + { 'mean': str(mean), + 'deviation': str(deviation)}) return element def parse_mean_range_element(element):