コード例 #1
0
ファイル: score.py プロジェクト: jwayne/conseval
def main():
    args = parse_args()

    # Get scorer
    scorer = get_scorer(args.scorer_name, **args.scorer_params)

    # Get alignment and supplementary inputs
    alignment = Alignment(args.align_file, **args.align_params)

    # Score
    scores = scorer.score(alignment)

    # Output
    header = list_scorer_params(scorer)
    scores_cols = [scores]
    write_scores(alignment, scores_cols, [args.scorer_name], header=header, f=sys.stdout)
    if args.draw:
        draw_scores(alignment, scores_cols, [args.scorer_name])
コード例 #2
0
ファイル: batchscore.py プロジェクト: jwayne/conseval
def main():
    parser = argparse.ArgumentParser(
        description="Batch score the conservation of multiple alignments, using multiple scorers.")

    parser.add_argument('config_file',
        help="YAML config file specifying the dataset and scorers.  See `exapmles/example.yaml` for an example.")
    args = parser.parse_args()


    dataset_names, scorers = read_batchscore_config(args.config_file)

    # Sanity check the output dirs
    for ds_name in dataset_names:
        ds_dir = os.path.join(OUTPUT_DIR, "batchscore-%s" % ds_name)
        if not os.path.exists(ds_dir):
            os.mkdir(ds_dir)
        for scorer in scorers:
            sc_dir = os.path.join(ds_dir, scorer.output_id)
            if os.path.exists(sc_dir):
                resp = raw_input("%s exists. Overwrite? y/[n]: " % sc_dir)
                if resp != 'y':
                    sys.exit(0)
                try:
                    for filename in os.listdir(sc_dir):
                        os.remove(os.path.join(sc_dir, filename))
                    os.rmdir(sc_dir)
                except OSError:
                    raise OSError("Could not overwrite directory %s" % sc_dir)

    # Perform the scoring
    for ds_name in dataset_names:
        ds_dir = os.path.join(OUTPUT_DIR, "batchscore-%s" % ds_name)
        for scorer in scorers:
            sc_dir = os.path.join(ds_dir, scorer.output_id)
            os.mkdir(sc_dir)
            params_file = os.path.join(ds_dir, "%s.params" % scorer.output_id)
            with open(params_file, 'w') as f:
                f.write(list_scorer_params(scorer))
            scorer.set_output_dir(sc_dir)
        run_experiments(ds_name, scorers)