code: def validate(args):
      
      p = OptionParser(validate.__doc__)
  
      opts, args = p.parse_args(args)
  
      try:
          agpfile, componentfasta, targetfasta = args
      except Exception as e:
          sys.exit(p.print_help())
  
      agp = AGP(agpfile)
      build = Fasta(targetfasta)
      bacs = Fasta(componentfasta, index=False)
  
      # go through this line by line
      for aline in agp:
          try:
              build_seq = build.sequence(dict(chr=aline.object,
                  start=aline.object_beg, stop=aline.object_end))
  
              if aline.is_gap:
                  assert build_seq.upper() == aline.gap_length * 'N', \
                      "gap mismatch: %s" % aline
              else:
                  bac_seq = bacs.sequence(dict(chr=aline.component_id,
                      start=aline.component_beg, stop=aline.component_end,
                      strand=aline.orientation))
  
                  assert build_seq.upper() == bac_seq.upper(), \
                          "sequence mismatch: %s" % aline
  
              logging.debug("%s:%d-%d verified" % (aline.object,
                  aline.object_beg, aline.object_end))
  
          except Exception as e:
              logging.error(e)
docs: %prog validate agpfile componentfasta targetfasta
  
      validate consistency between agpfile and targetfasta