Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/galaxy/util/ucsc.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d30785e31577 | 1:56ad4e20f292 |
---|---|
1 """ | |
2 Utilities for dealing with UCSC data. | |
3 """ | |
4 | |
5 | |
6 class UCSCLimitException(Exception): | |
7 pass | |
8 | |
9 | |
10 class UCSCOutWrapper(object): | |
11 """File-like object that throws an exception if it encounters the UCSC limit error lines""" | |
12 | |
13 def __init__(self, other): | |
14 self.other = iter(other) | |
15 # Need one line of lookahead to be sure we are hitting the limit message | |
16 self.lookahead = None | |
17 | |
18 def __iter__(self): | |
19 return self | |
20 | |
21 def __next__(self): | |
22 if self.lookahead is None: | |
23 line = next(self.other) | |
24 else: | |
25 line = self.lookahead | |
26 self.lookahead = None | |
27 if line.startswith("----------"): | |
28 next_line = next(self.other) | |
29 if next_line.startswith("Reached output limit"): | |
30 raise UCSCLimitException(next_line.strip()) | |
31 else: | |
32 self.lookahead = next_line | |
33 return line | |
34 | |
35 def next(self): | |
36 return self.__next__() | |
37 | |
38 def readline(self): | |
39 return self.next() |