GtScoreMatrix* gt_score_matrix_new_read(const char *path, GtAlphabet *alphabet, GtError *err) { GtScoreMatrix *sm; gt_error_check(err); gt_assert(path && alphabet); sm = gt_score_matrix_new(alphabet); if (parse_score_matrix(sm, path, err)) { gt_score_matrix_delete(sm); return NULL; } return sm; }
static GtScoreFunction* gt_dna_scorefunc_new(GtAlphabet *a, int match, int mismatch, int insertion, int deletion) { GtScoreMatrix *sm = gt_score_matrix_new(a); GtScoreFunction *sf = gt_score_function_new(sm, insertion, deletion); unsigned int m,n; for (m=0;m<gt_alphabet_size(a);m++) { for (n=0;n<gt_alphabet_size(a);n++) { gt_score_matrix_set_score(sm, m, n, (n==m ? match : mismatch)); } } /* make N-N a mismatch! */ gt_score_matrix_set_score(sm, gt_alphabet_size(a) - 1, gt_alphabet_size(a) - 1, mismatch); return sf; }
GtScoreMatrix* gt_score_matrix_new_read_protein(const char *path, GtError *err) { GtAlphabet *protein_alpha; GtScoreMatrix *sm; int had_err; gt_error_check(err); gt_assert(path); /* create score matrix */ protein_alpha = gt_alphabet_new_protein(); sm = gt_score_matrix_new(protein_alpha); gt_alphabet_delete(protein_alpha); /* parse matrix file */ had_err = parse_score_matrix(sm, path, err); if (had_err) { gt_score_matrix_delete(sm); return NULL; } return sm; }