erange 4.0a dev release with integrated cistematic
[erange.git] / cistematic / programs / __init__.py
1 ###########################################################################
2 #                                                                         #
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                                 #
6 #                                                                         #
7 #    All Rights Reserved.                                                 #
8 #                                                                         #
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:                                    #
16 #                                                                         #
17 # The above copyright notice and this permission notice shall be          #
18 # included in all copies or substantial portions of the Software.         #
19 #                                                                         #
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        #
27 # SOFTWARE.                                                               #
28 ###########################################################################
29 #
30 __all__ = ["meme", "locator","mafft", "paircomp", "cisGreedy", "gibbs"]
31
32 from os import environ
33
34 supportedPrograms = [("locator" ,"Locator", {"consensus": "",
35                                              "identifier": ""}),
36                      ("meme" ,"Meme", {"model": "zoops",
37                                        "nmotifs": 10,
38                                        "maxwidth": 16}),
39                      ("cisGreedy", "CisGreedy", {"model": "zoops",
40                                                  "nmotifs": 10,
41                                                  "maxwidth": 16,
42                                                  "minwidth": 6,
43                                                  "reverse": True,
44                                                  "background": "None",
45                                                  "iterations": 100,
46                                                  "founder": False,
47                                                  "percentID": 75,
48                                                  "Markov size": 3}),
49                      ("gibbs", "Gibbs", {"model": "zoops",
50                                          "nmotifs": 10,
51                                          "maxwidth":16,
52                                          "minwidth": 6,
53                                          "reverse": True,
54                                          "background": "None",
55                                          "percentID": 50,
56                                          "Markov size": 3,
57                                          "iterations": 100})
58 ]
59
60
61 class Program:
62     """ Program is the Super class for all of the programs supported by cistematic and 
63         that are typically called by other classes in cistematic, such as the Experiments.
64         Children will overide the methods that they need to instantiate. 
65     """
66     if environ.get("CISTEMATIC_ROOT"):
67         programRoot = "%s/programs" % environ.get("CISTEMATIC_ROOT")
68     else:
69         programRoot = "/proj/genome/programs"
70
71     contents = ""
72     tagID = ""
73
74     def __init__(self, tagID="", inputFilePath="", outputFilePath=""):
75         self.tagID = ""
76         self.inputFilePath = inputFilePath
77         self.outputFilePath = outputFilePath
78
79
80     def setTagID(self, tid):
81         self.tagID = tid
82
83
84     def name(self):
85         return self.__class__.__name__
86
87
88     def inputFile(self, inputFilePath):
89         self.inputFilePath = inputFilePath
90
91
92     def outputFile(self, outputFilePath):
93         self.outputFilePath = outputFilePath
94
95
96     def setSeqLength(self, length):
97         pass
98
99
100     def setGenome(self, genome):
101         pass
102
103
104     def setGenExpOptions(self, optionArray):
105         pass
106
107
108     def run(self):
109         pass
110
111
112     def display(self):
113         for line in self.contents:
114             print line
115
116
117     def load(self, inFilePath):
118         inFile = open(inFilePath, "r")
119         self.contents = inFile.readlines()
120         inFile.close()
121
122
123     def save(self):
124         outFile = open(self.outputFilePath, "w")
125         for line in self.contents:
126             outFile.write(line)
127
128         outFile.close()