예제 #1
0
    def copyWorkflowResultFileToFinalOutput(self, stats_param, stats_param_attribute, local_attribute, file_pathes):
        
        if stats_param_attribute in stats_param.keys():

            dir_path = os.path.join( self.outPath, stats_param_attribute)
            file_path =  stats_param[ stats_param_attribute]
            
            FileUtils.createDirectory( dir_path)
            FileUtils.copyFile( file_path, dir_path)
            
            final_path = os.path.join( stats_param_attribute, os.path.basename( file_path))
            
            file_pathes[ local_attribute] = final_path        
예제 #2
0
    def copyMotifResultFileToFinalOutput(self, motif_stats, motifStatistics_attribute, local_attribute, file_pathes):
        
        
        if motif_stats.hasAttribute( motifStatistics_attribute):
            if not local_attribute in file_pathes.keys():
                file_pathes[ local_attribute] = {}

            dir_path = os.path.join( self.outPath, motifStatistics_attribute)
            file_path =  motif_stats.getAttribute( motifStatistics_attribute)
            
            FileUtils.createDirectory( dir_path)
            FileUtils.copyFile( file_path, dir_path)
            
            final_path = os.path.join( motifStatistics_attribute, os.path.basename( file_path))
            
            file_pathes[ local_attribute][ motif_stats.motifName] = final_path     
예제 #3
0
    def execute( self, input_commstructs):
    
        if input_commstructs == None or len( input_commstructs) == 0:
            raise ExecutionException( "FinalOutputProcessor.execute : No inputs")
        
        input_commstruct = input_commstructs[0]
        
        # Retrieve the processor parameters
        self.dbPath = self.getParameter( FinalOutputProcessor.MOTIF_DATABASE_PATH_PARAM)
        
        # Retrieve the list of motif database files to use
        database_file_line = self.getParameter( FinalOutputProcessor.MOTIF_DATABASE_FILE_LIST_PARAM)
        if database_file_line != None and not database_file_line.isspace():
            file_list = database_file_line.split()
            self.dbFiles = []
            for file_path in file_list:
                self.dbFiles.append( os.path.join( self.dbPath, file_path))
        else:
            raise ExecutionException( "FinalOutputProcessor.getMethodParameters : No motif database file specified in parameter '" + FinalOutputProcessor.MOTIF_DATABASE_FILE_LIST_PARAM + "'")

        # Add the custom motif database files if any
        custom_database_file_line = self.getParameter( FinalOutputProcessor.CUSTOM_MOTIF_DATABASE_FILE_PARAM, False)
        if custom_database_file_line != None and not custom_database_file_line.isspace():
            self.dbFiles.append( custom_database_file_line)
        
        limit_value = self.getParameter( FinalOutputProcessor.DISPLAY_LIMIT_VALUE, False)
        if limit_value == None:
            limit_value = 1.0
        
        # Prepare the processor output dir
        self.outPath = os.path.join( self.component.outputDir, self.component.getComponentPrefix())
        shutil.rmtree( self.outPath, True)
        FileUtils.createDirectory( self.outPath, 0777)
        
        # Copy motif graph and stats files
        analysis = self.AnalyseMotifStats( input_commstruct)
        
        # Create motif logos
        self.createLogos( input_commstruct)
        
        # Output Results
        self.outputClassification( input_commstruct, analysis, limit_value)
        
        # Copy other information
        FileUtils.copyFile( os.path.join( self.component.outputDir, Constants.PROGRESSION_XSL_FILE), self.outPath) 
        FileUtils.copyFile( os.path.join( self.component.outputDir, Constants.PROGRESSION_XML_FILE), self.outPath)
예제 #4
0
    def execute(self, input_commstructs):

        if input_commstructs == None or len(input_commstructs) == 0:
            raise ExecutionException(
                "FinalOutputProcessor.execute : No inputs")

        input_commstruct = input_commstructs[0]

        # Get all the pipeline parameters
        parameter_dic = self.collectAllParameters()

        # Retrieve the processor parameters
        self.dbPath = self.getParameter(
            FinalOutputProcessor.MOTIF_DATABASE_PATH_PARAM)

        # Retrieve the list of motif database files to use and count motifs in the list
        database_file_line = self.getParameter(
            FinalOutputProcessor.MOTIF_DATABASE_FILE_LIST_PARAM)
        if database_file_line != None and not database_file_line.isspace():
            file_list = database_file_line.split()
            self.dbFiles = []
            count_motif_in_db = 0
            for file_path in file_list:
                current_path = os.path.join(self.dbPath, file_path)
                current_size = MotifUtils.getMotifsNumberFromTransfac(
                    current_path)
                if current_size != None:
                    count_motif_in_db = count_motif_in_db + current_size
                self.dbFiles.append(current_path)
            parameter_dic[
                FinalOutputProcessor.PARAM_MotifDatabaseFileListSize] = str(
                    count_motif_in_db)
        else:
            raise ExecutionException(
                "FinalOutputProcessor.getMethodParameters : No motif database file specified in parameter '"
                + FinalOutputProcessor.MOTIF_DATABASE_FILE_LIST_PARAM + "'")

        # Add the custom motif database files if any
        custom_database_file_line = self.getParameter(
            FinalOutputProcessor.CUSTOM_MOTIF_DATABASE_FILE_PARAM, False)
        if custom_database_file_line != None and not custom_database_file_line.isspace(
        ):
            self.dbFiles.append(custom_database_file_line)

        # Retrieve the ID and the name of the reference motif
        motif_name = parameter_dic[FinalOutputProcessor.PARAM_ReferenceMotif]
        for current_database in self.dbFiles:
            motif_ID = MotifUtils.getMotifIDFromTransfac(
                motif_name, current_database)
            if motif_ID != None:
                break
        parameter_dic[FinalOutputProcessor.PARAM_ReferenceMotifID] = motif_ID

        # Retrieve the Hypergeometric e/p-value threshold
        limit_value = self.getParameter(
            FinalOutputProcessor.DISPLAY_LIMIT_VALUE, False)
        if limit_value == None:
            limit_value = 1.0

        # Prepare the processor output dir
        self.outPath = os.path.join(self.component.outputDir,
                                    self.component.getComponentPrefix())
        shutil.rmtree(self.outPath, True)
        FileUtils.createDirectory(self.outPath, 0777)

        # Copy motif graph and stats files
        analysis = self.AnalyseMotifStats(input_commstruct)

        # Create motif logos
        self.createLogos(input_commstruct)

        # Copy input BED and custom motif files
        input_bed_file_destination_path = os.path.join(
            self.outPath, FinalOutputProcessor.PARAM_BEDFile)
        FileUtils.createDirectory(input_bed_file_destination_path)
        FileUtils.copyFile(parameter_dic[FinalOutputProcessor.PARAM_BEDFile],
                           input_bed_file_destination_path)
        parameter_dic[FinalOutputProcessor.PARAM_BEDFile] = os.path.join(
            input_bed_file_destination_path,
            os.path.basename(
                parameter_dic[FinalOutputProcessor.PARAM_BEDFile]))

        # Copy the custom motif file (if any) to output location and count motifs in this db
        if FinalOutputProcessor.PARAM_CustomMotifDatabaseFile in parameter_dic.keys(
        ) and parameter_dic[
                FinalOutputProcessor.PARAM_CustomMotifDatabaseFile] != None:
            custom_db_file_destination_path = os.path.join(
                self.outPath,
                FinalOutputProcessor.PARAM_CustomMotifDatabaseFile)
            FileUtils.createDirectory(custom_db_file_destination_path)
            FileUtils.copyFile(
                parameter_dic[
                    FinalOutputProcessor.PARAM_CustomMotifDatabaseFile],
                custom_db_file_destination_path)
            parameter_dic[
                FinalOutputProcessor.
                PARAM_CustomMotifDatabaseFile] = os.path.join(
                    custom_db_file_destination_path,
                    os.path.basename(parameter_dic[
                        FinalOutputProcessor.PARAM_CustomMotifDatabaseFile]))
            count_custom_motif = MotifUtils.getMotifsNumberFromTransfac(
                parameter_dic[
                    FinalOutputProcessor.PARAM_CustomMotifDatabaseFile])
            if (count_custom_motif != None):
                parameter_dic[FinalOutputProcessor.
                              PARAM_CustomMotifDatabaseFileSize] = str(
                                  count_custom_motif)
            else:
                parameter_dic[FinalOutputProcessor.
                              PARAM_CustomMotifDatabaseFileSize] = "0"

        # Output Results
        self.outputClassification(input_commstruct, analysis, limit_value,
                                  parameter_dic)

        # Copy other information
        FileUtils.copyFile(
            os.path.join(self.component.outputDir,
                         Constants.PROGRESSION_XSL_FILE), self.outPath)
        FileUtils.copyFile(
            os.path.join(self.component.outputDir,
                         Constants.PROGRESSION_XML_FILE), self.outPath)

        # Zip the complete result
        self.zipdir(self.outPath)