示例#1
0
    def upload_alignment(self, file_path, reads_upa, assembly_upa,
                         workspace_name, alignment_name):
        if not file_path:
            raise ValueError("file_path must be defined")
        if not os.path.exists(file_path):
            raise ValueError(
                "The given alignment file '{}' does not exist".format(
                    file_path))
        if not reads_upa:
            raise ValueError("The reads UPA must be defined")
        if not assembly_upa:
            raise ValueError("The assembly UPA must be defined")
        if not workspace_name:
            raise ValueError("workspace_name must be defined")
        if not alignment_name:
            raise ValueError("alignment_name must be defined")

        rau = ReadsAlignmentUtils(self.callback_url)
        alignment_upa = rau.upload_alignment({
            "file_path":
            file_path,
            "read_library_ref":
            reads_upa,
            "assembly_or_genome_ref":
            assembly_upa,
            "destination_ref":
            "{}/{}".format(workspace_name, alignment_name),
            "aligned_using":
            "BBMap",
            "condition":
            "new_assembly"
        })["obj_ref"]
        return alignment_upa
示例#2
0
 def save_read_alignment_output(self, run_output_info, input_configuration,
                                validated_params):
     rau = ReadsAlignmentUtils(self.callback_url)
     destination_ref = validated_params[
         'output_workspace'] + '/' + validated_params[
             'output_alignment_name']
     condition = 'unknown'
     if 'condition_label' in validated_params:
         condition = validated_params['condition_label']
     upload_params = {
         'file_path': run_output_info['output_sam_file'],
         'destination_ref': destination_ref,
         'read_library_ref': input_configuration['reads_lib_ref'],
         'assembly_or_genome_ref':
         validated_params['assembly_or_genome_ref'],
         'condition': condition
     }
     upload_results = rau.upload_alignment(upload_params)
     return upload_results
示例#3
0
    def upload_alignment(self, input_params, reads_info, alignment_name,
                         alignment_file):
        """
        Uploads the alignment file + metadata.
        This then returns the expected return dictionary from HISAT2.
        """
        aligner_opts = dict()
        for k in input_params:
            aligner_opts[k] = str(input_params[k])

        align_upload_params = {
            "destination_ref":
            "{}/{}".format(input_params["ws_name"], alignment_name),
            "file_path":
            alignment_file,
            "library_type":
            reads_info["style"],  # single or paired end,
            "condition":
            reads_info["condition"],
            "assembly_or_genome_ref":
            input_params["genome_ref"],
            "read_library_ref":
            reads_info["object_ref"],
            "aligned_using":
            "hisat2",
            "aligner_version":
            HISAT_VERSION,
            "aligner_opts":
            aligner_opts
        }
        if "sampleset_ref" in reads_info:
            align_upload_params["sampleset_ref"] = reads_info["sampleset_ref"]
        print("Uploading completed alignment")
        pprint(align_upload_params)

        ra_util = ReadsAlignmentUtils(self.callback_url, service_ver="dev")
        alignment_ref = ra_util.upload_alignment(
            align_upload_params)["obj_ref"]
        print(
            "Done! New alignment uploaded as object {}".format(alignment_ref))
        return alignment_ref