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 ###########################################################################
30 # a simple use of the experiment class
31 from experiment import Experiment
32 from analyzeMotifs import AnalyzeMotifs
33 from conservation import Conservation
35 from cistematic.core.homology import homologyDB
37 class PhyloTest(Experiment, AnalyzeMotifs, Conservation, Draw):
38 experimentType = "phyloTest"
40 useConservation = True
43 def initialize(self, sGenome="", rGenes=[], tGenomes=[], analysisDB="", conservationDB="", maskNonConserved=True):
46 self.createAnalysis(dbName=analysisDB)
47 self.createConservation(dbName=conservationDB)
52 sGenome = self.startingGenome
54 self.startingGenome = sGenome
57 rGenes = self.refGenes
59 self.refGenes = rGenes
61 if len(tGenomes) == 0:
62 tGenomes = self.targetGenomes
64 self.targetGenomes = tGenomes
66 self.useConservation = maskNonConserved
67 self.phyloTestMap[sGenome] = []
69 self.phyloTestMap[sGenome].append((sGenome, gene))
71 for genome in self.targetGenomes:
72 self.phyloTestMap[genome] = []
74 self.targetGenomes.append(sGenome)
77 wholeDataset.append((sGenome, [gene]))
78 hGenes = self.returnHomologs((sGenome, gene))
79 for oneGene in hGenes:
80 wholeDataset.append((oneGene[0], [oneGene[1]]))
81 self.phyloTestMap[oneGene[0]].append(oneGene)
83 self.mlog("could not load from homology for (%s,%s,%s)" % (sGenome, str(rGenes), str(tGenomes)))
85 Experiment.initialize(self, wholeDataset)
89 for genome in self.targetGenomes:
90 dset = self.phyloTestMap[genome]
91 datasetID = self.setSettingsID("dataset-%s" % genome, dset)
92 if self.useConservation:
93 fastaFile = self.createDataFile(datasetID, geneDict = self.maskNonConservedSequence(datasetID))
95 fastaFile = self.createDataFile(datasetID)
97 for (prog, settingsID) in self.programs:
98 prog.inputFile(fastaFile)
99 runID = self.setRun(prog.name(), datasetID, settingsID)
103 theMotifs = prog.getMotifs()
104 for mot in theMotifs:
105 self.appendResults(mot)