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 Orthology(Experiment, AnalyzeMotifs, Conservation, Draw):
38 experimentType = "orthology"
39 useConservation = False
42 def initialize(self, sGenome="", rGenes=[], tGenomes=[], analysisDB="", conservationDB="", maskNonConserved=True):
45 self.createAnalysis(dbName=analysisDB)
46 if self.consDBName == "":
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
69 wholeDataset.append((sGenome, [gene]))
70 hGenes = self.returnHomologs((sGenome, gene))
71 for oneGene in hGenes:
72 wholeDataset.append((oneGene[0], [oneGene[1]]))
74 self.mlog("could not load homologs for (%s,%s,%s)" % (sGenome, str(rGenes), (tGenomes)))
76 Experiment.initialize(self, wholeDataset)
80 for gene in self.refGenes:
81 dset = self.returnHomologs((self.startingGenome, gene))
82 dset.append((self.startingGenome, gene))
84 datasetID = self.genepoolID
85 if self.checkForConservedSequence():
86 fastaFile = self.createDataFile(geneDict = self.maskNonConservedSequence())
87 for (prog, settingsID) in self.programs:
88 prog.inputFile(fastaFile)
89 runID = self.setRun(prog.name(), datasetID, settingsID)
93 theMotifs = prog.getMotifs()
95 self.appendResults(mot)
96 elif self.useConservation == False:
97 fastaFile = self.createDataFile()
98 for (prog, settingsID) in self.programs:
99 prog.inputFile(fastaFile)
100 runID = self.setRun(prog.name(), datasetID, settingsID)
104 theMotifs = prog.getMotifs()
105 for mot in theMotifs:
106 self.appendResults(mot)
108 self.mlog("no conserved sequences to run motif finder on")