src.serena.utilities.comparison_structures

File to hold the comparison structures files

  1"""
  2File to hold the comparison structures files
  3"""
  4
  5from dataclasses import dataclass
  6from typing import List
  7
  8from serena.utilities.ensemble_structures import Sara2SecondaryStructure
  9
 10@dataclass
 11class ComparisonNucCounts():
 12    """
 13    Class for comparison nucs counts for analysis
 14    """
 15    bound_count:float = -1
 16    unbound_count:float = -1
 17    both_count:float = -1
 18    dot_count:float = -1
 19    num_nucs:int = -1
 20
 21@dataclass
 22class ComparisonNucResults():
 23    """
 24    Class that holds a list of comparison nucs 
 25    for analysis and result returning
 26    """
 27    comparison_nuc_counts: List[ComparisonNucCounts]
 28
 29@dataclass
 30class ComparisonResult():
 31    """
 32    Class that holds the results from comparying structures
 33    """
 34    #unbound_struct:Sara2SecondaryStructure
 35    #bound_struct: Sara2SecondaryStructure
 36    #reference_struct: Sara2SecondaryStructure
 37    comp_struct: Sara2SecondaryStructure
 38    comp_counts: ComparisonNucCounts
 39
 40
 41class ComparisonStructures():#pylint: disable=too-few-public-methods
 42    """
 43    Class for the comparison structure algorithm for switch performance predicitons
 44    """
 45    def __init__(self) -> None:
 46        pass
 47
 48    def compair_structures(self, unbound_struct:Sara2SecondaryStructure, bound_struct:Sara2SecondaryStructure, reference_struct:Sara2SecondaryStructure, nuc_count:int):#pylint: disable=line-too-long,too-many-locals
 49        """
 50        Compaire the weighted structure against the folded and not-folded mfe's.
 51        If a element is present in the folded mfe then it gets a '-'
 52        if element is in unbound only then it gets a '|'.
 53        The idea is that if you have a straight line in the list then it is very close to the
 54        folded mfe and if it is not straight then it is more like the unbound mfe.
 55        """
 56        unbound:str = '|'
 57        num_unbound:int = 0
 58        bound:str = '-'
 59        num_bound:int = 0
 60        both:str = '+'
 61        num_both:int = 0
 62        dot:str = '.'
 63        num_dot:int = 0
 64        temp_comp_struct:str = ''
 65
 66        for nuc_index in range(nuc_count):
 67            reference_nuc:str = reference_struct.structure[nuc_index]
 68            unbound_nuc:str = unbound_struct.structure[nuc_index]
 69            bound_nuc: str = bound_struct.structure[nuc_index]
 70
 71            comp_nuc_symbol:str = ''
 72
 73            if reference_nuc == bound_nuc and reference_nuc != unbound_nuc:
 74                comp_nuc_symbol = bound
 75                num_bound += 1
 76            elif reference_nuc != bound_nuc and reference_nuc == unbound_nuc:
 77                comp_nuc_symbol = unbound
 78                num_unbound += 1
 79            elif reference_nuc == bound_nuc and reference_nuc == unbound_nuc:
 80                comp_nuc_symbol = both
 81                num_both += 1
 82            else:
 83                comp_nuc_symbol = dot
 84                num_dot += 1
 85
 86            temp_comp_struct = temp_comp_struct + comp_nuc_symbol
 87
 88        sequence: str = unbound_struct.sequence
 89        comp_struct:Sara2SecondaryStructure = Sara2SecondaryStructure(sequence=sequence,
 90                                                                    structure=temp_comp_struct)
 91
 92        comp_nuc_num:ComparisonNucCounts = ComparisonNucCounts(bound_count=num_bound,
 93                                                                    unbound_count=num_unbound,
 94                                                                    both_count=num_both,
 95                                                                    dot_count=num_dot,
 96                                                                    num_nucs=nuc_count)
 97
 98        compared_result: ComparisonResult = ComparisonResult(comp_struct=comp_struct,
 99                                                                #unbound_struct=unbound_struct,
100                                                                #bound_struct=bound_struct,
101                                                                #reference_struct=reference_struct,
102                                                                comp_counts=comp_nuc_num)
103        return compared_result
@dataclass
class ComparisonNucCounts:
11@dataclass
12class ComparisonNucCounts():
13    """
14    Class for comparison nucs counts for analysis
15    """
16    bound_count:float = -1
17    unbound_count:float = -1
18    both_count:float = -1
19    dot_count:float = -1
20    num_nucs:int = -1

Class for comparison nucs counts for analysis

ComparisonNucCounts( bound_count: float = -1, unbound_count: float = -1, both_count: float = -1, dot_count: float = -1, num_nucs: int = -1)
bound_count: float = -1
unbound_count: float = -1
both_count: float = -1
dot_count: float = -1
num_nucs: int = -1
@dataclass
class ComparisonNucResults:
22@dataclass
23class ComparisonNucResults():
24    """
25    Class that holds a list of comparison nucs 
26    for analysis and result returning
27    """
28    comparison_nuc_counts: List[ComparisonNucCounts]

Class that holds a list of comparison nucs for analysis and result returning

ComparisonNucResults( comparison_nuc_counts: List[src.serena.utilities.comparison_structures.ComparisonNucCounts])
@dataclass
class ComparisonResult:
30@dataclass
31class ComparisonResult():
32    """
33    Class that holds the results from comparying structures
34    """
35    #unbound_struct:Sara2SecondaryStructure
36    #bound_struct: Sara2SecondaryStructure
37    #reference_struct: Sara2SecondaryStructure
38    comp_struct: Sara2SecondaryStructure
39    comp_counts: ComparisonNucCounts

Class that holds the results from comparying structures

ComparisonResult( comp_struct: serena.utilities.ensemble_structures.Sara2SecondaryStructure, comp_counts: src.serena.utilities.comparison_structures.ComparisonNucCounts)
comp_struct: serena.utilities.ensemble_structures.Sara2SecondaryStructure
class ComparisonStructures:
 42class ComparisonStructures():#pylint: disable=too-few-public-methods
 43    """
 44    Class for the comparison structure algorithm for switch performance predicitons
 45    """
 46    def __init__(self) -> None:
 47        pass
 48
 49    def compair_structures(self, unbound_struct:Sara2SecondaryStructure, bound_struct:Sara2SecondaryStructure, reference_struct:Sara2SecondaryStructure, nuc_count:int):#pylint: disable=line-too-long,too-many-locals
 50        """
 51        Compaire the weighted structure against the folded and not-folded mfe's.
 52        If a element is present in the folded mfe then it gets a '-'
 53        if element is in unbound only then it gets a '|'.
 54        The idea is that if you have a straight line in the list then it is very close to the
 55        folded mfe and if it is not straight then it is more like the unbound mfe.
 56        """
 57        unbound:str = '|'
 58        num_unbound:int = 0
 59        bound:str = '-'
 60        num_bound:int = 0
 61        both:str = '+'
 62        num_both:int = 0
 63        dot:str = '.'
 64        num_dot:int = 0
 65        temp_comp_struct:str = ''
 66
 67        for nuc_index in range(nuc_count):
 68            reference_nuc:str = reference_struct.structure[nuc_index]
 69            unbound_nuc:str = unbound_struct.structure[nuc_index]
 70            bound_nuc: str = bound_struct.structure[nuc_index]
 71
 72            comp_nuc_symbol:str = ''
 73
 74            if reference_nuc == bound_nuc and reference_nuc != unbound_nuc:
 75                comp_nuc_symbol = bound
 76                num_bound += 1
 77            elif reference_nuc != bound_nuc and reference_nuc == unbound_nuc:
 78                comp_nuc_symbol = unbound
 79                num_unbound += 1
 80            elif reference_nuc == bound_nuc and reference_nuc == unbound_nuc:
 81                comp_nuc_symbol = both
 82                num_both += 1
 83            else:
 84                comp_nuc_symbol = dot
 85                num_dot += 1
 86
 87            temp_comp_struct = temp_comp_struct + comp_nuc_symbol
 88
 89        sequence: str = unbound_struct.sequence
 90        comp_struct:Sara2SecondaryStructure = Sara2SecondaryStructure(sequence=sequence,
 91                                                                    structure=temp_comp_struct)
 92
 93        comp_nuc_num:ComparisonNucCounts = ComparisonNucCounts(bound_count=num_bound,
 94                                                                    unbound_count=num_unbound,
 95                                                                    both_count=num_both,
 96                                                                    dot_count=num_dot,
 97                                                                    num_nucs=nuc_count)
 98
 99        compared_result: ComparisonResult = ComparisonResult(comp_struct=comp_struct,
100                                                                #unbound_struct=unbound_struct,
101                                                                #bound_struct=bound_struct,
102                                                                #reference_struct=reference_struct,
103                                                                comp_counts=comp_nuc_num)
104        return compared_result

Class for the comparison structure algorithm for switch performance predicitons

def compair_structures( self, unbound_struct: serena.utilities.ensemble_structures.Sara2SecondaryStructure, bound_struct: serena.utilities.ensemble_structures.Sara2SecondaryStructure, reference_struct: serena.utilities.ensemble_structures.Sara2SecondaryStructure, nuc_count: int):
 49    def compair_structures(self, unbound_struct:Sara2SecondaryStructure, bound_struct:Sara2SecondaryStructure, reference_struct:Sara2SecondaryStructure, nuc_count:int):#pylint: disable=line-too-long,too-many-locals
 50        """
 51        Compaire the weighted structure against the folded and not-folded mfe's.
 52        If a element is present in the folded mfe then it gets a '-'
 53        if element is in unbound only then it gets a '|'.
 54        The idea is that if you have a straight line in the list then it is very close to the
 55        folded mfe and if it is not straight then it is more like the unbound mfe.
 56        """
 57        unbound:str = '|'
 58        num_unbound:int = 0
 59        bound:str = '-'
 60        num_bound:int = 0
 61        both:str = '+'
 62        num_both:int = 0
 63        dot:str = '.'
 64        num_dot:int = 0
 65        temp_comp_struct:str = ''
 66
 67        for nuc_index in range(nuc_count):
 68            reference_nuc:str = reference_struct.structure[nuc_index]
 69            unbound_nuc:str = unbound_struct.structure[nuc_index]
 70            bound_nuc: str = bound_struct.structure[nuc_index]
 71
 72            comp_nuc_symbol:str = ''
 73
 74            if reference_nuc == bound_nuc and reference_nuc != unbound_nuc:
 75                comp_nuc_symbol = bound
 76                num_bound += 1
 77            elif reference_nuc != bound_nuc and reference_nuc == unbound_nuc:
 78                comp_nuc_symbol = unbound
 79                num_unbound += 1
 80            elif reference_nuc == bound_nuc and reference_nuc == unbound_nuc:
 81                comp_nuc_symbol = both
 82                num_both += 1
 83            else:
 84                comp_nuc_symbol = dot
 85                num_dot += 1
 86
 87            temp_comp_struct = temp_comp_struct + comp_nuc_symbol
 88
 89        sequence: str = unbound_struct.sequence
 90        comp_struct:Sara2SecondaryStructure = Sara2SecondaryStructure(sequence=sequence,
 91                                                                    structure=temp_comp_struct)
 92
 93        comp_nuc_num:ComparisonNucCounts = ComparisonNucCounts(bound_count=num_bound,
 94                                                                    unbound_count=num_unbound,
 95                                                                    both_count=num_both,
 96                                                                    dot_count=num_dot,
 97                                                                    num_nucs=nuc_count)
 98
 99        compared_result: ComparisonResult = ComparisonResult(comp_struct=comp_struct,
100                                                                #unbound_struct=unbound_struct,
101                                                                #bound_struct=bound_struct,
102                                                                #reference_struct=reference_struct,
103                                                                comp_counts=comp_nuc_num)
104        return compared_result

Compaire the weighted structure against the folded and not-folded mfe's. If a element is present in the folded mfe then it gets a '-' if element is in unbound only then it gets a '|'. The idea is that if you have a straight line in the list then it is very close to the folded mfe and if it is not straight then it is more like the unbound mfe.