This is an automated email from the git hooks/post-receive script. tille pushed a commit to branch master in repository hyphy.
commit 979d9929dbe2e04a5204ef7572747c76b5a61a6f Author: Andreas Tille <[email protected]> Date: Fri Jul 10 08:55:09 2015 +0200 Provide examples for Python modules --- debian/Python/BasicHyPhy3.py | 113 +++++++++++++++++++++++++++++ debian/control | 13 ++-- debian/hyphy-common.examples | 1 + debian/{hyphy.install => hyphygui.install} | 0 debian/python-hyphy.examples | 1 + debian/python-hyphy.links | 2 + debian/python3-hyphy.examples | 1 + debian/python3-hyphy.links | 2 + 8 files changed, 127 insertions(+), 6 deletions(-) diff --git a/debian/Python/BasicHyPhy3.py b/debian/Python/BasicHyPhy3.py new file mode 100755 index 0000000..ef44457 --- /dev/null +++ b/debian/Python/BasicHyPhy3.py @@ -0,0 +1,113 @@ +#!/usr/bin/python3 +# import the HyPhy library +# and standard OS utilities + +import os, HyPhy + +# first, create a HyPhy interface instance (class _THyPhy) +# the first argument defines the root directory for HyPhy +# and the second - how many threads the computational core +# should spawn + +hyphyInstance = HyPhy._THyPhy (os.getcwd(),2) + +# the basic interface command is 'ExecuteBF' which +# executes HyPhy batch language commands in HyPhy +# and returns a string representation of the return value +# (if any) from HYPHY +# The returned object is of type _THyPhyString with +# sData and sLength fields +# HyPhy will take care of disposing of the memory needed +# to store the result + +hyphyResult = hyphyInstance.ExecuteBF ("return 2+2;"); +print("Testing a trivial HyPhy command. 2+2 = ", hyphyResult.sData) + +# an optional second argument to ExecuteBF +# can be used to "flush" the current state of the system + +# this is the default option for the call of ExecuteBF +# passing the second argument of False or 0 will preserve +# the execution state + +print("Consecutive command exection") +hyphyInstance.ExecuteBF ("z:=x+y;",False); +hyphyInstance.ExecuteBF ("x=3;",False); +hyphyInstance.ExecuteBF ("y=5;",False); +hyphyResult = hyphyInstance.ExecuteBF ("return z;",False); +print("The value of z is ", hyphyResult.sData) + +print("Resetting the state of the execution erases the value of 'z'") +hyphyResult = hyphyInstance.ExecuteBF ("return z;"); +print("The value of z is ", hyphyResult.sData) + +# the real utility of the interface is to be able +# to execute prewritten analyses from HBL files + +print("Executing the example F81.bf file") +hyphyResult = hyphyInstance.ExecuteBF ("ExecuteAFile(\"../HBL/F81.bf\")"); + +# retrive the standard output, error and runtime warnings + +hyphyOut = hyphyInstance.GetStdout() +#errors will be empty UNLESS there was an exection error +hyphyErrors = hyphyInstance.GetErrors() +hyphyWarnings = hyphyInstance.GetWarnings() + +print("Standard out: \n", hyphyOut.sData) +print("Errors: \n", hyphyErrors.sData) +print("Warnings/Log messages: \n", hyphyWarnings.sData) + +# these variables can be explicitly deleted when they are no longer needed +# python garbage collection should take care of disposing of disused variables + +del hyphyOut +del hyphyErrors +del hyphyWarnings + +# A tighter intergration can be achieved by defining a retrieval function +# with the reserved name _THyPhyAskFor in the HBL file; it retrieves data +# by key and returns them in a internal format that can be converted +# to one of the basic return types: number, string or matrix + +def retrieveValueByKey (key, returnType,hyphyInstance): + theResult = hyphyInstance.AskFor(key) + # see if HyPhy can retrieve a value with the requested key + if theResult: + canICast = hyphyInstance.CanCast(theResult,returnType) + # see if HyPhy can cast the value to the requested type + if canICast: + # do the casting + theResult = hyphyInstance.CastResult(theResult,returnType) + # the last step is to convert from the basic return type + # to a derived class that we can use in python directly + if (returnType == HyPhy.THYPHY_TYPE_NUMBER): + return theResult.castToNumber() + if (returnType == HyPhy.THYPHY_TYPE_STRING): + return theResult.castToString() + if (returnType == HyPhy.THYPHY_TYPE_MATRIX): + return theResult.castToMatrix() + return null + + +hyphyResult = hyphyInstance.ExecuteBF ("ExecuteAFile(\"../HBL/HKY85.bf\")"); + +print("Log-L = ", retrieveValueByKey ("LogL", HyPhy.THYPHY_TYPE_NUMBER, hyphyInstance).nValue); +print("kappa = ", retrieveValueByKey ("kappa", HyPhy.THYPHY_TYPE_NUMBER, hyphyInstance).nValue); +print("tree string = ", retrieveValueByKey ("Tree", HyPhy.THYPHY_TYPE_STRING, hyphyInstance).sData); +bl = retrieveValueByKey ("Branch lengths", HyPhy.THYPHY_TYPE_MATRIX, hyphyInstance); +print("retrieved ", bl.mCols-1, "branch lengths") +for i in range(0,bl.mCols-1): + print("Branch ", i+1, " has length ", bl.MatrixCell(0,i)) + + + + + + + + + + + + diff --git a/debian/control b/debian/control index 66b4954..fa2588e 100644 --- a/debian/control +++ b/debian/control @@ -24,7 +24,7 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, hyphy-common -Description: Hypothesis testing using Phylogenies (GTK gui) +Description: Hypothesis testing using Phylogenies (GTK+ gui) HyPhy is an open-source software package for the analysis of genetic sequences using techniques in phylogenetics, molecular evolution, and machine learning. It features a complete graphical user interface (GUI) @@ -35,7 +35,7 @@ Description: Hypothesis testing using Phylogenies (GTK gui) R. Continued development of HyPhy is currently supported in part by an NIGMS R01 award 1R01GM093939. . - This package contains the GTK gui. + This package contains the GTK+ gui. Package: hyphy-pt Architecture: any @@ -76,7 +76,7 @@ Description: Hypothesis testing using Phylogenies (MPI version) Package: hyphy-common Architecture: all Depends: ${misc:Depends} -Suggests: hyphy | hyphy-mpi +Suggests: hyphygui | hyphy-mpi | hyphy-pt Description: Hypothesis testing using Phylogenies (common files) HyPhy is an open-source software package for the analysis of genetic sequences using techniques in phylogenetics, molecular evolution, and @@ -94,7 +94,6 @@ Package: libhyphy Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Suggests: hyphy | hyphy-mpi Description: Hypothesis testing using Phylogenies (library) HyPhy is an open-source software package for the analysis of genetic sequences using techniques in phylogenetics, molecular evolution, and @@ -115,7 +114,8 @@ Architecture: any Section: python Depends: ${shlibs:Depends}, ${misc:Depends}, - ${python:Depends} + ${python:Depends}, + hyphy-common Description: Hypothesis testing using Phylogenies (Python 2 module) HyPhy is an open-source software package for the analysis of genetic sequences using techniques in phylogenetics, molecular evolution, and @@ -134,7 +134,8 @@ Architecture: any Section: python Depends: ${shlibs:Depends}, ${misc:Depends}, - ${python3:Depends} + ${python3:Depends}, + hyphy-common Description: Hypothesis testing using Phylogenies (Python 3 module) HyPhy is an open-source software package for the analysis of genetic sequences using techniques in phylogenetics, molecular evolution, and diff --git a/debian/hyphy-common.examples b/debian/hyphy-common.examples new file mode 100644 index 0000000..3ff8f68 --- /dev/null +++ b/debian/hyphy-common.examples @@ -0,0 +1 @@ +src/lib/Examples/HBL diff --git a/debian/hyphy.install b/debian/hyphygui.install similarity index 100% rename from debian/hyphy.install rename to debian/hyphygui.install diff --git a/debian/python-hyphy.examples b/debian/python-hyphy.examples new file mode 100644 index 0000000..eadb719 --- /dev/null +++ b/debian/python-hyphy.examples @@ -0,0 +1 @@ +src/lib/Examples/Python diff --git a/debian/python-hyphy.links b/debian/python-hyphy.links new file mode 100644 index 0000000..9d0a506 --- /dev/null +++ b/debian/python-hyphy.links @@ -0,0 +1,2 @@ +/usr/share/doc/hyphy-common/examples/HBL /usr/share/doc/python-hyphy/examples/HBL + diff --git a/debian/python3-hyphy.examples b/debian/python3-hyphy.examples new file mode 100644 index 0000000..ae7360d --- /dev/null +++ b/debian/python3-hyphy.examples @@ -0,0 +1 @@ +debian/Python diff --git a/debian/python3-hyphy.links b/debian/python3-hyphy.links new file mode 100644 index 0000000..52af957 --- /dev/null +++ b/debian/python3-hyphy.links @@ -0,0 +1,2 @@ +/usr/share/doc/hyphy-common/examples/HBL /usr/share/doc/python3-hyphy/examples/HBL + -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/hyphy.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
