def predict_json(json_in, json_out): """ predict the splicing effect with Houdayer method """ json_splice = JsonSplice(json_in) results = {} for counter in range(0, len(json_splice.json_dict)): # len(json_splice.json_dict) db_entry = json_splice.json_dict[counter] chrom = db_entry["chrom"] pos = db_entry["pos"] alt = db_entry["alt"] ref = db_entry["ref"] ID = db_entry["ID"] predict = SplicePredict(chrom, int(pos), ref, alt) predict.ID = ID predict.strategy = "Houdayer" # predict.load_json(json_splice) predict.score_annotate() effect, comments = predict.predict() print "[%s] chr%s:%s%s>%s : %s (%s)" % (ID, chrom, pos, ref, alt, ", ".join(effect), ", ".join(comments)) results[ID] = {"effect": effect, "comments": comments} with open(json_out, "w") as f: data = json.dumps(results, sort_keys=True, indent=4, separators=(",", ": "), ensure_ascii=True) data = unicode(data.strip(codecs.BOM_UTF8), "utf-8") f.write(data)
def predict_json(json_in, json_out, strategy = 'Houdayer'): ''' predict the splicing effect ''' print '***** PREDICTING *****' db1 = json.loads(open(json_in, 'r').read()) records = list() for record in db1: p = SplicePredict(record) p.set_ref_seq_gene(REFSEQGENE) p.set_ref_seq(REFSEQ) p.strategy = strategy p.predict() records.append(p) with open(json_out, 'w') as f: f.write(json.dumps(records, indent=4, ensure_ascii=False))