Permalink
Browse files

pm_depend now use phylomel, test

  • Loading branch information...
aryx committed Sep 6, 2011
1 parent 78f625e commit 8bf36daa754060172365b42f5335b260f450e562
Showing with 417 additions and 318 deletions.
  1. +15 −5 Makefile
  2. +49 −48 external/phylomel/phylogf.ml
  3. +177 −175 external/phylomel/src/barnesHut.ml
  4. +35 −35 external/phylomel/src/genotype.ml
  5. +52 −54 external/phylomel/src/genotype.mli
  6. +71 −1 main_pm_depend.ml
  7. +18 −0 project.el
View
@@ -131,6 +131,10 @@ OCAMLNETCMA= \
# external/ocamlnet/netstring/netaccel.cma \
+PHYLOMELDIR=external/phylomel/src
+PHYLOMELINCLUDE=external/phylomel/src
+PHYLOMELCMA=external/phylomel/src/lib.cma
+
ifeq ($(FEATURE_GRAPHICS), 1)
#GRAPHICSCMXA=graphics.cmxa
@@ -228,7 +232,7 @@ LIBS= commons/commons.cma \
MAKESUBDIRS=commons \
$(BDBDIR) $(REGEXPDIR) $(MPIDIR) \
- $(GRAPHDIR) \
+ $(GRAPHDIR) $(PHYLOMELDIR) \
$(THRIFTDIR) \
$(OCAMLNETDIR) \
$(GUIDIR) $(CAIRODIR) \
@@ -282,7 +286,8 @@ MAKESUBDIRS=commons \
INCLUDEDIRS=$(MAKESUBDIRS) \
commons/ocamlextra commons/ocollection \
commons/lib-json commons/lib-xml commons/lib-sexp \
- $(GTKINCLUDE) $(CAIROINCLUDE) $(PCREINCLUDE) $(OCAMLNETINCLUDE)
+ $(GTKINCLUDE) $(CAIROINCLUDE) $(PCREINCLUDE) $(OCAMLNETINCLUDE) \
+ $(PHYLOMELINCLUDE)
##############################################################################
# Generic
@@ -399,12 +404,17 @@ clean::
# pm_depend targets
#------------------------------------------------------------------------------
+SYSLIBS_PM= external/phylomel/src/lib.cma
+# external/ocamlgtk/src/lablgtk.cma \
+# external/ocamlcairo/src/cairo.cma \
+# external/ocamlcairo/src/cairo_lablgtk.cma \
-pm_depend: $(LIBS) main_pm_depend.cmo
- $(OCAMLC) $(CUSTOM) -o $@ $(SYSLIBS) $^
-pm_depend.opt: $(LIBS:.cma=.cmxa) main_pm_depend.cmx
+pm_depend: $(LIBS) $(SYSLIBS_PM) main_pm_depend.cmo
+ $(OCAMLC) $(CUSTOM) -o $@ $(BASICSYSLIBS) $^
+
+pm_depend.opt: $(SYSLIBS_PM:.cma=.cmxa) $(LIBS:.cma=.cmxa) main_pm_depend.cmx
$(OCAMLOPT) $(STATIC) -o $@ $(BASICSYSLIBS:.cma=.cmxa) $^
clean::
@@ -7,61 +7,62 @@ open Phylogram
open Printf
let update_state n fs bs fig =
- let delta = 0.05 in
+ let delta = 0.05 in
- (* Update forces *)
- ForceDirectedLayout.do_calc_forces fs bs fig;
+ (* Update forces *)
+ ForceDirectedLayout.do_calc_forces fs bs fig;
- (* Euler integration on each body *)
- for i=0 to n - 1 do
- let b = bs.(i) in
- let f = fs.(i) in
- b.p.x <-
- b.p.x +. delta *. b.v.x +. 1./.2. *. delta *. delta *. f.x;
- b.p.y <-
- b.p.y +. delta *. b.v.y +. 1./.2. *. delta *. delta *. f.y;
- b.v.x <- b.v.x +. delta *. f.x;
- b.v.y <- b.v.y +. delta *. f.y;
- f.x <- 0.;
- f.y <- 0.
- done
+ (* Euler integration on each body *)
+ for i=0 to n - 1 do
+ let b = bs.(i) in
+ let f = fs.(i) in
+ b.p.x <-
+ b.p.x +. delta *. b.v.x +. 1./.2. *. delta *. delta *. f.x;
+ b.p.y <-
+ b.p.y +. delta *. b.v.y +. 1./.2. *. delta *. delta *. f.y;
+ b.v.x <- b.v.x +. delta *. f.x;
+ b.v.y <- b.v.y +. delta *. f.y;
+ f.x <- 0.;
+ f.y <- 0.
+ done
let () =
- if (Array.length Sys.argv) < 3 then
- printf "usage : geno2svg input_file output_file\n"
- else
- let geno_file = Sys.argv.(1) in
- let svg_file = Sys.argv.(2) in
+ if (Array.length Sys.argv) < 3 then
+ printf "usage : geno2svg input_file output_file\n"
+ else
+ let geno_file = Sys.argv.(1) in
+ let svg_file = Sys.argv.(2) in
- (* We create four things :
- - genotypes collection
- - distance matrix
- - minimum spanning tree
- - figure (graphical tree) *)
+ (* We create four things :
+ - genotypes collection
+ - distance matrix
+ - minimum spanning tree
+ - figure (graphical tree) *)
+
+ let collec = Genotypes.read_file geno_file in
+ let collec = Genotypes.remove_duplicates collec in
+ let dmat = GenoMat.create collec in
+ let tree = Tree.prim_complete collec dmat in
+ let fig = Phylogram.radial_layout ~reframe:false 800. tree in
- let collec = Genotypes.read_file geno_file in
- let collec = Genotypes.remove_duplicates collec in
- let dmat = GenoMat.create collec in
- let tree = Tree.prim_complete collec dmat in
- let fig = Phylogram.radial_layout ~reframe:false 800. tree in
+ (* Creates force array, bodies *)
+ let n = Phylogram.size fig in
+ let fs = Array.init n (fun _ -> Vec2.null ()) in
+ let bs = Array.map ForceDirectedLayout.body_of_pos fig.ps in
- (* Creates force array, bodies *)
- let n = Phylogram.size fig in
- let fs = Array.init n (fun _ -> Vec2.null ()) in
- let bs = Array.map ForceDirectedLayout.body_of_pos fig.ps in
+ for i=0 to 2000 do
+ update_state n fs bs fig
+ done;
- for i=0 to 2000 do
- update_state n fs bs fig
- done;
+ let x0, y0 = (10.,10.) in
+ unsafe_reframe (10.,10.) fig.ps;
+ unsafe_crop_width (800.-.2.*.x0) fig.ps;
+ fig.h <- height fig.ps +. 2. *. y0;
+
+ (* let x0 = 10. in *)
+ (* unsafe_reframe (10., 10.) fig.ps; *)
+ (* unsafe_crop_width (800.-.2.*.x0) fig.ps; *)
+
+ Phylogram.write_svg_file collec fig svg_file
- let x0, y0 = (10.,10.) in
- unsafe_reframe (10.,10.) fig.ps;
- unsafe_crop_width (800.-.2.*.x0) fig.ps;
- fig.h <- height fig.ps +. 2. *. y0;
-
- (* let x0 = 10. in *)
- (* unsafe_reframe (10., 10.) fig.ps; *)
- (* unsafe_crop_width (800.-.2.*.x0) fig.ps; *)
-
- Phylogram.write_svg_file collec fig svg_file
Oops, something went wrong.

0 comments on commit 8bf36da

Please sign in to comment.