Skip to content

Commit

Permalink
1.0.6:
Browse files Browse the repository at this point in the history
	Corrected a bug that may produce biased output in pij_gassist, pij_gassist_trad, and pijs_gassist when nodiag is set or when memlimit is small so computation is split into chunks.
	Now setting histogram bounds based on the maximum of all LLRs (as opposed to the maximum of the chunk when memlimit is small) in pij_gassist, pij_gassist_trad, and pijs_gassist. This ensures the output is independent of memlimit (related to question from sritchie73@github).
	Added sanity checks for agreement between input data and nodiag flag for pij functions excluding _pv (suggested by sritchie73@github).
	Lots of internal function renaming and code restructuring.
	Removed some unneeded files and functions.
	Now support pkg-config setup.
  • Loading branch information
lingfeiwang committed Feb 5, 2018
1 parent 48917a1 commit 82b97e0
Show file tree
Hide file tree
Showing 92 changed files with 1,040 additions and 3,457 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright 2016, 2017 Lingfei Wang
Copyright 2016-2018 Lingfei Wang
44 changes: 27 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ URL_BIN_REL="$(URL_BIN)/releases"
URL_R_REL="$(URL_R)/releases"
VERSION1=1
VERSION2=0
VERSION3=5
VERSION3=6
LICENSE=AGPL-3
LICENSE_FULL="GNU Affero General Public License, Version 3"
LICENSE_URL="https://www.gnu.org/licenses/agpl-3.0"
#UNAME=$$(uname)
ifdef INCLUDE_MAKEFILE_BEFORE
#Input package info here
include $(INCLUDE_MAKEFILE_BEFORE)
Expand All @@ -39,7 +38,8 @@ DIR_SRC=.
endif
DIR_INSTALL_PREFIX=$(PREFIX)
DIR_INSTALL_LIB=$(DIR_INSTALL_PREFIX)/lib
DIR_INSTALL_INC=$(DIR_INSTALL_PREFIX)/include/$(LIB_NAME)
DIR_INSTALL_INC0=$(DIR_INSTALL_PREFIX)/include
DIR_INSTALL_INC=$(DIR_INSTALL_INC0)/$(LIB_NAME)

CC=gcc
CFLAGSI=$(addprefix -I ,. $(R_INCLUDE_DIR) $(PREFIX)/include /usr/local/include)
Expand All @@ -66,10 +66,24 @@ INC_INSTALL_FILES=$(LIB_H)
INC_INSTALL_DIRS=$(dir $(LIB_H))
LIB_UNINSTALL=$(addprefix $(DIR_INSTALL_LIB)/,$(notdir $(LIB_DPRODUCT)))
INC_UNINSTALL=$(DIR_INSTALL_INC)
PKGCONFIG=$(LIB_NAME).pc
PKGCONFIG_UNINSTALL=$(DIR_INSTALL_LIB)/pkgconfig/$(LIB_NAME).pc

.PHONY: all clean distclean install-lib install-inc install uninstall

all: $(LIB_DPRODUCT)
all: $(LIB_DPRODUCT) $(PKGCONFIG)

$(PKGCONFIG):
@echo "prefix=$(DIR_INSTALL_PREFIX)" > $@
@echo "exec_prefix=$(DIR_INSTALL_PREFIX)" >> $@
@echo "libdir=$(DIR_INSTALL_LIB)" >> $@
@echo "includedir=$(DIR_INSTALL_INC0)" >> $@
@echo >> $@
@echo "Name: $(LIB_NAME)" >> $@
@echo "Description: Fast Inference of Networks from Directed Regulations" >> $@
@echo "Version: $(VERSION1).$(VERSION2).$(VERSION3)" >> $@
@echo "Libs: -L$(DIR_INSTALL_LIB) -l$(LIB_NAME) -lgsl" >> $@
@echo "Cflags: -I$(DIR_INSTALL_INC0)" >> $@

$(LIB_CONFIG):
@echo "#ifndef _HEADER_LIB_CONFIG_AUTO_H_" > $@
Expand Down Expand Up @@ -100,23 +114,14 @@ clean:
$(RM) $(LIB_PRODUCT)

distclean: clean
$(RM) $(LIB_DPRODUCT)
$(RM) $(LIB_CONFIG)
$(RM) Makefile.flags $(TMP_FILE)
$(RM) $(LIB_DPRODUCT) $(PKGCONFIG) $(LIB_CONFIG) Makefile.flags $(TMP_FILE)

install-lib: SHELL:=/bin/bash
install-lib: all
umask 0022 && mkdir -p $(DIR_INSTALL_LIB) && \
cp $(LIB_DPRODUCT) $(DIR_INSTALL_LIB)/ && \
chmod 0755 $(DIR_INSTALL_LIB)/$(notdir $(LIB_DPRODUCT)) && \
if [ "$$(uname)" == "Linux" ]; then \
ldconfig $(DIR_INSTALL_LIB) || true; \
fi; \
tcyg=$$(uname | grep -io "cygwin"); \
if [ -n "$$tcyg" ]; then \
ln -s $(DIR_INSTALL_LIB)/$(notdir $(LIB_DPRODUCT)) $(basename $(DIR_INSTALL_LIB)/$(notdir $(LIB_DPRODUCT))).dll; \
fi

ldconfig $(DIR_INSTALL_LIB) || true

install-inc: SHELL:=/bin/bash
install-inc: $(LIB_CONFIG)
Expand All @@ -130,10 +135,15 @@ install-inc: $(LIB_CONFIG)
chmod 0644 $(DIR_INSTALL_INC)/$$fname || exit 1; \
done

install: install-lib install-inc
install-pkgconfig: $(PKGCONFIG)
umask 0022 && mkdir -p $(DIR_INSTALL_LIB)/pkgconfig && \
cp $< $(DIR_INSTALL_LIB)/pkgconfig/
chmod 0644 $(DIR_INSTALL_LIB)/pkgconfig/$(notdir $<)

install: install-lib install-inc install-pkgconfig

uninstall:
$(RM) -R $(LIB_UNINSTALL) $(INC_UNINSTALL)
$(RM) -R $(LIB_UNINSTALL) $(INC_UNINSTALL) $(PKGCONFIG_UNINSTALL)

TMP_FILE=.tmp
Makefile.flags:
Expand Down
11 changes: 9 additions & 2 deletions UPDATES
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
1.0.6:
Corrected a bug that may produce biased output in pij_gassist, pij_gassist_trad, and pijs_gassist when nodiag is set or when memlimit is small so computation is split into chunks.
Now setting histogram bounds based on the maximum of all LLRs (as opposed to the maximum of the chunk when memlimit is small) in pij_gassist, pij_gassist_trad, and pijs_gassist. This ensures the output is independent of memlimit (related to question from sritchie73@github).
Added sanity checks for agreement between input data and nodiag flag for pij functions excluding _pv (suggested by sritchie73@github).
Lots of internal function renaming and code restructuring.
Removed some unneeded files and functions.
Now support pkg-config setup.
1.0.5:
Updated Makefiles to account for different make environments.
Updated Makefiles to account for different make environments (reported by sritchie73@github).
1.0.1:
Bug correction:
Updated LDFLAGS for R interface.
Updated LDFLAGS for R interface (reported by audreyqyfu@github).
1.0.0:
New functions:
Included P-value computation for 4 tests in pijs_gassist_pv and correlation test in pij_rank_pv.
Expand Down
2 changes: 1 addition & 1 deletion base/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down
2 changes: 1 addition & 1 deletion base/const.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down
68 changes: 67 additions & 1 deletion base/data_process.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand All @@ -18,6 +18,7 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <tgmath.h>
#include "types.h"
Expand Down Expand Up @@ -435,7 +436,72 @@ void MATRIXFF(minmax_nodiag)(const MATRIXF* d,FTYPE* restrict dmin,FTYPE* restri
}
}

/* Quick hash of VECTORF using bitwise operation
* Return: hash of VECTORF as FTYPE
*/
static inline FTYPE VECTORFF(hash)(const VECTORF* v)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#define TFUTYPE CONCATENATE3(uint,FTYPEBITS,_t)
TFUTYPE h;
size_t i;

h=*(const TFUTYPE*)VECTORFF(const_ptr)(v,0);
for(i=1;i<v->size;i++)
{
h=(h<<1)|(h>>(FTYPEBITS-1));
h^=*(const TFUTYPE*)VECTORFF(const_ptr)(v,i);
}
return *(FTYPE*)(&h);
}

int MATRIXFF(cmprow)(const MATRIXF* m1,const MATRIXF* m2,VECTORF* buff1,VECTORF* buff2,char nodiag,char warn)
{
size_t i,j;
size_t ng,nt;
union u
{
FTYPE f;
TFUTYPE u;
} t;
FTYPE fmin,fmax;
int test;

ng=m1->size1;
nt=m2->size1;
assert((m2->size2==m1->size2)&&(buff->size1==ng)&&(buff1->size==ng)&&(buff2->size==m1->size2));

for(i=0;i<ng;i++)
{
VECTORFF(const_view) vv=MATRIXFF(const_row)(m1,i);
VECTORFF(set)(buff1,i,VECTORFF(hash)(&vv.vector));
}

for(i=0;i<nt;i++)
{
VECTORFF(const_view) vv=MATRIXFF(const_row)(m2,i);
t.f=VECTORFF(hash)(&vv.vector);
for(j=0;j<ng;j++)
{
test=nodiag&&(i==j);
if(test^(t.u!=*((const TFUTYPE*)VECTORFF(const_ptr)(buff1,j))))
continue;
VECTORFF(memcpy)(buff2,&vv.vector);
VECTORFF(const_view) vv2=MATRIXFF(const_row)(m1,j);
VECTORFF(sub)(buff2,&vv2.vector);
VECTORFF(minmax)(buff2,&fmin,&fmax);
if(test^((fmin!=0)||(fmax!=0)))
continue;
if(warn)
LOG(5,"Detected identical rows in dt and dt2 (at the same or different row numbers), or different rows at the same row number when nodiag is true. Make sure your input data and the nodiag flag are correct.")
return 1;
}
}
return 0;
#undef TFUTYPE
#pragma GCC diagnostic pop
}



Expand Down
27 changes: 22 additions & 5 deletions base/data_process.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down Expand Up @@ -193,6 +193,7 @@ static inline void MATRIXDF(set_nan)(MATRIXD* m,double val);

// Sets all old value to new value
static inline void MATRIXFF(set_value)(MATRIXF* m,FTYPE vold,FTYPE vnew);
static inline void VECTORFF(set_value)(VECTORF* v,FTYPE vold,FTYPE vnew);

/* Locates the first not number in a vector/matrix, and return its location.
* If not found, return -1.
Expand Down Expand Up @@ -351,8 +352,19 @@ static inline void VECTORFF(fluc)(VECTORF* v,FTYPE fluc);

void MATRIXFF(minmax_nodiag)(const MATRIXF* d,FTYPE* restrict dmin,FTYPE* restrict dmax,long nodiagshift);



/* Look for any (non)identical rows of two matrices efficiently.
* m1: (ng,ns) Matrix 1
* m2: (nt,ns) Matrix 2
* buff1: (ng) Buffer vector 1
* buff2: (ns) Buffer vector 2
* nodiag: Whether to the same rows should be the same in both matrices
* warn: Whether to show warning in log before returning 1
* Return: 1 if any of the following 3 conditions are satisfied, and 0 otherwise.
* 1. row i in m1 = row j in m2 and i!=j
* 2. row i in m1 = row i in m2 and !nodiag
* 3. row i in m1 != row i in m2 and nodiag
*/
int MATRIXFF(cmprow)(const MATRIXF* m1,const MATRIXF* m2,VECTORF* buff1,VECTORF* buff2,char nodiag,char warn);



Expand Down Expand Up @@ -655,7 +667,6 @@ static inline void MATRIXDF(set_nan)(MATRIXD* m,double val)
MATRIXDF(set_cond)(m,gsl_isnan,val);
}


static inline void MATRIXFF(set_value)(MATRIXF* m,FTYPE vold,FTYPE vnew)
{
size_t i,j;
Expand All @@ -665,7 +676,13 @@ static inline void MATRIXFF(set_value)(MATRIXF* m,FTYPE vold,FTYPE vnew)
MATRIXFF(set)(m,i,j,vnew);
}


static inline void VECTORFF(set_value)(VECTORF* v,FTYPE vold,FTYPE vnew)
{
size_t i;
for(i=0;i<v->size;i++)
if(VECTORFF(get)(v,i)==vold)
VECTORFF(set)(v,i,vnew);
}

static inline void MATRIXFF(cov1)(const MATRIXF* m,MATRIXF* cov)
{
Expand Down
2 changes: 1 addition & 1 deletion base/data_struct.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down
2 changes: 1 addition & 1 deletion base/data_struct_heap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down
2 changes: 1 addition & 1 deletion base/data_struct_heap.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down
2 changes: 1 addition & 1 deletion base/data_struct_ll.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down
2 changes: 1 addition & 1 deletion base/data_struct_ll.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, 2017 Lingfei Wang
/* Copyright 2016-2018 Lingfei Wang
*
* This file is part of Findr.
*
Expand Down
Loading

0 comments on commit 82b97e0

Please sign in to comment.