-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-proteins
executable file
·52 lines (32 loc) · 1.02 KB
/
load-proteins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import nearproteins as nerp
import argparse
import logging
from Bio import SeqIO
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--input', default='/dev/stdin')
parser.add_argument('--output', default='/dev/stdout')
return parser.parse_args()
def main():
args = parse_args()
logging.basicConfig(level=logging.INFO,
filename='/dev/stderr')
store = nerp.SimilarStringStore()
logging.info('store: %s' % store)
logging.info('adding proteins to store')
with open(args.input) as handle:
records = { int(r.id): str(r.seq) for r in SeqIO.parse(handle, 'fasta') }
for id, seq in records.items():
store.add(id, seq)
store.build_and_save()
store.load()
caught, missed = 0, 0
for id, seq in records.items():
if id in set(store.query(seq)):
caught += 1
else:
missed += 1
print('{} caught, {} missed'.format(caught, missed))
if __name__ == '__main__':
main()