lib/Variation_Viewer/Variation_ViewerImpl.py
def run_Variation_Viewer(self, ctx, params):
        """
        This example function accepts any number of parameters and returns results in a KBaseReport
        :param params: instance of type "InputParams" -> structure: parameter
           "vcf_ref" of String, parameter "workspace_name" of String,
           parameter "genome_or_assembly_ref" of String
        :returns: instance of type "ReportResults" -> structure: parameter
           "report_name" of String, parameter "report_ref" of String
        """

        # ctx is the context object
        # return variables are: output
        #BEGIN run_Variation_Viewer
        workspace = params['workspace_name']
        self.vu.validate_params(params)
        outputdir = self.shared_folder + '/' + str(uuid.uuid1())
        os.mkdir(outputdir)

        logging.info("Downlading assembly ...")

        self.ws_url = self.config['workspace-url']
        self.ws = Workspace(self.ws_url, token=ctx['token'])
        variation_ref= params['vcf_ref']
        variation_obj = self.ws.get_objects2({'objects': [{'ref':variation_ref}]})['data'][0]
        
        #assembly_ref = variation_obj.get('assembly_ref') 
        assembly_ref= variation_obj['data']['assemby_ref']
        genome_info = self.du.download_genome(assembly_ref)
        
        #genome_info = self.du.download_genome(params)
        genome_path = genome_info['path']
        genome_file = genome_path.split("/")[-1]

        logging.info("downloading variants ...")
        params['variation_name'] = "snps.vcf"
        vcf_info = self.du.download_vcf(params)
        vcf_path = vcf_info['path']
        vcf_file = vcf_path.split("/")[-1]

        # igv tool  path
        src = "/kb/module/deps/igv_output"
        dest = outputdir +"/igv_output"

        try:
           logging.info('Copying directory: %s to %s', src, dest)
           shutil.copytree(src, dest)
        except (shutil.Error, OSError) as e:
           raise ActionError('Unable to copy %s to %s: %s' % (src, dest, str(e)))  

        #shutil.copytree(src,dest)
        self.vu.copy_file(genome_path, outputdir+"/igv_output/data/"+genome_file)
        self.vu.copy_file(vcf_path, outputdir+"/igv_output/data/"+vcf_file)

        logging.info("prepare input data ...")

        self.vu.prepare_genome(outputdir, genome_file)
        self.vu.prepare_vcf(outputdir, vcf_file)

        #gff_file = "/kb/module/test/sample_data/GCA_009858895.3_ASM985889v3_genomic.gff"  #hardcode for testing
        #bed_file = self.gu.gff2bed(gff_file,outputdir)
        #src_path = "/kb/module/test/sample_data"                                          #hardcode for testing
        #self.vu.copy_file(src_path+"/"+bed_file,outputdir + "/igv_output/data/")
        #self.vu.prepare_vcf(outputdir,bed_file)
        
        bed_file = "dummy name"  #will be added for organism with genome
        logging.info("prepare input data ...")
        self.vu.create_html(outputdir, bed_file, vcf_file, genome_file)

        logging.info("creating html report ...")
        output = self.hr.create_html_report(self.callback_url, outputdir, workspace) 
        report = KBaseReport(self.callback_url)

        #END run_Variation_Viewer

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

        This example function accepts any number of parameters and returns results in a KBaseReport
        :param params: instance of type "InputParams" -> structure: parameter
           "vcf_ref" of String, parameter "workspace_name" of String,
           parameter "genome_or_assembly_ref" of String
        :returns: instance of type "ReportResults" -> structure: parameter
           "report_name" of String, parameter "report_ref" of String
        
This example function accepts any number of parameters and returns results in a KBaseReport
This example function accepts any number of parameters and returns results in a KBaseReport
def run_Variation_Viewer(self, ctx, params):
        workspace = params['workspace_name']
        self.vu.validate_params(params)
        outputdir = self.shared_folder + '/' + str(uuid.uuid1())
        os.mkdir(outputdir)
        logging.info("Downlading assembly ...")
        self.ws_url = self.config['workspace-url']
        self.ws = Workspace(self.ws_url, token=ctx['token'])
        variation_ref= params['vcf_ref']
        variation_obj = self.ws.get_objects2({'objects': [{'ref':variation_ref}]})['data'][0]
        assembly_ref= variation_obj['data']['assemby_ref']
        genome_info = self.du.download_genome(assembly_ref)
        genome_path = genome_info['path']
        genome_file = genome_path.split("/")[-1]
        logging.info("downloading variants ...")
        params['variation_name'] = "snps.vcf"
        vcf_info = self.du.download_vcf(params)
        vcf_path = vcf_info['path']
        vcf_file = vcf_path.split("/")[-1]
        src = "/kb/module/deps/igv_output"
        dest = outputdir +"/igv_output"
        try:
           logging.info('Copying directory: %s to %s', src, dest)
           shutil.copytree(src, dest)
        except (shutil.Error, OSError) as e:
           raise ActionError('Unable to copy %s to %s: %s' % (src, dest, str(e)))  
        self.vu.copy_file(genome_path, outputdir+"/igv_output/data/"+genome_file)
        self.vu.copy_file(vcf_path, outputdir+"/igv_output/data/"+vcf_file)
        logging.info("prepare input data ...")
        self.vu.prepare_genome(outputdir, genome_file)
        self.vu.prepare_vcf(outputdir, vcf_file)
        bed_file = "dummy name"  
        logging.info("prepare input data ...")
        self.vu.create_html(outputdir, bed_file, vcf_file, genome_file)
        logging.info("creating html report ...")
        output = self.hr.create_html_report(self.callback_url, outputdir, workspace) 
        report = KBaseReport(self.callback_url)
        if not isinstance(output, dict):
            raise ValueError('Method run_Variation_Viewer return value ' +
                             'output is not type dict as required.')
        return [output]
def run_Variation_Viewer ( self , ctx , params ) : workspace = params [ 'workspace_name' ] self . vu . validate_params ( params ) outputdir = self . shared_folder + '/' + str ( uuid . uuid1 ( ) ) os . mkdir ( outputdir ) logging . info ( "Downlading assembly ..." ) self . ws_url = self . config [ 'workspace-url' ] self . ws = Workspace ( self . ws_url , token = ctx [ 'token' ] ) variation_ref = params [ 'vcf_ref' ] variation_obj = self . ws . get_objects2 ( { 'objects' : [ { 'ref' : variation_ref } ] } ) [ 'data' ] [ 0 ] assembly_ref = variation_obj [ 'data' ] [ 'assemby_ref' ] genome_info = self . du . download_genome ( assembly_ref ) genome_path = genome_info [ 'path' ] genome_file = genome_path . split ( "/" ) [ - 1 ] logging . info ( "downloading variants ..." ) params [ 'variation_name' ] = "snps.vcf" vcf_info = self . du . download_vcf ( params ) vcf_path = vcf_info [ 'path' ] vcf_file = vcf_path . split ( "/" ) [ - 1 ] src = "/kb/module/deps/igv_output" dest = outputdir + "/igv_output" try : logging . info ( 'Copying directory: %s to %s' , src , dest ) shutil . copytree ( src , dest ) except ( shutil . Error , OSError ) as e : raise ActionError ( 'Unable to copy %s to %s: %s' % ( src , dest , str ( e ) ) ) self . vu . copy_file ( genome_path , outputdir + "/igv_output/data/" + genome_file ) self . vu . copy_file ( vcf_path , outputdir + "/igv_output/data/" + vcf_file ) logging . info ( "prepare input data ..." ) self . vu . prepare_genome ( outputdir , genome_file ) self . vu . prepare_vcf ( outputdir , vcf_file ) bed_file = "dummy name" logging . info ( "prepare input data ..." ) self . vu . create_html ( outputdir , bed_file , vcf_file , genome_file ) logging . info ( "creating html report ..." ) output = self . hr . create_html_report ( self . callback_url , outputdir , workspace ) report = KBaseReport ( self . callback_url ) if not isinstance ( output , dict ) : raise ValueError ( 'Method run_Variation_Viewer return value ' + 'output is not type dict as required.' ) return [ output ]
This example function accepts any number of parameters and returns results in a KBaseReport
This example function accepts any number of parameters and returns results in a KBaseReport
"""
        This example function accepts any number of parameters and returns results in a KBaseReport
        :param params: instance of type "InputParams" -> structure: parameter
           "vcf_ref" of String, parameter "workspace_name" of String,
           parameter "genome_or_assembly_ref" of String
        :returns: instance of type "ReportResults" -> structure: parameter
           "report_name" of String, parameter "report_ref" of String
        """ # ctx is the context object # return variables are: output #BEGIN run_Variation_Viewer #assembly_ref = variation_obj.get('assembly_ref')  #genome_info = self.du.download_genome(params) # igv tool  path #shutil.copytree(src,dest) #gff_file = "/kb/module/test/sample_data/GCA_009858895.3_ASM985889v3_genomic.gff"  #hardcode for testing #bed_file = self.gu.gff2bed(gff_file,outputdir) #src_path = "/kb/module/test/sample_data"                                          #hardcode for testing #self.vu.copy_file(src_path+"/"+bed_file,outputdir + "/igv_output/data/") #self.vu.prepare_vcf(outputdir,bed_file) #will be added for organism with genome #END run_Variation_Viewer # At some point might do deeper type checking... # return the results
instance of type "ReportResults" -> structure: parameter
"report_name" of String, parameter "report_ref" of String
instance of type " ReportResults " - > structure : parameter " report_name " of String parameter " report_ref " of String
self
ctx
params
instance of type "InputParams" -> structure: parameter
"vcf_ref" of String, parameter "workspace_name" of String,
parameter "genome_or_assembly_ref" of String
instance of type " InputParams " - > structure : parameter " vcf_ref " of String parameter " workspace_name " of String parameter " genome_or_assembly_ref " of String