| 1 |
|
| 2 |
import os.path |
| 3 |
|
| 4 |
|
| 5 |
def eprint(*args, **kwargs): |
| 6 |
print(*args, file=sys.stderr, **kwargs) |
| 7 |
|
| 8 |
|
| 9 |
class Gramstain(dict): |
| 10 |
""" |
| 11 |
""" |
| 12 |
gram_neg_file = ("{}/gram_neg.txt" |
| 13 |
.format(os.path.abspath(os.path.dirname(__file__)))) |
| 14 |
gram_pos_file = ("{}/gram_pos.txt" |
| 15 |
.format(os.path.abspath(os.path.dirname(__file__)))) |
| 16 |
|
| 17 |
def __init__(self): |
| 18 |
""" |
| 19 |
""" |
| 20 |
self.load_gram_file(file=Gramstain.gram_neg_file, gram="-") |
| 21 |
self.load_gram_file(file=Gramstain.gram_pos_file, gram="+") |
| 22 |
|
| 23 |
def load_gram_file(self, file, gram): |
| 24 |
""" |
| 25 |
""" |
| 26 |
with open(file, "r") as fh: |
| 27 |
for line in fh: |
| 28 |
line = line.rstrip() |
| 29 |
if(not line): |
| 30 |
continue |
| 31 |
if(line.startswith("#")): |
| 32 |
continue |
| 33 |
self[line.lower()] = gram |