Commit 5e73cabf authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Merge branch 'fix-include-sequence' into 'develop'

Fix loss of last fasta entry. Solves #31

See merge request SOaAS/psot!7
parents 639c784e 171d47d8
import sys
import json
import argparse
parser = argparse.ArgumentParser(description='Convert a fasta file into a json document')
parser.add_argument('--result', '-r', required=True, help='The fasta file result directory')
parser.add_argument('--result', '-r', required=True, help='The fasta file')
parser.add_argument('--output', '-o', required=True, help='The json file')
args = parser.parse_args()
documents = {}
with open(args.result) as f:
# second scan for data
entry = None
id = None
for line in f:
if line.startswith(">"):
id = line.split()[0][1:]
if entry is not None:
documents[entry['id']] = entry
entry = {'id': id, 'sequence': ''}
entry['sequence'] = entry['sequence'] + line.strip()
id = line.split()[0][1:]
documents[id] = {'id': id, 'sequence': ''}
elif id is not None:
documents[id]['sequence'] += line.strip()
output_filename = args.output
with open(output_filename, 'w') as o:
Supports Markdown
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