comparison bamparse.py @ 1:ae9ea0488850 draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/bamparse commit 9aec415b3fcc66bf3ed2aad43fd70b57bfe2fb18
author artbio
date Sun, 15 Oct 2017 19:14:29 -0400
parents 2a1a2bc6ae8b
children 8ea06787c08a
comparison
equal deleted inserted replaced
0:2a1a2bc6ae8b 1:ae9ea0488850
60 def writetable(diclist, labels, output, number): 60 def writetable(diclist, labels, output, number):
61 ''' diclist is a list of count dictionnaries ''' 61 ''' diclist is a list of count dictionnaries '''
62 countlists = [] 62 countlists = []
63 for dic in diclist: 63 for dic in diclist:
64 counts = sorted(dic.items()) 64 counts = sorted(dic.items())
65 counts = [j for (i,j) in counts] 65 counts = [j for (i, j) in counts]
66 countlists.append(counts) 66 countlists.append(counts)
67 if number == "unique": 67 if number == "unique":
68 out = open("outputdir/table.tabular", "w") 68 out = open("outputdir/table.tabular", "w")
69 out.write("gene\t%s\n" % "\t".join(labels)) 69 out.write("gene\t%s\n" % "\t".join(labels))
70 for countline in zip(sorted(diclist[0]), *countlists): 70 for countline in zip(sorted(diclist[0]), *countlists):
71 line = [ str(i) for i in countline] 71 line = [str(i) for i in countline]
72 out.write("%s\n" % "\t".join(line)) 72 out.write("%s\n" % "\t".join(line))
73 out.close() 73 out.close()
74 else: 74 else:
75 for i, (dic, label) in enumerate(zip(diclist, labels)): 75 for i, (dic, label) in enumerate(zip(diclist, labels)):
76 out = open("outputdir/table" + str(i) + ".tabular", "w") 76 out = open("outputdir/table" + str(i) + ".tabular", "w")
77 out.write("gene\t%s\n" % label) 77 out.write("gene\t%s\n" % label)
78 for gene in sorted(dic): 78 for gene in sorted(dic):
79 out.write("%s\t%s\n" % (gene, dic[gene])) 79 out.write("%s\t%s\n" % (gene, dic[gene]))
80 out.close() 80 out.close()
81
82 81
83 82
84 def main(alignments, labels, polarity, output, number): 83 def main(alignments, labels, polarity, output, number):
85 diclist = [] 84 diclist = []
86 for file in alignments: 85 for file in alignments: