samtools 0.1 → 0.1.1
raw patch · 8 files changed
+444/−5 lines, 8 files
Files
- samtools-0.1.13/bam_maqcns.h +61/−0
- samtools-0.1.13/bgzf.h +157/−0
- samtools-0.1.13/errmod.h +24/−0
- samtools-0.1.13/kaln.h +67/−0
- samtools-0.1.13/knetfile.h +75/−0
- samtools-0.1.13/kprobaln.h +49/−0
- samtools.cabal +9/−5
- src/Bio/SamTools/LowLevel.chs +2/−0
+ samtools-0.1.13/bam_maqcns.h view
@@ -0,0 +1,61 @@+#ifndef BAM_MAQCNS_H+#define BAM_MAQCNS_H++#include "glf.h"++#define BAM_ERRMOD_MAQ2 0+#define BAM_ERRMOD_MAQ 1+#define BAM_ERRMOD_SOAP 2++struct __bmc_aux_t;++typedef struct {+ float het_rate, theta;+ int n_hap, cap_mapQ, errmod, min_baseQ;++ float eta, q_r;+ double *fk, *coef;+ double *lhet;+ struct __bmc_aux_t *aux;+} bam_maqcns_t;++typedef struct {+ int q_indel; // indel sequencing error, phred scaled+ float r_indel; // indel prior+ float r_snp; // snp prior+ // hidden parameters, unchangeable from command line+ int mm_penalty, indel_err, ambi_thres;+} bam_maqindel_opt_t;++typedef struct {+ int indel1, indel2;+ int cnt1, cnt2, cnt_anti;+ int cnt_ref, cnt_ambi;+ char *s[2];+ //+ int gt, gl[2];+ int q_cns, q_ref;+} bam_maqindel_ret_t;++#ifdef __cplusplus+extern "C" {+#endif++ bam_maqcns_t *bam_maqcns_init();+ void bam_maqcns_prepare(bam_maqcns_t *bm);+ void bam_maqcns_destroy(bam_maqcns_t *bm);+ glf1_t *bam_maqcns_glfgen(int n, const bam_pileup1_t *pl, uint8_t ref_base, bam_maqcns_t *bm);+ uint32_t bam_maqcns_call(int n, const bam_pileup1_t *pl, bam_maqcns_t *bm);+ // return: cns<<28 | cns2<<24 | mapQ<<16 | cnsQ<<8 | cnsQ2+ uint32_t glf2cns(const glf1_t *g, int q_r);++ bam_maqindel_opt_t *bam_maqindel_opt_init();+ bam_maqindel_ret_t *bam_maqindel(int n, int pos, const bam_maqindel_opt_t *mi, const bam_pileup1_t *pl, const char *ref,+ int _n_types, int *_types);+ void bam_maqindel_ret_destroy(bam_maqindel_ret_t*);++#ifdef __cplusplus+}+#endif++#endif
+ samtools-0.1.13/bgzf.h view
@@ -0,0 +1,157 @@+/* The MIT License++ Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology++ Permission is hereby granted, free of charge, to any person obtaining a copy+ of this software and associated documentation files (the "Software"), to deal+ in the Software without restriction, including without limitation the rights+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+ copies of the Software, and to permit persons to whom the Software is+ furnished to do so, subject to the following conditions:++ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software.++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+ THE SOFTWARE.+*/++#ifndef __BGZF_H+#define __BGZF_H++#include <stdint.h>+#include <stdio.h>+#include <stdbool.h>+#include <zlib.h>+#ifdef _USE_KNETFILE+#include "knetfile.h"+#endif++//typedef int8_t bool;++typedef struct {+ int file_descriptor;+ char open_mode; // 'r' or 'w'+ bool owned_file, is_uncompressed;+#ifdef _USE_KNETFILE+ union {+ knetFile *fpr;+ FILE *fpw;+ } x;+#else+ FILE* file;+#endif+ int uncompressed_block_size;+ int compressed_block_size;+ void* uncompressed_block;+ void* compressed_block;+ int64_t block_address;+ int block_length;+ int block_offset;+ int cache_size;+ const char* error;+ void *cache; // a pointer to a hash table+} BGZF;++#ifdef __cplusplus+extern "C" {+#endif++/*+ * Open an existing file descriptor for reading or writing.+ * Mode must be either "r" or "w".+ * A subsequent bgzf_close will not close the file descriptor.+ * Returns null on error.+ */+BGZF* bgzf_fdopen(int fd, const char* __restrict mode);++/*+ * Open the specified file for reading or writing.+ * Mode must be either "r" or "w".+ * Returns null on error.+ */+BGZF* bgzf_open(const char* path, const char* __restrict mode);++/*+ * Close the BGZ file and free all associated resources.+ * Does not close the underlying file descriptor if created with bgzf_fdopen.+ * Returns zero on success, -1 on error.+ */+int bgzf_close(BGZF* fp);++/*+ * Read up to length bytes from the file storing into data.+ * Returns the number of bytes actually read.+ * Returns zero on end of file.+ * Returns -1 on error.+ */+int bgzf_read(BGZF* fp, void* data, int length);++/*+ * Write length bytes from data to the file.+ * Returns the number of bytes written.+ * Returns -1 on error.+ */+int bgzf_write(BGZF* fp, const void* data, int length);++/*+ * Return a virtual file pointer to the current location in the file.+ * No interpetation of the value should be made, other than a subsequent+ * call to bgzf_seek can be used to position the file at the same point.+ * Return value is non-negative on success.+ * Returns -1 on error.+ */+#define bgzf_tell(fp) ((fp->block_address << 16) | (fp->block_offset & 0xFFFF))++/*+ * Set the file to read from the location specified by pos, which must+ * be a value previously returned by bgzf_tell for this file (but not+ * necessarily one returned by this file handle).+ * The where argument must be SEEK_SET.+ * Seeking on a file opened for write is not supported.+ * Returns zero on success, -1 on error.+ */+int64_t bgzf_seek(BGZF* fp, int64_t pos, int where);++/*+ * Set the cache size. Zero to disable. By default, caching is+ * disabled. The recommended cache size for frequent random access is+ * about 8M bytes.+ */+void bgzf_set_cache_size(BGZF *fp, int cache_size);++int bgzf_check_EOF(BGZF *fp);+int bgzf_read_block(BGZF* fp);+int bgzf_flush(BGZF* fp);+int bgzf_flush_try(BGZF *fp, int size);++#ifdef __cplusplus+}+#endif++static inline int bgzf_getc(BGZF *fp)+{+ int c;+ if (fp->block_offset >= fp->block_length) {+ if (bgzf_read_block(fp) != 0) return -2; /* error */+ if (fp->block_length == 0) return -1; /* end-of-file */+ }+ c = ((unsigned char*)fp->uncompressed_block)[fp->block_offset++];+ if (fp->block_offset == fp->block_length) {+#ifdef _USE_KNETFILE+ fp->block_address = knet_tell(fp->x.fpr);+#else+ fp->block_address = ftello(fp->file);+#endif+ fp->block_offset = 0;+ fp->block_length = 0;+ }+ return c;+}++#endif
+ samtools-0.1.13/errmod.h view
@@ -0,0 +1,24 @@+#ifndef ERRMOD_H+#define ERRMOD_H++#include <stdint.h>++struct __errmod_coef_t;++typedef struct {+ double depcorr;+ struct __errmod_coef_t *coef;+} errmod_t;++errmod_t *errmod_init(float depcorr);+void errmod_destroy(errmod_t *em);++/*+ n: number of bases+ m: maximum base+ bases[i]: qual:6, strand:1, base:4+ q[i*m+j]: phred-scaled likelihood of (i,j)+ */+int errmod_cal(const errmod_t *em, int n, int m, uint16_t *bases, float *q);++#endif
+ samtools-0.1.13/kaln.h view
@@ -0,0 +1,67 @@+/* The MIT License++ Copyright (c) 2003-2006, 2008, 2009 by Heng Li <lh3@live.co.uk>++ Permission is hereby granted, free of charge, to any person obtaining+ a copy of this software and associated documentation files (the+ "Software"), to deal in the Software without restriction, including+ without limitation the rights to use, copy, modify, merge, publish,+ distribute, sublicense, and/or sell copies of the Software, and to+ permit persons to whom the Software is furnished to do so, subject to+ the following conditions:++ The above copyright notice and this permission notice shall be+ included in all copies or substantial portions of the Software.++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+ SOFTWARE.+*/++#ifndef LH3_KALN_H_+#define LH3_KALN_H_++#include <stdint.h>++#define MINOR_INF -1073741823++typedef struct {+ int gap_open;+ int gap_ext;+ int gap_end_open;+ int gap_end_ext;++ int *matrix;+ int row;+ int band_width;+} ka_param_t;++typedef struct {+ int iio, iie, ido, ide;+ int eio, eie, edo, ede;+ int *matrix;+ int row;+ int band_width;+} ka_param2_t;++#ifdef __cplusplus+extern "C" {+#endif++ uint32_t *ka_global_core(uint8_t *seq1, int len1, uint8_t *seq2, int len2, const ka_param_t *ap,+ int *_score, int *n_cigar);+ int ka_global_score(const uint8_t *_seq1, int len1, const uint8_t *_seq2, int len2, const ka_param2_t *ap);+#ifdef __cplusplus+}+#endif++extern ka_param_t ka_param_blast; /* = { 5, 2, 5, 2, aln_sm_blast, 5, 50 }; */+extern ka_param_t ka_param_qual; // only use this for global alignment!!!+extern ka_param2_t ka_param2_qual; // only use this for global alignment!!!++#endif
+ samtools-0.1.13/knetfile.h view
@@ -0,0 +1,75 @@+#ifndef KNETFILE_H+#define KNETFILE_H++#include <stdint.h>+#include <fcntl.h>++#ifndef _WIN32+#define netread(fd, ptr, len) read(fd, ptr, len)+#define netwrite(fd, ptr, len) write(fd, ptr, len)+#define netclose(fd) close(fd)+#else+#include <winsock2.h>+#define netread(fd, ptr, len) recv(fd, ptr, len, 0)+#define netwrite(fd, ptr, len) send(fd, ptr, len, 0)+#define netclose(fd) closesocket(fd)+#endif++// FIXME: currently I/O is unbuffered++#define KNF_TYPE_LOCAL 1+#define KNF_TYPE_FTP 2+#define KNF_TYPE_HTTP 3++typedef struct knetFile_s {+ int type, fd;+ int64_t offset;+ char *host, *port;++ // the following are for FTP only+ int ctrl_fd, pasv_ip[4], pasv_port, max_response, no_reconnect, is_ready;+ char *response, *retr, *size_cmd;+ int64_t seek_offset; // for lazy seek+ int64_t file_size;++ // the following are for HTTP only+ char *path, *http_host;+} knetFile;++#define knet_tell(fp) ((fp)->offset)+#define knet_fileno(fp) ((fp)->fd)++#ifdef __cplusplus+extern "C" {+#endif++#ifdef _WIN32+ int knet_win32_init();+ void knet_win32_destroy();+#endif++ knetFile *knet_open(const char *fn, const char *mode);++ /* + This only works with local files.+ */+ knetFile *knet_dopen(int fd, const char *mode);++ /*+ If ->is_ready==0, this routine updates ->fd; otherwise, it simply+ reads from ->fd.+ */+ off_t knet_read(knetFile *fp, void *buf, off_t len);++ /*+ This routine only sets ->offset and ->is_ready=0. It does not+ communicate with the FTP server.+ */+ off_t knet_seek(knetFile *fp, int64_t off, int whence);+ int knet_close(knetFile *fp);++#ifdef __cplusplus+}+#endif++#endif
+ samtools-0.1.13/kprobaln.h view
@@ -0,0 +1,49 @@+/* The MIT License++ Copyright (c) 2003-2006, 2008, 2009 by Heng Li <lh3@live.co.uk>++ Permission is hereby granted, free of charge, to any person obtaining+ a copy of this software and associated documentation files (the+ "Software"), to deal in the Software without restriction, including+ without limitation the rights to use, copy, modify, merge, publish,+ distribute, sublicense, and/or sell copies of the Software, and to+ permit persons to whom the Software is furnished to do so, subject to+ the following conditions:++ The above copyright notice and this permission notice shall be+ included in all copies or substantial portions of the Software.++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+ SOFTWARE.+*/++#ifndef LH3_KPROBALN_H_+#define LH3_KPROBALN_H_++#include <stdint.h>++typedef struct {+ float d, e;+ int bw;+} kpa_par_t;++#ifdef __cplusplus+extern "C" {+#endif++ int kpa_glocal(const uint8_t *_ref, int l_ref, const uint8_t *_query, int l_query, const uint8_t *iqual,+ const kpa_par_t *c, int *state, uint8_t *q);++#ifdef __cplusplus+}+#endif++extern kpa_par_t kpa_par_def, kpa_par_alt;++#endif
samtools.cabal view
@@ -1,5 +1,5 @@ Name: samtools-Version: 0.1+Version: 0.1.1 Synopsis: Binding to the C samtools library Description: Binding to the C samtools library, which reads and writes SAM format alignments, both binary and tab-@@ -49,8 +49,10 @@ samtools-0.1.13/bam.h, samtools-0.1.13/bam_endian.h, samtools-0.1.13/faidx.h, samtools-0.1.13/glf.h, samtools-0.1.13/khash.h, samtools-0.1.13/kseq.h, samtools-0.1.13/ksort.h, samtools-0.1.13/kstring.h,- samtools-0.1.13/razf.h, samtools-0.1.13/sam.h, samtools-0.1.13/sam_header.h- CC-options: -g -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -Wno-unused-result+ samtools-0.1.13/razf.h, samtools-0.1.13/sam.h, samtools-0.1.13/sam_header.h,+ samtools-0.1.13/bgzf.h, samtools-0.1.13/knetfile.h, samtools-0.1.13/kaln.h,+ samtools-0.1.13/kprobaln.h, samtools-0.1.13/bam_maqcns.h, samtools-0.1.13/errmod.h+ CC-options: -g -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE Extra-libraries: z Ghc-options: -Wall @@ -77,7 +79,9 @@ samtools-0.1.13/bam.h, samtools-0.1.13/bam_endian.h, samtools-0.1.13/faidx.h, samtools-0.1.13/glf.h, samtools-0.1.13/khash.h, samtools-0.1.13/kseq.h, samtools-0.1.13/ksort.h, samtools-0.1.13/kstring.h,- samtools-0.1.13/razf.h, samtools-0.1.13/sam.h, samtools-0.1.13/sam_header.h- CC-options: -g -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -Wno-unused-result+ samtools-0.1.13/razf.h, samtools-0.1.13/sam.h, samtools-0.1.13/sam_header.h,+ samtools-0.1.13/bgzf.h, samtools-0.1.13/knetfile.h, samtools-0.1.13/kaln.h,+ samtools-0.1.13/kprobaln.h, samtools-0.1.13/bam_maqcns.h, samtools-0.1.13/errmod.h+ CC-options: -g -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE Extra-libraries: z Ghc-options: -Wall
src/Bio/SamTools/LowLevel.chs view
@@ -46,6 +46,8 @@ import Control.Monad import qualified Data.ByteString.Char8 as BS +#undef __BLOCKS__+ #include "faidx.h" #include "sam.h" #include "samtools.h"