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 # The locate class allows mapping of known motifs to sequences or genomes
31 # should only be used with the Locator program, for now
32 from experiment import Experiment
33 from analyzeMotifs import AnalyzeMotifs
34 from cistematic.core import getChromosomeNames, readChromosome
36 class Locate(Experiment, AnalyzeMotifs):
37 experimentType = "locate"
40 def getChromosomeList(self, genome, partition=1, slice=0, db=""):
41 """ return a list of the chromosomes available for a given genome.
45 chromList = getChromosomeNames(genome, db, partition, slice)
49 for entry in chromList:
50 result.append((genome, entry))
55 def initialize(self, listType, compoundList):
56 """ must initialize with listType='chromosome' in order to scan chromosomes
60 if listType == "chromosome":
61 for (genome, chromName) in compoundList:
62 self.genepool[(genome, chromName)] = readChromosome(genome, chromName)
63 genepoolKeys.append("%s\t%s" % (genome, chromName))
65 self.genepoolID = self.setSettings("chromolist", genepoolKeys)
67 Experiment.initialize(self, compoundList)
72 datasetID = self.genepoolID
73 for (prog, settingsID) in self.programs:
75 if prog.name() == "Locator":
76 (settingName, settingData) = self.getSettingsID(settingsID)
77 prog.setSettings(settingData)
78 runID = self.setRun(prog.name(), datasetID, settingsID)
82 theMotifs = prog.getMotifs()
84 self.appendResults(mot)
86 self.mlog("Can only run Locate experiment with Locator program")
88 self.mlog("Error running program %s with settings %s" % (prog, settingsID))