当前位置: 首页>>代码示例>>Python>>正文


Python CharonSession.post方法代码示例

本文整理汇总了Python中ngi_pipeline.database.classes.CharonSession.post方法的典型用法代码示例。如果您正苦于以下问题:Python CharonSession.post方法的具体用法?Python CharonSession.post怎么用?Python CharonSession.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ngi_pipeline.database.classes.CharonSession的用法示例。


在下文中一共展示了CharonSession.post方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestCommunicate

# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import post [as 别名]
class TestCommunicate(unittest.TestCase):

    def setUp(self):
        # Create the test project
        self.project_id = "P100000"
        self.project_name = "P.Mayhem_14_01"
        self.project_data = dict(projectid=self.project_id, name=self.project_name, status=None)
        self.session = CharonSession()
        response = self.session.post(self.session.construct_charon_url('project'),
                                     data=json.dumps(self.project_data))
        assert response.status_code == 201, "Could not create test project in Charon: {}".format(response.reason)
        project = response.json()
        assert project['projectid'] == self.project_id, "Test project ID is incorrect"


    def tearDown(self):
        # Remove the test project
        response = self.session.delete(self.session.construct_charon_url('project', self.project_id))
        assert response.status_code == 204, "Could not delete test project from Charon: {}".format(response.reason)


    def test_get_project_id_from_name(self):
        # Check that it matches
        self.assertEqual(self.project_id, get_project_id_from_name(self.project_name))

    def test_rebuild_project_obj_from_charon(self):
        # Create fake project / sample / libprep / seqrun
        pass
开发者ID:Galithil,项目名称:ngi_pipeline,代码行数:30,代码来源:test_communicate.py

示例2: main

# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import post [as 别名]
def main(args):
    originalProject = {}
    originalProject["fc_dir"] = "/proj/a2010002/INBOX/140702_D00415_0052_AC41A2ANXX/"
    originalProject["fc_name"] = "140702_D00415_0052_AC41A2ANXX"
    originalProject["fc_id"] = "C41A2ANXX"
    originalProject["project_name"] = "M.Kaller_14_06"
    originalProject["project_name_ill"] = "M__Kaller_14_06"
    originalProject["project_id"] = "P1171"
    originalProject["samples_id"] = ["102", "104", "106", "108"]

    ##create random
    rnd_fc_id_noplate = id_generator_digits_chars(9)
    rnd_fc_id = "A{}".format(rnd_fc_id_noplate)
    rnd_instrument = id_generator_digits_chars(6)
    rnd_date = id_generator_digits(6)
    rnd_fc_name = "{}_{}_{}_{}".format(rnd_date, rnd_instrument, id_generator_digits(4), rnd_fc_id)

    rnd_fc_path = os.path.join(data_folder, rnd_fc_name)
    if os.path.isdir(rnd_fc_path):
        print "flowcell name already exists: bad luck!!!! Abort"
        return 1
    rnd_project_name = args.rnd_project_name
    if args.rnd_project_name is "":
        print "error project-name must be specified (something like M.Kaller_14_06)"
        return 1

    charon_session = CharonSession()

    rndProject = {}
    try:
        rnd_project_id = get_project_id_from_name(rnd_project_name)
        rndProject["project_id"] = rnd_project_id
        rndProject["project_name"] = rnd_project_name
    except (RuntimeError, ValueError) as e:
        print " project does not exits on Charon, creating it"
        rnd_project_id = "P{}".format(id_generator_digits(4))
        rndProject["project_id"] = rnd_project_id
        rndProject["project_name"] = rnd_project_name

        base_url = charon_session.construct_charon_url("project")
        project_dict = {
            "projectid": rndProject["project_id"],
            "name": rndProject["project_name"],
            "status": "SEQUENCED",
            "pipeline": "NGI",
            "best_practice_analysis": "IGN",
            "sequencing_facility": "NGI-S",
        }
        # create the project on charon
        charon_session.post(base_url, json.dumps(project_dict))

    rndProject["fc_dir"] = rnd_fc_path
    rndProject["fc_name"] = rnd_fc_name
    rndProject["fc_id"] = rnd_fc_id

    rndProject["project_name_ill"] = rnd_project_name.replace(".", "__")

    rndProject["samples_id"] = [
        "{}".format(id_generator_digits(3)),
        "{}".format(id_generator_digits(3)),
        "{}".format(id_generator_digits(3)),
        "{}".format(id_generator_digits(3)),
    ]
    if args.restrict_to_sample is not "":
        originalProject["samples_id"] = [args.restrict_to_sample]
        rndProject["samples_id"] = ["{}".format(id_generator_digits(3))]

    # TODO: check that this project does not already exists on charon
    os.mkdir(rnd_fc_path)
    # parse SampleSheet_16bp.csv
    parse_sample_sheet("SampleSheet_16bp.csv", originalProject, rndProject)
    # parse SampleSheet.csv
    parse_sample_sheet("SampleSheet.csv", originalProject, rndProject)

    createDir(rndProject["fc_dir"], "Data")
    createDir(rndProject["fc_dir"], "InterOp")

    # Unaligned
    createDir(rndProject["fc_dir"], "Unaligned")
    Unaligned_dir = os.path.join(rndProject["fc_dir"], "Unaligned")
    BaseCall_stats_dir = "Basecall_Stats_{}".format(rndProject["fc_id"])
    createDir(Unaligned_dir, BaseCall_stats_dir)
    # I do not need to copy the file... I hope as it is madness parse them

    # Unaligned_16bp
    createDir(rndProject["fc_dir"], "Unaligned_16bp")
    Unaligned_path = os.path.join(rndProject["fc_dir"], "Unaligned_16bp")
    BaseCall_stats_dir = "Basecall_Stats_{}".format(rndProject["fc_id"])
    createDir(Unaligned_path, BaseCall_stats_dir)
    Project_dir = "Project_{}".format(rndProject["project_name_ill"])
    createDir(Unaligned_path, Project_dir)
    # need to create samples now
    Project_path = os.path.join(Unaligned_path, Project_dir)
    rndSamplePos = 0

    for originalSample in originalProject["samples_id"]:
        rndSample = rndProject["samples_id"][rndSamplePos]
        sample_dir = "Sample_{}_{}".format(rndProject["project_id"], rndSample)
        createDir(Project_path, sample_dir)
        Sample_path = os.path.join(Project_path, sample_dir)
#.........这里部分代码省略.........
开发者ID:Hammarn,项目名称:ngi_pipeline,代码行数:103,代码来源:create_flowcell_from_existing_one.py


注:本文中的ngi_pipeline.database.classes.CharonSession.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。