Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/galaxy/util/ucsc.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 """ | |
2 Utilities for dealing with UCSC data. | |
3 """ | |
4 | |
5 | |
6 class UCSCLimitException(Exception): | |
7 pass | |
8 | |
9 | |
10 class UCSCOutWrapper: | |
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 next(self) |