Beispiel #1
0
    def upload_STARalignment(self, input_params, reads_ref, reads_info, output_bam_file):
        """
        Uploads the alignment file + metadata.
        Returns the STAR alignment reference.
        """

        aligner_opts = dict()
        for k in input_params:
            aligner_opts[k] = str(input_params[k])
        pprint(reads_info)

        alignment_name = reads_ref['alignment_output_name']
        align_upload_params = {
            "destination_ref": "{}/{}".format(input_params[self.PARAM_IN_WS], alignment_name),
            "file_path": output_bam_file,
            "assembly_or_genome_ref": input_params[self.PARAM_IN_GENOME],
            "read_library_ref": reads_info['object_ref'],
            "library_type": reads_info['style'],
            "condition": reads_info['condition'],
            "aligned_using": 'STAR',
            "aligner_version":self.STAR_VERSION,
            "aligner_opts": aligner_opts
        }

        pprint(align_upload_params)

        ra_util = ReadsAlignmentUtils(self.callback_url, service_ver='beta')
        rau_upload_ret = ra_util.upload_alignment(align_upload_params)
        alignment_ref = rau_upload_ret["obj_ref"]
        print("STAR alignment uploaded as object {}".format(alignment_ref))
        return rau_upload_ret
 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
Beispiel #3
0
 def load_bam_file(self, file_path, genome_ref, reads_ref, obj_name):
     rau = ReadsAlignmentUtils(self.callback_url, service_ver='dev')
     return rau.upload_alignment({
         "destination_ref":
         "{}/{}".format(self.ws_name, obj_name),
         "file_path":
         file_path,
         "read_library_ref":
         reads_ref,
         "assembly_or_genome_ref":
         genome_ref,
         "condition":
         "none"
     })["obj_ref"]
Beispiel #4
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
Beispiel #5
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