Commit d3676bc7 authored by Jerome Mariette's avatar Jerome Mariette

allow to config the cherrypy server

parent adf66792
......@@ -14,12 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[grid]
[global]
makeflow = /usr/bin/makeflow
# batch system type: local, condor, sge, moab, cluster, wq, hadoop, mpi-queue
batch_system_type = local
# add these options to all batch submit files
batch_options =
# on which socket host should run the web server
server_socket_host = 127.0.0.1
# on which socket port should run the web server
server_socket_port = 8080
[database]
host = localhost
......
......@@ -29,6 +29,7 @@ except ImportError:
sys.exc_clear()
from jflow.workflows_manager import WorkflowsManager
from jflow.config_reader import JFlowConfigReader
from jflow.workflow import Workflow
import jflow.utils as utils
from cctools.util import time_format
......@@ -159,7 +160,11 @@ if __name__ == '__main__':
if args["daemon"]:
from cherrypy.process.plugins import Daemonizer
Daemonizer(cherrypy.engine).subscribe()
# define the socket host and port
jflowconf = JFlowConfigReader()
socket_opts = jflowconf.get_socket_options()
cherrypy.config.update({'server.socket_host': socket_opts[0],
'server.socket_port': socket_opts[1]})
# start the server
cherrypy.quickstart(JFlowServer())
\ No newline at end of file
......@@ -57,18 +57,24 @@ class JFlowConfigReader(object):
def get_makeflow_path(self):
try:
return self.reader.get("grid", "makeflow")
return self.reader.get("global", "makeflow")
except NoOptionError, e:
return None
def get_batch(self):
try:
type = self.reader.get("grid", "batch_system_type")
options = self.reader.get("grid", "batch_options")
type = self.reader.get("global", "batch_system_type")
options = self.reader.get("global", "batch_options")
return [type, options]
except NoOptionError, e:
return None
def get_socket_options(self):
try:
return [self.reader.get("global", "server_socket_host"), self.reader.get("global", "server_socket_port")]
except:
return ["127.0.0.1", "8080"]
def get_component_batch_options(self, component_class):
try:
return self.reader.get("components", component_class+".batch_options")
......
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
from subprocess import Popen, PIPE
from jflow.component import Component
from jflow.iotypes import OutputFileList, InputFileList, Formats
from jflow.abstraction import MultiMap
from ng6.analysis import Analysis
from weaver.function import ShellFunction
from weaver.abstraction import Map
class SFFExtract (Analysis):
def define_parameters(self, input_files, archive_name=None):
self.input_files = InputFileList(input_files, Formats.SFF)
self.archive_name = archive_name
self.fastq_files = OutputFileList(self.get_outputs('{basename_woext}.fastq', self.input_files), Formats.FASTQ)
self.stdouts = OutputFileList(self.get_outputs('{basename_woext}.stdout', self.input_files))
def define_analysis(self):
self.name = "Convert"
self.description = "Convert sff file in fastq format."
self.software = "sff_extract.py"
self.options = "-c"
def post_process(self):
import re
extract_regex = re.compile("Converted (.*) reads into (.*) sequences.")
clips_regexp = re.compile("After applying left clips, (.*) sequences \(=(.*)%\) start with these bases:")
for stdout in self.stdouts:
found = False
nb_reads, nb_seq, cliped, perc_cliped, seq_cliped = 0, 0, 0, 0, ""
for line in open(stdout).readlines():
mr = extract_regex.match(line)
cr = clips_regexp.match(line)
if found:
seq_cliped = line.strip()
found = False
if mr != None:
nb_reads, nb_seq = mr.group(1), mr.group(2)
if cr != None:
cliped, perc_cliped = cr.group(1), cr.group(2)
found = True
self._add_result_element(os.path.basename(stdout), "nb_reads", nb_reads)
self._add_result_element(os.path.basename(stdout), "nb_seq", nb_seq)
self._add_result_element(os.path.basename(stdout), "cliped", cliped)
self._add_result_element(os.path.basename(stdout), "perc_cliped", perc_cliped)
self._add_result_element(os.path.basename(stdout), "seq_cliped", seq_cliped)
self._create_and_archive(self.fastq_files, self.archive_name)
def get_version(self):
cmd = [self.get_exec_path("sff_extract.py"), "--version"]
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
return stdout.split()[1]
def process(self):
sff_extract = ShellFunction(self.get_exec_path("sff_extract.py") + " -c $1 -s $2 > $3", cmd_format='{EXE} {IN} {OUT}')
sff_extract = MultiMap(sff_extract, self.input_files, [self.fastq_files, self.stdouts])
\ No newline at end of file
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
from subprocess import Popen, PIPE
from jflow.component import Component
from jflow.iotypes import OutputFileList, InputFileList, Formats
from jflow.abstraction import MultiMap
from ng6.analysis import Analysis
from weaver.function import ShellFunction
from weaver.abstraction import Map
class SFFextract (Component):
def define_parameters(self, input_files):
self.input_files = InputFileList(input_files, Formats.SFF)
self.fastq_files = OutputFileList(self.get_outputs('{basename_woext}.fastq', self.input_files), Formats.FASTQ)
self.stdouts = OutputFileList(self.get_outputs('{basename_woext}.stdout', self.input_files))
def process(self):
sff_extract = ShellFunction(self.get_exec_path("sff_extract.py") + " -c $1 -s $2 > $3", cmd_format='{EXE} {IN} {OUT}')
sff_extract = MultiMap(sff_extract, self.input_files, [self.fastq_files, self.stdouts])
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment