Changeset: 652329ec295a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=652329ec295a Modified Files: sql/backends/monet5/bam/bam.mal sql/backends/monet5/bam/bam_lib.c Branch: bamloader Log Message:
Revert bam_lib.c and bam.mal back to their previous bulk operator for seq_char diffs (167 lines): diff --git a/sql/backends/monet5/bam/bam.mal b/sql/backends/monet5/bam/bam.mal --- a/sql/backends/monet5/bam/bam.mal +++ b/sql/backends/monet5/bam/bam.mal @@ -53,7 +53,9 @@ pattern bam_export(output_path:str):void address bam_exportf comment "Export results in the bam.export table to a BAM file" + # BAT signatures for bam_lib + module batbam; command bam_flag(flags:bat[:oid,:sht], name:str):bat[:oid,:bit] @@ -72,6 +74,6 @@ command seq_length(cigars:bat[:oid,:str] address seq_length_bat comment "Calculate the real length of a bat of DNA sequences, given their CIGAR string." -command seq_char(ref_pos:bat[:oid,:int], alg_seq:bat[:oid,:str], alg_pos:bat[:oid,:int], alg_cigar:bat[:oid,:str]):bat[:oid,:str] +command seq_char(ref_pos:int, alg_seq:bat[:oid,:str], alg_pos:bat[:oid,:int], alg_cigar:bat[:oid,:str]):bat[:oid,:str] address seq_char_bat comment "Calculate the character in the alignment string (alg_str) that is aligned to position 'ref_pos', conforming to the given cigar string (bat based version)" diff --git a/sql/backends/monet5/bam/bam_lib.c b/sql/backends/monet5/bam/bam_lib.c --- a/sql/backends/monet5/bam/bam_lib.c +++ b/sql/backends/monet5/bam/bam_lib.c @@ -54,7 +54,6 @@ bam_flag(bit * ret, sht * flag, str * na return MAL_SUCCEED; } -// use a simple lookup table for these mappings str reverse_seq(str * ret, str * seq) { @@ -254,7 +253,6 @@ bam_flag_bat(bat * ret, bat * bid, str * /* allocate result BAT */ result = BATnew(TYPE_void, TYPE_bit, BATcount(flags), TRANSIENT); if (result == NULL) { - BBPreleaseref(flags->batCacheid); throw(MAL, "bam_flag_bat", MAL_MALLOC_FAIL); } BATseqbase(result, flags->hseqbase); @@ -291,7 +289,6 @@ reverse_seq_bat(bat * ret, bat * bid) /* allocate result BAT */ result = BATnew(TYPE_void, TYPE_str, BATcount(seqs), TRANSIENT); if (result == NULL) { - BBPreleaseref(seqs->batCacheid); throw(MAL, "reverse_seq_bat", MAL_MALLOC_FAIL); } BATseqbase(result, seqs->hseqbase); @@ -304,7 +301,6 @@ reverse_seq_bat(bat * ret, bat * bid) if ((msg = reverse_seq(&r, &t)) != MAL_SUCCEED) { BBPreleaseref(result->batCacheid); - BBPreleaseref(seqs->batCacheid); return msg; } BUNappend(result, (ptr) r, FALSE); @@ -334,7 +330,6 @@ reverse_qual_bat(bat * ret, bat * bid) /* allocate result BAT */ result = BATnew(TYPE_void, TYPE_str, BATcount(quals), TRANSIENT); if (result == NULL) { - BBPreleaseref(quals->batCacheid); throw(MAL, "reverse_qual_bat", MAL_MALLOC_FAIL); } BATseqbase(result, quals->hseqbase); @@ -346,7 +341,6 @@ reverse_qual_bat(bat * ret, bat * bid) str r, msg; if ((msg = reverse_qual(&r, &t)) != MAL_SUCCEED) { - BBPreleaseref(quals->batCacheid); BBPreleaseref(result->batCacheid); return msg; } @@ -377,7 +371,6 @@ seq_length_bat(bat * ret, bat * bid) /* allocate result BAT */ result = BATnew(TYPE_void, TYPE_int, BATcount(cigars), TRANSIENT); if (result == NULL) { - BBPreleaseref(cigars->batCacheid); throw(MAL, "seq_length_bat", MAL_MALLOC_FAIL); } BATseqbase(result, cigars->hseqbase); @@ -391,7 +384,6 @@ seq_length_bat(bat * ret, bat * bid) if ((msg = seq_length(&r, &t)) != MAL_SUCCEED) { BBPreleaseref(result->batCacheid); - BBPreleaseref(cigars->batCacheid); return msg; } BUNappend(result, (ptr) &r, FALSE); @@ -409,26 +401,18 @@ seq_length_bat(bat * ret, bat * bid) str seq_char_bat(bat * ret, int * ref_pos, bat * alg_seq, bat * alg_pos, bat * alg_cigar) { - BAT *seqs = NULL, *poss = NULL, *refs = NULL, *cigars = NULL, *result = NULL; - BUN ref= 0, seq = 0, pos = 0, cigar = 0, seq_end = 0; - BATiter ref_it, seq_it, pos_it, cigar_it; + BAT *seqs, *poss, *cigars, *result; + BUN seq = 0, pos = 0, cigar = 0, seq_end = 0; + BATiter seq_it, pos_it, cigar_it; assert(ret != NULL && ref_pos != NULL && alg_seq != NULL && alg_pos != NULL && alg_cigar != NULL); if ((seqs = BATdescriptor(*alg_seq)) == NULL || (poss = BATdescriptor(*alg_pos)) == NULL || - (refs = BATdescriptor(*ref_pos)) == NULL || - (cigars = BATdescriptor(*alg_cigar)) == NULL) { - if( seqs) BBPreleaseref(seqs->batCacheid); - if( poss) BBPreleaseref(poss->batCacheid); - if( refs) BBPreleaseref(refs->batCacheid); - throw(MAL, "seq_char_bat", RUNTIME_OBJECT_MISSING); - } + (cigars = BATdescriptor(*alg_cigar)) == NULL) + throw(MAL, "seq_char_bat", RUNTIME_OBJECT_MISSING); if(BATcount(seqs) != BATcount(poss) || BATcount(seqs) != BATcount(cigars)) { - BBPreleaseref(seqs->batCacheid); - BBPreleaseref(poss->batCacheid); - BBPreleaseref(refs->batCacheid); throw(MAL, "seq_char_bat", "Misalignment in input BATs: "BUNFMT"/"BUNFMT"/"BUNFMT, BATcount(poss), BATcount(seqs), BATcount(cigars)); @@ -437,37 +421,27 @@ seq_char_bat(bat * ret, int * ref_pos, b /* allocate result BAT */ result = BATnew(TYPE_void, TYPE_str, BATcount(cigars), TRANSIENT); if (result == NULL) { - BBPreleaseref(seqs->batCacheid); - BBPreleaseref(poss->batCacheid); - BBPreleaseref(refs->batCacheid); throw(MAL, "seq_char_bat", MAL_MALLOC_FAIL); } BATseqbase(result, seqs->hseqbase); - ref = BUNfirst(refs); seq = BUNfirst(seqs); pos = BUNfirst(poss); cigar = BUNfirst(cigars); seq_end = BUNlast(seqs); - ref_it = bat_iterator(refs); seq_it = bat_iterator(seqs); pos_it = bat_iterator(poss); cigar_it = bat_iterator(cigars); while(seq < seq_end) { str seq_val = (str) BUNtail(seq_it, seq); - int * ref_val = (int *) BUNtail(ref_it, ref); int * pos_val = (int *) BUNtail(pos_it, pos); str cigar_val = (str) BUNtail(cigar_it, cigar); str r; str msg; - if ((msg = seq_char(&r, ref_val, &seq_val, pos_val, &cigar_val)) != MAL_SUCCEED) { - BBPreleaseref(refs->batCacheid); - BBPreleaseref(seqs->batCacheid); - BBPreleaseref(poss->batCacheid); - BBPreleaseref(cigars->batCacheid); + if ((msg = seq_char(&r, ref_pos, &seq_val, pos_val, &cigar_val)) != MAL_SUCCEED) { BBPreleaseref(result->batCacheid); return msg; } @@ -478,7 +452,6 @@ seq_char_bat(bat * ret, int * ref_pos, b } /* release input BAT-descriptors */ - BBPreleaseref(refs->batCacheid); BBPreleaseref(seqs->batCacheid); BBPreleaseref(poss->batCacheid); BBPreleaseref(cigars->batCacheid); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list