code: def geneinfo(args):
      
      p = OptionParser(geneinfo.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 5:
          sys.exit(not p.print_help())
  
      scfbed, liftoverbed, lgbed, note, ipr = args
      note = DictFile(note, delimiter="\t")
      scfbed = Bed(scfbed)
      lgorder = Bed(lgbed).order
      liftover = Bed(liftoverbed).order
      header = "Accession Scaffold-position LG-position "\
               "Description Interpro-domain Interpro-description "\
               "GO-term KEGG".split()
      ipr = read_interpro(ipr)
  
      fw_clean = must_open("master.txt", "w")
      fw_removed = must_open("master-removed.txt", "w")
  
      for fw in (fw_clean, fw_removed):
          print("\t".join(header), file=fw)
  
      for b in scfbed:
          accession = b.accn
          scaffold_position = b.tag
          if accession in liftover:
              lg_position = liftover[accession][-1].tag
          else:
              lg_position = "split"
          fw = fw_clean if accession in lgorder else fw_removed
          description = note[accession]
          interpro = interpro_description = go = kegg = ""
          if accession in ipr:
              interpro, interpro_description, go, kegg = ipr[accession]
          print("\t".join((accession, scaffold_position, lg_position,
                          description, interpro, interpro_description, go, kegg)), file=fw)
      fw.close()
docs: %prog geneinfo pineapple.20141004.bed liftover.bed pineapple.20150413.bed \
                     note.txt interproscan.txt
  
      Build gene info table from various sources. The three beds contain
      information on the original scaffolds, linkage groups, and final selected
      loci (after removal of TEs and split loci). The final two text files contain
      AHRD and domain data.