1 ###########################################################################
3 # C O P Y R I G H T N O T I C E #
4 # Copyright (c) 2003-10 by: #
5 # * California Institute of Technology #
7 # All Rights Reserved. #
9 # Permission is hereby granted, free of charge, to any person #
10 # obtaining a copy of this software and associated documentation files #
11 # (the "Software"), to deal in the Software without restriction, #
12 # including without limitation the rights to use, copy, modify, merge, #
13 # publish, distribute, sublicense, and/or sell copies of the Software, #
14 # and to permit persons to whom the Software is furnished to do so, #
15 # subject to the following conditions: #
17 # The above copyright notice and this permission notice shall be #
18 # included in all copies or substantial portions of the Software. #
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, #
21 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF #
22 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND #
23 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS #
24 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN #
25 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN #
26 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
28 ###########################################################################
31 from pysqlite2 import dbapi2 as sqlite
33 from sqlite3 import dbapi2 as sqlite
35 __all__ = ["analyzeMotifs", "experiment", "locate", "phyloFoot", "phyloTest",
36 "randomset", "simple", "varyLength", "orthology"]
38 experimentTypes = [("simple", "Simple"), ("fasta", "Fasta"), ("locate", "Locate"),
39 ("varyLength", "VaryLength"), ("phyloFoot", "PhyloFoot"),
40 ("phyloTest", "PhyloTest"), ("orthology", "Orthology"),
41 ("experiment", "generic")]
43 webExperimentTypes = [("simple", "Simple"), ("orthology", "Orthology")]
46 def loadExperiment(expID, expFilePath, analysisID="default", conservationID="default", consDB=""):
49 db = sqlite.connect(expFilePath)
51 sql.execute('select data from settings where expID = :expID and settingName = "experimentType"', locals())
52 expType = str(sql.fetchone()[0])
56 for etype in experimentTypes:
57 if etype[0] == expType:
61 importString = "from %s import %s" % (expType, expClass)
63 expString = 'newExp = %s("%s","%s")' % (expClass, expID, expFilePath)
66 print "Could not find associated class for %s" % expType
68 print "Could not load experiment %s from database %s " % (expID, expFilePath)
73 expString = 'newExp.loadAnalysis("%s")' % analysisID
75 print "loaded analysis %s" % analysisID
76 expString = "newExp.loadConservation('%s', '%s')" % (conservationID, consDB)
78 print "loaded conservation %s" % conservationID
85 def listExperiments(expFilePath):
88 db = sqlite.connect(expFilePath)
90 sql.execute('select distinct expID, data from settings where settingName = "experimentType" ')
94 for (expID, expType) in data:
95 result.append((str(expID), str(expType)))
97 print "Could not list experiments in database %s " % (expFilePath)