Skip to content

Instantly share code, notes, and snippets.

@ctb
Created September 28, 2018 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctb/94b811dccacbe559dd8d5241fa74cb19 to your computer and use it in GitHub Desktop.
Save ctb/94b811dccacbe559dd8d5241fa74cb19 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
"""
Usage:
python -m screed db <sequencefile>
python extract-screed.py <list of names> <sequencefile>
"""
import argparse, screed, sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument('names')
parser.add_argument('dbfile')
args = parser.parse_args()
names = set([ x.strip() for x in open(args.names) ])
found = set()
db = screed.ScreedDB(args.dbfile)
for name in names:
record = db.get(name)
if record:
print('>{}\n{}'.format(record.name, record.sequence))
else:
sys.stderr.write('key "{}" not in database\n'.format(name))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment