Changeset 234


Ignore:
Timestamp:
Oct 5, 2009, 3:05:57 PM (10 years ago)
Author:
pvkouteren
Message:

Added Hypergeometric test to statistics module and AtomicServices?
Added array operations to modules
Modified source file builders to obtain numpy path from config file

Files:
9 added
9 edited

Legend:

Unmodified
Added
Removed
  • patricktest.py

    r231 r234  
    180180
    181181from log.Logger import Logger
    182 
    183 timelogger = Logger(name='querytimes_msigdb_4_20090929', format="%(message)s")
     182from time import strftime
    184183
    185184auth_modes = ['off', 'on']
     
    198197           ]
    199198'''
     199
     200timelogger = Logger(name=strftime("%Y%m%d%H%M")+'querytimes_msigdb_'+str(len(queries))+'_'+str(runs), format="%(message)s")
     201qtimelogger = Logger(name=strftime("%Y%m%d%H%M")+'singlequerytimes_'+str(len(queries))+'_'+str(runs), format="%(message)s")
     202
    200203for auth_mode in auth_modes:
    201204    testconfig['ibidas.authenticated_mode'] = auth_mode
     
    208211    print "Authentication " + auth_mode
    209212    print "===================="
    210     timelogger.log("Authentication: " + auth_mode)
     213    #timelogger.log("Authentication: " + auth_mode)
    211214    #usertime = 0
    212215    result = []
     
    218221        max = None
    219222        usertime = 0
     223        qtimes = []
    220224        for run0 in range(1, (runs+1)):
    221225            t1 = time.time()
     
    224228            t2 = time.time()
    225229            totaltime = t2-t1
     230            qtimes.append(str(totaltime).replace(".",",") + "\t")
    226231            usertime += totaltime
    227232            if run0 == 1:
     
    236241        mins.append(str(min).replace(".",",") + "\t")
    237242        maxs.append(str(max).replace(".",",") + "\t")
     243        qtimelogger.log("".join(qtimes) + "\n")
    238244        print str(len(res)) + " results, " + str(runs) + " runs in a total of " + str(usertime) + " secs. On average: " + str(avg) + " secs."
    239245        print "min: " + str(min) + ", max: " + str(max) + ", run0: " + str(run0tt)
    240246    timelogger.log("".join(result))
    241     timelogger.log("run0s")
     247    #timelogger.log("run0s")
    242248    timelogger.log("".join(run0s))
    243     timelogger.log("mins")
     249    #timelogger.log("mins")
    244250    timelogger.log("".join(mins))
    245     timelogger.log("maxs")
     251    #timelogger.log("maxs")
    246252    timelogger.log("".join(maxs))
    247253cd.close()
  • src/setup_base_container.py

    r37 r234  
    33import distutils.sysconfig
    44from distutils.debug import DEBUG
    5 include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
     5import config
     6include_dir = config.getValue('setup.ini', {"setup.numpy_path":distutils.sysconfig.get_python_lib() + "/numpy/core/include"}, 'setup.numpy_path')
     7#include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
    68#include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
     9
    710
    811setup(name="base_container", version="1.0",
  • src/setup_closure.py

    r30 r234  
    33import distutils.sysconfig
    44from distutils.debug import DEBUG
     5import config
     6include_dir = config.getValue('setup.ini', {"setup.numpy_path":distutils.sysconfig.get_python_lib() + "/numpy/core/include"}, 'setup.numpy_path')
    57#include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
    6 include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
     8#include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
    79
    810setup(name="closure", version="1.0",
  • src/setup_itypes.py

    r42 r234  
    33import distutils.sysconfig
    44from distutils.debug import DEBUG
    5 
    6 include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
     5import config
     6include_dir = config.getValue('setup.ini', {"setup.numpy_path":distutils.sysconfig.get_python_lib() + "/numpy/core/include"}, 'setup.numpy_path')
     7#include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
    78#include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
    89
  • src/setup_multi_visitor.py

    r37 r234  
    33import distutils.sysconfig
    44from distutils.debug import DEBUG
     5import config
     6include_dir = config.getValue('setup.ini', {"setup.numpy_path":distutils.sysconfig.get_python_lib() + "/numpy/core/include"}, 'setup.numpy_path')
    57#include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
    6 include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
     8#include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
    79
    810setup(name="multi_visitor", version="1.0",
  • src/setup_qgraph.py

    r34 r234  
    33import distutils.sysconfig
    44from distutils.debug import DEBUG
     5import config
     6include_dir = config.getValue('setup.ini', {"setup.numpy_path":distutils.sysconfig.get_python_lib() + "/numpy/core/include"}, 'setup.numpy_path')
    57#include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
    6 include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
     8#include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
    79
    810setup(name="qgraph", version="1.0",
  • src/setup_query_graph.py

    r4 r234  
    33import distutils.sysconfig
    44from distutils.debug import DEBUG
     5import config
     6include_dir = config.getValue('setup.ini', {"setup.numpy_path":distutils.sysconfig.get_python_lib() + "/numpy/core/include"}, 'setup.numpy_path')
    57#include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
    6 include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
     8#include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
    79
    810setup(name="query_graph", version="1.0",
  • src/setup_xnumpy.py

    r4 r234  
    1 
    21from distutils.core import setup, Extension
    32import distutils.sysconfig
    43from distutils.debug import DEBUG
    5 
     4import config
     5include_dir = config.getValue('setup.ini', {"setup.numpy_path":distutils.sysconfig.get_python_lib() + "/numpy/core/include"}, 'setup.numpy_path')
    66#include_dir = distutils.sysconfig.get_python_lib() + "/numpy/core/include"
    7 include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
     7#include_dir = "/usr/lib64/python2.5/site-packages" + "/numpy/core/include"
    88
    99setup(name="xnumpy", version="1.0",
  • web/IbidasAtomicServicesTemp.py

    r223 r234  
    99from container import postgres
    1010import web.IbidasMessage
     11from modules.statistics.Hypergeometric import Hypergeometric
    1112
    1213class IbidasAtomicServices:
     
    193194            result.append(a_res)
    194195        return result
     196   
     197    def _getItemIDs(self, ts):
     198        return self.cd.item[_.display_name.within(*ts)].select(_.item_id)().tolist()
     199   
     200    @soapmethod(Array(String), Array(String), String, Float, _returns=Boolean)
     201    def geneEnrichmentTest(self, top, back, reference, threshold):
     202        """ Returns whether a geneset is enriched """
     203        result = self.calculateGeneEnrichment(top, back, reference)
     204        return result < threshold
     205   
     206    @soapmethod(Array(String), Array(String), String, _returns=Float)
     207    def calculateGeneEnrichment(self, top, back, reference):
     208        """ Returns the value of the gene enrichment (hypergeometric) test """
     209        top_ids  = self._getItemIDs(top)
     210        back_ids = self._getItemIDs(back)
     211        set_id = self.cd.set[_.name == reference].select(_.set_id)()
     212        set_ids = self.cd.item_prop_term[_.source_id == set_id].select(_.item_id)().tolist()
     213        h = Hypergeometric(top_ids, back_ids, set_ids)
     214        return h.calculate()
     215   
     216    @soapmethod(Array(Array(String)), Array(Array(String)), Array(String), Float, _returns=Array(Array(Array(Boolean))))
     217    def geneEnrichmentTests(self, tops, backs, references, threshold):
     218        """ Do multiple enrichment tests with multiple lists and multiple backgrounds on multiple reference sets """
     219        tbsrs = []
     220        for top in tops:   
     221            tbrs = []
     222            for back in backs:
     223                reference_array = []
     224                for reference in references:
     225                    reference_array.append(self.geneEnrichmentTest(top, back, reference, threshold))
     226                tbrs.append(reference_array)
     227            tbsrs.append(tbrs)
     228        return tbsrs
     229                   
Note: See TracChangeset for help on using the changeset viewer.