Commit 6ddf8881 authored by hmueller's avatar hmueller
Browse files

Minor code cleanup.

parent 6f1bf564
......@@ -2,11 +2,10 @@
import argparse
import fileinput
import os
parser = argparse.ArgumentParser(description='Replaces fasta headers with unique numbers and saves both in tsv format')
parser = argparse.ArgumentParser(description='Replaces fasta headers with unique numbers and saves a dictionary of both in tsv format')
parser.add_argument('--fasta', '-f', required=True, help='The fasta file')
parser.add_argument('--enum-headers-dir', '-d', default='.', help='Target directory for headers file enum_headers.tsv')
parser.add_argument('--enum-headers-dir', '-d', default='.', help='Target directory for headers dictionary file enum_headers.tsv')
args = parser.parse_args()
fasta = args.fasta
......@@ -24,6 +23,7 @@ with fileinput.FileInput(fasta, inplace=True) as f:
print(line, end='')
enum_headers_file = args.enum_headers_dir + '/enum_headers.tsv'
with open(enum_headers_file, 'w') as o:
for key in headers_dict:
o.write("{}\t{}\n".format(key, headers_dict[key]))
......@@ -3,7 +3,7 @@
import json
import argparse
parser = argparse.ArgumentParser(description='Substitute enumerated id of sequence with original identifier')
parser = argparse.ArgumentParser(description='Replace enumerated id of sequences with original identifier')
parser.add_argument('--json', '-j', required=True, help='The results json file')
parser.add_argument('--enum-headers', '-e', required=True, help='The enumerated original headers in tsv format')
args = parser.parse_args()
......@@ -16,7 +16,7 @@ with open(args.json) as j:
with open(args.enum_headers) as h:
for line in h:
num, header = line.strip().split('\t')
num, header = line.strip().split('\t', 1)
seq_id_dict[num] = header.split()[0]
documents_restored = {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment