Skip to content

Commit

Permalink
Miscellaneous minor build infrastructure and code fixes (PR #1807)
Browse files Browse the repository at this point in the history
* Ignore and clean test/*/FAIL* for six subdirectories

These files can appear in base_mods, fastq, mpileup, and sam_filter
as well as faidx and tabix.

* Fix comment header to use `@CO\t` as per other comment headers

* Remove extraneous inclusion and add missing dependency

* Remove last traces of previously deleted bgzf_idx_amend_last()

As noted in #1722, this function was removed in PR #1672.

* Use isspace_c() et al in annot-tsv.c

* Minor corrections to system headers

Plain getopt() is declared in <unistd.h>; strcasecmp() et al are only
portably declared in <strings.h>.
  • Loading branch information
jmarshall authored Jul 17, 2024
1 parent 19a27e9 commit db2b449
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 25 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ shlib-exports-*.txt
/bgzip
/htsfile
/tabix
/test/*/FAIL*
/test/bgzf_boundaries/*.tmp.*
/test/faidx/*.tmp*
/test/faidx/FAIL*
/test/fieldarith
/test/hfile
/test/hts_endian
Expand All @@ -57,7 +57,6 @@ shlib-exports-*.txt
/test/plugins-dlhts
/test/sam
/test/tabix/*.tmp.*
/test/tabix/FAIL*
/test/test-bcf-sr
/test/test-bcf-translate
/test/test-bcf_set_variant_type
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,10 @@ htsfile: htsfile.o libhts.a
tabix: tabix.o libhts.a
$(CC) $(LDFLAGS) -o $@ tabix.o libhts.a $(LIBS) -lpthread

annot-tsv.o: annot-tsv.c config.h $(htslib_hts_h) $(htslib_hts_defs_h) $(htslib_khash_str2int_h) $(htslib_kstring_h) $(htslib_kseq_h) $(htslib_bgzf_h) $(htslib_regidx_h)
annot-tsv.o: annot-tsv.c config.h $(htslib_hts_h) $(htslib_hts_defs_h) $(htslib_khash_str2int_h) $(htslib_kstring_h) $(htslib_kseq_h) $(htslib_bgzf_h) $(htslib_regidx_h) $(textutils_internal_h)
bgzip.o: bgzip.c config.h $(htslib_bgzf_h) $(htslib_hts_h) $(htslib_hfile_h)
htsfile.o: htsfile.c config.h $(htslib_hfile_h) $(htslib_hts_h) $(htslib_sam_h) $(htslib_vcf_h)
tabix.o: tabix.c config.h $(htslib_tbx_h) $(htslib_sam_h) $(htslib_vcf_h) $(htslib_kseq_h) $(htslib_bgzf_h) $(htslib_hts_h) $(htslib_regidx_h) $(htslib_hts_defs_h) $(htslib_hts_log_h)
tabix.o: tabix.c config.h $(htslib_tbx_h) $(htslib_sam_h) $(htslib_vcf_h) $(htslib_kseq_h) $(htslib_bgzf_h) $(htslib_hts_h) $(htslib_regidx_h) $(htslib_hts_defs_h) $(htslib_hts_log_h) $(htslib_thread_pool_h)

# Runes to check that the htscodecs submodule is present
ifdef HTSCODECS_SOURCES
Expand Down Expand Up @@ -924,9 +924,9 @@ htslib-uninstalled.pc: htslib.pc.tmp


testclean:
-rm -f test/*.tmp test/*.tmp.* test/faidx/*.tmp* test/faidx/FAIL* \
test/longrefs/*.tmp.* test/tabix/*.tmp.* test/tabix/FAIL* \
test/bgzf_boundaries/*.tmp.* \
-rm -f test/*.tmp test/*.tmp.* test/faidx/*.tmp* \
test/longrefs/*.tmp.* test/tabix/*.tmp.* \
test/bgzf_boundaries/*.tmp.* test/*/FAIL* \
header-exports.txt shlib-exports-$(SHLIB_FLAVOUR).txt
-rm -rf htscodecs/tests/test.out

Expand Down
7 changes: 4 additions & 3 deletions annot-tsv.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "htslib/kseq.h"
#include "htslib/bgzf.h"
#include "htslib/regidx.h"
#include "textutils_internal.h"

#define ANN_NBP 1
#define ANN_FRAC 2
Expand Down Expand Up @@ -409,15 +410,15 @@ void parse_header(dat_t *dat, char *fname, int nth_row, int autodetect)
for (i=0; i<cols->n; i++)
{
char *ss = cols->off[i];
while ( *ss && (*ss=='#' || isspace(*ss)) ) ss++;
while ( *ss && (*ss=='#' || isspace_c(*ss)) ) ss++;
if ( !*ss ) error("Could not parse the header field \"%s\": %s\n", cols->off[i],dat->line.s);
if ( *ss=='[' )
{
char *se = ss+1;
while ( *se && isdigit(*se) ) se++;
while ( *se && isdigit_c(*se) ) se++;
if ( *se==']' ) ss = se + 1;
}
while ( *ss && (*ss=='#' || isspace(*ss)) ) ss++;
while ( *ss && (*ss=='#' || isspace_c(*ss)) ) ss++;
if ( !*ss ) error("Could not parse the header field \"%s\": %s\n", cols->off[i],dat->line.s);
cols->off[i] = ss;
khash_str2int_set(dat->hdr.name2idx, cols->off[i], i);
Expand Down
1 change: 0 additions & 1 deletion cram/cram_external.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif

#include "../htslib/hfile.h"
#include "../hfile_internal.h"
#include "cram.h"

/*
Expand Down
12 changes: 0 additions & 12 deletions hts_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,6 @@ const char *hts_plugin_path(void);
*/
int bgzf_idx_push(BGZF *fp, hts_idx_t *hidx, int tid, hts_pos_t beg, hts_pos_t end, uint64_t offset, int is_mapped);

/*
* bgzf analogue to hts_idx_amend_last.
*
* This is needed when multi-threading and writing indices on the fly.
* At the point of writing a record we know the virtual offset for start
* and end, but that end virtual offset may be the end of the current
* block. In standard indexing our end virtual offset becomes the start
* of the next block. Thus to ensure bit for bit compatibility we
* detect this boundary case and fix it up here.
*/
void bgzf_idx_amend_last(BGZF *fp, hts_idx_t *hidx, uint64_t offset);

static inline int find_file_extension(const char *fn, char ext_out[static HTS_MAX_EXT_LEN])
{
const char *delim = fn ? strstr(fn, HTS_IDX_DELIM) : NULL, *ext;
Expand Down
1 change: 1 addition & 0 deletions samples/mod_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DEALINGS IN THE SOFTWARE
/* The pupose of this code is to demonstrate the library apis and need proper error handling and optimization */

#include <getopt.h>
#include <strings.h>
#include <unistd.h>
#include <htslib/sam.h>

Expand Down
1 change: 1 addition & 0 deletions samples/mod_bam.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DEALINGS IN THE SOFTWARE
/* The pupose of this code is to demonstrate the library apis and need proper error handling and optimization */

#include <getopt.h>
#include <strings.h>
#include <unistd.h>
#include <htslib/sam.h>

Expand Down
2 changes: 1 addition & 1 deletion test/base_mods/MM-explicit.sam
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@CO ATCATCATTCCTACCGCTATAGCCT r3; mixture
@CO - - . -. - --
@CO M M
@CO - - ?? ?? ? --
@CO - - ?? ?? ? --
@CO hH hh h --
@CO
r1 0 * 0 0 * * 0 0 ATCATCATTCCTACCGCTATAGCCT * Mm:Z:C+mh,2,0,1; Ml:B:C,200,10,50,170,160,20
Expand Down
2 changes: 1 addition & 1 deletion test/test_faidx.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DEALINGS IN THE SOFTWARE. */

#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>

#include "../htslib/faidx.h"

Expand Down

0 comments on commit db2b449

Please sign in to comment.