code: def extract_pairs(abed, bbed, groups):
      
      agenome = op.basename(abed.filename).split(".")[0]
      bgenome = op.basename(bbed.filename).split(".")[0]
      aorder = abed.order
      border = bbed.order
      pairsfile = "{0}.{1}.pairs".format(agenome, bgenome)
      fw = open(pairsfile, "w")
  
      is_self = abed.filename == bbed.filename
      npairs = 0
      for group in groups:
          iter = combinations(group, 2) if is_self \
                      else product(group, repeat=2)
  
          for a, b in iter:
              if a not in aorder or b not in border:
                  continue
  
              print("\t".join((a, b)), file=fw)
              npairs += 1
  
      logging.debug("File `{0}` written with {1} pairs.".format(pairsfile, npairs))
docs: Called by fromgroups(), extract pairs specific to a pair of species.