From bfaa812d86b0e018a9776259210379b337bf203c Mon Sep 17 00:00:00 2001 From: ntfrgl Date: Sat, 10 Dec 2016 16:00:02 +0100 Subject: [PATCH 1/3] add interface for MotifCluster (incomplete) - check if ARPACK installed (so far only on Linux, OSX) - compile motifcluster.cpp, include motifcluster.h in snap.i - missing: typedef WeightVH --- Makefile.config | 8 ++++++++ swig/Makefile | 35 ++++++++++++----------------------- swig/snap.i | 4 +++- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Makefile.config b/Makefile.config index 344f3677..941b6d69 100644 --- a/Makefile.config +++ b/Makefile.config @@ -10,6 +10,10 @@ ifeq ($(UNAME), Linux) CXXFLAGS += -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp LDFLAGS += -shared -fopenmp MANIFEST = MANIFEST.nx + ifneq (, $(strip $(shell ldconfig -p | grep libarpack))) + CXXFLAGS += -DF77_POST + LDFLAGS += -larpack + endif else ifeq ($(UNAME), Darwin) # OS X flags SWIGFLAGS += -D_CMPWARN -D__stdcall -DSW_SNAPPY -DNONUMPY @@ -26,6 +30,10 @@ else ifeq ($(UNAME), Darwin) CXXOPENMP = endif MANIFEST = MANIFEST.mac + ifneq (, $(strip $(shell ld -larpack 2>&1 | grep symbol))) + CXXFLAGS += -DF77_POST + LDFLAGS += -larpack + endif else ifeq ($(shell uname -o), Cygwin) # Cygwin flags SWIGFLAGS += -D_CMPWARN -D__stdcall -DSW_SNAPPY -DNONUMPY diff --git a/swig/Makefile b/swig/Makefile index a6fbae09..8a008e84 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -5,7 +5,7 @@ # Build instructions for Mac OS X and Linux: # make # make dist -# +# # Build instructions for Windows: # - run swig in Cygwin to generate snap_wrap.cxx and snap.py # make swig-win @@ -38,32 +38,21 @@ snap_wrap.cxx: snap.i snap_types.i tvec.i pneanet.i tmodenet.i tcrossnet.i pungr snap_wrap.o: snap_wrap.cxx g++ $(CXXFLAGS) -c snap_wrap.cxx -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) -I/usr/include/python2.6 -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -Snap.o: +Snap.o: $(CC) $(CXXFLAGS) -c $(SNAPDIR)/Snap.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) -cliques.o: - $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/cliques.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) - -agm.o: - $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/agm.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) - -agmfast.o: - $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/agmfast.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) - -agmfit.o: - $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/agmfit.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) - -biasedrandomwalk.o: - $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/biasedrandomwalk.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) - -word2vec.o: - $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/word2vec.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) +OBJS = $(addsuffix .o, cliques agm agmfast agmfit biasedrandomwalk motifcluster word2vec n2v) -n2v.o: - $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/n2v.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) +$(OBJS): %.o: + $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/$*.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) -_snap.so: snap_wrap.o Snap.o cliques.o agm.o agmfast.o agmfit.o biasedrandomwalk.o word2vec.o n2v.o - g++ $(LDFLAGS) -o _snap.so snap_wrap.o Snap.o cliques.o agm.o agmfast.o agmfit.o biasedrandomwalk.o word2vec.o n2v.o $(LIBS) +ifeq (, $(findstring -larpack, $(LDFLAGS))) +_snap.so: $(filter-out motifcluster.o, $(OBJS)) +else +_snap.so: $(OBJS) +endif +_snap.so: snap_wrap.o Snap.o + g++ $(LDFLAGS) -o _snap.so $^ $(LIBS) snap.py: snap_wrap.cxx diff --git a/swig/snap.i b/swig/snap.i index 6d993359..cf270a77 100644 --- a/swig/snap.i +++ b/swig/snap.i @@ -20,8 +20,9 @@ Version = "3.0.2" #include "agm.h" #include "agmfast.h" #include "agmfit.h" +#include "motifcluster.h" #include "n2v.h" - + /* #include "Engine.h" */ #include "snapswig.h" @@ -225,6 +226,7 @@ Version = "3.0.2" %include "agm.h" %include "agmfast.h" %include "agmfit.h" +%include "motifcluster.h" %include "n2v.h" //%template(Schema) TVec< TPair< TStr, TAttrType> >; From 2b976748cc31a47b780a77421c78044a1c3b4a75 Mon Sep 17 00:00:00 2001 From: ntfrgl Date: Sat, 10 Dec 2016 17:56:13 +0100 Subject: [PATCH 2/3] add MotifCluster.WeightVH type --- swig/snap.i | 6 ++++++ swig/tvec.i | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/swig/snap.i b/swig/snap.i index cf270a77..bab35b74 100644 --- a/swig/snap.i +++ b/swig/snap.i @@ -109,6 +109,9 @@ Version = "3.0.2" %ignore TVec< TPair< TStr,TAttrType > >::TVec(TSIn &); //%ignore Schema::Load; +%ignore TVec::GetPrimHashCd; +%ignore TVec::GetSecHashCd; + %ignore TVec::Intrs; %ignore TVec::IntrsLen; %ignore TVec::AddSorted; @@ -540,6 +543,9 @@ Version = "3.0.2" //%template(TStrIntSH) TStrHash; //%template(TStrToIntVSH) TStrHash; +// define vector types +%template(WeightVH) TVec; + // define keydat types //%template(TChChHI) THashKeyDatI ; //%template(TChTrIntHI) THashKeyDatI ; diff --git a/swig/tvec.i b/swig/tvec.i index fe2afd2d..004e1c6f 100644 --- a/swig/tvec.i +++ b/swig/tvec.i @@ -513,6 +513,10 @@ TIntStrStrTrV.__setitem__ = setitem_vec TIntStrStrTrV.__iter__ = itervec TIntStrStrTrV.__len__ = len_vec TIntStrStrTrV.__delitem__ = delitem_vec +WeightVH.__getitem__ = getitem_vec +WeightVH.__setitem__ = setitem_vec +WeightVH.__iter__ = itervec +WeightVH.__len__ = len_vec +WeightVH.__delitem__ = delitem_vec %} #endif - From 2de7cf45d4504e97d6f3027f050a866c6a355dbc Mon Sep 17 00:00:00 2001 From: ntfrgl Date: Sat, 28 Jan 2017 15:39:17 +0100 Subject: [PATCH 3/3] fix: position of lib flag --- Makefile.config | 4 ++-- swig/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.config b/Makefile.config index 941b6d69..222b157b 100644 --- a/Makefile.config +++ b/Makefile.config @@ -12,7 +12,7 @@ ifeq ($(UNAME), Linux) MANIFEST = MANIFEST.nx ifneq (, $(strip $(shell ldconfig -p | grep libarpack))) CXXFLAGS += -DF77_POST - LDFLAGS += -larpack + LIBS += -larpack endif else ifeq ($(UNAME), Darwin) # OS X flags @@ -32,7 +32,7 @@ else ifeq ($(UNAME), Darwin) MANIFEST = MANIFEST.mac ifneq (, $(strip $(shell ld -larpack 2>&1 | grep symbol))) CXXFLAGS += -DF77_POST - LDFLAGS += -larpack + LIBS += -larpack endif else ifeq ($(shell uname -o), Cygwin) # Cygwin flags diff --git a/swig/Makefile b/swig/Makefile index 8a008e84..f237266a 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -46,7 +46,7 @@ OBJS = $(addsuffix .o, cliques agm agmfast agmfit biasedrandomwalk motifcluster $(OBJS): %.o: $(CC) $(CXXFLAGS) -c $(SNAPADVDIR)/$*.cpp -I$(SNAPDIR) -I$(SNAPADVDIR) -I$(GLIBDIR) -ifeq (, $(findstring -larpack, $(LDFLAGS))) +ifeq (, $(findstring -larpack, $(LIBS))) _snap.so: $(filter-out motifcluster.o, $(OBJS)) else _snap.so: $(OBJS)