コード例 #1
0
    def save_assembly_from_fasta(self, ctx, params):
        """
        WARNING: has the side effect of moving the file to a temporary staging directory, because the upload
        script for assemblies currently requires a working directory, not a specific file.  It will attempt
        to upload everything in that directory.  This will move the file back to the original location, but
        if you are trying to keep an open file handle or are trying to do things concurrently to that file,
        this will break.  So this method is certainly NOT thread safe on the input file.
        :param params: instance of type "SaveAssemblyParams" (Options
           supported: file / shock_id / ftp_url - mutualy exclusive
           parameters pointing to file content workspace_name - target
           workspace assembly_name - target object name type - should be one
           of 'isolate', 'metagenome', (maybe 'transcriptome')
           min_contig_length - if set and value is greater than 1, this will
           only include sequences with length greater or equal to the
           min_contig_length specified, discarding all other sequences
           taxon_ref         - sets the taxon_ref if present contig_info     
           - map from contig_id to a small structure that can be used to set
           the is_circular and description fields for Assemblies (optional)
           Uploader options not yet supported taxon_reference: The ws
           reference the assembly points to.  (Optional) source: The source
           of the data (Ex: Refseq) date_string: Date (or date range)
           associated with data. (Optional)) -> structure: parameter "file"
           of type "FastaAssemblyFile" -> structure: parameter "path" of
           String, parameter "assembly_name" of String, parameter "shock_id"
           of type "ShockNodeId", parameter "ftp_url" of String, parameter
           "workspace_name" of String, parameter "assembly_name" of String,
           parameter "external_source" of String, parameter
           "external_source_id" of String, parameter "taxon_ref" of String,
           parameter "min_contig_length" of Long, parameter "contig_info" of
           mapping from String to type "ExtraContigInfo" (Structure for
           setting additional Contig information per contig is_circ - flag if
           contig is circular, 0 is false, 1 is true, missing indicates
           unknown description - if set, sets the description of the field in
           the assembly object which may override what was in the fasta file)
           -> structure: parameter "is_circ" of Long, parameter "description"
           of String
        :returns: instance of String
        """
        # ctx is the context object
        # return variables are: ref
        #BEGIN save_assembly_from_fasta

        print('save_assembly_from_fasta -- paramaters = ')
        #pprint(params)

        fta = FastaToAssembly(self.callback_url, self.sharedFolder,
                              self.ws_url)
        assembly_info = fta.import_fasta(ctx, params)
        ref = f'{assembly_info[6]}/{assembly_info[0]}/{assembly_info[4]}'
        print(ref)
        #END save_assembly_from_fasta

        # At some point might do deeper type checking...
        if not isinstance(ref, str):
            raise ValueError('Method save_assembly_from_fasta return value ' +
                             'ref is not type str as required.')
        # return the results
        return [ref]
コード例 #2
0
    def save_assembly_from_fasta(self, ctx, params):
        """
        WARNING: has the side effect of moving the file to a temporary staging directory, because the upload
        script for assemblies currently requires a working directory, not a specific file.  It will attempt
        to upload everything in that directory.  This will move the file back to the original location, but
        if you are trying to keep an open file handle or are trying to do things concurrently to that file,
        this will break.  So this method is certainly NOT thread safe on the input file.
        :param params: instance of type "SaveAssemblyParams" (Options
           supported: file / shock_id / ftp_url - mutualy exclusive
           parameters pointing to file content workspace_name - target
           workspace assembly_name - target object name type - should be one
           of 'isolate', 'metagenome', (maybe 'transcriptome')
           min_contig_length - if set and value is greater than 1, this will
           only include sequences with length greater or equal to the
           min_contig_length specified, discarding all other sequences
           taxon_ref         - sets the taxon_ref if present contig_info     
           - map from contig_id to a small structure that can be used to set
           the is_circular and description fields for Assemblies (optional)
           Uploader options not yet supported taxon_reference: The ws
           reference the assembly points to.  (Optional) source: The source
           of the data (Ex: Refseq) date_string: Date (or date range)
           associated with data. (Optional)) -> structure: parameter "file"
           of type "FastaAssemblyFile" -> structure: parameter "path" of
           String, parameter "assembly_name" of String, parameter "shock_id"
           of type "ShockNodeId", parameter "ftp_url" of String, parameter
           "workspace_name" of String, parameter "assembly_name" of String,
           parameter "external_source" of String, parameter
           "external_source_id" of String, parameter "taxon_ref" of String,
           parameter "min_contig_length" of Long, parameter "contig_info" of
           mapping from String to type "ExtraContigInfo" (Structure for
           setting additional Contig information per contig is_circ - flag if
           contig is circular, 0 is false, 1 is true, missing indicates
           unknown) -> structure: parameter "is_circ" of Long, parameter
           "description" of String
        :returns: instance of String
        """
        # ctx is the context object
        # return variables are: ref
        #BEGIN save_assembly_from_fasta

        print('save_assembly_from_fasta -- paramaters = ')
        pprint(params)

        fta = FastaToAssembly(self.callback_url, self.sharedFolder)
        assembly_info = fta.import_fasta(ctx, params)
        ref = str(assembly_info[6]) + '/' + str(assembly_info[0]) + '/' + str(assembly_info[4])

        #END save_assembly_from_fasta

        # At some point might do deeper type checking...
        if not isinstance(ref, basestring):
            raise ValueError('Method save_assembly_from_fasta return value ' +
                             'ref is not type basestring as required.')
        # return the results
        return [ref]