Commit edd143bc authored by Jerome Mariette's avatar Jerome Mariette
Browse files

No commit message

No commit message
parent 97b3b8a6
......@@ -27,50 +27,12 @@ from weaver.function import ShellFunction
from weaver.abstraction import Map
class SFFExtract (Analysis):
class SFFextract (Component):
def define_parameters(self, input_files, archive_name=None):
def define_parameters(self, input_files):
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}')
......
#
# 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])
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