Changeset: f4b5d5702d8b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f4b5d5702d8b
Added Files:
        sql/backends/monet5/bam/bam_export.c
        sql/backends/monet5/bam/bam_export.h
Modified Files:
        sql/backends/monet5/bam/85_bam.sql
        sql/backends/monet5/bam/Makefile.ag
        sql/backends/monet5/bam/bam.mal
        sql/backends/monet5/bam/bam_db_interface.h
        sql/backends/monet5/bam/bam_loader.c
Branch: bamloader
Log Message:

Created framework for export functions


diffs (217 lines):

diff --git a/sql/backends/monet5/bam/85_bam.sql 
b/sql/backends/monet5/bam/85_bam.sql
--- a/sql/backends/monet5/bam/85_bam.sql
+++ b/sql/backends/monet5/bam/85_bam.sql
@@ -22,3 +22,10 @@ RETURNS STRING EXTERNAL NAME bam.reverse
 
 CREATE FUNCTION seq_length(cigar STRING)
 RETURNS INT EXTERNAL NAME bam.seq_length;
+
+
+CREATE PROCEDURE sam_export(output_path STRING)
+EXTERNAL NAME bam.sam_export;
+
+CREATE PROCEDURE bam_export(output_path STRING)
+EXTERNAL NAME bam.bam_export;
diff --git a/sql/backends/monet5/bam/Makefile.ag 
b/sql/backends/monet5/bam/Makefile.ag
--- a/sql/backends/monet5/bam/Makefile.ag
+++ b/sql/backends/monet5/bam/Makefile.ag
@@ -36,7 +36,12 @@ INCLUDES = .. \
 lib__bam = {
        MODULE
        DIR = libdir/monetdb5
-       SOURCES = bam_loader.c bam_loader.h bam_wrapper.c bam_wrapper.h 
bam_db_interface.c bam_db_interface.h bam_globals.h bam_lib.c bam_lib.h
+       SOURCES = bam_loader.c bam_loader.h \
+                 bam_wrapper.c bam_wrapper.h \
+                 bam_db_interface.c bam_db_interface.h \
+                 bam_globals.h \
+                 bam_lib.c bam_lib.h \
+                 bam_export.c bam_export.h
        LIBS = ../../../../monetdb5/tools/libmonetdb5 \
                   ../../../../gdk/libbat \
        $(SAMTOOLS_LIBS)
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
@@ -39,6 +39,17 @@ address seq_length_bat
 comment "Calculate the real length of a DNA sequence, given its CIGAR string."
 
 
+# Export signatures
+
+pattern sam_export(output_path:str):void
+address sam_export
+comment "Export results in the bam.export table to a SAM file"
+
+pattern bam_export(output_path:str):void
+address bam_export
+comment "Export results in the bam.export table to a BAM file"
+
+
 # BAT signatures for bam_lib
 
 module batbam;
diff --git a/sql/backends/monet5/bam/bam_db_interface.h 
b/sql/backends/monet5/bam/bam_db_interface.h
--- a/sql/backends/monet5/bam/bam_db_interface.h
+++ b/sql/backends/monet5/bam/bam_db_interface.h
@@ -108,6 +108,20 @@
         CONSTRAINT pg_fkey_file_id FOREIGN KEY (file_id) REFERENCES bam.files 
(file_id) \n\
     );"
 
+#define SQL_CREATE_EXPORT \
+    "CREATE TABLE bam.export ( \n\
+        qname                         STRING      NOT NULL, \n\
+        flag                          SMALLINT    NOT NULL, \n\
+        rname                         STRING      NOT NULL, \n\
+        pos                           INT         NOT NULL, \n\
+        mapq                          SMALLINT    NOT NULL, \n\
+        cigar                         STRING      NOT NULL, \n\
+        rnext                         STRING      NOT NULL, \n\
+        pnext                         INT         NOT NULL, \n\
+        tlen                          INT         NOT NULL, \n\
+        seq                           STRING      NOT NULL, \n\
+        qual                          STRING      NOT NULL  \n\
+    );"
 
 str create_schema_if_not_exists(Client cntxt, mvc * m, str schemaname,
                                str descr, sql_schema ** ret);
diff --git a/sql/backends/monet5/bam/bam_export.c 
b/sql/backends/monet5/bam/bam_export.c
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/bam/bam_export.c
@@ -0,0 +1,60 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2014 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+/*
+ * (author) R Cijvat
+ * The code in this file defines export functionality, that enables
+ * users to write data from the bam.export table to a SAM or BAM file.
+ * After exporting data, the exporting functions will automatically
+ * empty the bam.export table.
+ */
+ 
+#include "monetdb_config.h"
+#include "bam_export.h"
+
+str 
+sam_export(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+    /* arg 1: path to desired output file */
+       str output_path = *(str *) getArgReference(stk, pci, pci->retc);
+       
+    (void)output_path;
+    (void)cntxt;
+    (void)mb;
+    (void)stk;
+    (void)pci;
+    throw(MAL, "sam_export", "Not implemented yet...");
+}
+
+
+
+str 
+bam_export(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+    /* arg 1: path to desired output file */
+       str output_path = *(str *) getArgReference(stk, pci, pci->retc);
+
+    (void)output_path;
+    (void)cntxt;
+    (void)mb;
+    (void)stk;
+    (void)pci;
+    throw(MAL, "bam_export", "Not implemented yet...");
+}
+
diff --git a/sql/backends/monet5/bam/bam_export.h 
b/sql/backends/monet5/bam/bam_export.h
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/bam/bam_export.h
@@ -0,0 +1,55 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2014 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+/*
+ * (author) R Cijvat
+ * The code in this file defines export functionality, that enables
+ * users to write data from the bam.export table to a SAM or BAM file.
+ * After exporting data, the exporting functions will automatically
+ * empty the bam.export table.
+ */
+ 
+#ifndef _BAM_EXPORT_H
+#define _BAM_EXPORT_H
+ 
+#include "sql_scenario.h"
+#include "sql_mvc.h"
+ 
+ 
+/* Note: Unlike in the other BAM source files, we use bam_exp instead of
+ * bam_export here, since bam_export is a used function name in this file */
+#ifdef WIN32
+#ifndef LIBBAM
+#define bam_exp extern __declspec(dllimport)
+#else
+#define bam_exp extern __declspec(dllexport)
+#endif
+#else
+#define bam_exp extern
+#endif
+
+
+bam_exp str sam_export(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
+                               InstrPtr pci);
+bam_exp str bam_export(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
+                               InstrPtr pci);
+ 
+ 
+ 
+#endif
diff --git a/sql/backends/monet5/bam/bam_loader.c 
b/sql/backends/monet5/bam/bam_loader.c
--- a/sql/backends/monet5/bam/bam_loader.c
+++ b/sql/backends/monet5/bam/bam_loader.c
@@ -247,6 +247,12 @@ bam_loader(Client cntxt, MalBlkPtr mb, s
                                        "bam.create_pg",
                                        NULL)) != MAL_SUCCEED)
                goto cleanup;
+               
+       if ((msg =
+            create_table_if_not_exists(cntxt, m, s, "export", 
SQL_CREATE_EXPORT,
+                                       "bam.create_export",
+                                       NULL)) != MAL_SUCCEED)
+               goto cleanup;
 
        /* Get next file id */
        TO_LOG("<bam_loader> Retrieving next file id...\n");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to