Skip to content

Commit

Permalink
transcript abundance simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
hasindu2008 committed Feb 8, 2024
1 parent 1769b30 commit b116835
Show file tree
Hide file tree
Showing 9 changed files with 1,140 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ endif
$(BINARY): $(OBJ) slow5lib/lib/libslow5.a
$(CC) $(CFLAGS) $(OBJ) slow5lib/lib/libslow5.a $(LDFLAGS) -o $@

HEADERS = src/error.h src/format.h src/kseq.h src/misc.h src/model.h \
src/rand.h src/ref.h src/seq.h src/sq.h src/str.h src/version.h
HEADERS = src/error.h src/format.h src/misc.h src/model.h \
src/rand.h src/ref.h src/seq.h src/sq.h src/str.h src/version.h \
src/kseq.h src/khash.h src/ksort.h

$(BUILD_DIR)/main.o: src/main.c $(HEADERS)
$(CC) $(CFLAGS) $(CPPFLAGS) $< -c -o $@
Expand Down
20 changes: 19 additions & 1 deletion src/genread.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,24 @@ static char *gen_read_dna(core_t *core, ref_t *ref, char **ref_id, int32_t *ref_
return seq;
}

static inline int transcript_idx(core_t *core,int tid){
int seq_i = 0;
trans_t *trans = core->ref->trans_counts;
if(trans == NULL){
seq_i = round(rng(&core->ref_pos[tid])*(core->ref->num_ref-1));
} else {
float r = rng(&core->ref_pos[tid]);
//fprintf(stderr, "r: %f, ", r);
for(int i=0; i<trans->n; i++){
if(r <= trans->trans_csum[i]){
seq_i = trans->trans_idx[i];
//fprintf(stderr, "seq_i: %d\n", seq_i);
break;
}
}
}
return seq_i;
}

static char *gen_read_rna(core_t *core, ref_t *ref, char **ref_id, int32_t *ref_len, int32_t *ref_pos, int32_t *rlen, char *c, int tid){

Expand All @@ -214,7 +232,7 @@ static char *gen_read_rna(core_t *core, ref_t *ref, char **ref_id, int32_t *ref_

//int len = grng(core->rand_rlen); //for now the whole transcript is is simulated

int seq_i = round(rng(&core->ref_pos[tid])*(ref->num_ref-1)); //random transcript
int seq_i = transcript_idx(core,tid); //random transcript
int len = ref->ref_lengths[seq_i];
*ref_pos=0;
*ref_id = ref->ref_names[seq_i];
Expand Down
2 changes: 1 addition & 1 deletion src/gensig.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @file gensig.c
** Stupidly simple signal simulator
** squigulator, a nanopore signal simulator
**
** @@
******************************************************************************/
Expand Down
Loading

0 comments on commit b116835

Please sign in to comment.