-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quick utility to set name in a .sig file
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#! /usr/bin/env python | ||
from __future__ import print_function | ||
import sys | ||
import os, os.path | ||
import argparse | ||
import csv | ||
|
||
import sourmash_lib | ||
from sourmash_lib import signature as sig | ||
from sourmash_lib import fig as sourmash_fig | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('sigfile') | ||
parser.add_argument('name') | ||
args = parser.parse_args() | ||
|
||
print('setting name on %s to %s' % (args.sigfile, args.name)) | ||
|
||
with open(args.sigfile, 'rt') as fp: | ||
sigs = sig.load_signatures(fp) | ||
|
||
for s in sigs: | ||
s.d['name'] = args.name | ||
|
||
outputname = os.path.basename(args.sigfile) | ||
with open(outputname, 'wt') as fp: | ||
sig.save_signatures(sigs, fp) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
|