From fa410aa2d6d4355115855f6047770d4384175b02 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 21 Nov 2022 09:18:36 -0500 Subject: [PATCH] Review fixes --- lib/galaxy/datatypes/registry.py | 3 -- lib/galaxy/datatypes/tabular.py | 83 +++++++------------------------- 2 files changed, 18 insertions(+), 68 deletions(-) diff --git a/lib/galaxy/datatypes/registry.py b/lib/galaxy/datatypes/registry.py index 4fa5b3d9e27..746761d9a74 100644 --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -711,7 +711,6 @@ class Registry: "customtrack": interval.CustomTrack(), "csfasta": sequence.csFasta(), "fasta": sequence.Fasta(), - "psl": tabular.Psl(), "eland": tabular.Eland(), "fastq": sequence.Fastq(), "fastqsanger": sequence.FastqSanger(), @@ -760,7 +759,6 @@ class Registry: "maf": "text/plain", "memexml": "application/xml", "pileup": "text/plain", - "psl": "text/plain", "qualsolid": "text/plain", "qualsolexa": "text/plain", "qual454": "text/plain", @@ -805,7 +803,6 @@ class Registry: interval.Gff(), interval.Gff3(), tabular.Pileup(), - tabular.Psl(), interval.Interval(), tabular.Sam(), tabular.Eland(), diff --git a/lib/galaxy/datatypes/tabular.py b/lib/galaxy/datatypes/tabular.py index 473576da9fe..4c38d82dc51 100644 --- a/lib/galaxy/datatypes/tabular.py +++ b/lib/galaxy/datatypes/tabular.py @@ -1817,10 +1817,6 @@ class Psl(Tabular): "tStarts", ] - def display_peek(self, dataset): - """Returns formated html of peek""" - return self.make_html_table(dataset, column_names=self.column_names) - def sniff_prefix(self, file_prefix: FilePrefix): """ PSL lines represent alignments, and are typically generated @@ -1862,6 +1858,11 @@ class Psl(Tabular): >>> Psl().sniff( fname ) False """ + def check_items(s): + s_items = s.split(",") + for item in s_items: + if int(item) < 0: + raise Exception("Out of range") count = 0 for line in file_prefix.line_iterator(): line = line.strip() @@ -1874,72 +1875,24 @@ class Psl(Tabular): items = line.split("\t") if len(items) != 21: return False - # matches - if int(items[0]) < 0: - raise Exception("Out of range") - # misMatches - if int(items[1]) < 0: - raise Exception("Out of range") - # repMatches - if int(items[2]) < 0: - raise Exception("Out of range") - # nCount - if int(items[3]) < 0: - raise Exception("Out of range") - # qNumInsert - if int(items[4]) < 0: - raise Exception("Out of range") - # qBaseInsert - if int(items[5]) < 0: - raise Exception("Out of range") - # tNumInsert - if int(items[6]) < 0: - raise Exception("Out of range") - # tBaseInsert - if int(items[7]) < 0: - raise Exception("Out of range") + # tName is a string + items.pop(13) + # qName is a string + items.pop(9) # strand - if items[8] not in ["-", "+", "+-", "-+"]: + if items.pop(8) not in ["-", "+", "+-", "-+"]: raise Exception("Invalid strand") - # qSize - if int(items[10]) < 0: - raise Exception("Out of range") - # qStart - if int(items[11]) < 0: - raise Exception("Out of range") - # qEnd - if int(items[12]) < 0: - raise Exception("Out of range") - # tSize - if int(items[14]) < 0: - raise Exception("Out of range") - # tStart - if int(items[15]) < 0: - raise Exception("Out of range") - # tEnd - if int(items[16]) < 0: - raise Exception("Out of range") - # blockCount - if int(items[17]) < 0: - raise Exception("Out of range") # blockSizes - s = items[18].rstrip(",") - s_items = s.split(",") - for item in s_items: - if int(item) < 0: - raise Exception("Out of range") + s = items.pop(15).rstrip(",") + check_items(s) # qStarts - s = items[19].rstrip(",") - s_items = s.split(",") - for item in s_items: - if int(item) < 0: - raise Exception("Out of range") + s = items.pop(15).rstrip(",") + check_items(s) # tStarts - s = items[20].rstrip(",") - s_items = s.split(",") - for item in s_items: - if int(item) < 0: - raise Exception("Out of range") + s = items.pop(15).rstrip(",") + check_items(s) + if any(int(item) < 0 for item in items): + raise Exception("Out of range") count += 1 if count == 10: break