Ejemplo n.º 1
0
    def run(self):
        """
		"""
        if self.debug:
            import pdb
            pdb.set_trace()

        db_250k = self.db_250k

        #construct the bands to be highlighted in manhattan plot
        highlightBandLs = []
        rm = None
        for peak_id in self.peak_id_ls:
            result_peak = Stock_250kDB.ResultPeak.get(peak_id)
            highlightBandLs.append(
                [result_peak.chromosome, result_peak.start, result_peak.stop])
            #take the 1st result_peak's result as the association result to get locus_type_id
            if rm is None:
                rm = result_peak.result
        if not rm:
            sys.stderr.write(
                "Error: no results_method (association result) fetched from db.\n"
            )
            sys.exit(1)
        if self.inputFname and os.path.isfile(self.inputFname):
            locus_type_id = self.getLocusTypeIDFromInput(
                self.inputFname, datasetName=self.datasetName)

            pd = PassingData()
            if rm.cnv_method_id and not db_250k._cnv_id2chr_pos:
                db_250k.cnv_id2chr_pos = rm.cnv_method_id
                pd.db_id2chr_pos = db_250k.cnv_id2chr_pos
            elif rm.call_method_id:
                db_250k.snp_id2chr_pos = (
                    False, locus_type_id
                )  #correspond to priorTAIRVersion, locus_type_id
                pd.db_id2chr_pos = db_250k.snp_id2chr_pos

            #need to setup a different db setting
            db_genome = GenomeDB.GenomeDatabase(drivername=self.genome_drivername, username=self.genome_db_user,
                password=self.genome_db_passwd, hostname=self.genome_hostname, database=self.genome_dbname, \
                schema=self.genome_schema)
            db_genome.setup(create_tables=False)

            gwr_name = ''
            gwr = SNP.GenomeWideResult(name=gwr_name, construct_chr_pos2index=False, \
              construct_data_obj_id2index=False)
            gwr.fillGenomeWideResultFromHDF5CorrelationFile(
                self.inputFname, datasetName=self.datasetName, pdata=pd)
            gwr.drawManhattanPlot(db_genome, outputFnamePrefix=self.outputFnamePrefix,\
                 min_value=None, need_svg=False, ylim_type=2,\
                 drawBonferroni=False, highlightBandLs=highlightBandLs)
        else:  #2012.3.28 input is invalid.
            sys.stderr.write("inputFname %s is not valid (inexistent).\n" %
                             (self.inputFname))
            sys.exit(0)  #fake ok as I want pegasus workflow to keep running.