[Bio] / Babel / bin / source2ach.py Repository:
ViewVC logotype

Annotation of /Babel/bin/source2ach.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (view) (download) (as text)

1 : tharriso 1.1 #!/usr/bin/env python
2 :    
3 :     import os, sys, re, hashlib
4 :     from optparse import OptionParser
5 : tharriso 1.10 from multiprocessing import Pool
6 : tharriso 1.1 from Bio import SeqIO
7 :     from Bio.Seq import Seq
8 :     from Bio.SeqRecord import SeqRecord
9 :     from Bio.Alphabet import IUPAC
10 :    
11 :     __doc__ = """
12 :     Script to take a repository file from the following formats:
13 :     genbank, kegg, swiss, fasta
14 :     and output the following tab seperated files:
15 :    
16 :     SOURCE.md52id2func:
17 :     md5, id, function, organism, source, beg_pos*, end_pos*, strand*, contig_id*, contig_desc*, contig_length*
18 : tharriso 1.5 SOURCE.ms52id2ont:
19 :     md5, id, function, ontology, source
20 : tharriso 1.1 SOURCE.md52seq:
21 :     md5, sequence
22 : tharriso 1.4 SOURCE.id2xref:
23 : tharriso 1.1 id, external refrence 1, [external refrence 2, external refrence 3, ...]
24 : tharriso 1.9 SOURCE.id2tax:
25 :     id, genbank tax string
26 : tharriso 1.1
27 :     Values with * are optional, only genbank files contain that data."""
28 :    
29 : tharriso 1.10 class Info:
30 :     def __init__(self):
31 :     self.source = ''
32 :     self.format = 'fasta'
33 :     self.verbose = False
34 :     self.outdir = ''
35 :     self.orghead = False
36 :     self.getont = False
37 :     self.getctg = False
38 :     self.gettax = False
39 : tharriso 1.12 self.rnagg = False
40 : tharriso 1.10 self.amap = {}
41 :    
42 : tharriso 1.12 func_map = {'LSU': '23S/28S ribosomal RNA', 'SSU': '16S/18S ribosomal RNA'}
43 : tharriso 1.2 desc_re = re.compile('(Rec|Sub)Name: Full=(.*?);')
44 : tharriso 1.1 entry_re = re.compile('^ENTRY\s+(\S+)\s+CDS\s+(.*)$', re.MULTILINE)
45 :     name_re = re.compile('^NAME\s+(.*)$', re.MULTILINE)
46 :     func_re = re.compile('^DEFINITION\s+(.*?)^\S', re.DOTALL | re.MULTILINE)
47 : tharriso 1.5 orth_re = re.compile('^ORTHOLOGY\s+(.*?)^\S', re.DOTALL | re.MULTILINE)
48 : tharriso 1.1 dbref_re = re.compile('^DBLINKS\s+(.*?)^\S', re.DOTALL | re.MULTILINE)
49 :     seq_re = re.compile('^AASEQ\s+\d+\s+(.*?)^\S', re.DOTALL | re.MULTILINE)
50 : tharriso 1.5 up_go_re = re.compile('^GO:GO:(.*)')
51 :     gb_go_re = re.compile('^GO:(\d+)\s+-\s+(.*)')
52 : tharriso 1.6 gb_go_rm = re.compile('( \[Evidence [A-Z]+\])')
53 : tharriso 1.12 gg_re = re.compile('^[kpcofgs]__(\S+)$')
54 : tharriso 1.5 ko_re = re.compile('^(K\d+)\s+(.*)')
55 :     ogid_re = re.compile('^(\S+?OG)\d+')
56 : tharriso 1.10 nr_re = re.compile('^gi\|(\d+)\|(\w+)\|(\S+)\|\S*?\s+(.*)\]$')
57 :     nr_types = {'ref': 'RefSeq', 'gb': 'GenBank', 'emb': 'EMBL', 'dbj': 'DDBJ', 'pir': 'PIR', 'prf': 'PRF', 'pdb': 'PDB'}
58 : tharriso 1.5 go_types = ['GO_function', 'GO_process', 'GO_component']
59 : tharriso 1.9 file_ext = [".md52id2func", ".md52id2ont", ".md52seq", ".id2xref", ".id2tax"]
60 : tharriso 1.10 params = Info()
61 :    
62 :     def parse_nr_header(line):
63 :     items = []
64 :     hdr_set = nr_re.match(line)
65 :     if hdr_set:
66 :     (gi_id, nrdb, nrdb_id, func_org) = hdr_set.groups()
67 :     if nrdb in params.amap:
68 :     org_rev = ''
69 :     rev_fo = reverse_string(func_org)
70 :     end_brk = 1
71 :     beg_brk = 0
72 :     for i, c in enumerate(rev_fo):
73 :     if c == ']': end_brk += 1
74 :     if c == '[': beg_brk += 1
75 :     if beg_brk == end_brk: break
76 :     org_rev += c
77 :     org_txt = reverse_string( org_rev )
78 :     func_txt = reverse_string( rev_fo[i+1:] )
79 :     items = [ gi_id, params.amap[nrdb], nrdb_id, func_txt.strip(), org_txt.strip() ]
80 :     return items
81 :    
82 :     def reverse_string(string):
83 :     return string[::-1]
84 : tharriso 1.1
85 : tharriso 1.10 def get_eggnog_map(filename):
86 : tharriso 1.2 emap = {}
87 : tharriso 1.1 if filename is None:
88 : tharriso 1.2 return emap
89 : tharriso 1.10 if params.verbose: sys.stdout.write("Parsing file %s ... " %filename)
90 : tharriso 1.2 fhdl = open(filename, 'r')
91 :     try:
92 :     for line in fhdl:
93 :     if line.startswith("#"): continue
94 :     parts = line.strip().split("\t")
95 :     if parts[0] in emap:
96 : tharriso 1.5 emap[ parts[0] ].append( [parts[3], parts[4]] )
97 : tharriso 1.2 else :
98 : tharriso 1.5 emap[ parts[0] ] = [ [parts[3], parts[4]] ]
99 : tharriso 1.2 finally:
100 :     fhdl.close()
101 : tharriso 1.10 if params.verbose: sys.stdout.write("Done\n")
102 : tharriso 1.2 return emap
103 :    
104 : tharriso 1.10 def get_kegg_map(filename):
105 : tharriso 1.2 kmap = {}
106 :     if filename is None:
107 :     return kmap
108 : tharriso 1.10 if params.verbose: sys.stdout.write("Parsing file %s ... " %filename)
109 : tharriso 1.1 for text in kegg_iter(filename):
110 :     rec = get_kegg_rec(text)
111 :     if (not rec.name) or (not rec.description): continue
112 :     names = rec.name.split(', ')
113 :     if len(names) > 1:
114 : tharriso 1.11 kmap[ names[1] ] = [ rec.description, names[0] ]
115 : tharriso 1.10 if params.verbose: sys.stdout.write("Done\n")
116 : tharriso 1.2 return kmap
117 : tharriso 1.1
118 :     def kegg_iter(filename):
119 :     fhdl = file(filename, 'rb')
120 :     recs = ['']
121 :     for data in iter(lambda: fhdl.read(100000), ''):
122 :     recs = (recs[-1] + data).split("\n///\n")
123 :     for rec in recs[:-1]:
124 :     yield rec
125 :    
126 :     def get_kegg_rec(text):
127 :     record = SeqRecord(Seq("",IUPAC.protein), id='', name='', description='', dbxrefs=[], annotations={'organism':''})
128 :     entry_s = entry_re.search(text)
129 :     name_s = name_re.search(text)
130 :     func_s = func_re.search(text)
131 : tharriso 1.5 orth_s = orth_re.search(text)
132 : tharriso 1.1 dbref_s = dbref_re.search(text)
133 :     seq_s = seq_re.search(text)
134 :     if entry_s:
135 :     record.id = entry_s.group(1)
136 :     record.annotations['organism'] = entry_s.group(2).strip()
137 :     if name_s:
138 :     record.name = name_s.group(1).strip()
139 :     if func_s:
140 :     record.description = re.sub('\s+', ' ', func_s.group(1).strip())
141 : tharriso 1.5 if orth_s:
142 :     orths = {}
143 :     for o in filter( lambda y: y, map(lambda x: ko_re.search(x.strip()), orth_s.group(1).strip().split("\n")) ):
144 :     orths[ o.group(1) ] = o.group(2)
145 :     record.annotations['orthology'] = orths
146 : tharriso 1.1 if dbref_s:
147 :     parts = dbref_s.group(1).split()
148 :     if (len(parts) % 2) == 0:
149 :     for i in range(0, len(parts)-1, 2):
150 :     record.dbxrefs.append(parts[i].replace('NCBI-', '') + parts[i+1])
151 :     if seq_s:
152 :     record.seq = Seq( re.sub('\s+', '', seq_s.group(1)), IUPAC.protein )
153 :     return record
154 :    
155 : tharriso 1.10 def format_factory(out_files):
156 : tharriso 1.9 (prot_f, ont_f, seq_f, ref_f, tax_f) = out_files
157 : tharriso 1.10 source = params.source
158 :     form = params.format
159 :     org_desc = params.orghead
160 :     get_ont = params.getont
161 :     get_ctg = params.getctg
162 :     get_tax = params.gettax
163 : tharriso 1.12 rna_gg = params.rnagg
164 : tharriso 1.10 amap = params.amap
165 : tharriso 1.1 if form == 'genbank':
166 : tharriso 1.10 def parse_genbank(rec):
167 : tharriso 1.1 if (not rec) or (not rec.id) or (not rec.seq): return
168 :     cid = rec.id
169 :     cdesc = rec.description.rstrip('.')
170 : tharriso 1.10 seq = str(rec.seq).upper()
171 :     clen = len(seq)
172 : tharriso 1.1 org = rec.annotations['organism']
173 : tharriso 1.3 # only one entry on rec (first feat is source and is not a feature), use first real feature, no contig data
174 :     if len(rec.features) == 2:
175 : tharriso 1.10 md5 = hashlib.md5(seq).hexdigest()
176 : tharriso 1.3 func = ''
177 :     if 'product' in rec.features[1].qualifiers:
178 :     func = rec.features[1].qualifiers['product'][0]
179 : tharriso 1.10 seq_f.write("%s\t%s\n" %(md5, seq))
180 : tharriso 1.5 prot_f.write("\t".join([md5, rec.name, func, org, source]) + "\n")
181 : tharriso 1.9 if get_tax and ('taxonomy' in rec.annotations):
182 :     if rec.annotations['taxonomy'][0] == 'Root':
183 :     x = rec.annotations['taxonomy'].pop(0)
184 :     tax_f.write("%s\t%s;%s\n" %(rec.name, ";".join(rec.annotations['taxonomy']), org))
185 : tharriso 1.3 return
186 :     # multiple entries on rec, use CDS features, get contig data
187 : tharriso 1.1 for feat in rec.features:
188 :     if feat.type == 'CDS':
189 :     if ( (not feat.qualifiers) or (not feat.location) or
190 :     ('translation' not in feat.qualifiers) or
191 :     ('product' not in feat.qualifiers) ): continue
192 : tharriso 1.6 fid = ''
193 :     if 'protein_id' in feat.qualifiers:
194 :     fid = feat.qualifiers['protein_id'][0]
195 :     elif 'locus_tag' in feat.qualifiers:
196 :     fid = feat.qualifiers['locus_tag'][0]
197 :     else:
198 :     continue
199 : tharriso 1.1 seq = feat.qualifiers['translation'][0]
200 :     md5 = hashlib.md5(seq).hexdigest()
201 :     func = feat.qualifiers['product'][0]
202 :     beg = feat.location.start.position
203 :     end = feat.location.end.position
204 :     if feat.strand:
205 :     strd = feat.strand
206 :     else:
207 :     strd = 1
208 :     if (beg > end):
209 :     strd = -1
210 :     beg = feat.location.end.position
211 :     end = feat.location.start.position
212 : tharriso 1.5 # output GO ontology
213 :     if get_ont:
214 :     for gtype in go_types:
215 :     if gtype in feat.qualifiers:
216 :     for goid in feat.qualifiers[gtype]:
217 :     go_m = gb_go_re.match(goid)
218 :     if go_m:
219 : tharriso 1.6 desc = gb_go_rm.sub('', go_m.group(2))
220 : tharriso 1.10 ont_f.write("\t".join([md5, go_m.group(1), desc, 'GO']) + "\n")
221 : tharriso 1.1 seq_f.write("%s\t%s\n" %(md5, seq))
222 : tharriso 1.8 if get_ctg:
223 :     prot_f.write("\t".join([md5, fid, func, org, source, str(beg), str(end), str(strd), cid, cdesc, str(clen)]) + "\n")
224 :     else:
225 :     prot_f.write("\t".join([md5, fid, func, org, source]) + "\n")
226 : tharriso 1.1 if ('db_xref' in feat.qualifiers) and (len(feat.qualifiers['db_xref']) > 0):
227 :     ref_f.write(fid + "\t" + "\t".join(feat.qualifiers['db_xref']) + "\n")
228 :     return parse_genbank
229 :    
230 :     elif form == 'swiss':
231 : tharriso 1.10 def parse_swiss(rec):
232 : tharriso 1.1 if (not rec) or (not rec.id) or (not rec.seq): return
233 : tharriso 1.10 seq = str(rec.seq).upper()
234 :     md5 = hashlib.md5(seq).hexdigest()
235 : tharriso 1.1 func = rec.description
236 :     srch = desc_re.search(func)
237 : tharriso 1.2 if srch: func = srch.group(2)
238 : tharriso 1.10 seq_f.write("%s\t%s\n" %(md5, seq))
239 : tharriso 1.5 prot_f.write("\t".join([md5, rec.id, func, rec.annotations['organism'], source]) + "\n")
240 : tharriso 1.1 if len(rec.dbxrefs) > 0:
241 :     ref_str = rec.id
242 :     for ref in rec.dbxrefs:
243 : tharriso 1.5 go_m = up_go_re.match(ref)
244 :     # output GO ontology
245 :     if go_m and get_ont:
246 : tharriso 1.10 ont_f.write("\t".join([md5, go_m.group(1), func, 'GO']) + "\n")
247 : tharriso 1.1 else:
248 :     ref_str += "\t" + ref
249 :     ref_f.write(ref_str + "\n")
250 :     return parse_swiss
251 :    
252 :     elif form == 'fasta':
253 : tharriso 1.10 def parse_fasta(rec):
254 : tharriso 1.1 if (not rec) or (not rec.id) or (not rec.seq): return
255 : tharriso 1.2 desc = ''
256 : tharriso 1.6 org = ''
257 :     func = ''
258 : tharriso 1.2 hdrs = rec.description.split()
259 : tharriso 1.10 seq = str(rec.seq).upper()
260 :     md5 = hashlib.md5(seq).hexdigest()
261 :     seq_f.write("%s\t%s\n" %(md5, seq))
262 : tharriso 1.12 if rna_gg:
263 : tharriso 1.2 hdrs.pop(0)
264 : tharriso 1.12 hdrs.pop(0)
265 :     hdrs.pop()
266 :     tax_list = []
267 :     org_list = []
268 :     for x in hdrs:
269 :     gg_m = gg_re.match(x)
270 :     if (gg_m): tax_list.append(gg_m.group(1))
271 :     else: org_list.append(x)
272 :     org = " ".join(org_list).split(";")[0]
273 :     func = "16S/18S ribosomal RNA"
274 :     if get_tax:
275 :     tax_f.write("%s\t%s;%s\n" %(rec.id, "".join(tax_list), org))
276 :     else:
277 :     if len(hdrs) > 1:
278 :     hdrs.pop(0)
279 :     desc = " ".join(hdrs)
280 :     if desc.startswith("("): desc = desc.strip(')(')
281 :     if desc.startswith("|"): desc = desc.strip('| ')
282 :     if org_desc:
283 :     org = desc
284 :     if source in func_map:
285 :     func = func_map[source]
286 :     else:
287 :     func = desc
288 : tharriso 1.6 if get_ont and (rec.id in amap):
289 :     for f in amap[rec.id]:
290 :     prot_f.write("\t".join([md5, rec.id, f[1], org, source]) + "\n")
291 :     ogid_m = ogid_re.match(f[0])
292 :     if ogid_m:
293 : tharriso 1.7 ont_f.write("\t".join([md5, f[0], f[1], ogid_m.group(1)]) + "\n")
294 : tharriso 1.1 else:
295 : tharriso 1.6 prot_f.write("\t".join([md5, rec.id, func, org, source]) + "\n")
296 : tharriso 1.1 return parse_fasta
297 :    
298 : tharriso 1.10 elif form == 'nr':
299 :     def parse_nr(rec):
300 :     if (not rec) or (not rec.description) or (not rec.seq): return
301 :     get_seq = False
302 :     hdrs = rec.description.split('\x01')
303 :     seq = str(rec.seq).upper()
304 :     md5 = hashlib.md5(seq).hexdigest()
305 :     if len(hdrs) > 0:
306 :     for h in hdrs:
307 :     info = parse_nr_header(h)
308 :     if len(info) > 0:
309 :     (gi_id, nrdb, nrdb_id, func, org) = info
310 :     get_seq = True
311 :     prot_f.write("\t".join([md5, nrdb_id, func, org, nrdb]) + "\n")
312 :     ref_f.write("%s\tGI:%s\n"%(nrdb_id, gi_id))
313 :     if get_seq:
314 :     seq_f.write("%s\t%s\n" %(md5, seq))
315 :     return parse_nr
316 :    
317 : tharriso 1.1 elif form == 'kegg':
318 : tharriso 1.10 def parse_kegg(text):
319 : tharriso 1.1 rec = get_kegg_rec(text)
320 :     if (not rec.id) or (not rec.description) or (not rec.seq): return
321 : tharriso 1.10 seq = str(rec.seq).upper()
322 :     md5 = hashlib.md5(seq).hexdigest()
323 : tharriso 1.5 org = rec.annotations['organism']
324 : tharriso 1.11 code = ""
325 : tharriso 1.5 orth = []
326 : tharriso 1.2 if org in amap:
327 : tharriso 1.11 (org, code) = amap[org]
328 :     code += ":"
329 : tharriso 1.5 # output KO ontology
330 :     if get_ont and ('orthology' in rec.annotations):
331 :     orth = rec.annotations['orthology']
332 :     for oid, odesc in orth.iteritems():
333 : tharriso 1.7 ont_f.write("\t".join([md5, oid, odesc, 'KO']) + "\n")
334 : tharriso 1.10 seq_f.write("%s\t%s\n" %(md5, seq))
335 : tharriso 1.11 prot_f.write("\t".join([md5, code + rec.id, rec.description, org, source]) + "\n")
336 : tharriso 1.1 if len(rec.dbxrefs) > 0:
337 :     ref_f.write(rec.id + "\t" + "\t".join(rec.dbxrefs) + "\n")
338 :     return parse_kegg
339 :    
340 :     else:
341 :     return None
342 :    
343 : tharriso 1.10 def process_file(infile):
344 :     o_files = []
345 :     o_hdls = []
346 :     fformat = params.format
347 :     fname = os.path.basename(infile)
348 :     for e in file_ext: o_files.append( os.path.join(params.outdir, fname + e) )
349 :     for f in o_files: o_hdls.append( open(f, 'w') )
350 :    
351 :     parse_format = format_factory( o_hdls )
352 :     if not parse_format:
353 :     sys.stderr.write("Invalid format %s\n"%fformat)
354 :     sys.exit(1)
355 :    
356 :     if params.verbose: sys.stdout.write("Parsing file %s ...\n" %infile)
357 :     if fformat == 'kegg':
358 :     for rec in kegg_iter(infile):
359 :     parse_format(rec)
360 :     else:
361 :     if fformat == 'nr': fformat = 'fasta'
362 :     for rec in SeqIO.parse(infile, fformat):
363 :     parse_format(rec)
364 :    
365 :     for h in o_hdls: h.close()
366 :     return os.path.join(params.outdir, fname)
367 :    
368 : tharriso 1.1
369 :     usage = "usage: %prog [options] source input_file1 [input_file2 input_file3 ...]" + __doc__
370 :    
371 :     def main(args):
372 : tharriso 1.10 global params
373 : tharriso 1.1 parser = OptionParser(usage=usage)
374 :     parser.add_option("-f", "--format", dest="format", metavar="FORMAT", default="fasta",
375 : tharriso 1.10 help="FORMAT inputed file is in. Must be one of following: genbank, kegg, swiss, nr, fasta [default is 'fasta']")
376 :     parser.add_option("-n", "--nr_dbs", dest="nrdbs", metavar="DBs", default="ref,gb",
377 :     help="Comma seperated list of databases to parse out of ncbi nr, from following: ref, gb, emb, dbj, pir, prf, pdb [default is 'ref,gb']")
378 :     parser.add_option("-p", "--processes", dest="processes", metavar="NUM_PROCESSES", type="int", default=4, help="Number of processes to use [default '4']")
379 : tharriso 1.2 parser.add_option("-k", "--kegg_map", dest="keggmap", metavar="FILE", default=None, help="Optional KEGG genome FILE for org name mapping")
380 :     parser.add_option("-e", "--eggnog_map", dest="eggnogmap", metavar="FILE", default=None, help="Optional eggNOG orthgroups tabed FILE for func mapping")
381 : tharriso 1.10 parser.add_option("-d", "--out_dir", dest="outdir", metavar="DIR", default="", help="DIR to write output [default is current dir]")
382 : tharriso 1.1 parser.add_option("-o", "--org_header", dest="orgheader", action="store_true", default=False, help="For fasta files, header description is organism [default is function]")
383 : tharriso 1.5 parser.add_option("-g", "--get_ontology", dest="getont", action="store_true", default=False, help="Output ontology (id, type) for proteins with mapped ontology [default is off]")
384 : tharriso 1.8 parser.add_option("-c", "--get_contig", dest="getcontig", action="store_true", default=False, help="Output contig info for organism genbank files [default is off]")
385 : tharriso 1.9 parser.add_option("-t", "--get_tax", dest="gettax", action="store_true", default=False, help="Output taxonomy string for genbank files [default is off]")
386 : tharriso 1.12 parser.add_option("-r", "--rna_gg", dest="rnagg", action="store_true", default=False, help="fasta file is greengenes format (header has tax string) [default is false]")
387 : tharriso 1.1 parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="Wordy [default is off]")
388 :    
389 :     (opts, args) = parser.parse_args()
390 :     if len(args) < 2:
391 :     parser.error("Incorrect number of arguments")
392 : tharriso 1.10 sfiles = filter(lambda x: os.path.isfile(x), args[1:])
393 :     scount = len(sfiles)
394 :    
395 :     params.source = args[0]
396 :     params.format = opts.format
397 :     params.verbose = opts.verbose
398 :     params.outdir = opts.outdir
399 :     params.orghead = opts.orgheader
400 :     params.getont = opts.getont
401 :     params.getctg = opts.getcontig
402 :     params.gettax = opts.gettax
403 : tharriso 1.12 params.rnagg = opts.rnagg
404 : tharriso 1.10
405 :     if (params.format == 'nr') and opts.nrdbs:
406 :     for d in opts.nrdbs.split(','):
407 :     if d in nr_types:
408 :     params.amap[d] = nr_types[d]
409 :     elif (params.format == 'kegg') and opts.keggmap and os.path.isfile(opts.keggmap):
410 :     params.amap = get_kegg_map(opts.keggmap)
411 :     elif (params.format == 'fasta') and opts.eggnogmap and os.path.isfile(opts.eggnogmap):
412 :     params.amap = get_eggnog_map(opts.eggnogmap)
413 : tharriso 1.1
414 : tharriso 1.10 if scount < opts.processes:
415 :     min_proc = scount
416 :     else:
417 :     min_proc = opts.processes
418 : tharriso 1.2
419 : tharriso 1.10 if min_proc == 1:
420 :     if params.verbose: sys.stdout.write("Parsing %d %s files, single threaded\n"%(scount, params.format))
421 :     rfiles = []
422 :     for f in sfiles:
423 :     r = process_file(f)
424 :     rfiles.append(r)
425 :     else:
426 :     if params.verbose: sys.stdout.write("Parsing %d %s files using %d threades\n"%(scount, params.format, min_proc))
427 :     pool = Pool(processes=min_proc)
428 :     rfiles = pool.map(process_file, sfiles, 1)
429 :     pool.close()
430 :     pool.join()
431 :     if params.verbose: sys.stdout.write("Done\n")
432 : tharriso 1.9
433 : tharriso 1.10 if params.verbose: sys.stdout.write("Merging %d files ... "%len(rfiles))
434 : tharriso 1.9 for e in file_ext:
435 : tharriso 1.10 out_file = os.path.join(params.outdir, params.source + e)
436 :     file_set = map( lambda x: x + e, rfiles )
437 :     if os.path.isfile(out_file):
438 :     os.remove(out_file)
439 :     os.system( "cat %s | sort -u > %s"%(" ".join(file_set), out_file) )
440 :     for f in file_set:
441 : tharriso 1.9 os.remove(f)
442 : tharriso 1.10 if os.path.isfile(out_file) and (os.path.getsize(out_file) == 0):
443 :     os.remove(out_file)
444 :     if params.verbose: sys.stdout.write("Done\n")
445 : tharriso 1.9
446 : tharriso 1.10 if params.verbose: sys.stdout.write("All Done\n")
447 : tharriso 1.1
448 :     if __name__ == "__main__":
449 : tharriso 1.10 sys.exit( main(sys.argv) )

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3