Skip to content
Commits on Source (7)
......@@ -14,6 +14,7 @@ tests/*.sam
tests/*.fai
tests/pysam_data
tests/cbcf_data
tests/tabix_data
samtools/config.h
htslib/config.status
......@@ -52,6 +53,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
doc/_build
# Installer logs
pip-log.txt
......
......@@ -17,16 +17,22 @@ include pysam/libc*.c
include pysam/*.c
include pysam/*.h
# exclude tests from pypi tar-ball - they
# require additional data
prune tests/
# samtools
include samtools/configure
include samtools/config.mk.in
include samtools/config.h.in
include samtools/*.h
include samtools/*.c
exclude samtools/config.h
include samtools/*/*.h
# bcftools
include bcftools/*.h
include bcftools/*.c
exclude bcftools/config.h
# htslib
......@@ -50,39 +56,5 @@ include cy_build.py
include pysam.py
include requirements.txt
# pysam tests
include tests/00README.txt
include tests/pysam_data
include tests/tabix_data
include tests/*.py
#ex1.fa
#include tests/ex1.sam.gz
#include tests/ex3.sam
#include tests/ex4.sam
#include tests/ex5.sam
#include tests/ex6.sam
#include tests/ex7.sam
#include tests/ex8.sam
#include tests/ex9_fail.bam
#include tests/ex9_nofail.bam
#include tests/ex10.sam
#include tests/example.py
#include tests/pysam_test.py
#include tests/segfault_tests.py
#include tests/example_*.sam
#include tests/example_btag.bam
#include tests/tag_bug.bam
#include tests/example.vcf40
#include tests/example_empty_header.bam
#include tests/test_unaligned.bam
#include tests/issue100.bam
# tabix tests
#include tests/example.gtf.gz
#include tests/example.gtf.gz.tbi
#include tests/example.bed.gz
#include tests/example.bed.gz.tbi
#include tests/vcf-examples/*.vcf
# documentation
include doc/*
......@@ -5,6 +5,55 @@ http://pysam.readthedocs.io/en/latest/release.html
Release notes
=============
Release 0.14.0
==============
This release wraps htslib/samtools versions 1.7.0.
* SAM/BAM/CRAM headers are now managed by a separate AlignmentHeader
class.
* AlignmentFile.header.as_dict() returns an ordered dictionary.
* Use "stop" instead of "end" to ensure consistency to
VariantFile. The end designations have been kept for backwards
compatibility.
* [#611] and [#293] CRAM repeated fetch now works, each iterator
reloads index if multiple_iterators=True
* [#608] pysam now wraps htslib 1.7 and samtools 1.7.
* [#580] reference_name and next_reference_name can now be set to "*"
(will be converted to None to indicate an unmapped location)
* [#302] providing no coordinate to count_coverage will not count from
start/end of contig.
* [#325] @SQ records will be automatically added to header if they are
absent from text section of header.
* [#529] add get_forward_sequence() and get_forward_qualities()
methods
* [#577] add from_string() and to_dict()/from_dict() methods to
AlignedSegment. Rename tostring() to to_string() throughout for
consistency
* [#589] return None from build_alignment_sequence if no MD tag is set
* [#528] add PileupColumn.__len__ method
Backwards incompatible changes:
* AlignmentFile.header now returns an AlignmentHeader object. Use
AlignmentFile.header.to_dict() to get the dictionary as
previously. Most dictionary accessor methods (keys(), values(),
__getitem__, ...) have been implemented to ensure some level of
backwards compatibility when only reading.
The rationale for this change is to have consistency between
AlignmentFile and VariantFile.
* AlignmentFile and FastaFile now raise IOError instead of OSError
Medium term we plan to have a 1.0 release. The pysam
interface has grown over the years and the API is cluttered with
deprecated names (Samfile, getrname(), gettid(), ...). To work towards
this, the next release (0.15.0) will yield DeprecationWarnings
for any parts of the API that are considered obsolete and will not be
in 1.0. Once 1.0 has been reached, we will use semantic versioning.
Release 0.13.0
===============
......@@ -20,7 +69,6 @@ contains a series of bugfixes.
* [#537] allow tabix index files to be created in a custom location.
* [#530] add get_index_statistics() method
Release 0.12.0.1
================
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* The MIT License
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* bam2bcf.c -- variant calling.
......@@ -108,7 +108,7 @@ static int get_position(const bam_pileup1_t *p, int *len)
if ( cig==BAM_CHARD_CLIP ) continue;
if ( cig==BAM_CPAD ) continue;
if ( cig==BAM_CREF_SKIP ) continue;
fprintf(pysam_stderr,"todo: cigar %d\n", cig);
fprintf(bcftools_stderr,"todo: cigar %d\n", cig);
assert(0);
}
*len = n_tot_bases;
......@@ -504,7 +504,7 @@ void calc_SegBias(const bcf_callret1_t *bcr, bcf_call_t *call)
double sum = 0;
const double log2 = log(2.0);
// fprintf(pysam_stderr,"M=%.1f p=%e q=%e f=%f dp=%d\n",M,p,q,f,avg_dp);
// fprintf(bcftools_stderr,"M=%.1f p=%e q=%e f=%f dp=%d\n",M,p,q,f,avg_dp);
int i;
for (i=0; i<call->n; i++)
{
......@@ -519,7 +519,7 @@ void calc_SegBias(const bcf_callret1_t *bcr, bcf_call_t *call)
else
tmp = log(2*f*(1-f)*exp(-q) + f*f*exp(-2*q) + (1-f)*(1-f)) + p;
sum += tmp;
// fprintf(pysam_stderr,"oi=%d %e\n", oi,tmp);
// fprintf(bcftools_stderr,"oi=%d %e\n", oi,tmp);
}
call->seg_bias = sum;
}
......@@ -683,7 +683,7 @@ int bcf_call_combine(int n, const bcf_callret1_t *calls, bcf_callaux_t *bca, int
}
}
// if (ref_base < 0) fprintf(pysam_stderr, "%d,%d,%f,%d\n", call->n_alleles, x, sum_min, call->unseen);
// if (ref_base < 0) fprintf(bcftools_stderr, "%d,%d,%f,%d\n", call->n_alleles, x, sum_min, call->unseen);
call->shift = (int)(sum_min + .499);
}
// combine annotations
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* bam2bcf_indel.c -- indel caller.
......@@ -158,7 +158,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
free(aux);
// TODO revisit how/whether to control printing this warning
if (hts_verbose >= 2)
fprintf(pysam_stderr, "[%s] excessive INDEL alleles at position %d. Skip the position.\n", __func__, pos + 1);
fprintf(bcftools_stderr, "[%s] excessive INDEL alleles at position %d. Skip the position.\n", __func__, pos + 1);
return -1;
}
types = (int*)calloc(n_types, sizeof(int));
......@@ -231,7 +231,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
if ((double)(max2&0xffff) / ((max2&0xffff) + (max2>>16)) >= 0.7) max2_i = -1;
if (max_i >= 0) r[max_i] = 15;
if (max2_i >= 0) r[max2_i] = 15;
//for (i = 0; i < right - left; ++i) fputc("=ACMGRSVTWYHKDBN"[(int)r[i]], pysam_stderr); fputc('\n', pysam_stderr);
//for (i = 0; i < right - left; ++i) fputc("=ACMGRSVTWYHKDBN"[(int)r[i]], bcftools_stderr); fputc('\n', bcftools_stderr);
}
free(ref0); free(cns);
}
......@@ -299,7 +299,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
else if (types[t] > 0) ir = est_indelreg(pos, ref, types[t], &inscns[t*max_ins]);
else ir = est_indelreg(pos, ref, -types[t], 0);
if (ir > bca->indelreg) bca->indelreg = ir;
// fprintf(pysam_stderr, "%d, %d, %d\n", pos, types[t], ir);
// fprintf(bcftools_stderr, "%d, %d, %d\n", pos, types[t], ir);
// realignment
for (s = K = 0; s < n; ++s) {
// write ref2
......@@ -361,11 +361,11 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
}
#if 0
for (l = 0; l < tend - tbeg + abs(types[t]); ++l)
fputc("ACGTN"[(int)ref2[tbeg-left+l]], pysam_stderr);
fputc('\n', pysam_stderr);
for (l = 0; l < qend - qbeg; ++l) fputc("ACGTN"[(int)query[l]], pysam_stderr);
fputc('\n', pysam_stderr);
fprintf(pysam_stderr, "pos=%d type=%d read=%d:%d name=%s qbeg=%d tbeg=%d score=%d\n", pos, types[t], s, i, bam_get_qname(p->b), qbeg, tbeg, sc);
fputc("ACGTN"[(int)ref2[tbeg-left+l]], bcftools_stderr);
fputc('\n', bcftools_stderr);
for (l = 0; l < qend - qbeg; ++l) fputc("ACGTN"[(int)query[l]], bcftools_stderr);
fputc('\n', bcftools_stderr);
fprintf(bcftools_stderr, "pos=%d type=%d read=%d:%d name=%s qbeg=%d tbeg=%d score=%d\n", pos, types[t], s, i, bam_get_qname(p->b), qbeg, tbeg, sc);
#endif
}
}
......@@ -424,7 +424,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
if (seqQ > 255) seqQ = 255;
p->aux = (sc[0]&0x3f)<<16 | seqQ<<8 | indelQ; // use 22 bits in total
sumq[sc[0]&0x3f] += indelQ < seqQ? indelQ : seqQ;
// fprintf(pysam_stderr, "pos=%d read=%d:%d name=%s call=%d indelQ=%d seqQ=%d\n", pos, s, i, bam1_qname(p->b), types[sc[0]&0x3f], indelQ, seqQ);
// fprintf(bcftools_stderr, "pos=%d read=%d:%d name=%s call=%d indelQ=%d seqQ=%d\n", pos, s, i, bam1_qname(p->b), types[sc[0]&0x3f], indelQ, seqQ);
}
}
// determine bca->indel_types[] and bca->inscns
......@@ -456,7 +456,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
if (x == bca->indel_types[j]) break;
p->aux = j<<16 | (j == 4? 0 : (p->aux&0xffff));
if ((p->aux>>16&0x3f) > 0) ++n_alt;
//fprintf(pysam_stderr, "X pos=%d read=%d:%d name=%s call=%d type=%d seqQ=%d indelQ=%d\n", pos, s, i, bam_get_qname(p->b), (p->aux>>16)&0x3f, bca->indel_types[(p->aux>>16)&0x3f], (p->aux>>8)&0xff, p->aux&0xff);
//fprintf(bcftools_stderr, "X pos=%d read=%d:%d name=%s call=%d type=%d seqQ=%d indelQ=%d\n", pos, s, i, bam_get_qname(p->b), (p->aux>>16)&0x3f, bca->indel_types[(p->aux>>16)&0x3f], (p->aux>>8)&0xff, p->aux&0xff);
}
}
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* bam_sample.c -- group data by sample.
......
#include <ctype.h>
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bcftools.pysam.h"
FILE * bcftools_stderr = NULL;
FILE * bcftools_stdout = NULL;
const char * bcftools_stdout_fn = NULL;
int bcftools_stdout_fileno = STDOUT_FILENO;
FILE * bcftools_set_stderr(int fd)
{
if (bcftools_stderr != NULL)
fclose(bcftools_stderr);
bcftools_stderr = fdopen(fd, "w");
return bcftools_stderr;
}
void bcftools_unset_stderr(void)
{
if (bcftools_stderr != NULL)
fclose(bcftools_stderr);
bcftools_stderr = fopen("/dev/null", "w");
}
FILE * bcftools_set_stdout(int fd)
{
if (bcftools_stdout != NULL)
fclose(bcftools_stdout);
bcftools_stdout = fdopen(fd, "w");
if (bcftools_stdout == NULL)
{
fprintf(bcftools_stderr, "could not set stdout to fd %i", fd);
}
bcftools_stdout_fileno = fd;
return bcftools_stdout;
}
void bcftools_set_stdout_fn(const char *fn)
{
bcftools_stdout_fn = fn;
}
void bcftools_unset_stdout(void)
{
if (bcftools_stdout != NULL)
fclose(bcftools_stdout);
bcftools_stdout = fopen("/dev/null", "w");
bcftools_stdout_fileno = STDOUT_FILENO;
}
void bcftools_set_optind(int val)
{
// setting this in cython via
// "from posix.unistd cimport optind"
// did not work.
//
// setting to 0 forces a complete re-initialization
optind = val;
}
#ifndef BCFTOOLS_PYSAM_H
#define BCFTOOLS_PYSAM_H
#include "stdio.h"
extern FILE * bcftools_stderr;
extern FILE * bcftools_stdout;
extern const char * bcftools_stdout_fn;
/*! set pysam standard error to point to file descriptor
Setting the stderr will close the previous stderr.
*/
FILE * bcftools_set_stderr(int fd);
/*! set pysam standard output to point to file descriptor
Setting the stderr will close the previous stdout.
*/
FILE * bcftools_set_stdout(int fd);
/*! set pysam standard output to point to filename
*/
void bcftools_set_stdout_fn(const char * fn);
/*! set pysam standard error to /dev/null.
Unsetting the stderr will close the previous stderr.
*/
void bcftools_unset_stderr(void);
/*! set pysam standard error to /dev/null.
Unsetting the stderr will close the previous stderr.
*/
void bcftools_unset_stdout(void);
int bcftools_dispatch(int argc, char *argv[]);
void bcftools_set_optind(int);
extern int bcftools_main(int argc, char *argv[]);
#endif
#include "pysam.h"
#include "bcftools.pysam.h"
/* The MIT License
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* ccall.c -- consensus variant calling.
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* The MIT License
......@@ -103,7 +103,7 @@ args_t;
static chain_t* init_chain(chain_t *chain, int ref_ori_pos)
{
// fprintf(pysam_stderr, "init_chain(*chain, ref_ori_pos=%d)\n", ref_ori_pos);
// fprintf(bcftools_stderr, "init_chain(*chain, ref_ori_pos=%d)\n", ref_ori_pos);
chain = (chain_t*) calloc(1,sizeof(chain_t));
chain->num = 0;
chain->block_lengths = NULL;
......@@ -173,7 +173,7 @@ static void print_chain(args_t *args)
static void push_chain_gap(chain_t *chain, int ref_start, int ref_len, int alt_start, int alt_len)
{
// fprintf(pysam_stderr, "push_chain_gap(*chain, ref_start=%d, ref_len=%d, alt_start=%d, alt_len=%d)\n", ref_start, ref_len, alt_start, alt_len);
// fprintf(bcftools_stderr, "push_chain_gap(*chain, ref_start=%d, ref_len=%d, alt_start=%d, alt_len=%d)\n", ref_start, ref_len, alt_start, alt_len);
int num = chain->num;
if (ref_start <= chain->ref_last_block_ori) {
......@@ -235,8 +235,8 @@ static void init_data(args_t *args)
args->fp_out = fopen(args->output_fname,"w");
if ( ! args->fp_out ) error("Failed to create %s: %s\n", args->output_fname, strerror(errno));
}
else args->fp_out = pysam_stdout;
if ( args->isample<0 ) fprintf(pysam_stderr,"Note: the --sample option not given, applying all records\n");
else args->fp_out = bcftools_stdout;
if ( args->isample<0 ) fprintf(bcftools_stderr,"Note: the --sample option not given, applying all records\n");
if ( args->filter_str )
args->filter = filter_init(args->hdr, args->filter_str);
}
......@@ -279,7 +279,7 @@ static void init_region(args_t *args, char *line)
}
}
args->rid = bcf_hdr_name2id(args->hdr,line);
if ( args->rid<0 ) fprintf(pysam_stderr,"Warning: Sequence \"%s\" not in %s\n", line,args->fname);
if ( args->rid<0 ) fprintf(bcftools_stderr,"Warning: Sequence \"%s\" not in %s\n", line,args->fname);
args->fa_buf.l = 0;
args->fa_length = 0;
args->fa_end_pos = to;
......@@ -371,7 +371,7 @@ static void apply_variant(args_t *args, bcf1_t *rec)
if ( rec->pos <= args->fa_frz_pos )
{
fprintf(pysam_stderr,"The site %s:%d overlaps with another variant, skipping...\n", bcf_seqname(args->hdr,rec),rec->pos+1);
fprintf(bcftools_stderr,"The site %s:%d overlaps with another variant, skipping...\n", bcf_seqname(args->hdr,rec),rec->pos+1);
return;
}
if ( args->mask )
......@@ -474,7 +474,7 @@ static void apply_variant(args_t *args, bcf1_t *rec)
int idx = rec->pos - args->fa_ori_pos + args->fa_mod_off;
if ( idx<0 )
{
fprintf(pysam_stderr,"Warning: ignoring overlapping variant starting at %s:%d\n", bcf_seqname(args->hdr,rec),rec->pos+1);
fprintf(bcftools_stderr,"Warning: ignoring overlapping variant starting at %s:%d\n", bcf_seqname(args->hdr,rec),rec->pos+1);
return;
}
if ( rec->rlen > args->fa_buf.l - idx )
......@@ -484,7 +484,7 @@ static void apply_variant(args_t *args, bcf1_t *rec)
if ( alen > rec->rlen )
{
rec->d.allele[ialt][rec->rlen] = 0;
fprintf(pysam_stderr,"Warning: trimming variant starting at %s:%d\n", bcf_seqname(args->hdr,rec),rec->pos+1);
fprintf(bcftools_stderr,"Warning: trimming variant starting at %s:%d\n", bcf_seqname(args->hdr,rec),rec->pos+1);
}
}
if ( idx>=args->fa_buf.l )
......@@ -502,7 +502,7 @@ static void apply_variant(args_t *args, bcf1_t *rec)
}
else if ( strncasecmp(rec->d.allele[0],args->fa_buf.s+idx,rec->rlen) )
{
// fprintf(pysam_stderr,"%d .. [%s], idx=%d ori=%d off=%d\n",args->fa_ori_pos,args->fa_buf.s,idx,args->fa_ori_pos,args->fa_mod_off);
// fprintf(bcftools_stderr,"%d .. [%s], idx=%d ori=%d off=%d\n",args->fa_ori_pos,args->fa_buf.s,idx,args->fa_ori_pos,args->fa_mod_off);
char tmp = 0;
if ( args->fa_buf.l - idx > rec->rlen )
{
......@@ -672,35 +672,35 @@ static void consensus(args_t *args)
static void usage(args_t *args)
{
fprintf(pysam_stderr, "\n");
fprintf(pysam_stderr, "About: Create consensus sequence by applying VCF variants to a reference fasta\n");
fprintf(pysam_stderr, " file. By default, the program will apply all ALT variants. Using the\n");
fprintf(pysam_stderr, " --sample (and, optionally, --haplotype) option will apply genotype\n");
fprintf(pysam_stderr, " (or haplotype) calls from FORMAT/GT. The program ignores allelic depth\n");
fprintf(pysam_stderr, " information, such as INFO/AD or FORMAT/AD.\n");
fprintf(pysam_stderr, "Usage: bcftools consensus [OPTIONS] <file.vcf>\n");
fprintf(pysam_stderr, "Options:\n");
fprintf(pysam_stderr, " -c, --chain <file> write a chain file for liftover\n");
fprintf(pysam_stderr, " -e, --exclude <expr> exclude sites for which the expression is true (see man page for details)\n");
fprintf(pysam_stderr, " -f, --fasta-ref <file> reference sequence in fasta format\n");
fprintf(pysam_stderr, " -H, --haplotype <which> choose which allele to use from the FORMAT/GT field, note\n");
fprintf(pysam_stderr, " the codes are case-insensitive:\n");
fprintf(pysam_stderr, " 1: first allele from GT\n");
fprintf(pysam_stderr, " 2: second allele\n");
fprintf(pysam_stderr, " R: REF allele in het genotypes\n");
fprintf(pysam_stderr, " A: ALT allele\n");
fprintf(pysam_stderr, " LR,LA: longer allele and REF/ALT if equal length\n");
fprintf(pysam_stderr, " SR,SA: shorter allele and REF/ALT if equal length\n");
fprintf(pysam_stderr, " -i, --include <expr> select sites for which the expression is true (see man page for details)\n");
fprintf(pysam_stderr, " -I, --iupac-codes output variants in the form of IUPAC ambiguity codes\n");
fprintf(pysam_stderr, " -m, --mask <file> replace regions with N\n");
fprintf(pysam_stderr, " -o, --output <file> write output to a file [standard output]\n");
fprintf(pysam_stderr, " -s, --sample <name> apply variants of the given sample\n");
fprintf(pysam_stderr, "Examples:\n");
fprintf(pysam_stderr, " # Get the consensus for one region. The fasta header lines are then expected\n");
fprintf(pysam_stderr, " # in the form \">chr:from-to\".\n");
fprintf(pysam_stderr, " samtools faidx ref.fa 8:11870-11890 | bcftools consensus in.vcf.gz > out.fa\n");
fprintf(pysam_stderr, "\n");
fprintf(bcftools_stderr, "\n");
fprintf(bcftools_stderr, "About: Create consensus sequence by applying VCF variants to a reference fasta\n");
fprintf(bcftools_stderr, " file. By default, the program will apply all ALT variants. Using the\n");
fprintf(bcftools_stderr, " --sample (and, optionally, --haplotype) option will apply genotype\n");
fprintf(bcftools_stderr, " (or haplotype) calls from FORMAT/GT. The program ignores allelic depth\n");
fprintf(bcftools_stderr, " information, such as INFO/AD or FORMAT/AD.\n");
fprintf(bcftools_stderr, "Usage: bcftools consensus [OPTIONS] <file.vcf>\n");
fprintf(bcftools_stderr, "Options:\n");
fprintf(bcftools_stderr, " -c, --chain <file> write a chain file for liftover\n");
fprintf(bcftools_stderr, " -e, --exclude <expr> exclude sites for which the expression is true (see man page for details)\n");
fprintf(bcftools_stderr, " -f, --fasta-ref <file> reference sequence in fasta format\n");
fprintf(bcftools_stderr, " -H, --haplotype <which> choose which allele to use from the FORMAT/GT field, note\n");
fprintf(bcftools_stderr, " the codes are case-insensitive:\n");
fprintf(bcftools_stderr, " 1: first allele from GT\n");
fprintf(bcftools_stderr, " 2: second allele\n");
fprintf(bcftools_stderr, " R: REF allele in het genotypes\n");
fprintf(bcftools_stderr, " A: ALT allele\n");
fprintf(bcftools_stderr, " LR,LA: longer allele and REF/ALT if equal length\n");
fprintf(bcftools_stderr, " SR,SA: shorter allele and REF/ALT if equal length\n");
fprintf(bcftools_stderr, " -i, --include <expr> select sites for which the expression is true (see man page for details)\n");
fprintf(bcftools_stderr, " -I, --iupac-codes output variants in the form of IUPAC ambiguity codes\n");
fprintf(bcftools_stderr, " -m, --mask <file> replace regions with N\n");
fprintf(bcftools_stderr, " -o, --output <file> write output to a file [standard output]\n");
fprintf(bcftools_stderr, " -s, --sample <name> apply variants of the given sample\n");
fprintf(bcftools_stderr, "Examples:\n");
fprintf(bcftools_stderr, " # Get the consensus for one region. The fasta header lines are then expected\n");
fprintf(bcftools_stderr, " # in the form \">chr:from-to\".\n");
fprintf(bcftools_stderr, " samtools faidx ref.fa 8:11870-11890 | bcftools consensus in.vcf.gz > out.fa\n");
fprintf(bcftools_stderr, "\n");
exit(1);
}
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* convert.c -- functions for converting between VCF/BCF and related formats.
......@@ -213,7 +213,7 @@ static void process_info(convert_t *convert, bcf1_t *line, fmt_t *fmt, int isamp
case BCF_BT_INT32: if ( info->v1.i==bcf_int32_missing ) kputc('.', str); else kputw(info->v1.i, str); break;
case BCF_BT_FLOAT: if ( bcf_float_is_missing(info->v1.f) ) kputc('.', str); else kputd(info->v1.f, str); break;
case BCF_BT_CHAR: kputc(info->v1.i, str); break;
default: fprintf(pysam_stderr,"todo: type %d\n", info->type); exit(1); break;
default: fprintf(bcftools_stderr,"todo: type %d\n", info->type); exit(1); break;
}
}
else if ( fmt->subscript >=0 )
......@@ -234,7 +234,7 @@ static void process_info(convert_t *convert, bcf1_t *line, fmt_t *fmt, int isamp
case BCF_BT_INT16: BRANCH(int16_t, val==bcf_int16_missing, val==bcf_int16_vector_end, kputw(val, str)); break;
case BCF_BT_INT32: BRANCH(int32_t, val==bcf_int32_missing, val==bcf_int32_vector_end, kputw(val, str)); break;
case BCF_BT_FLOAT: BRANCH(float, bcf_float_is_missing(val), bcf_float_is_vector_end(val), kputd(val, str)); break;
default: fprintf(pysam_stderr,"todo: type %d\n", info->type); exit(1); break;
default: fprintf(bcftools_stderr,"todo: type %d\n", info->type); exit(1); break;
}
#undef BRANCH
}
......@@ -1015,7 +1015,7 @@ static fmt_t *register_tag(convert_t *convert, int type, char *key, int is_gtf)
else if ( id>=0 && bcf_hdr_idinfo_exists(convert->header,BCF_HL_INFO,id) )
{
fmt->type = T_INFO;
fprintf(pysam_stderr,"Warning: Assuming INFO/%s\n", key);
fprintf(bcftools_stderr,"Warning: Assuming INFO/%s\n", key);
}
}
}
......@@ -1199,7 +1199,7 @@ convert_t *convert_init(bcf_hdr_t *hdr, int *samples, int nsamples, const char *
char *p = convert->format_str;
while ( *p )
{
//fprintf(pysam_stderr,"<%s>\n", p);
//fprintf(bcftools_stderr,"<%s>\n", p);
switch (*p)
{
case '[': is_gtf = 1; p++; break;
......
This diff is collapsed.
#include "pysam.h"
#include "bcftools.pysam.h"
/* em.c -- mathematical functions.
......@@ -74,7 +74,7 @@ static double prob1(double f, void *data)
minaux1_t *a = (minaux1_t*)data;
double p = 1., l = 0., f3[3];
int i;
// fprintf(pysam_stdout, "brent %lg\n", f);
// fprintf(bcftools_stdout, "brent %lg\n", f);
if (f < 0 || f > 1) return 1e300;
f3[0] = (1.-f)*(1.-f); f3[1] = 2.*f*(1.-f); f3[2] = f*f;
for (i = a->beg; i < a->end; ++i) {
......@@ -90,7 +90,7 @@ static double freq_iter(double *f, const double *_pdg, int beg, int end)
{
double f0 = *f, f3[3], err;
int i;
// fprintf(pysam_stdout, "em %lg\n", *f);
// fprintf(bcftools_stdout, "em %lg\n", *f);
f3[0] = (1.-f0)*(1.-f0); f3[1] = 2.*f0*(1.-f0); f3[2] = f0*f0;
for (i = beg, f0 = 0.; i < end; ++i) {
const double *pdg = _pdg + i * 3;
......@@ -128,7 +128,7 @@ static double g3_iter(double g[3], const double *_pdg, int beg, int end)
double err, gg[3];
int i;
gg[0] = gg[1] = gg[2] = 0.;
// fprintf(pysam_stdout, "%lg,%lg,%lg\n", g[0], g[1], g[2]);
// fprintf(bcftools_stdout, "%lg,%lg,%lg\n", g[0], g[1], g[2]);
for (i = beg; i < end; ++i) {
double sum, tmp[3];
const double *pdg = _pdg + i * 3;
......@@ -237,7 +237,7 @@ static int pair_freq_iter(int n, double *pdg[2], double f[4])
{
double ff[4];
int i, k, h;
// fprintf(pysam_stdout, "%lf,%lf,%lf,%lf\n", f[0], f[1], f[2], f[3]);
// fprintf(bcftools_stdout, "%lf,%lf,%lf,%lf\n", f[0], f[1], f[2], f[3]);
memset(ff, 0, 4 * sizeof(double));
for (i = 0; i < n; ++i) {
double *p[2], sum, tmp;
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* filter.c -- filter expressions.
......@@ -403,7 +403,7 @@ static int bcf_get_info_value(bcf1_t *line, int info_id, int ivec, void *value)
case BCF_BT_INT16: BRANCH(int16_t, p[j]==bcf_int16_missing, p[j]==bcf_int16_vector_end, int64_t); break;
case BCF_BT_INT32: BRANCH(int32_t, p[j]==bcf_int32_missing, p[j]==bcf_int32_vector_end, int64_t); break;
case BCF_BT_FLOAT: BRANCH(float, bcf_float_is_missing(p[j]), bcf_float_is_vector_end(p[j]), double); break;
default: fprintf(pysam_stderr,"todo: type %d\n", info->type); exit(1); break;
default: fprintf(bcftools_stderr,"todo: type %d\n", info->type); exit(1); break;
}
#undef BRANCH
return -1; // this shouldn't happen
......@@ -1320,7 +1320,7 @@ static int vector_logic_or(token_t *atok, token_t *btok, int or_type)
{ \
if ( (atok)->values[0] CMP_OP (btok)->values[0] ) { pass_site = 1; } \
} \
/*fprintf(pysam_stderr,"pass=%d\n", pass_site);*/ \
/*fprintf(bcftools_stderr,"pass=%d\n", pass_site);*/ \
(ret) = pass_site; \
} \
}
......@@ -1757,16 +1757,16 @@ static void filter_debug_print(token_t *toks, token_t **tok_ptrs, int ntoks)
if ( tok->tok_type==TOK_VAL )
{
if ( tok->key )
fprintf(pysam_stderr,"%s", tok->key);
fprintf(bcftools_stderr,"%s", tok->key);
else if ( tok->tag )
fprintf(pysam_stderr,"%s", tok->tag);
fprintf(bcftools_stderr,"%s", tok->tag);
else
fprintf(pysam_stderr,"%e", tok->threshold);
fprintf(bcftools_stderr,"%e", tok->threshold);
}
else
fprintf(pysam_stderr,"%c", TOKEN_STRING[tok->tok_type]);
if ( tok->setter ) fprintf(pysam_stderr,"\t[setter %p]", tok->setter);
fprintf(pysam_stderr,"\n");
fprintf(bcftools_stderr,"%c", TOKEN_STRING[tok->tok_type]);
if ( tok->setter ) fprintf(bcftools_stderr,"\t[setter %p]", tok->setter);
fprintf(bcftools_stderr,"\n");
}
}
......@@ -1795,8 +1795,8 @@ filter_t *filter_init(bcf_hdr_t *hdr, const char *str)
ret = filters_next_token(&tmp, &len);
if ( ret==-1 ) error("Missing quotes in: %s\n", str);
// fprintf(pysam_stderr,"token=[%c] .. [%s] %d\n", TOKEN_STRING[ret], tmp, len);
// int i; for (i=0; i<nops; i++) fprintf(pysam_stderr," .%c.", TOKEN_STRING[ops[i]]); fprintf(pysam_stderr,"\n");
// fprintf(bcftools_stderr,"token=[%c] .. [%s] %d\n", TOKEN_STRING[ret], tmp, len);
// int i; for (i=0; i<nops; i++) fprintf(bcftools_stderr," .%c.", TOKEN_STRING[ops[i]]); fprintf(bcftools_stderr,"\n");
if ( ret==TOK_LFT ) // left bracket
{
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* gvcf.c -- support for gVCF files.
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* The MIT License
......@@ -89,7 +89,7 @@ void remove_node(hclust_t *clust, node_t *node)
void hclust_debug(hclust_t *clust)
{
int i;
fprintf(pysam_stderr,"nrmme=%d nclust=%d\n", clust->nrmme,clust->nclust);
fprintf(bcftools_stderr,"nrmme=%d nclust=%d\n", clust->nrmme,clust->nclust);
for (i=0; i<clust->nrmme; i++)
{
node_t *node = clust->rmme[i];
......@@ -97,7 +97,7 @@ void hclust_debug(hclust_t *clust)
int bkid = node->bkid ? node->bkid->id : -1;
int akidx = node->akid ? node->akid->idx : -1;
int bkidx = node->bkid ? node->bkid->idx : -1;
fprintf(pysam_stderr,"\t%d\t%d\t%f\t%d %d\t%d %d\n",node->id,node->idx,node->value,akid,bkid,akidx,bkidx);
fprintf(bcftools_stderr,"\t%d\t%d\t%f\t%d %d\t%d %d\n",node->id,node->idx,node->value,akid,bkid,akidx,bkidx);
}
int j;
......@@ -110,17 +110,17 @@ void hclust_debug(hclust_t *clust)
if ( node->idx==i ) { active=1; break; }
node = node->next;
}
fprintf(pysam_stderr,"%2d%c ",i,active?'*':' ');
fprintf(bcftools_stderr,"%2d%c ",i,active?'*':' ');
for (j=0; j<i; j++)
{
if ( PDIST(clust->pdist,i,j)==9 )
fprintf(pysam_stderr," ----- ");
fprintf(bcftools_stderr," ----- ");
else
fprintf(pysam_stderr," %f", PDIST(clust->pdist,i,j));
fprintf(bcftools_stderr," %f", PDIST(clust->pdist,i,j));
}
fprintf(pysam_stderr,"\n");
fprintf(bcftools_stderr,"\n");
}
for (j=0; j<clust->ndat-1; j++) fprintf(pysam_stderr," %6d ",j); fprintf(pysam_stderr,"\n");
for (j=0; j<clust->ndat-1; j++) fprintf(bcftools_stderr," %6d ",j); fprintf(bcftools_stderr,"\n");
}
#endif
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* The MIT License
......
#include "pysam.h"
#include "bcftools.pysam.h"
/* main.c -- main bcftools command front-end.
......@@ -49,7 +49,7 @@ int main_vcfcall(int argc, char *argv[]);
int main_vcfannotate(int argc, char *argv[]);
int main_vcfroh(int argc, char *argv[]);
int main_vcfconcat(int argc, char *argv[]);
int main_reheader(int argc, char *argv[]);
int main_bcftools_reheader(int argc, char *argv[]);
int main_vcfconvert(int argc, char *argv[]);
int main_vcfcnv(int argc, char *argv[]);
#if USE_GPL
......@@ -125,7 +125,7 @@ static cmd_t cmds[] =
.alias = "query",
.help = "transform VCF/BCF into user-defined formats"
},
{ .func = main_reheader,
{ .func = main_bcftools_reheader,
.alias = "reheader",
.help = "modify VCF/BCF header, change sample names"
},
......@@ -239,24 +239,24 @@ static void usage(FILE *fp)
int bcftools_main(int argc, char *argv[])
{
if (argc < 2) { usage(pysam_stderr); return 1; }
if (argc < 2) { usage(bcftools_stderr); return 1; }
if (strcmp(argv[1], "version") == 0 || strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0) {
fprintf(pysam_stdout, "bcftools %s\nUsing htslib %s\nCopyright (C) 2016 Genome Research Ltd.\n", bcftools_version(), hts_version());
fprintf(bcftools_stdout, "bcftools %s\nUsing htslib %s\nCopyright (C) 2016 Genome Research Ltd.\n", bcftools_version(), hts_version());
#if USE_GPL
fprintf(pysam_stdout, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
fprintf(bcftools_stdout, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
#else
fprintf(pysam_stdout, "License Expat: The MIT/Expat license\n");
fprintf(bcftools_stdout, "License Expat: The MIT/Expat license\n");
#endif
fprintf(pysam_stdout, "This is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n");
fprintf(bcftools_stdout, "This is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n");
return 0;
}
else if (strcmp(argv[1], "--version-only") == 0) {
fprintf(pysam_stdout, "%s+htslib-%s\n", bcftools_version(), hts_version());
fprintf(bcftools_stdout, "%s+htslib-%s\n", bcftools_version(), hts_version());
return 0;
}
else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) {
if (argc == 2) { usage(pysam_stdout); return 0; }
if (argc == 2) { usage(bcftools_stdout); return 0; }
// Otherwise change "bcftools help COMMAND [...]" to "bcftools COMMAND";
// main_xyz() functions by convention display the subcommand's usage
// when invoked without any arguments.
......@@ -281,7 +281,7 @@ int bcftools_main(int argc, char *argv[])
}
i++;
}
fprintf(pysam_stderr, "[E::%s] unrecognized command '%s'\n", __func__, argv[1]);
fprintf(bcftools_stderr, "[E::%s] unrecognized command '%s'\n", __func__, argv[1]);
return 1;
}