comparison baseline/script_xlsx.py @ 83:729738462297 draft

"planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
author rhpvorderman
date Wed, 15 Sep 2021 12:24:06 +0000
parents c33d93683a09
children
comparison
equal deleted inserted replaced
82:a103134ee6e0 83:729738462297
32 currentId = "" 32 currentId = ""
33 with xlrd.open_workbook(args.input, 'r') as wb: 33 with xlrd.open_workbook(args.input, 'r') as wb:
34 with open(args.output, 'a') as o: 34 with open(args.output, 'a') as o:
35 for sheet in wb.sheets(): 35 for sheet in wb.sheets():
36 if sheet.cell(1,gene_column).value.find("IGHV") < 0: 36 if sheet.cell(1,gene_column).value.find("IGHV") < 0:
37 print "Genes not in column " + LETTERS[gene_column] + ", skipping sheet " + sheet.name 37 print("Genes not in column " + LETTERS[gene_column] + ", skipping sheet " + sheet.name)
38 continue 38 continue
39 o.write(">>>" + sheet.name + "\n") 39 o.write(">>>" + sheet.name + "\n")
40 outputdic = dict() 40 outputdic = dict()
41 for rowindex in range(1, sheet.nrows): 41 for rowindex in range(1, sheet.nrows):
42 ref = sheet.cell(rowindex, gene_column).value.replace(">", "") 42 ref = sheet.cell(rowindex, gene_column).value.replace(">", "")
44 outputdic[ref] += [(sheet.cell(rowindex, id_column).value.replace(">", ""), sheet.cell(rowindex, seq_column).value)] 44 outputdic[ref] += [(sheet.cell(rowindex, id_column).value.replace(">", ""), sheet.cell(rowindex, seq_column).value)]
45 else: 45 else:
46 outputdic[ref] = [(sheet.cell(rowindex, id_column).value.replace(">", ""), sheet.cell(rowindex, seq_column).value)] 46 outputdic[ref] = [(sheet.cell(rowindex, id_column).value.replace(">", ""), sheet.cell(rowindex, seq_column).value)]
47 #print outputdic 47 #print outputdic
48 48
49 for k in outputdic.keys(): 49 for k in list(outputdic.keys()):
50 if k in refdic: 50 if k in refdic:
51 o.write(">>" + k + "\n") 51 o.write(">>" + k + "\n")
52 o.write(refdic[k] + "\n") 52 o.write(refdic[k] + "\n")
53 for seq in outputdic[k]: 53 for seq in outputdic[k]:
54 #print seq 54 #print seq
55 o.write(">" + seq[0] + "\n") 55 o.write(">" + seq[0] + "\n")
56 o.write(seq[1] + "\n") 56 o.write(seq[1] + "\n")
57 else: 57 else:
58 print k + " not in reference, skipping " + k 58 print(k + " not in reference, skipping " + k)