示例#1
0
文件: __init__.py 项目: bsmithers/hpf
    def create(self,score):
        """
        Create an McmData ORM object (hpf.hddb.db.McmData, hpf table mcm) from a Mammoth score.
        Entities:
          experiment_key  - structure ID of "experiment" source entry in McmDB obj that cluster center was compared against
          experiment      - McmDB Struct object with ID = experiment_key. All from mcmdb data.mammothDb file entries.
                          - Struct(id, sequence_key, length, percent_alpha/beta, sccs, astral_ac)
        Parameters:
          score           - hpf.mcm.mammoth.MammothScore object
        Returns an McmData ORM object corresponding to the given mammoth score
        """
        
        #?#TODO: Include values here to FULLY populate McmData ORM object. That way, return McmData 
        #?#TODO: objects can be added without modification to the DB
        ##NOTE: Leave outfile_mcm_result_key NULL (was used to reprsent MCM xml log files)
        # sequence_key
        # outfile_key
        # convergence_key
        # structure_key
        # astral_structure_key

        from hpf.hddb.db import McmData
        experiment_key = int(score.experiment.split(".")[0])
        experiment = self.mcmdb[experiment_key]

        prob,ratio,aratio,bratio,ssclass = self.probability(score=score, 
                                                            pred_percent_alpha=self.percent_alpha, 
                                                            pred_percent_beta=self.percent_beta, 
                                                            convergence=self.convergence_radius1, 
                                                            experiment=experiment)
        
        if self.debug: print "MCM probability: {0} {1} {2} {3} {4} {5}".format(experiment.id, 
                score.prediction, score.zscore, prob, ratio, ssclass)
        
        data= McmData(ratio = ratio,
                      aratio = aratio,
                      bratio = bratio,
                      percent_alpha = self.percent_alpha,
                      percent_beta  = self.percent_beta,
                      astral_percent_alpha = experiment.percent_alpha,
                      astral_percent_beta  = experiment.percent_beta,
                      sequence_length = int(score.num_p),
                      astral_sequence_length = int(score.num_e),
                      probability = prob,
                      sccs = experiment.sccs,
                      scop = self.mcmdb.scop,
                      )
        # "class" is a reserved word in python
        data.__dict__["class"] = ssclass
        # MammothScore object is saved in McmData object to make DB storage easier
        data.mammoth = score
        return data
示例#2
0
文件: __init__.py 项目: bsmithers/hpf
    def create(self,score):
        """
        Create an McmData ORM object (hpf.hddb.db.McmData, hpf table mcm) from a Mammoth score.
        Patrick:
          Conspicuously missing from here is an 'outfile_key'. This is tricky.  McmData objects 
          store EVERYTHING compiled from Rosetta clustering runs, mammoth, and the mcm database.
        Entities:
          experiment_key  - structure ID of "experiment" source entry in McmDB obj that cluster center was compared against
          experiment      - McmDB Struct object with ID = experiment_key. All from mcmdb data.mammothDb file entries.
                          - Struct(id, sequence_key, length, percent_alpha/beta, sccs, astral_ac)
          prediction      - hpf.mcm.cluster.ClusterCenter object from convergence task (TODO: CHANGE)
        Parameters:
          score           - hpf.mcm.mammoth.MammothScore object
        Returns an McmData ORM object corresponding to the given mammoth score
        """
        from hpf.hddb.db import McmData
        experiment_key = int(score.experiment.split(".")[0])
        experiment = self.mcmdb[experiment_key]
        prediction = self.convergence[score.prediction]

        prob,ratio,aratio,bratio,ssclass = self.probability(score,prediction,experiment)
        e = experiment
        p = prediction
        s = score
        print "probability: ", e.id, p.index, s.zscore, prob, ratio, ssclass
        
        data= McmData(ratio = ratio,
                      aratio = aratio,
                      bratio = bratio,
                      percent_alpha = p.percent_alpha,
                      percent_beta = p.percent_beta,
                      astral_percent_alpha = e.percent_alpha,
                      astral_percent_beta = e.percent_beta,
                      sequence_length = s.num_p,
                      astral_sequence_length = int(s.num_e),
                      probability = prob,
                      sccs = e.sccs,
                      scop = self.mcmdb.scop,
                      )
        # "class" is a reserved word in python
        data.__dict__["class"] = ssclass
        data.mammoth = score
        return data