Commit e94c764a authored by Jerome Mariette's avatar Jerome Mariette

addproject addrun as normal pipelines

parent 6e541a44
......@@ -17,7 +17,6 @@
import sys
import argparse
import datetime
try:
import _preamble
......@@ -26,45 +25,13 @@ except ImportError:
from jflow.workflows_manager import WorkflowsManager
from jflow.workflow import Workflow
from ng6.project import Project
from ng6.run import Run
if __name__ == '__main__':
# Create the top-level parser
parser = argparse.ArgumentParser(prog='ng6')
subparsers = parser.add_subparsers(title='Available pipelines')
# Add project menu
sub_parser = subparsers.add_parser("addproject", help="Add a brand new project")
sub_parser.add_argument("--name", type=str, help="Give a name to your project (has to be unique)",
required=True, dest="project_name", metavar="STR")
sub_parser.add_argument("--description", type=str, help="Give a description to your project",
required=True, dest="project_description", metavar="STR")
sub_parser.add_argument("--admin-login", type=str, help="Who is the project administrator",
required=True, dest="admin_login", metavar="STR")
sub_parser.set_defaults(cmd_object="addproject")
# Add run menu
sub_parser = subparsers.add_parser("addrun", help="Add a brand new run to a project")
sub_parser.add_argument("--project-id", type=str, help="The project id the run belongs to",
required=True, dest="project_id", metavar="STR")
sub_parser.add_argument("--name", type=str, help="Give a name to your run",
required=True, dest="run_name", metavar="STR")
sub_parser.add_argument("--description", type=str, help="Give a description to your run",
required=True, dest="run_description", metavar="STR")
sub_parser.add_argument("--date", type=str, help="When were the data produced",
required=True, dest="run_date", metavar="STR")
sub_parser.add_argument("--data-nature", type=str, help="Sequences are cDNA, genomique, RNA, ...",
required=True, dest="data_nature", metavar="STR")
sub_parser.add_argument("--sequencer", type=str, help="Which sequencer produced the data",
required=True, choices=Run.SEQUENCERS, dest="sequencer", metavar="STR")
sub_parser.add_argument("--species", type=str, help="Which species was sequenced",
required=True, dest="species", metavar="STR")
sub_parser.add_argument("--type", type=str, help="What type of data is it (1 lane, 1 region)",
required=True, dest="type", metavar="STR")
sub_parser.set_defaults(cmd_object="addrun")
subparsers = parser.add_subparsers(title='Available sub commands')
# Add available pipelines
wf_instances = WorkflowsManager.get_workflows()
......@@ -83,20 +50,4 @@ if __name__ == '__main__':
args["cmd_object"].execute(args)
#except (IOError, NameError), e:
# sys.exit("Error: " + str(e))
elif args["cmd_object"] == "addproject":
try:
my_project = Project(args["project_name"], args["project_description"], args["admin_login"])
except NameError, e:
sys.exit("Error: " + str(e))
elif args["cmd_object"] == "addrun":
try:
# Build the project and the run
my_project = Project.get_from_id(args["project_id"])
run_date = args["run_date"].split("/")
my_run = Run(args["run_name"], datetime.date(int(run_date[2]), int(run_date[1]), int(run_date[0])),
args["species"], args["data_nature"], args["type"], args["run_description"], args["sequencer"])
# Then add the run to the project
my_project.add_run(my_run)
except NameError, e:
sys.exit("Error: " + str(e))
\ 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/>.
#
from jflow.workflow import Workflow
from ng6.project import Project
class AddProject (Workflow):
def run(self):
"""
Run the workflow
"""
my_project = Project(self.args["project_name"], self.args["project_description"], self.args["admin_login"])
#
# 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/>.
#
[global]
name = addproject
description = add a brand new project
#
# Parameter section
# param.name: the parameter display name
# .option: the parameter argument
# .help: a brief description of what the parameter does
# .default: the value produced if the parameter is not provided
# .type: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices: a container of the allowable values for the parameter
# .required: whether or not the command-line option may be omitted
#
[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
#
# Bellow workflow specifc sections
#
\ 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 datetime
from jflow.workflow import Workflow
from ng6.project import Project
from ng6.run import Run
class AddRun (Workflow):
def run(self):
"""
Run the workflow
"""
# 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"])
# Then add the run to the project
my_project.add_run(my_run)
#
# 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/>.
#
[global]
name = addrun
description = add a brand new run to a project
#
# Parameter section
# param.name: the parameter display name
# .option: the parameter argument
# .help: a brief description of what the parameter does
# .default: the value produced if the parameter is not provided
# .type: the parameter type that should be tested (str|int|file|long|bool|...)
# .choices: a container of the allowable values for the parameter
# .required: whether or not the command-line option may be omitted
#
[parameters]
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.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
#
# Bellow workflow specifc sections
#
\ 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