annotate deseq/sam2counts_galaxy.py @ 0:d7f27b43b8ff draft

Uploaded
author nikhil-joshi
date Thu, 05 Jul 2012 21:02:43 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
1 #!/usr/bin/env python
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
2
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
3 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
4 count.py -- Take SAM files and output a table of counts with column
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
5 names that are the filenames, and rowname that are the reference
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
6 names.
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
7
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
8 Author: Vince Buffalo
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
9 Email: vsbuffaloAAAAA@gmail.com (with poly-A tail removed)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
10 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
11
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
12 VERSION = 0.91
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
13
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
14 import sys
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
15 import csv
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
16 from os import path
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
17 try:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
18 import pysam
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
19 except ImportError:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
20 sys.exit("pysam not installed; please install it\n")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
21
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
22 from optparse import OptionParser
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
23
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
24 def SAM_file_to_counts(filename, bam=False, extra=False, use_all_references=True):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
25 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
26 Take SAM filename, and create a hash of mapped and unmapped reads;
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
27 keys are reference sequences, values are the counts of occurences.
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
28
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
29 Also, a hash of qualities (either 0 or >0) of mapped reads
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
30 is output, which is handy for diagnostics.
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
31 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
32 counts = dict()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
33 unique = dict()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
34 nonunique = dict()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
35 mode = 'r'
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
36 if bam:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
37 mode = 'rb'
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
38 sf = pysam.Samfile(filename, mode)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
39
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
40 if use_all_references:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
41 # Make dictionary of all entries in header
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
42 for sn in sf.header['SQ']:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
43 if extra:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
44 unique[sn['SN']] = 0
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
45 nonunique[sn['SN']] = 0
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
46 counts[sn['SN']] = 0
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
47
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
48 for read in sf:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
49 if not read.is_unmapped:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
50 id_name = sf.getrname(read.rname) if read.rname != -1 else 0
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
51
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
52 if not use_all_references and not counts.get(id_name, False):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
53 ## Only make keys based on aligning reads, make empty hash
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
54 if extra:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
55 unique[id_name] = 0
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
56 nonunique[id_name] = 0
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
57 ## initiate entry; even if not mapped, record 0 count
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
58 counts[id_name] = counts.get(id_name, 0)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
59
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
60
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
61 counts[id_name] = counts.get(id_name, 0) + 1
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
62
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
63 if extra:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
64 if read.mapq == 0:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
65 nonunique[id_name] = nonunique[id_name] + 1
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
66 else:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
67 unique[id_name] = unique[id_name] + 1
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
68
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
69 if extra:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
70 return {'counts':counts, 'unique':unique, 'nonunique':nonunique}
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
71
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
72 return {'counts':counts}
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
73
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
74 def collapsed_nested_count_dict(counts_dict, all_ids, order=None):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
75 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
76 Takes a nested dictionary `counts_dict` and `all_ids`, which is
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
77 built with the `table_dict`. All files (first keys) in
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
78 `counts_dict` are made into columns with order specified by
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
79 `order`.
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
80
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
81 Output is a dictionary with keys that are the id's (genes or
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
82 transcripts), with values that are ordered counts. A header will
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
83 be created on the first row from the ordered columns (extracted
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
84 from filenames).
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
85 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
86 if order is None:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
87 col_order = counts_dict.keys()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
88 else:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
89 col_order = order
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
90
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
91 collapsed_dict = dict()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
92 for i, filename in enumerate(col_order):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
93 for id_name in all_ids:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
94 if not collapsed_dict.get(id_name, False):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
95 collapsed_dict[id_name] = list()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
96
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
97 # get counts and append
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
98 c = counts_dict[filename].get(id_name, 0)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
99 collapsed_dict[id_name].append(c)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
100 return {'table':collapsed_dict, 'header':col_order}
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
101
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
102
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
103 def counts_to_file(table_dict, outfilename, delimiter=',', labels=''):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
104 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
105 A function for its side-effect of writing `table_dict` (which
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
106 contains a table and header), to `outfilename` with the specified
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
107 `delimiter`.
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
108 """
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
109 writer = csv.writer(open(outfilename, 'w'), delimiter=delimiter)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
110 table = table_dict['table']
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
111 if labels:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
112 header = labels.split(',')
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
113 else:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
114 header = table_dict['header']
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
115
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
116 header_row = True
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
117 for id_name, fields in table.items():
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
118 if header_row:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
119 row = ['id'] + header
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
120 writer.writerow(row)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
121 header_row = False
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
122
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
123 if id_name == 0:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
124 continue
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
125 row = [id_name]
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
126 row.extend(fields)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
127 writer.writerow(row)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
128
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
129 if __name__ == '__main__':
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
130 parser = OptionParser()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
131 parser.add_option("-d", "--delimiter", dest="delimiter",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
132 help="the delimiter (default: tab)", default='\t')
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
133 parser.add_option("-o", "--out-file", dest="out_file",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
134 help="output filename (default: counts.txt)",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
135 default='counts.txt', action="store", type="string")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
136 parser.add_option("-u", "--extra-output", dest="extra_out",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
137 help="output extra information on non-unique and unique mappers (default: False)",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
138 default=False, action="store_true")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
139 parser.add_option("-b", "--bam", dest="bam",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
140 help="all input files are BAM (default: False)",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
141 default=False, action="store_true")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
142 parser.add_option("-r", "--use-all-references", dest="use_all_references",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
143 help="Use all the references from the SAM header (default: True)",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
144 default=True, action="store_false")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
145 parser.add_option("-f", "--extra-out-files", dest="extra_out_files",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
146 help="comma-delimited filenames of unique and non-unique output "
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
147 "(default: unique.txt,nonunique.txt)",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
148 default='unique.txt,nonunique.txt', action="store", type="string")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
149 parser.add_option("-v", "--verbose", dest="verbose",
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
150 help="enable verbose output")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
151 parser.add_option("-l", "--columns-labels", dest="col_labels", help="comma-delimited label names for samples", action="store", type="string")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
152
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
153 (options, args) = parser.parse_args()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
154
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
155 if len(args) < 1:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
156 parser.error("one or more SAM files as arguments required")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
157
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
158 file_counts = dict()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
159 file_unique_counts = dict()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
160 file_nonunique_counts = dict()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
161 all_ids = list()
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
162 files = [path.basename(f) for f in args]
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
163
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
164 if options.col_labels and len(files) != len(options.col_labels.split(',')):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
165 parser.error("Number of sample names does not equal number of files")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
166
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
167 if len(set(files)) != len(set(args)):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
168 parser.error("file args must have unique base names (i.e. no foo/bar joo/bar)")
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
169
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
170 ## do a pre-run check that all files exist
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
171 for full_filename in args:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
172 if not path.exists(full_filename):
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
173 parser.error("file '%s' does not exist" % full_filename)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
174
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
175 for full_filename in args:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
176 filename = path.basename(full_filename)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
177 ## read in SAM file, extract counts, and unpack counts
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
178 tmp = SAM_file_to_counts(full_filename, bam=options.bam, extra=options.extra_out,
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
179 use_all_references=options.use_all_references)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
180
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
181 if options.extra_out:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
182 counts, unique, nonunique = tmp['counts'], tmp['unique'], tmp['nonunique']
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
183 else:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
184 counts = tmp['counts']
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
185
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
186 ## save counts, and unique/non-unique counts
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
187 file_counts[filename] = counts
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
188
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
189 if options.extra_out:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
190 file_unique_counts[filename] = unique
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
191 file_nonunique_counts[filename] = nonunique
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
192
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
193 ## add all ids encountered in this in this file
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
194 all_ids.extend(file_counts[filename].keys())
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
195
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
196 ## Uniquify all_ids, and then take the nested file_counts
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
197 ## dictionary, collapse, and write to file.
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
198 all_ids = set(all_ids)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
199 table_dict = collapsed_nested_count_dict(file_counts, all_ids, order=files)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
200 counts_to_file(table_dict, options.out_file, delimiter=options.delimiter, labels=options.col_labels)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
201
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
202 if options.extra_out:
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
203 unique_fn, nonunique_fn = options.extra_out_files.split(',')
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
204 unique_table_dict = collapsed_nested_count_dict(file_unique_counts, all_ids, order=files)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
205 nonunique_table_dict = collapsed_nested_count_dict(file_nonunique_counts, all_ids, order=files)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
206
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
207 counts_to_file(unique_table_dict, unique_fn, delimiter=options.delimiter)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
208 counts_to_file(nonunique_table_dict, nonunique_fn, delimiter=options.delimiter)
d7f27b43b8ff Uploaded
nikhil-joshi
parents:
diff changeset
209