Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 65 additions & 68 deletions src/gensig.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,94 +37,91 @@ char *attach_prefix(core_t *core, const char *read, int32_t *len, aln_t *aln);
void gen_prefix_dna(int16_t *raw_signal, int64_t* n, int64_t *c, profile_t *profile, double offset);
int16_t *gen_prefix_rna(core_t *core, int16_t *raw_signal, int64_t* n, int64_t *c, double offset, int tid, aln_t *aln);

void set_header_attributes(slow5_file_t *sp, int8_t rna, int8_t r10, double sample_frequency){

slow5_hdr_t *header=sp->header;

//add a header group attribute called run_id
if (slow5_hdr_add("run_id", header) < 0){
ERROR("%s","Error adding run_id attribute");
exit(EXIT_FAILURE);
}
//add another header group attribute called asic_id
if (slow5_hdr_add("asic_id", header) < 0){
ERROR("%s","Error adding asic_id attribute");
exit(EXIT_FAILURE);
}
//add another header group attribute called asic_id
if (slow5_hdr_add("exp_start_time", header) < 0){
ERROR("%s","Error adding asic_id attribute");
exit(EXIT_FAILURE);
}
//add another header group attribute called flow_cell_id
if (slow5_hdr_add("flow_cell_id", header) < 0){
ERROR("%s","Error adding flow_cell_id attribute");
exit(EXIT_FAILURE);
}
//add another header group attribute called experiment_type
if (slow5_hdr_add("experiment_type", header) < 0){
ERROR("%s","Error adding experiment_type attribute");
exit(EXIT_FAILURE);
}
//add another header group attribute called sequencing_kit
if (slow5_hdr_add("sequencing_kit", header) < 0){
ERROR("%s","Error adding sequencing_kit attribute");
exit(EXIT_FAILURE);
}
//add another header group attribute called sample_frequency
if (slow5_hdr_add("sample_frequency", header) < 0){
ERROR("%s","Error adding sample_frequency attribute");
static inline void slow5_hdr_add_check(const char *attr_name, slow5_hdr_t *header){
if (slow5_hdr_add(attr_name, header) < 0){
ERROR("Error adding %s attribute", attr_name);
exit(EXIT_FAILURE);
}
}

//set the run_id attribute to "run_0" for read group 0
if (slow5_hdr_set("run_id", "run_0", 0, header) < 0){
ERROR("%s","Error setting run_id attribute in read group 0");
exit(EXIT_FAILURE);
}
//set the asic_id attribute to "asic_0" for read group 0
if (slow5_hdr_set("asic_id", "asic_id_0", 0, header) < 0){
ERROR("%s","Error setting asic_id attribute in read group 0");
exit(EXIT_FAILURE);
}
//set the exp_start_time attribute to "2022-07-20T00:00:00Z" for read group 0
if (slow5_hdr_set("exp_start_time", "2022-07-20T00:00:00Z", 0, header) < 0){
ERROR("%s","Error setting exp_start_time attribute in read group 0");
exit(EXIT_FAILURE);
}
//set the flow_cell_id attribute to "FAN00000" for read group 0
if (slow5_hdr_set("flow_cell_id", "FAN00000", 0, header) < 0){
ERROR("%s","Error setting flow_cell_id attribute in read group 0");
static inline void slow5_hdr_set_check(const char *attr_name, const char *value, slow5_hdr_t *header){
if (slow5_hdr_set(attr_name, value, 0, header) < 0){
ERROR("Error setting %s attribute in read group %d", attr_name, 0);
exit(EXIT_FAILURE);
}
//set the experiment_type attribute to genomic_dna or rna for read group 0
}

void set_header_attributes(slow5_file_t *sp, int8_t rna, int8_t r10, int8_t prom, double sample_frequency){

slow5_hdr_t *header=sp->header;

//header group attributes

slow5_hdr_add_check("asic_id", header);
slow5_hdr_add_check("exp_start_time", header);
slow5_hdr_add_check("experiment_name", header);
slow5_hdr_add_check("experiment_type", header);
slow5_hdr_add_check("flow_cell_id", header);
slow5_hdr_add_check("flow_cell_product_code", header);

slow5_hdr_add_check("protocol_run_id", header);
slow5_hdr_add_check("protocol_start_time", header);
slow5_hdr_add_check("run_id", header);
slow5_hdr_add_check("sample_frequency", header);
slow5_hdr_add_check("sample_id", header);
slow5_hdr_add_check("sequencing_kit", header);
slow5_hdr_add_check("sequencer_position", header);
slow5_hdr_add_check("system_name", header);


//dna/rna
const char* experiment_type = rna ? "rna" : "genomic_dna" ;
if (slow5_hdr_set("experiment_type", experiment_type, 0, header) < 0){
ERROR("%s","Error setting experiment_type attribute in read group 0");
exit(EXIT_FAILURE);

//flow cell
const char* flow_cell = ".";
if(r10){
if(rna){
flow_cell = prom ? "FLO-PRO004RA" : "FLO-MIN004RA";
} else {
flow_cell = prom ? "FLO-PRO114M" : "FLO-MIN114";
}
} else {
flow_cell = prom ? "FLO-PRO002" : "FLO-MIN106";
}

//sequencing kit
const char* kit = ".";
if(rna){
kit = r10 ? "sqk-rna004" : "sqk-rna002";
} else{
kit = r10 ? "sqk-lsk114" : "sqk-lsk109";
}
if (slow5_hdr_set("sequencing_kit", kit, 0, header) < 0){
ERROR("%s","Error setting sequencing_kit attribute in read group 0");
exit(EXIT_FAILURE);
}

//sample_frequency
if(sample_frequency<=0 || sample_frequency>1000000000){
ERROR("%s","A weird sample frequency. It should be between 0 and 1000000000 Hz");
exit(EXIT_FAILURE);
}
char buffer[100];
sprintf(buffer, "%d", (int)sample_frequency);
if (slow5_hdr_set("sample_frequency", buffer, 0, header) < 0){
ERROR("%s","Error setting sample_frequency attribute in read group 0");
exit(EXIT_FAILURE);
}
char sample_frequency_str[100];
sprintf(sample_frequency_str, "%d", (int)sample_frequency);

//set header attributes
slow5_hdr_set_check("asic_id", "asic_id_0", header);
slow5_hdr_set_check("exp_start_time", "2026-02-20T00:00:00Z", header);
slow5_hdr_set_check("experiment_name", "experiment_0", header);
slow5_hdr_set_check("experiment_type", experiment_type, header);
slow5_hdr_set_check("flow_cell_id", "FAN00000", header);
slow5_hdr_set_check("flow_cell_product_code", flow_cell, header);
slow5_hdr_set_check("protocol_run_id", "protocol_run_0", header);
slow5_hdr_set_check("protocol_start_time", "2026-02-20T00:00:00Z", header);
slow5_hdr_set_check("run_id", "run_0", header);
slow5_hdr_set_check("sample_frequency", sample_frequency_str, header);
slow5_hdr_set_check("sample_id", "squigulator", header);
slow5_hdr_set_check("sequencing_kit", kit, header);
slow5_hdr_set_check("sequencer_position", "P0", header);
slow5_hdr_set_check("system_name", "PCA000000", header);


}

Expand Down
8 changes: 6 additions & 2 deletions src/sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ SOFTWARE.
#include "error.h"
#include "misc.h"

void set_header_attributes(slow5_file_t *sp, int8_t rna, int8_t r10, double sample_frequency);
void set_header_attributes(slow5_file_t *sp, int8_t rna, int8_t r10, int8_t prom, double sample_frequency);
void set_header_aux_fields(slow5_file_t *sp, int8_t ont_friendly);
void set_record_primary_fields(profile_t *profile, slow5_rec_t *slow5_record, char *read_id, double offset, int64_t len_raw_signal, int16_t *raw_signal);
void set_record_aux_fields(slow5_rec_t *slow5_record, slow5_file_t *sp, double median_before, int32_t read_number, uint64_t start_time, int8_t ont_friendly);
Expand Down Expand Up @@ -154,17 +154,20 @@ static inline profile_t set_profile(char *prof_name, opt_t *opt){
if(strcmp(prof_name, "dna-r9-min") == 0){
return minion_r9_dna_prof;
}else if(strcmp(prof_name, "dna-r9-prom") == 0){
opt->flag |= SQ_PROM;
return prom_r9_dna_prof;
}else if(strcmp(prof_name, "rna-r9-min") == 0){
opt->flag |= SQ_RNA;
return minion_r9_rna_prof;
}else if(strcmp(prof_name, "rna-r9-prom") == 0){
opt->flag |= SQ_RNA;
opt->flag |= SQ_PROM;
return prom_r9_rna_prof;
}else if(strcmp(prof_name, "dna-r10-prom") == 0){
INFO("%s", "dna-r10-prom is 5kHz from squigulator v0.3.0 onwards. Specify --sample-rate 4000 for old 4kHz.")
WARNING("%s","Parameters and models for dna-r10-prom 5khz are still crude. If you have good modification-free data, please share!");
opt->flag |= SQ_R10;
opt->flag |= SQ_PROM;
return prom_r10_dna_prof;
}else if(strcmp(prof_name, "dna-r10-min") == 0){
INFO("%s", "dna-r10-min is 5kHz from squigulator v0.3.0 onwards. Specify --sample-rate 4000 for old 4kHz.")
Expand All @@ -180,6 +183,7 @@ static inline profile_t set_profile(char *prof_name, opt_t *opt){
WARNING("%s","Parameters and models for rna004-prom are still crude. If you have good IVT data, please share!");
opt->flag |= SQ_R10;
opt->flag |= SQ_RNA;
opt->flag |= SQ_PROM;
return prom_rna004_rna_prof;
}else{
ERROR("Unknown profile: %s\n", prof_name);
Expand Down Expand Up @@ -346,7 +350,7 @@ static core_t *init_core(opt_t opt, profile_t p, char *refname, char *output_fil
exit(EXIT_FAILURE);
}

set_header_attributes(core->sp, opt.flag & SQ_RNA ? 1 : 0, opt.flag & SQ_R10 ? 1 : 0, p.sample_rate);
set_header_attributes(core->sp, opt.flag & SQ_RNA ? 1 : 0, opt.flag & SQ_R10 ? 1 : 0, opt.flag & SQ_PROM ? 1 : 0, p.sample_rate);
set_header_aux_fields(core->sp, opt.flag & SQ_ONT ? 1 : 0);

if(slow5_hdr_write(core->sp) < 0){
Expand Down
1 change: 1 addition & 0 deletions src/sq.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define SQ_TRANS_TRUNC 0x100 //trans-trunc
#define SQ_CDNA 0x200 //CDNA
#define SQ_ONT 0x400 //ont friendly
#define SQ_PROM 0x800 //is a promethion

#define WORK_STEAL 1 //simple work stealing enabled or not (no work stealing mean no load balancing)
#define STEAL_THRESH 1 //stealing threshold
Expand Down
9 changes: 8 additions & 1 deletion test/bps.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/cdna.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dev.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_full_contig.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_ideal_amp_slow5.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_ideal_slow5.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_ideal_time_slow5.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_prefix_slow5.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_r10_amp_noise.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_r10_paf-ref.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/dna_r10_paf.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/ont_friendly.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/r9_mfreq.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/rna004.slow5.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/rna004_dwell.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/rna_paf.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/rna_prefixno_slow5.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/rna_prefixyes_slow5.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/rna_slow5.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/slow5.exp
100755 → 100644

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/trans_count.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/trans_count_cdna.exp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion test/trans_trunc.exp

Large diffs are not rendered by default.

Loading