# Path: scripts/variantJSONtocsv.py
# def parseJson(data):
# 	parsedDataSet = []
# 	sample = data["Sample"]
# 	genome = data["genome"]
# 	for i in range(0,len(genome)):
# 		#cycle through each segment
# 		chr = genome[i]["chr"]
# 		for j in range(0,len(genome[i]['seq'])):
# 			consensus = genome[i]['seq'][j]['consensus']
# 			coverage = genome[i]['seq'][j]['coverage']
# 			concat_pos = genome[i]['seq'][j]['concat_pos']
# 			pos = genome[i]['seq'][j]['pos']
# 			for key in genome[i]['seq'][j]['alleles'].keys():
# 				freq = genome[i]['seq'][j]['alleles'][key]['freq']
# 				nt = genome[i]['seq'][j]['alleles'][key]['nucleotide']
# 				count = genome[i]['seq'][j]['alleles'][key]['count']
# 				datapoint = {
# 					"Sample": sample,
# 					"chr": chr,
# 					"nucleotide": nt,
# 					"consensus": consensus,
# 					"pos": pos,
# 					"concat_pos": concat_pos,
# 					"freq": freq,
# 					"count": count,
# 					"coverage": coverage,
# 					"mutationalClass": genome[i]['seq'][j]['alleles'][key]['mutationalClass']
# 				}
# 				parsedDataSet.append(datapoint)
# 	return(parsedDataSet)


import unittest
import copy
import json
from scripts.variantJSONtocsv import parseJson


class parsejsonfile(unittest.TestCase):
    def setUp(self):
        self.maxDiff=2000
        self.jsonString='{"Sample":"5_5","genome":[{ "chr":"PA", "seq":[ { "alleles":{ "A":{ "count":90, "freq":0.90, "mutationalClass":[ { "ORF":"PA", "aminoAcidPos":6, "classification":"Synonymous", "codingPos":20, "codonPos":2, "consensusAA":"Q", "varAA":"Q" } ], "nucleotide":"A" }, "G":{ "count":10, "freq":0.10, "mutationalClass":[ { "ORF":"PA", "aminoAcidPos":6, "classification":"Synonymous", "codingPos":20, "codonPos":2, "consensusAA":"Q", "varAA":"Q" } ], "nucleotide":"G" } }, "concat_pos":4728, "consensus":"A", "coverage":100, "pos":44 }]}]}'
        self.solution =[{
    "Sample": u"5_5",
    "chr": u"PA",

# Path: scripts/variantJSONtocsv.py
# def parseJson(data):
# 	parsedDataSet = []
# 	sample = data["Sample"]
# 	genome = data["genome"]
# 	for i in range(0,len(genome)):
# 		#cycle through each segment
# 		chr = genome[i]["chr"]
# 		for j in range(0,len(genome[i]['seq'])):
# 			consensus = genome[i]['seq'][j]['consensus']
# 			coverage = genome[i]['seq'][j]['coverage']
# 			concat_pos = genome[i]['seq'][j]['concat_pos']
# 			pos = genome[i]['seq'][j]['pos']
# 			for key in genome[i]['seq'][j]['alleles'].keys():
# 				freq = genome[i]['seq'][j]['alleles'][key]['freq']
# 				nt = genome[i]['seq'][j]['alleles'][key]['nucleotide']
# 				count = genome[i]['seq'][j]['alleles'][key]['count']
# 				datapoint = {
# 					"Sample": sample,
# 					"chr": chr,
# 					"nucleotide": nt,
# 					"consensus": consensus,
# 					"pos": pos,
# 					"concat_pos": concat_pos,
# 					"freq": freq,
# 					"count": count,
# 					"coverage": coverage,
# 					"mutationalClass": genome[i]['seq'][j]['alleles'][key]['mutationalClass']
# 				}
# 				parsedDataSet.append(datapoint)
# 	return(parsedDataSet)


# Path: test/parsejson_test.py
import unittest
import copy
import json
from scripts.variantJSONtocsv import parseJson



class parsejsonfile(unittest.TestCase):
    def setUp(self):
        self.maxDiff=2000
        self.jsonString='{"Sample":"5_5","genome":[{ "chr":"PA", "seq":[ { "alleles":{ "A":{ "count":90, "freq":0.90, "mutationalClass":[ { "ORF":"PA", "aminoAcidPos":6, "classification":"Synonymous", "codingPos":20, "codonPos":2, "consensusAA":"Q", "varAA":"Q" } ], "nucleotide":"A" }, "G":{ "count":10, "freq":0.10, "mutationalClass":[ { "ORF":"PA", "aminoAcidPos":6, "classification":"Synonymous", "codingPos":20, "codonPos":2, "consensusAA":"Q", "varAA":"Q" } ], "nucleotide":"G" } }, "concat_pos":4728, "consensus":"A", "coverage":100, "pos":44 }]}]}'
        self.solution =[{
    "Sample": u"5_5",
    "chr": u"PA",

    "count": 90,