def main(args):
  """
  main entry point for the GenomicIntIntersection script.

  :param args: the arguments for this script, as a list of string. Should
               already have had things like the script name stripped. That
               is, if there are no args provided, this should be an empty
               list.
  """
  # get options and arguments
  ui = getUI(args)

  if ui.optionIsSet("test"):
    # just run unit tests
    unittest.main(argv=[sys.argv[0]])
  elif ui.optionIsSet("help"):
    # just show help
    ui.usage()
  else:
    verbose = ui.optionIsSet("verbose")

    # stranded?
    stranded = ui.optionIsSet("stranded")
    if stranded:
      sys.stderr.write("Sorry, stranded mode hasn't been implemented yet.")
      sys.exit()

    # get output handle
    out_fh = sys.stdout
    if ui.optionIsSet("output"):
      out_fh = open(ui.getValue("output"), "w")

    # get input file-handles -- we know we'll get exactly two, since we
    # specified it in the UI definition
    regions_1 = [x for x in BEDIterator(ui.getArgument(0), verbose=verbose)]
    regions_2 = [x for x in BEDIterator(ui.getArgument(1), verbose=verbose)]

    for r in regionsIntersection(regions_1, regions_2):
      out_fh.write(str(r) + "\n")
def main ( args ) : ui = getUI ( args ) if ui . optionIsSet ( "test" ) : unittest . main ( argv = [ sys . argv [ 0 ] ] ) elif ui . optionIsSet ( "help" ) : ui . usage ( ) else : verbose = ui . optionIsSet ( "verbose" ) stranded = ui . optionIsSet ( "stranded" ) if stranded : sys . stderr . write ( "Sorry, stranded mode hasn't been implemented yet." ) sys . exit ( ) out_fh = sys . stdout if ui . optionIsSet ( "output" ) : out_fh = open ( ui . getValue ( "output" ) , "w" ) regions_1 = [ x for x in BEDIterator ( ui . getArgument ( 0 ) , verbose = verbose ) ] regions_2 = [ x for x in BEDIterator ( ui . getArgument ( 1 ) , verbose = verbose ) ] for r in regionsIntersection ( regions_1 , regions_2 ) : out_fh . write ( str ( r ) + "\n" )
main entry point for the GenomicIntIntersection script.

  :param args: the arguments for this script, as a list of string. Should
               already have had things like the script name stripped. That
               is, if there are no args provided, this should be an empty
               list.