# 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
    "count": 10,
    "freq": 0.10,
    "mutationalClass": [
                                {
                                    u"ORF": u"PA",
                                    u"aminoAcidPos": 6,
                                    u"classification": u"Synonymous",
                                    u"codingPos": 20,
                                    u"codonPos": 2,
                                    u"consensusAA": u"Q",
                                    u"varAA": u"Q"
                                }
                            ],
    "nucleotide": u"G",
    "concat_pos": 4728,
    "consensus": u"A",
    "coverage": 100,
    "pos": 44
    }]
        
    def tearDown(self):
        """
        This method is called after each test
        """
        pass
    def test_parse_correctly(self):
        """
        Test that we can add bases and count correctly
        """
        x = parseJson(json.loads(self.jsonString))

# 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

    "count": 10,
    "freq": 0.10,
    "mutationalClass": [
                                {
                                    u"ORF": u"PA",
                                    u"aminoAcidPos": 6,
                                    u"classification": u"Synonymous",
                                    u"codingPos": 20,
                                    u"codonPos": 2,
                                    u"consensusAA": u"Q",
                                    u"varAA": u"Q"
                                }
                            ],
    "nucleotide": u"G",
    "concat_pos": 4728,
    "consensus": u"A",
    "coverage": 100,
    "pos": 44
    }]
        
    def tearDown(self):
        """
        This method is called after each test
        """
        pass
    def test_parse_correctly(self):
        """
        Test that we can add bases and count correctly
        """
        x = parseJson(json.loads(self.jsonString))

        self.assertListEqual(self.solution,parseJson(json.loads(self.jsonString)))