Commit 3cdeb73c authored by Jerome Mariette's avatar Jerome Mariette

add action attributes to parameters

parent 3a413541
......@@ -19,13 +19,13 @@
# The Typo3 pid where to link datas
pid = 5
# The ng6 work directory
work_dir = /path/to/working/directory
work_dir = /home/jmariett/scratch/ng6/
# The ng6 save directory
save_dir = /path/to/saving/directory
save_dir = /home/jmariett/scratch/ng6/
# The ng6 tmp directory, should be accessible
# from any nodes if running in a cluster
# environment
tmp_dir = /path/to/tmp/directory
tmp_dir = /home/jmariett/scratch/ng6/tmp/
[database]
host = localhost
......@@ -43,6 +43,7 @@ working_directory = /home/jmariett/scratch/weaver
[softwares]
blastall = /usr/bin/blastall
formatdb = /usr/bin/formatdb
fastqc = /home/jmariett/softwares/FastQC/fastqc
[454_mids]
MID1 = ACGAGTGCGT
......
......@@ -41,7 +41,8 @@ if __name__ == '__main__':
for param in instance.parameters:
sub_parser.add_argument(param.flag, type=param.type, help=param.help,
required=param.required, dest=param.name,
metavar=param.metavar.upper(), default=param.default)
metavar=param.metavar, default=param.default,
action=param.action)
sub_parser.set_defaults(cmd_object=instance)
args = vars(parser.parse_args())
......
......@@ -66,11 +66,14 @@ class WorkflowConfigReader(object):
metavar = params[param]["type"]
except:
type = types.StringType
metavar = str
metavar = "str"
try: required = params[param]["required"].lower() in ("yes", "y", "true", "t", "1")
except: required = False
try: action = params[param]["action"]
except: action = "store"
oparam = Parameter(name=name, flag=flag, help=help, default=default,
type=type, required=required, metavar=metavar)
type=type, required=required, metavar=metavar,
action=action)
parameters.append(oparam)
except:
pass
......
......@@ -23,7 +23,7 @@ class Parameter(object):
"""
def __init__(self, name, flag, help, default=None, type=types.StringType, choices=None,
required=False, metavar=None):
required=False, metavar=None, action="store"):
self.name = name
self.flag = flag
self.help = help
......@@ -31,7 +31,8 @@ class Parameter(object):
self.type = type
self.choices = choices
self.required = required
self.metavar = metavar
self.metavar = str(metavar).upper()
self.action = action
def __str__(self):
return self.name + ": " + self.flag + " | " + self.help + " (default=" + \
......
......@@ -32,23 +32,17 @@ description = add a brand new project
[parameters]
name.name = project_name
name.flag = --name
name.type = str
name.help = Give a name to your project (has to be unique)
name.default = None
name.required = True
description.name = project_description
description.flag = --description
description.type = str
description.help = Give a description to your project
description.default = None
description.required = True
admin_login.name = admin_login
admin_login.flag = --admin-login
admin_login.type = str
admin_login.help = Who is the project administrator
admin_login.default = None
admin_login.required = True
#
......
......@@ -34,5 +34,8 @@ class AddRun (Workflow):
my_run = Run(self.args["run_name"], datetime.date(int(run_date[2]), int(run_date[1]), int(run_date[0])),
self.args["species"], self.args["data_nature"], self.args["type"], self.args["run_description"],
self.args["sequencer"])
print self.args["data_file"]
# Then add the run to the project
my_project.add_run(my_run)
......@@ -30,60 +30,51 @@ description = add a brand new run to a project
# .required: whether or not the command-line option may be omitted
#
[parameters]
data_file.name = data_file
data_file.flag = --data-file
data_file.help = Which data files are linked to the run (if multiple, the option should be called as many times as files to add)
data_file.required = True
data_file.action = append
project_id.name = project_id
project_id.flag = --project-id
project_id.type = str
project_id.help = The project id the run belongs to
project_id.default = None
project_id.type = int
project_id.required = True
run_name.name = run_name
run_name.flag = --name
run_name.type = str
run_name.help = Give a name to your run
run_name.default = None
run_name.required = True
run_description.name = run_description
run_description.flag = --description
run_description.type = str
run_description.help = Give a description to your run
run_description.default = None
run_description.required = True
run_date.name = run_date
run_date.flag = --date
run_date.type = str
run_date.help = When were the data produced
run_date.default = None
run_date.required = True
data_nature.name = data_nature
data_nature.flag = --data-nature
data_nature.type = str
data_nature.help = Are Sequences cDNA, genomique, RNA, ...
data_nature.default = None
data_nature.required = True
sequencer.name = sequencer
sequencer.flag = --sequencer
sequencer.type = str
sequencer.help = Which sequencer produced the data
sequencer.default = None
sequencer.required = True
species.name = species
species.flag = --species
species.type = str
species.help = Which species has been sequenced
species.default = None
species.required = True
type.name = type
type.flag = --type
type.type = str
type.help = What type of data is it (1 lane, 1 region)
type.default = None
type.required = True
#
......
......@@ -15,14 +15,31 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import datetime
from jflow.workflow import Workflow
from ng6.project import Project
from ng6.run import Run
class IlluminaFastq (Workflow):
def run(self):
"""
Run the workflow
"""
print "sdsd"
# Build the project and the run
my_project = Project.get_from_id(self.args["project_id"])
run_date = self.args["run_date"].split("/")
my_run = Run(self.args["run_name"], datetime.date(int(run_date[2]), int(run_date[1]), int(run_date[0])),
self.args["species"], self.args["data_nature"], self.args["type"], self.args["run_description"],
self.args["sequencer"])
# If it's a run with some index, let's write down description
if self.args["index_description"]:
mids_desc_array = {}
for mids_desc in self.args["index_description"].split(";"):
parts = mids_desc.split(":")
mids_desc_array[parts[0]] = parts[1]
my_run.add_mids_description(mids_desc_array)
# Then add the run to the project
my_project.add_run(my_run)
fastqc = self.add_component("FastQC", [self.args["contigs_file"]])
\ No newline at end of file
#
# Copyright (C) 2009 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/>.
#
__author__ = 'Plateforme bioinformatique Midi Pyrenees'
__copyright__ = 'Copyright (C) 2009 INRA'
__license__ = 'GNU General Public License'
__version__ = '1.0'
__email__ = 'support.genopole@toulouse.inra.fr'
__status__ = 'beta'
from optparse import *
import os, sys, re, datetime
from shutil import copyfile
from ng6.Project import Project
from ng6.Run import Run
if __name__ == '__main__':
parser = OptionParser(usage="Usage: %prog", description = "Add a run to ng6.")
# Define input options
igroup = OptionGroup(parser, "Input options","")
igroup.add_option("-a", "--date", help="The run date in dd/mm/yyyy format.", dest="date", type="string")
igroup.add_option("-g", "--admin-login", help="The project administrator login.", dest="admin_login", type="string")
igroup.add_option("-d", "--description", help="Run description.", dest="description", type="string")
igroup.add_option("-e", "--name", help="The run name.", dest="name", type="string")
igroup.add_option("-n", "--data_nature", help="The nature of the data.", dest="data_nature", type="string")
igroup.add_option("-p", "--project-description", help="The project description the run belongs to.", dest="project_description", type="string")
igroup.add_option("-q", "--sequencer", help="The sequencer name used.", dest="sequencer", type="string")
igroup.add_option("-r", "--project-name", help="The project name the run belongs to.", dest="project_name", type="string")
igroup.add_option("-s", "--species", help="The species used for this run.", dest="species", type="string")
igroup.add_option("-t", "--type", help="The type of run done.", dest="type", type="string")
igroup.add_option("-x", "--index-description", help="The index description.", dest="index_description", type="string")
parser.add_option_group(igroup)
# Define output options
ogroup = OptionGroup(parser, "Output options","")
ogroup.add_option("-c", "--cfg", help="Where the cfg file should be write down.", dest="cfg", metavar="FILE")
parser.add_option_group(ogroup)
(options, args) = parser.parse_args()
if options.date == None :
parser.print_help()
sys.exit(1)
else :
# Create a project and run object
my_project = Project(options.project_name, options.project_description, options.admin_login)
run_date = options.date.split("/")
my_run = Run(options.name, datetime.date(int(run_date[2]), int(run_date[1]), int(run_date[0])),
options.species, options.data_nature, options.type, options.description, options.sequencer)
# If it's a run with some index, let's write down description
if options.index_description:
mids_desc_array = {}
for mids_desc in options.index_description.split(";"):
parts = mids_desc.split(":")
mids_desc_array[parts[0]] = parts[1]
my_run.add_mids_description(mids_desc_array)
# Then add the run to the project
my_project.add_run(my_run)
# Finaly copy the config file where it is asked to
copyfile(my_run.get_config_file(), options.cfg)
sys.exit(0)
\ 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 jflow.component import Component
from weaver.function import PythonFunction, ShellFunction
from weaver.abstraction import Merge, Map
class FastQC (Component):
def define_parameters(self, input_files):
self.input_files = input_files
self.nb_seq_per_file = nb_seq_per_file
self.renamed_seq_file = os.path.join(self.output_directory, get_file_base(input_file) + ".numeric_ids.fasta")
def run(self):
# first define if files are casava outputed files
casava_regexp = '.+\/([^\/]+_[^\/]+_L\d+_R\d)_\d+\.fastq\.gz'
casava_opts = ""
for file in self.input_files:
if re.search(casava_regexp, file):
casava_opts = "--casava"
break
fastqc = ShellFunction(self.get_exec_path("fastqc") + " --outdir " + self.output_directory + " " + casava_opts + " " +
self.blast_options + " | " + self.get_exec_path("annot_blast2dump.pl") + " -g -s '" +
self.species + "'" + " -b " + self.db_name + " -a __ID__ - $2" , cmd_format='{EXE} {IN} {OUT}')
fastqc = Map(fastqc, self.input_files, self.dumps)
......@@ -30,12 +30,52 @@ description = illumina quality check without reference genome
# .required: whether or not the command-line option may be omitted
#
[parameters]
contigs_file.name = contigs_file
contigs_file.flag = --contigs-fasta
contigs_file.type = str
contigs_file.help = The fasta contigs file path
contigs_file.default = None
contigs_file.required = True
project_id.name = project_id
project_id.flag = --project-id
project_id.type = int
project_id.help = The project id the run belongs to
project_id.default = None
project_id.required = True
run_name.name = run_name
run_name.flag = --name
run_name.help = Give a name to your run
run_name.required = True
run_description.name = run_description
run_description.flag = --description
run_description.help = Give a description to your run
run_description.required = True
run_date.name = run_date
run_date.flag = --date
run_date.help = When were the data produced
run_date.required = True
data_nature.name = data_nature
data_nature.flag = --data-nature
data_nature.help = Are Sequences cDNA, genomique, RNA, ...
data_nature.required = True
sequencer.name = sequencer
sequencer.flag = --sequencer
sequencer.help = Which sequencer produced the data
sequencer.required = True
species.name = species
species.flag = --species
species.help = Which species has been sequenced
species.required = True
type.name = type
type.flag = --type
type.help = What type of data is it (1 lane, 1 region)
type.required = True
index_description.name = index_description
index_description.flag = --index-description
index_description.help = Which description is link to which index
index_description.required = False
#
# Bellow workflow specifc sections
......
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