code: def fromblast(args):
      
      from jcvi.formats.blast import sort
      from jcvi.utils.range import range_distance
  
      p = OptionParser(fromblast.__doc__)
      p.add_option("--clique", default=False, action="store_true",
                   help="Populate clique instead of linear path [default: %default]")
      p.add_option("--maxdist", default=100000, type="int",
                   help="Create edge within certain distance [default: %default]")
      p.set_verbose(help="Print verbose reports to stdout")
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      blastfile, subjectfasta = args
      clique = opts.clique
      maxdist = opts.maxdist
      sort([blastfile, "--query"])
      blast = BlastSlow(blastfile, sorted=True)
      g = BiGraph()
      for query, blines in groupby(blast, key=lambda x: x.query):
          blines = list(blines)
          iterator = combinations(blines, 2) if clique else pairwise(blines)
          for a, b in iterator:
              asub, bsub = a.subject, b.subject
              if asub == bsub:
                  continue
  
              arange = (a.query, a.qstart, a.qstop, "+")
              brange = (b.query, b.qstart, b.qstop, "+")
              dist, oo = range_distance(arange, brange, distmode="ee")
              if dist > maxdist:
                  continue
  
              atag = ">" if a.orientation == "+" else "<"
              btag = ">" if b.orientation == "+" else "<"
              g.add_edge(asub, bsub, atag, btag)
  
      graph_to_agp(g, blastfile, subjectfasta, verbose=opts.verbose)
docs: %prog fromblast blastfile subject.fasta
  
      Generate path from BLAST file. If multiple subjects map to the same query,
      an edge is constructed between them (with the link provided by the query).
  
      The BLAST file MUST be filtered, chained, supermapped.