annotate commons/pyRepetUnit/hmmer/check/OldDetectFeatureConfigChecker.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 '''
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2 Created on 14 avr. 2009
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 @author: oinizan
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 '''
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 import re
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 from commons.core.checker.IChecker import IChecker
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8 from commons.core.checker.OldConfigChecker import ConfigChecker
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 from commons.core.checker.ConfigException import ConfigException
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 from commons.core.checker.CheckerException import CheckerException
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 class DetectFeatureConfigChecker (IChecker):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 '''
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 classdocs
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 '''
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 def __init__(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 '''
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 Constructor
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 '''
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 self._dict = {"te_hmmer" : "",
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 "te_blrn" : ""
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 }
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 self._specifiqueDict = {"te_hmmer_evalue" : "",
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 "te_hmm_profiles" : ""
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 }
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 def _appendMessageToConfigExceptionMessage(self, messages):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 appendedMessages = []
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 for msg in messages:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 if (re.match("\[detect_features\] - No option 'te_hmm_profiles' in section: 'detect_features'", msg)):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 appendedMessages.append(msg + " whereas te_hmmer is set")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 if (re.match("\[detect_features\] - No option 'te_hmmer_evalue' in section: 'detect_features'", msg)):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 appendedMessages.append(msg + " whereas te_hmmer is set - Default value will be set")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 return appendedMessages
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 def check(self, configFile):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 chk = ConfigChecker("detect_features", self._dict)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 try :
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 chk.check(configFile)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 except ConfigException, e :
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 raise e
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 if self._dict["te_hmmer"] == "yes":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 isErrorOccured = False
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 chk = ConfigChecker("detect_features", self._specifiqueDict)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 chk.check(configFile)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 except ConfigException, e:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 appendedMessages = self._appendMessageToConfigExceptionMessage(e.messages)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 raise ConfigException("", appendedMessages)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 pass