Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
The information in the output files is improved by separating the mapping of unmethylated Cs from non-hydroxymethylated Cs. Same action with nonC
  • Loading branch information
nosexybot authored Jul 9, 2021
1 parent e0e44fc commit 6caa5c8
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 14 deletions.
30 changes: 21 additions & 9 deletions hmapper/src/consumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,25 @@ int consumer_stage_step(void* data, scheduler_input_t* scheduler) {
void consumer_meth_array_serialize(meth_array_node_t* array, size_t length,
FILE* fd, char delimiter, char record_delimiter, size_t coverage) {
uint32_t position = 0;
uint16_t c = 0, nc = 0, mc = 0, hmc = 0;
uint16_t c = 0, nc = 0, mc = 0, ch = 0, nch = 0, hmc = 0;

for (size_t i = 0; i < length; ++i) {
position = array[i].position;
c = array[i].c_count;
nc = array[i].nc_count;
mc = array[i].mc_count;
c = array[i].c_count;
nc = array[i].nc_count;
mc = array[i].mc_count;
ch = array[i].ch_count;
nch = array[i].nch_count;
hmc = array[i].hmc_count;

if (c + mc > coverage || c + hmc > coverage) {
fprintf(fd, "%u%c%u%c%u%c%u%c%u%c",
if (c + mc > coverage || ch + hmc > coverage) {
fprintf(fd, "%u%c%u%c%u%c%u%c%u%c%u%c%u%c",
position, delimiter,
c, delimiter,
nc, delimiter,
mc, delimiter,
ch, delimiter,
nch, delimiter,
hmc, record_delimiter);
}
}
Expand All @@ -188,7 +192,7 @@ void consumer_meth_array_serialize_mix(meth_array_node_t* array_f,
char record_delimiter,
size_t coverage) {
uint32_t position = 0;
uint16_t c = 0, nc = 0, mc = 0, hmc = 0;
uint16_t c = 0, nc = 0, mc = 0, ch = 0, nch = 0, hmc = 0;

uint32_t idx_f = 0, idx_r = 0;
uint32_t position_f = 0, position_r = 0;
Expand All @@ -206,6 +210,8 @@ void consumer_meth_array_serialize_mix(meth_array_node_t* array_f,
c = array_f[idx_f].c_count;
nc = array_f[idx_f].nc_count;
mc = array_f[idx_f].mc_count;
ch = array_f[idx_f].ch_count;
nch = array_f[idx_f].nch_count;
hmc = array_f[idx_f].hmc_count;

idx_f++;
Expand All @@ -215,6 +221,8 @@ void consumer_meth_array_serialize_mix(meth_array_node_t* array_f,
c = array_r[idx_r].c_count;
nc = array_r[idx_r].nc_count;
mc = array_r[idx_r].mc_count;
ch = array_r[idx_f].ch_count;
nch = array_r[idx_f].nch_count;
hmc = array_r[idx_r].hmc_count;

idx_r++;
Expand All @@ -224,19 +232,23 @@ void consumer_meth_array_serialize_mix(meth_array_node_t* array_f,
c = array_r[idx_r].c_count + array_f[idx_f].c_count;
nc = array_r[idx_r].nc_count + array_f[idx_f].nc_count;
mc = array_r[idx_r].mc_count + array_f[idx_f].mc_count;
ch = array_r[idx_r].ch_count + array_f[idx_f].ch_count;
nch = array_r[idx_r].nch_count + array_f[idx_f].nch_count;
hmc = array_r[idx_r].hmc_count + array_f[idx_f].hmc_count;

idx_f++;
idx_r++;
}

// write the position and coverage in file
if (c + mc > coverage || c + hmc > coverage) {
fprintf(fd, "%u%c%u%c%u%c%u%c%u%c",
if (c + mc > coverage || ch + hmc > coverage) {
fprintf(fd, "%u%c%u%c%u%c%u%c%u%c%u%c%u%c",
position, delimiter,
c, delimiter,
nc, delimiter,
mc, delimiter,
ch, delimiter,
nch, delimiter,
hmc, record_delimiter);
}

Expand Down
Binary file added hmapper/src/consumer.o
Binary file not shown.
Binary file added hmapper/src/main.o
Binary file not shown.
Binary file added hmapper/src/options.o
Binary file not shown.
Binary file added hmapper/src/producer.o
Binary file not shown.
Binary file added hmapper/src/scheduler.o
Binary file not shown.
18 changes: 15 additions & 3 deletions hmapper/src/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,28 @@ void worker_process_alignment(worker_input_t* worker, alignment_t* alignment, si
current_node->hmc_count++;
}
} else {
current_node->c_count++;
if (alignment->methylation_type == MC_QUEUE_INDEX) {
current_node->c_count++;
} else {
current_node->ch_count++;
}
}
} else {
if (strand == STRAND_FORWARD) {
if (seq_base != 'C') {
current_node->nc_count++;
if (alignment->methylation_type == MC_QUEUE_INDEX) {
current_node->nc_count++;
} else {
current_node->nch_count++;
}
}
} else {
if (seq_base != 'G') {
current_node->nc_count++;
if (alignment->methylation_type == MC_QUEUE_INDEX) {
current_node->nc_count++;
} else {
current_node->nch_count++;
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions hmapper/src/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
*/
typedef struct __attribute__((__packed__)) meth_array_node {
uint32_t position; /* Position in the chromosome */
uint16_t c_count; /* Number of total cytosines */
uint16_t nc_count; /* Number of non-methylated cytosines */
uint16_t c_count; /* Number of non-methylated cytosines */
uint16_t nc_count; /* Number of overlaping non-cytosines (5mC)*/
uint16_t mc_count; /* Number of 5-mC cytosines */
uint16_t ch_count; /* Number of non-hydroxymethylated cytosines */
uint16_t nch_count; /* Number of overlaping non-cytosines (5hmC)*/
uint16_t hmc_count; /* Number of 5-hmC cytosines */
} meth_array_node_t;

Expand Down
Binary file added hmapper/src/worker.o
Binary file not shown.

0 comments on commit 6caa5c8

Please sign in to comment.