Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# Build artifacts
*.o
prodigal
prodigal.exe
prodigal-table
prodigal-table.exe

# Release binary names
prodigal.linux
prodigal.osx*
prodigal.windows.exe

# A playground directory
test/


24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,49 @@ CFLAGS += -pedantic -Wall -O3 -DSUPPORT_GZIP_COMPRESSED
LFLAGS = -lm $(LDFLAGS) -lz

TARGET = prodigal
TABLEUTIL = prodigal-table
ZTARGET = zprodigal
SOURCES = $(shell echo *.c)
HEADERS = $(shell echo *.h)
HEADERS = $(shell echo *.h) table-data.hh
OBJECTS = $(SOURCES:.c=.o)
ZOBJECTS = $(SOURCES:.c=.oz)

INSTALLDIR = /usr/local/bin

all: $(TARGET)
all: $(TARGET) $(TABLEUTIL)

$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS)

table-data.hh table-data.cc: gc.prt
./maketable.sh < gc.prt

table.o: table.c $(HEADERS) table-data.cc
$(CC) $(CFLAGS) -c -o $@ $<

# Too big to recompile on every header change
training.o: training.c training.h table.h
$(CC) $(CFLAGS) -c -o $@ $<

%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<

install: $(TARGET)
$(TABLEUTIL): table.c table.h
$(CC) $(CFLAGS) -DTABLE_UTIL -Wno-parentheses -o $@ $< $(LFLAGS)

install: $(TARGET) $(TABLEUTIL)
install -d -m 0755 $(INSTALLDIR)
install -m 0755 $(TARGET) $(INSTALLDIR)
install -m 0755 $(TABLEUTIL) $(INSTALLDIR)

uninstall:
-rm $(INSTALLDIR)/$(TARGET)
-rm $(INSTALLDIR)/$(TABLEUTIL)

clean:
-rm -f $(OBJECTS) $(ZOBJECTS)

distclean: clean
-rm -f $(TARGET)
-rm -f $(TARGET) $(TABLEUTIL)

.PHONY: all install uninstall clean distclean
41 changes: 0 additions & 41 deletions bitmap.c

This file was deleted.

50 changes: 46 additions & 4 deletions bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,52 @@

#ifndef BITMAP_H_
#define BITMAP_H_
#include <stddef.h>

unsigned char test(unsigned char *, int);
void clear(unsigned char *, int);
void set(unsigned char *, int);
void toggle(unsigned char *, int);
/* Test a bit, 0 = not set, 1 = set */
static inline unsigned char test(unsigned char *bm, size_t ndx) {
return ( bm[ndx>>3] & (1 << (ndx&0x07))?1:0 );
}

/* Clear a bit (set it to 0) */
static inline void clear(unsigned char *bm, size_t ndx) {
bm[ndx>>3] &= ~(1 << (ndx&0x07));
}

/* Set a bit to 1 */
static inline void set(unsigned char *bm, size_t ndx) {
bm[ndx>>3] |= (1 << (ndx&0x07));
}

/* Flip a bit's value 0->1 or 1->0 */
static inline void toggle(unsigned char *bm, size_t ndx) {
bm[ndx>>3] ^= (1 << (ndx&0x07));
}

/* Get two bits */
static inline unsigned char nuc(unsigned char *bm, size_t ndx) {
ndx *= 2;
return ((bm[ndx >> 3] >> (ndx & 0x07)) & 0x03);
}

/* Get six bits, which can be in two bytes
out-of-bound read may happen but will not affect result */
static inline unsigned char trinuc(unsigned char *bm, size_t ndx) {
ndx *= 2;
unsigned byte = ndx >> 3;
unsigned stretch = (bm[byte + 1] << 8) | bm[byte];
return ((stretch >> (ndx & 0x07)) & 0x3F);
}

/* Get twelve bits, which can be in four bytes
mer_ndx(6) is relatively common and should be replaced with this
(shorter assembly). unfortunately the order is different, which
breaks tinf->gene_dc compatibility! */
static inline unsigned char hexnuc(unsigned char *bm, int ndx) {
ndx *= 2;
unsigned byte = ndx >> 3;
unsigned stretch = (bm[byte + 3] << 24) | (bm[byte + 2] << 16) |
(bm[byte + 1] << 8) | bm[byte];
return ((stretch >> (ndx & 0x07)) & 0x3F);
}
#endif
68 changes: 68 additions & 0 deletions compare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
# compare.sh: compare two versions of prodigal
# ./compare.sh <old_binary> <input_file>

if [[ $# -lt 2 ]]; then
echo "Usage: $0 <old_binary> <input_file> [additional opts]"
echo "Example: $0 ./prodigal.windows.exe anthus_aco.fas -t test/anthus_aco.train"
exit 1
fi

OLD_BINARY="$1"
INPUT_FILE="$2"
OUT_PREFIX="test/$(basename "$INPUT_FILE")"
shift 2

if ! command -v "$OLD_BINARY" >/dev/null; then
echo "Error: Old binary '$OLD_BINARY' is not executable. Did you forget a './' prefix?"
exit 1
fi
if [[ ! -f $INPUT_FILE ]]; then
echo "Error: Input file '$INPUT_FILE' does not exist."
exit 1
fi

mkdir -p "test"
rm -f "$OUT_PREFIX".old.* "$OUT_PREFIX".new.* "$OUT_PREFIX".*.diff

time "$OLD_BINARY" -i "$INPUT_FILE" -f gbk -o "$OUT_PREFIX".old.gbk -d "$OUT_PREFIX".old.ffn -a "$OUT_PREFIX".old.faa "$@"
ret=$?
if ((ret)); then
echo "Error: Old binary failed to run with $ret."
fi
# rerun if empty (first training creation)
if [[ ! -s "$OUT_PREFIX".old.gbk || ! -s "$OUT_PREFIX".old.ffn || ! -s "$OUT_PREFIX".old.faa ]]; then
echo "Warning: Old binary produced empty output files, retrying..."
time "$OLD_BINARY" -i "$INPUT_FILE" -f gbk -o "$OUT_PREFIX".old.gbk -d "$OUT_PREFIX".old.ffn -a "$OUT_PREFIX".old.faa "$@"
ret=$?
if ((ret)); then
echo "Error: Old binary failed to run with $ret on retry."
fi
fi

time ./prodigal -i "$INPUT_FILE" -f gbk -o "$OUT_PREFIX".new.gbk -d "$OUT_PREFIX".new.ffn -a "$OUT_PREFIX".new.faa "$@"
ret=$?
if ((ret)); then
echo "Error: New binary failed to run with $ret."
fi

# normalize line endings
sed -i -e 's/\r//g' "$OUT_PREFIX".{old,new}.*

if ! diff -u "$OUT_PREFIX".old.gbk "$OUT_PREFIX".new.gbk >"$OUT_PREFIX".gbk.diff; then
echo "GBK files differ."
else
echo "GBK files are identical."
fi

if ! diff -u "$OUT_PREFIX".old.ffn "$OUT_PREFIX".new.ffn >"$OUT_PREFIX".ffn.diff; then
echo "FFN files differ."
else
echo "FFN files are identical."
fi

if ! diff -u "$OUT_PREFIX".old.faa "$OUT_PREFIX".new.faa >"$OUT_PREFIX".faa.diff; then
echo "FAA files differ."
else
echo "FAA files are identical."
fi
Loading