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

Diff of /Babel/bin/source2ach.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7, Fri Oct 22 15:12:00 2010 UTC revision 1.8, Fri Nov 12 19:42:55 2010 UTC
# Line 107  Line 107 
107          record.seq = Seq( re.sub('\s+', '', seq_s.group(1)), IUPAC.protein )          record.seq = Seq( re.sub('\s+', '', seq_s.group(1)), IUPAC.protein )
108      return record      return record
109    
110  def format_factory(prot_f, ont_f, seq_f, ref_f, source, form, org_desc, get_ont):  def format_factory(prot_f, ont_f, seq_f, ref_f, source, form, org_desc, get_ont, get_ctg):
111      if form == 'genbank':      if form == 'genbank':
112          def parse_genbank(rec, amap):          def parse_genbank(rec, amap):
113              if (not rec) or (not rec.id) or (not rec.seq): return              if (not rec) or (not rec.id) or (not rec.seq): return
# Line 160  Line 160 
160                                          desc = gb_go_rm.sub('', go_m.group(2))                                          desc = gb_go_rm.sub('', go_m.group(2))
161                                          ont_f.write("\t".join([md5, go_m.group(1), desc, gtype.replace('_',':')]) + "\n")                                          ont_f.write("\t".join([md5, go_m.group(1), desc, gtype.replace('_',':')]) + "\n")
162                      seq_f.write("%s\t%s\n" %(md5, seq))                      seq_f.write("%s\t%s\n" %(md5, seq))
163                        if get_ctg:
164                      prot_f.write("\t".join([md5, fid, func, org, source, str(beg), str(end), str(strd), cid, cdesc, str(clen)]) + "\n")                      prot_f.write("\t".join([md5, fid, func, org, source, str(beg), str(end), str(strd), cid, cdesc, str(clen)]) + "\n")
165                        else:
166                            prot_f.write("\t".join([md5, fid, func, org, source]) + "\n")
167                      if ('db_xref' in feat.qualifiers) and (len(feat.qualifiers['db_xref']) > 0):                      if ('db_xref' in feat.qualifiers) and (len(feat.qualifiers['db_xref']) > 0):
168                          ref_f.write(fid + "\t" + "\t".join(feat.qualifiers['db_xref']) + "\n")                          ref_f.write(fid + "\t" + "\t".join(feat.qualifiers['db_xref']) + "\n")
169          return parse_genbank          return parse_genbank
# Line 246  Line 249 
249      parser.add_option("-d", "--out_dir", dest="outdir", metavar="DIR", default=None, help="DIR to write output [default is current dir]")      parser.add_option("-d", "--out_dir", dest="outdir", metavar="DIR", default=None, help="DIR to write output [default is current dir]")
250      parser.add_option("-o", "--org_header", dest="orgheader", action="store_true", default=False, help="For fasta files, header description is organism [default is function]")      parser.add_option("-o", "--org_header", dest="orgheader", action="store_true", default=False, help="For fasta files, header description is organism [default is function]")
251      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]")      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]")
252        parser.add_option("-c", "--get_contig", dest="getcontig", action="store_true", default=False, help="Output contig info for organism genbank files [default is off]")
253      parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="Wordy [default is off]")      parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="Wordy [default is off]")
254    
255      (opts, args) = parser.parse_args()      (opts, args) = parser.parse_args()
# Line 264  Line 268 
268      seq_file  = open( os.path.join(outdir, source + ".md52seq"), 'w' )      seq_file  = open( os.path.join(outdir, source + ".md52seq"), 'w' )
269      ref_file  = open( os.path.join(outdir, source + ".id2xref"), 'w' )      ref_file  = open( os.path.join(outdir, source + ".id2xref"), 'w' )
270    
271      parse_format = format_factory( prot_file, ont_file, seq_file, ref_file, source, opts.format, opts.orgheader, opts.getont )      parse_format = format_factory( prot_file, ont_file, seq_file, ref_file, source, opts.format, opts.orgheader, opts.getont, opts.getcontig )
272      if not parse_format:      if not parse_format:
273          parser.error("Incorrect format entered")          parser.error("Incorrect format entered")
274    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3