Config = ConfigParser.ConfigParser()
Config.read(configfile)

members=ConfigSectionMap("Inputs")["sample_id"]
target_pattern=ConfigSectionMap("Inputs")["target"]
stress_cutoff=ConfigSectionMap("Inputs")["stress_cutoff"]
freq_cutoff=ConfigSectionMap("Inputs")["qaf_cutoff"]
candidate_cutoff=ConfigSectionMap("Inputs")["score_cutoff"]
snpeff_file=ConfigSectionMap("Inputs")["snpeff_file"]

snpeff_file=snpeff_file.replace('"','')

### Creating objects for annotater and
## segregation classes
segregation_object = segregation()
annotation_object = annotater()

## Reading input mergedVCF file
vcf_Reader=vcf.Reader(open(inputfile),'r')

target = open(outputfile, 'w')

target.write("#Chromosome\tPosition\tReference\tAllele\tcandidate_stress\tmax_score\tmin_score\tavg_score\tCount\tKaviar\tUCSC_gene\tclinvar\tcms_annotation\tcadd_annotation\tsnpeff_annotation\tcandidate_score\n")

## The following reads the mergedVCF using python's VCF tools
## All positions that are homozygous reference [ALT=.] are skipped here.
## Every line is then passed onto the process_genotype function to get information 
## about sample specific genotypes and quality scores.
## Next the script calls the compute_sequence_quality_score_statistics function to get 
## maximum,minimum and average scores. In the further steps unique alleles at every position
target_inheritance = targets.split(",")
target_hash = {}
for pattern in target_inheritance:
    completeName = os.path.join(outdir,
                                'candidate_pattern_' + pattern + '.txt')
    writer_pattern = open(completeName, 'w')
    target_hash[pattern] = writer_pattern
    header_out(pattern, writer_pattern)

##Database connection to Impala
conn = connect(host='glados19', port=21050, database=db_user)
DB = conn.cursor()
DB.execute("SELECT VERSION()")
results = DB.fetchone()

segregation_object = segregation()  #Object for the segregation class
"""
Vividict allows creation of perl like
hashes of hashes or multi key level hash
User would always have to point their hash/dict to Vividict
Eg: hash_dict=Vividict()

"""


class Vividict(dict):
    def __missing__(self, key):
        value = self[key] = type(self)()
        return value

    writer_pattern = open(completeName, 'w')
    target_hash[pattern]=writer_pattern
    header_out(pattern,writer_pattern)

##Database connection to Impala
try:
    conn=connect(host='glados19', port=21050,database=db_user)
    DB = conn.cursor()
    DB.execute("SELECT VERSION()")
    results=DB.fetchone()
    print ("Connection successful")
except:
    print("Connection failed, check if connection parameters are correct")
    sys.exit()

segregation_object=segregation()  #Object for the segregation class

"""
Vividict allows creation of perl like
hashes of hashes or multi key level hash
User would always have to point their hash/dict to Vividict
Eg: hash_dict=Vividict()

"""
class Vividict(dict):
    def __missing__(self, key):
        value= self[key] = type(self)()
        return value

"""
The compute_sequence_quality_score_statistics returns