Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/galaxy/util/ucsc.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
comparison
equal
deleted
inserted
replaced
1:75ca89e9b81c | 2:6af9afd405e9 |
---|---|
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() |