You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

79 lines
1.6 KiB

#!/usr/bin/env python3
# standard library
import csv
# pip
import click
import pprint
from pprint import pprint
# local modules
import utils.fs
from utils.fs import search_dir
import utils.io
from utils.io import write_json
jfs2003id_loci = [
'D8S1179',
'D21S11',
'D7S820',
'CSF1PO',
'D3S1358',
'TH01',
'D13S317',
'D16S539',
'D2S1338',
'D19S433',
'vWA',
'TPOX',
'D18S51',
'AMEL',
'D5S818',
'FGA',
]
@click.group()
@click.pass_context
def convert(ctx):
pass
@convert.command()
@click.argument('input_dir', type=click.Path())
@click.argument('output_dir', type=click.Path())
@click.pass_context
def jfs2003id(ctx, input_dir, output_dir):
input_files = search_dir(input_dir, '*.csv')
output_dict = {}
for file_path in input_files:
with open(file_path, 'r') as f:
reader = csv.DictReader(f)
race_list = []
for row in reader:
tmp_dict = {}
name = row['Sample Info']
tmp_dict['name'] = name
for locus in jfs2003id_loci:
alleles = []
for i in range(2):
key = '%s %d' % (locus, (i+1))
alleles.append(row[key])
tmp_dict[locus] = alleles
race_list.append(tmp_dict)
output_dict[file_path.stem.split('-')[1]] = race_list
write_json('%s/jfs2003id.json' % output_dir, output_dict)