code: def query(args):
      
      p = OptionParser(query.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      locifile, contig = args
      idx = build_index(locifile)
      pos = idx[contig]
      logging.debug("Contig {0} found at pos {1}".format(contig, pos))
      fp = open(locifile)
      fp.seek(pos)
      section = []
      while True:
          row = fp.readline()
          if row.startswith("//") and row.split()[1] != contig:
              break
          section.append(row)
      print("".join(section))
docs: %prog query out.loci contig
  
      Random access to loci file. This script helps speeding up debugging.