예제 #1
0
def result_to_dict(result):
    from trident.classify import get_grade
    result_dict = {}
    result_dict['microrna'] = result.microrna
    result_dict['chromosome'] = result.chromosome
    result_dict['hit_genomic_start'] = result.hit_genomic_start
    result_dict['hit_genomic_end'] = result.hit_genomic_end
    result_dict['base_type'] = result.base_type.__unicode__()
    result_dict['hit_score'] = result.hit_score
    result_dict['hit_energy'] = result.hit_energy
    result_dict['query_seq'] = result.query_seq
    result_dict['hit_string'] = result.hit_string
    result_dict['ref_seq'] = result.ref_seq
    result_dict['match_type'] = result.match_type.__unicode__()
    result_dict['genome'] = result.genome.__unicode__()

    interp = get_interpolator()
    if interp:
        result_dict["grade"] = get_grade(
            interp({
                'query_id': result.microrna,
                'energy': result.hit_energy,
                'score': result.hit_score
            })
        )  # Supplying the necessary fields for the inerpolator as a dict (instead of full trident score dict)

    return result_dict
예제 #2
0
    def dict(self, interp=None):
        result_dict = {}
        result_dict['microrna'] = self.microrna
        result_dict['chromosome'] = self.chromosome
        result_dict['hit_genomic_start'] = self.hit_genomic_start
        result_dict['hit_genomic_end'] = self.hit_genomic_end
        result_dict['base_type'] = self.base_type.__unicode__()
        result_dict['hit_score'] = self.hit_score
        result_dict['hit_energy'] = self.hit_energy
        result_dict['query_seq'] = self.query_seq
        result_dict['hit_string'] = self.hit_string
        result_dict['ref_seq'] = self.ref_seq
        result_dict['match_type'] = self.match_type.__unicode__()
        result_dict['genome'] = self.genome.__unicode__()
        result_dict["browser_name"] = self.genome.browser_name
        result_dict['id'] = self.id

        if interp:
            from trident.classify import get_grade
            if not hasattr(interp, "__call__"):
                from trident import TridentException
                raise TridentException("Interpolator object is not callable")
            result_dict["grade"] = get_grade(
                interp({
                    'query_id': self.microrna,
                    'energy': self.hit_energy,
                    'score': self.hit_score
                })
            )  # Supplying the necessary fields for the inerpolator as a dict (instead of full trident score dict)

        return result_dict
def ple_to_resultlist(parser, browser_name=None, genome=None):
    from views import get_interpolator

    interp = get_interpolator()
    
    result_list = []
    for score in parser:
        if score is None:
            raise Exception("Error in trident output")
        score['microrna'] = ""
        score['chromosome'] = ""
        score['hit_genomic_start'] = score['ref_start']
        score['hit_genomic_end'] = score['ref_end']
        score['hit_score'] = score['score']
        score['hit_energy'] = score['energy']
        score['hit_string'] = score['match_seq']
        score['ref_seq'] = score['reference_seq']
        score['genome'] = ""
        if genome:
            score['genome'] = "Based on {0}".format(genome)
        if browser_name:
            if interp:
                from trident.classify import get_grade
                if not hasattr(interp,"__call__"):
                    from trident import TridentException
                    raise TridentException("Interpolator object is not callable")
                score["grade"] = get_grade(interp({'query_id': browser_name, 'energy': score['energy'], 'score': score['score']}))
        result_list.append(score)
        
    return result_list
예제 #4
0
 def dict(self,interp = None):
     result_dict = {}
     result_dict['microrna'] = self.microrna
     result_dict['chromosome'] = self.chromosome
     result_dict['hit_genomic_start'] = self.hit_genomic_start
     result_dict['hit_genomic_end'] = self.hit_genomic_end
     result_dict['base_type'] = self.base_type.__unicode__()
     result_dict['hit_score'] = self.hit_score
     result_dict['hit_energy'] = self.hit_energy
     result_dict['query_seq'] = self.query_seq
     result_dict['hit_string'] = self.hit_string
     result_dict['ref_seq'] = self.ref_seq
     result_dict['match_type'] = self.match_type.__unicode__()
     result_dict['genome'] = self.genome.__unicode__()
     result_dict["browser_name"] = self.genome.browser_name
     result_dict['id'] = self.id
 
     if interp:
         from trident.classify import get_grade
         if not hasattr(interp,"__call__"):
             from trident import TridentException
             raise TridentException("Interpolator object is not callable")
         result_dict["grade"] = get_grade(interp({'query_id': self.microrna, 'energy': self.hit_energy,'score': self.hit_score})) # Supplying the necessary fields for the inerpolator as a dict (instead of full trident score dict)
 
     return result_dict
예제 #5
0
def result_to_dict(result):
	from trident.classify import get_grade
	result_dict = {}
	result_dict['microrna'] = result.microrna
	result_dict['chromosome'] = result.chromosome
	result_dict['hit_genomic_start'] = result.hit_genomic_start
	result_dict['hit_genomic_end'] = result.hit_genomic_end
	result_dict['base_type'] = result.base_type.__unicode__()
	result_dict['hit_score'] = result.hit_score
	result_dict['hit_energy'] = result.hit_energy
	result_dict['query_seq'] = result.query_seq
	result_dict['hit_string'] = result.hit_string
	result_dict['ref_seq'] = result.ref_seq
	result_dict['match_type'] = result.match_type.__unicode__()
	result_dict['genome'] = result.genome.__unicode__()
	
	interp = get_interpolator()
	if interp:
		result_dict["grade"] = get_grade(interp({'query_id': result.microrna, 'energy': result.hit_energy,'score': result.hit_score})) # Supplying the necessary fields for the inerpolator as a dict (instead of full trident score dict)
		
	return result_dict
예제 #6
0
def ple_to_resultlist(parser, browser_name=None, genome=None):
    from views import get_interpolator

    interp = get_interpolator()

    result_list = []
    for score in parser:
        if score is None:
            raise Exception("Error in trident output")
        score['microrna'] = ""
        score['chromosome'] = ""
        score['hit_genomic_start'] = score['ref_start']
        score['hit_genomic_end'] = score['ref_end']
        score['hit_score'] = score['score']
        score['hit_energy'] = score['energy']
        score['hit_string'] = score['match_seq']
        score['ref_seq'] = score['reference_seq']
        score['genome'] = ""
        if genome:
            score['genome'] = "Based on {0}".format(genome)
        if browser_name:
            if interp:
                from trident.classify import get_grade
                if not hasattr(interp, "__call__"):
                    from trident import TridentException
                    raise TridentException(
                        "Interpolator object is not callable")
                score["grade"] = get_grade(
                    interp({
                        'query_id': browser_name,
                        'energy': score['energy'],
                        'score': score['score']
                    }))
        result_list.append(score)

    return result_list