def get_phenotypes(self, gene, diplotypes, sample_variants, uncallable, extra_variants=None): g = gene.name # Load phenotype file into object phenotypes = Phenotype() results = [] for sample, diplotype in diplotypes.items(): haps = split_genotype(diplotype) haplotype_data = {} for i in range(len(haps)): h = haps[i] h_function = phenotypes.get_haplotype_function(g, h) h_presumptive = phenotypes.get_presumptive_haplotype_function( g, h) haplotype_data["hap_%s" % i] = h haplotype_data["hap_%s_function" % i] = h_function haplotype_data["hap_%s_presumptive" % i] = h_presumptive phenotype = phenotypes.get_diplotype_function(g, haps[0], haps[1]) presumptive_phenotype = phenotypes.get_diplotype_function( g, haps[0], haps[1], presumptive=True) activity_score = phenotypes.get_activity_score(g, haps[0], haps[1], presumptive=True) #if phenotype != presumptive_phenotype: # print(phenotype, presumptive_phenotype) # exit() results.append({ "sample": sample, "gene": g, "diplotype": diplotype, "hap_1": haplotype_data["hap_0"], "hap_2": haplotype_data["hap_1"], "hap_1_function": haplotype_data["hap_0_function"], "hap_2_function": haplotype_data["hap_1_function"], "hap_1_presumptive_function": haplotype_data["hap_0_presumptive"], "hap_2_presumptive_function": haplotype_data["hap_1_presumptive"], "hap_1_variants": sample_variants[sample][0], "hap_2_variants": sample_variants[sample][1], "phenotype": phenotype, "phenotype_presumptive": presumptive_phenotype, "activity_score": activity_score, "uncallable": ";".join(x.split("%")[0] for x in uncallable[sample]), "extra_variants": None if extra_variants is None else ";".join( x.split("%")[0] for x in extra_variants[sample]) }) return results