Beispiel #1
0
def gui():
    """Run the OpenBioLink GUI."""
    glob.GUI_MODE = True
    from openbiolink.gui import gui

    gui.start_gui()
Beispiel #2
0
def main(args_list=None):
    if (len(sys.argv) < 2) and not args_list:
        glob.GUI_MODE = True
        import openbiolink.gui.gui as gui
        gui.start_gui()
        return

    parser = argparse.ArgumentParser('OpenBioLink Toolbox')

    # Global config
    parser.add_argument('-p', type=str, default= os.getcwd(),help='specify a working directory (default = current working dictionary')

    # Graph Creation
    parser.add_argument('-g', action='store_true', help='Generate Graph')
    parser.add_argument('--undir', action='store_true', help='Output-Graph should be undirectional (default = directional)')
    parser.add_argument('--qual', type=str, help= 'quality level od the output-graph, options = [hq, mq, lq], (default = None -> all entries are used)')
    parser.add_argument('--no_interact', action='store_true', help='Disables interactive mode - existing files will be replaced (default = interactive)')
    parser.add_argument('--skip', action='store_true', help='Existing files will be skipped - in combination with --no_interact (default = replace)')
    parser.add_argument('--no_dl', action='store_true', help='No download is being performed (e.g. when local data is used)')
    parser.add_argument('--no_in', action='store_true', help='No input_files are created (e.g. when local data is used)')
    parser.add_argument('--no_create', action='store_true', help='No graph is created (e.g. when only in-files should be created)')
    parser.add_argument('--out_format', nargs=2,type=list, default='s t', help='Format of graph output, takes 2 arguments: list of file formats [s= single file, m=multiple files] and list of separators (e.g. t=tab, n=newline, or any other character) (default= s t)')
    parser.add_argument('--no_qscore', action='store_true', help='The output files will contain no scores')
    parser.add_argument('--dbs', nargs='+', help='custom source databases selection to be used, full class name, options --> see doc')
    parser.add_argument('--mes', nargs='+', help='custom meta edges selection to be used, full class name, options --> see doc')

    # Train- Test Split Generation
    parser.add_argument('-s', action='store_true', help='Generate Train-,Validation-, Test-Split')
    parser.add_argument('--edges', type=str, help='Path to edges.csv file (required with action -s')
    parser.add_argument('--tn_edges', type=str, help='Path to true_negatives_edges.csv file (required with action -s)')
    parser.add_argument('--nodes', type=str, help='Path to nodes.csv file (required with action -s)')
    parser.add_argument('--tts_sep', type=str, default='t', help='Separator of edge, tn-edge and nodes file (e.g. t=tab, n=newline, or any other character) (default=t)')
    parser.add_argument('--mode', type=str, default='rand', help='Mode of train-test-set split, options=[rand, time], (default=rand)')
    parser.add_argument('--test_frac', type=float, default='0.2', help='Fraction of test set as float (default= 0.2)')
    parser.add_argument('--crossval', action='store_true', help='Multiple train-validation-sets are generated')
    parser.add_argument('--val', type=float, default='0.2',help='Fraction of validation set as float (default= 0.2) or number of folds as int')
    #niceToHave (1)
    #parser.add_argument('--meta', type=str, help='Path to meta_edge triples (only required if meta-edges are not in OpenBioLink Benchmark Data)')
    parser.add_argument('--tmo_edges', type=str, help='Path to edges.csv file of t-minus-one graph (required for --mode time')
    parser.add_argument('--tmo_tn_edges', type=str, help='Path to true_negatives_edges.csv file of t-minus-one graph (required for --mode time')
    parser.add_argument('--tmo_nodes', type=str, help='Path to nodes.csv file of t-minus-one graph (required for --mode time')

    # Training and Evaluation
    parser.add_argument('-e', action='store_true', help='Apply Training and Evaluation')
    parser.add_argument('--model_cls', type=str, help='class of the model to be trained/evaluated (required with -e)')
    parser.add_argument('--config', type=str, help='Path to the model\' config file')
    parser.add_argument('--no_train', action='store_true', help='No training is being performed, trained model id provided via --model')
    parser.add_argument('--trained_model', type=str, help='Path to trained model (required with --no_train)')
    parser.add_argument('--no_eval', action='store_true', help='No evaluation is being performed, only training')
    parser.add_argument('--test', type=str, help='Path to test set file (required with -e)')
    parser.add_argument('--train', type=str, help='Path to trainings set file')# (alternative: --cv_folder)')
    parser.add_argument('--corrupted', type=str, help='path to the corrupted triples (required for ranked triples if no nodes file is provided') #fixme no longer an option
    parser.add_argument('--eval_nodes', type=str, help='path to the nodes file (required for ranked triples if no corrupted triples file is provided and nodes cannot be taken from graph creation')
    parser.add_argument('--metrics', nargs='+', help='evaluation metrics')
    parser.add_argument('--ks', nargs='+', help='k\'s for hits@k metric')
    #parser.add_argument('--cv_folder', type=str, help='Path to cross validation folder (alternative: --train)')

    #niceToHave (7) option to load info from config file

    if args_list:
        args = parser.parse_args(args_list)
    else:
        args = parser.parse_args()

    check_args_validity(args, parser)
    glob.WORKING_DIR = args.p

    if args.qual == 'hq':
        args.qual = QualityType.HQ
    elif args.qual == 'mq':
        args.qual = QualityType.MQ
    elif args.qual == 'lq':
        args.qual = QualityType.LQ

    if args.g:
        create_graph(args)
    if args.s:
        create_train_test_splits(args)
    if args.e:
        train_and_evaluate(args)

    logging.info('Finished!')