Example #1
0
def test_check_number_less_saved_paths(tmpdir):
    path = tmpdir.join("output.txt")
    gc = GenomCompare(same=5, diff=-5, gp=-2, max_paths=1, max_seq_len=100)
    seq1 = 'MARS'
    seq2 = 'SMART'
    _, saved_paths = gc.run_save(seq1, seq2, path)
    assert saved_paths == 1
Example #2
0
def test_high_penalty_gap(tmpdir):
    path = tmpdir.join("output.txt")
    gc = GenomCompare(same=5, diff=-5, gp=-10, max_paths=100, max_seq_len=100)
    seq1 = 'SAM'
    seq2 = 'SUM'
    _ = gc.run_save(seq1, seq2, path)
    with open(path) as f:
        assert f.read() == 'SCORE = 5\n\nSAM\nSUM\n'
Example #3
0
def test_check_saving_less_paths(tmpdir):
    path = tmpdir.join("output.txt")
    gc = GenomCompare(same=5, diff=-5, gp=-2, max_paths=1, max_seq_len=100)
    seq1 = 'MARS'
    seq2 = 'SMART'
    _ = gc.run_save(seq1, seq2, path)
    with open(path) as f:
        assert f.read() == 'SCORE = 9\n\n-MAR-S\nSMART-\n'
Example #4
0
    parser.add_argument('-c', dest='config_path', required=True, help='path to config file')
    parser.add_argument('-o', dest='output_path', required=True, help='path to output file')

    args = parser.parse_args()
    return args


if __name__ == '__main__':
    args = parse_args()
    parser = ConfigParser()

    try:
        config = parser.load_config(args.config_path)
    except (json.JSONDecodeError, ConfigError) as e:
        logging.error(e)
        sys.exit(1)

    comparer = GenomCompare(same=config['SAME'], diff=config['DIFF'], gp=config['GP'], \
                            max_paths=config['MAX_NUMBER_PATHS'], max_seq_len=config['MAX_SEQ_LENGTH'])

    seq1 = load_fasta(args.seq1_path)
    seq2 = load_fasta(args.seq2_path)
    
    try:
        score, saved_paths = comparer.run_save(seq1, seq2, 'tmp.txt')
    except InvalidSeqLengthError as e:
        logging.error(e)
        sys.exit(1)

    print(f'Score: {score}\nPaths written: {saved_paths}')