def runEach(self,task_list):
	 ### Call Cuffmerge function
	 used_tool = self.details['used_tool']
	 if used_tool == 'StringTie':
           merged_gtf = rnaseq_util.call_stringtiemerge(diffexp_dir,merge_dir,num_threads,self.details['gtf_file'],assembly_file)
           run_tool =  "StringTie"
           tool_version = "1.2.3"
         elif used_tool == 'Cufflinks':
           merged_gtf = rnaseq_util.call_cuffmerge(diffexp_dir,merge_dir,num_threads,gtf_file,assembly_file)
           run_tool = "Tablemaker" 
	   tool_version = '2.0.9'
	 cuffmerge_dir = os.path.join(self.directory,"cuffmerge")
	 merged_gtf = rnaseq_util.call_cuffmerge(self.directory,cuffmerge_dir,self.num_threads,self.details['gtf_file'],self.details['gtf_list_file'])
	 ### Run DiffExpforBallgown
	 output_dir = os.path.join(self.directory,self.method_params['output_obj_name'])
	 diffexp_command = (' -p '+str(self.num_threads))

	 ### Setting Advanced parameters for DiffExpforBallgown

         if('time_series' in self.method_params and self.method_params['time_series'] != 0) : diffexp_command += (' -T ')
         if('min_alignment_count' in self.method_params and self.method_params['min_alignment_count'] is not None ) : diffexp_command += (' -c '+str(self.method_params['min_alignment_count']))
         if('multi_read_correct' in self.method_params and self.method_params['multi_read_correct'] != 0 ): diffexp_command += (' --multi-read-correct ')
         if('library_type' in self.method_params and self.method_params['library_type'] is not None ) : diffexp_command += ( ' --library-type '+self.method_params['library_type'])
         if('library_norm_method' in self.method_params and self.method_params['library_norm_method'] is not None ) : diffexp_command += ( ' --library-norm-method '+self.method_params['library_norm_method'])
         try:
                diffexp_command += " -o {0} -L {1} -u {2} {3}".format(output_dir,self.t_labels,merged_gtf,self.bam_files)
                self.logger.info("Executing: diffexp {0}".format(diffexp_command))
                ret = script_util.runProgram(None,"diffexp",diffexp_command,None,self.directory)
                result = ret["result"]
		#error =  ret['stderr']
		#print result
		for line in result.splitlines(False):
                       self.logger.info(line)
                       stderr = ret["stderr"]
                       prev_value = ''
                       for line in stderr.splitlines(False):
                           if line.startswith('> Processing Locus'):
                                   words = line.split()
                                   cur_value = words[len(words) - 1]
                                   if prev_value != cur_value:
                                      prev_value = cur_value
                                      self.logger.info(line)
                                   else:
                                      prev_value = ''
                                      self.logger.info(line)
         except Exception,e:
		raise Exception(e)
                raise Exception("Error executing diffexp {0},{1}".format(diffexp_command,e))
Example #2
0
    def runEach(self, task_list):
        ### Call Cuffmerge function
        cuffmerge_dir = os.path.join(self.directory, "cuffmerge")
        merged_gtf = rnaseq_util.call_cuffmerge(self.directory, cuffmerge_dir,
                                                self.num_threads,
                                                self.details['gtf_file'],
                                                self.details['gtf_list_file'])
        ### Run Cuffdiff
        output_dir = os.path.join(self.directory,
                                  self.method_params['output_obj_name'])
        cuffdiff_command = (' -p ' + str(self.num_threads))

        ### Setting Advanced parameters for Cuffdiff

        if ('time_series' in self.method_params
                and self.method_params['time_series'] != 0):
            cuffdiff_command += (' -T ')
        if ('min_alignment_count' in self.method_params
                and self.method_params['min_alignment_count'] is not None):
            cuffdiff_command += (
                ' -c ' + str(self.method_params['min_alignment_count']))
        if ('multi_read_correct' in self.method_params
                and self.method_params['multi_read_correct'] != 0):
            cuffdiff_command += (' --multi-read-correct ')
        if ('library_type' in self.method_params
                and self.method_params['library_type'] is not None):
            cuffdiff_command += (' --library-type ' +
                                 self.method_params['library_type'])
        if ('library_norm_method' in self.method_params
                and self.method_params['library_norm_method'] is not None):
            cuffdiff_command += (' --library-norm-method ' +
                                 self.method_params['library_norm_method'])
        try:
            cuffdiff_command += " -o {0} -L {1} -u {2} {3}".format(
                output_dir, self.t_labels, merged_gtf, self.bam_files)
            self.logger.info(
                "Executing: cuffdiff {0}".format(cuffdiff_command))
            ret = script_util.runProgram(None, "cuffdiff", cuffdiff_command,
                                         None, self.directory)
            result = ret["result"]
            for line in result.splitlines(False):
                self.logger.info(line)
                stderr = ret["stderr"]
                prev_value = ''
                for line in stderr.splitlines(False):
                    if line.startswith('> Processing Locus'):
                        words = line.split()
                        cur_value = words[len(words) - 1]
                        if prev_value != cur_value:
                            prev_value = cur_value
                            self.logger.info(line)
                        else:
                            prev_value = ''
                            self.logger.info(line)
        except Exception, e:
            raise Exception(e)
            raise Exception("Error executing cuffdiff {0},{1}".format(
                cuffdiff_command, e))
    def prepare(self):
        # for quick testing, we recover parameters here
        ws_client = self.common_params['ws_client']
        hs = self.common_params['hs_client']
        params = self.method_params
        logger = self.logger
        token = self.common_params['user_token']
        diffexp_dir = self.directory
	self.details = rnaseq_util.get_details_for_diff_exp(logger,ws_client,hs,params['ws_id'],self.urls,diffexp_dir,params['expressionset_id'],token)
    	self.num_threads = mp.cpu_count()
	self.num_jobs = 1
	als = [] 
	for l in self.details['labels']:
		rep_files=[ (os.path.join(diffexp_dir+'/'+l,sub+'/accepted_hits.bam'), os.path.join(diffexp_dir+'/'+l,sub+'/transcripts.gtf')) for sub in os.listdir(os.path.join(diffexp_dir,l)) if os.path.isdir(os.path.join(diffexp_dir,l+'/'+sub))]
                #rep_files=",".join([ os.path.join(diffexp_dir+'/'+l,sub+'/accepted_hits.bam') for sub in os.listdir(os.path.join(diffexp_dir,l)) if os.path.isdir(os.path.join(diffexp_dir,l+'/'+sub))])
                als += rep_files
	### Call Cuffmerge function
        used_tool = self.details['used_tool']
	merge_dir = os.path.join(diffexp_dir,"merge")
        if used_tool == 'StringTie':
           run_tool =  "StringTie"
           tool_version = "1.2.3"
           merged_gtf = rnaseq_util.call_stringtiemerge(diffexp_dir,merge_dir,self.num_threads,self.details['gtf_file'],self.details['gtf_list_file'])
        elif used_tool == 'Cufflinks':
           merged_gtf = rnaseq_util.call_cuffmerge(diffexp_dir,merge_dir,num_threads,gtf_file,self.details['gtf_list_file'])
           run_tool = "Tablemaker"
           tool_version = '2.0.9'
           merged_gtf = rnaseq_util.call_cuffmerge(diffexp_dir,merge_dir,self.num_threads,self.details['gtf_file'],self.details['gtf_list_file'])

        self.bam_files = " ".join([i for i in als])
        self.t_labels = ",".join(self.details['labels'])
	ballgown_dir = os.path.join(diffexp_dir,"ballgown")
        if not os.path.exists(ballgown_dir): os.mkdir(ballgown_dir)
	### Make Input_dir from expression_file_name
	
        self.task_list = [self.__class__]
Example #4
0
    def runEach(self,task_list):
	 ### Call Cuffmerge function
	 cuffmerge_dir = os.path.join(self.directory,"cuffmerge")
	 merged_gtf = rnaseq_util.call_cuffmerge(self.directory,cuffmerge_dir,self.num_threads,self.details['gtf_file'],self.details['gtf_list_file'])
	 ### Run Cuffdiff
	 output_dir = os.path.join(self.directory,self.method_params['output_obj_name'])
	 cuffdiff_command = (' -p '+str(self.num_threads))

	 ### Setting Advanced parameters for Cuffdiff

         if('time_series' in self.method_params and self.method_params['time_series'] != 0) : cuffdiff_command += (' -T ')
         if('min_alignment_count' in self.method_params and self.method_params['min_alignment_count'] is not None ) : cuffdiff_command += (' -c '+str(self.method_params['min_alignment_count']))
         if('multi_read_correct' in self.method_params and self.method_params['multi_read_correct'] != 0 ): cuffdiff_command += (' --multi-read-correct ')
         if('library_type' in self.method_params and self.method_params['library_type'] is not None ) : cuffdiff_command += ( ' --library-type '+self.method_params['library_type'])
         if('library_norm_method' in self.method_params and self.method_params['library_norm_method'] is not None ) : cuffdiff_command += ( ' --library-norm-method '+self.method_params['library_norm_method'])
         try:
                cuffdiff_command += " -o {0} -L {1} -u {2} {3}".format(output_dir,self.t_labels,merged_gtf,self.bam_files)
                self.logger.info("Executing: cuffdiff {0}".format(cuffdiff_command))
                ret = script_util.runProgram(None,"cuffdiff",cuffdiff_command,None,self.directory)
                result = ret["result"]
		for line in result.splitlines(False):
                       self.logger.info(line)
                       stderr = ret["stderr"]
                       prev_value = ''
                       for line in stderr.splitlines(False):
                           if line.startswith('> Processing Locus'):
                                   words = line.split()
                                   cur_value = words[len(words) - 1]
                                   if prev_value != cur_value:
                                      prev_value = cur_value
                                      self.logger.info(line)
                                   else:
                                      prev_value = ''
                                      self.logger.info(line)
         except Exception,e:
		raise Exception(e)
                raise Exception("Error executing cuffdiff {0},{1}".format(cuffdiff_command,e))
Example #5
0
    def runEach(self, task_list):
        logger = self.logger
        ### Call Cuffmerge function
        used_tool = self.details['used_tool']
        logger.info('in DiffExpfoBallgown.runEach()')
        if used_tool == "Ballgown (Bioconductor)":
            #merged_gtf = rnaseq_util.call_stringtiemerge(diffexp_dir,merge_dir,num_threads,self.details['gtf_file'],assembly_file)
            #run_tool =  "StringTie"
            #tool_version = "1.2.3"
            # For now, take no action for StringTie processing
            logger.info('Exiting immediately - StringTie case')
            return
        elif used_tool == 'Cufflinks':
            merged_gtf = rnaseq_util.call_cuffmerge(diffexp_dir, merge_dir,
                                                    num_threads, gtf_file,
                                                    assembly_file)
            run_tool = "Tablemaker"
            tool_version = '2.0.9'
        cuffmerge_dir = os.path.join(self.directory, "cuffmerge")
        merged_gtf = rnaseq_util.call_cuffmerge(self.directory, cuffmerge_dir,
                                                self.num_threads,
                                                self.details['gtf_file'],
                                                self.details['gtf_list_file'])
        ### Run DiffExpforBallgown
        output_dir = os.path.join(self.directory,
                                  self.method_params['output_obj_name'])
        diffexp_command = (' -p ' + str(self.num_threads))

        ### Setting Advanced parameters for DiffExpforBallgown

        if ('time_series' in self.method_params
                and self.method_params['time_series'] != 0):
            diffexp_command += (' -T ')
        if ('min_alignment_count' in self.method_params
                and self.method_params['min_alignment_count'] is not None):
            diffexp_command += (' -c ' +
                                str(self.method_params['min_alignment_count']))
        if ('multi_read_correct' in self.method_params
                and self.method_params['multi_read_correct'] != 0):
            diffexp_command += (' --multi-read-correct ')
        if ('library_type' in self.method_params
                and self.method_params['library_type'] is not None):
            diffexp_command += (' --library-type ' +
                                self.method_params['library_type'])
        if ('library_norm_method' in self.method_params
                and self.method_params['library_norm_method'] is not None):
            diffexp_command += (' --library-norm-method ' +
                                self.method_params['library_norm_method'])
        try:
            diffexp_command += " -o {0} -L {1} -u {2} {3}".format(
                output_dir, self.t_labels, merged_gtf, self.bam_files)
            logger.info("Executing: diffexp {0}".format(diffexp_command))
            ret = script_util.runProgram(None, "diffexp", diffexp_command,
                                         None, self.directory)
            result = ret["result"]
            #error =  ret['stderr']
            #print result
            for line in result.splitlines(False):
                logger.info(line)
                stderr = ret["stderr"]
                prev_value = ''
                for line in stderr.splitlines(False):
                    if line.startswith('> Processing Locus'):
                        words = line.split()
                        cur_value = words[len(words) - 1]
                        if prev_value != cur_value:
                            prev_value = cur_value
                            logger.info(line)
                        else:
                            prev_value = ''
                            logger.info(line)
        except Exception, e:
            raise Exception(e)
            raise Exception("Error executing diffexp {0},{1}".format(
                diffexp_command, e))