Skip to content

Commit

Permalink
save hit_start hit_stop
Browse files Browse the repository at this point in the history
  • Loading branch information
horta committed Feb 15, 2024
1 parent 78bafe9 commit 25919b7
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion c-core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20.2 FATAL_ERROR)
project(deciphon VERSION 0.17.2 LANGUAGES C)
project(deciphon VERSION 0.17.3 LANGUAGES C)

include(cmake/warnings.cmake)
include(cmake/sanitizers.cmake)
Expand Down
2 changes: 2 additions & 0 deletions c-core/product.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ int product_close(struct product *x)
ok &= fputs("window\t", fp) >= 0;
ok &= fputs("window_start\t", fp) >= 0;
ok &= fputs("window_stop\t", fp) >= 0;
ok &= fputs("hit_start\t", fp) >= 0;
ok &= fputs("hit_stop\t", fp) >= 0;
ok &= fputs("profile\t", fp) >= 0;
ok &= fputs("abc\t", fp) >= 0;
ok &= fputs("lrt\t", fp) >= 0;
Expand Down
3 changes: 3 additions & 0 deletions c-core/product_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ void product_line_init(struct product_line *x)
x->window_start = 0;
x->window_stop = 0;

x->hit_start = 0;
x->hit_stop = 0;

memset(x->protein, 0, sizeof_field(struct product_line, protein));
memset(x->abc, 0, sizeof_field(struct product_line, abc));

Expand Down
5 changes: 5 additions & 0 deletions c-core/product_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ struct product_line
long sequence;

int window;
// [window_start, window_stop)
int window_start;
int window_stop;

// [hit_start, hit_stop)
int hit_start;
int hit_stop;

char protein[64];
char abc[16];

Expand Down
2 changes: 2 additions & 0 deletions c-core/product_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ int product_thread_put_match(struct product_thread *x, struct match *match,
if (fprintf(fp, "%d\t", line->window) < 0) defer_error(DCP_EWRITEPROD);
if (fprintf(fp, "%d\t", line->window_start) < 0) defer_error(DCP_EWRITEPROD);
if (fprintf(fp, "%d\t", line->window_stop) < 0) defer_error(DCP_EWRITEPROD);
if (fprintf(fp, "%d\t", line->hit_start) < 0) defer_error(DCP_EWRITEPROD);
if (fprintf(fp, "%d\t", line->hit_stop) < 0) defer_error(DCP_EWRITEPROD);
if (fprintf(fp, "%s\t", line->protein) < 0) defer_error(DCP_EWRITEPROD);
if (fprintf(fp, "%s\t", line->abc) < 0) defer_error(DCP_EWRITEPROD);
if (fprintf(fp, "%.1f\t", line->lrt) < 0) defer_error(DCP_EWRITEPROD);
Expand Down
2 changes: 1 addition & 1 deletion c-core/test_massive.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(void)
}
eq(scan_run(scan, PRODDIR, NULL, NULL), 0);
eq(scan_progress(scan), 100);
eq(chksum(PRODDIR "/products.tsv"), 27703);
eq(chksum(PRODDIR "/products.tsv"), 61836);
eq(scan_close(scan), 0);

scan_del(scan);
Expand Down
4 changes: 2 additions & 2 deletions c-core/test_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ static struct params params_list[] = {
{1, false, false}, {1, false, false}, {1, false, true}, {1, false, true},
{1, true, false}, {1, true, false}, {1, true, true}, {1, true, true}};
static bool dial_list[] = {true, false, true, false, true, false, true, false};
static long chksum_list[] = {55932, 55932, 35953, 35953,
4940, 4940, 4940, 4940};
static long chksum_list[] = {10096, 10096, 27848, 27848,
44180, 44180, 44180, 44180};

static void test_invalid_sequence();
static void test_normal_scan(void);
Expand Down
2 changes: 1 addition & 1 deletion c-core/test_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(void)
eq(scan_add(scan, sequences[0].id, sequences[0].name, seq), 0);
eq(scan_run(scan, PRODDIR, NULL, NULL), 0);
eq(scan_progress(scan), 100);
eq(chksum(PRODDIR "/products.tsv"), 25112);
eq(chksum(PRODDIR "/products.tsv"), 38063);
eq(scan_close(scan), 0);

scan_del(scan);
Expand Down
13 changes: 8 additions & 5 deletions c-core/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static int code_fn(int pos, int len, void *arg)
}

static int trim_path(struct protein *, struct imm_seq const *,
struct imm_path *, struct imm_seq *);
struct imm_path *, struct imm_seq *, int *seqstart);

static int process_window(struct thread *x, int protein_idx,
struct window const *w)
Expand Down Expand Up @@ -174,8 +174,11 @@ static int process_window(struct thread *x, int protein_idx,
subseq = seq->imm.seq;
else
{
if ((rc = trim_path(&x->protein, &seq->imm.seq, subpath, &subseq)))
line->hit_start = 0;
if ((rc = trim_path(&x->protein, &seq->imm.seq, subpath, &subseq,
&line->hit_start)))
return rc;
line->hit_stop = line->hit_start + imm_seq_size(&subseq);
}

if (hmmer_online(&x->hmmer))
Expand Down Expand Up @@ -206,7 +209,7 @@ static int process_window(struct thread *x, int protein_idx,
}

static int trim_path(struct protein *protein, struct imm_seq const *seq,
struct imm_path *path, struct imm_seq *subseq)
struct imm_path *path, struct imm_seq *subseq, int *seqstart)
{
int rc = 0;

Expand All @@ -225,7 +228,7 @@ static int trim_path(struct protein *protein, struct imm_seq const *seq,
}
if (rc) return rc;
start = match_iter_tell(&it) - 1;
int seqstart = match_iter_seqtell(&it) - match.step.seqsize;
*seqstart = match_iter_seqtell(&it) - match.step.seqsize;

if ((rc = match_iter_seek(&it, &match, INT_MAX))) return rc;
while (!(rc = match_iter_prev(&it, &match)))
Expand All @@ -239,7 +242,7 @@ static int trim_path(struct protein *protein, struct imm_seq const *seq,

match_iter_seek(&it, &match, start);

*subseq = imm_seq_slice(seq, imm_range(seqstart, seqstop));
*subseq = imm_seq_slice(seq, imm_range(*seqstart, seqstop));
imm_path_cut(path, start, stop - start);

return 0;
Expand Down

0 comments on commit 25919b7

Please sign in to comment.